Test Failed
Push — master ( 21ce85...fda949 )
by Devin
06:42
created
includes/payments/functions.php 1 patch
Spacing   +326 added lines, -329 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
 
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array $payments Payments retrieved from the database
46 46
  */
47
-function give_get_payments( $args = array() ) {
47
+function give_get_payments($args = array()) {
48 48
 
49 49
 	// Fallback to post objects to ensure backwards compatibility.
50
-	if ( ! isset( $args['output'] ) ) {
50
+	if ( ! isset($args['output'])) {
51 51
 		$args['output'] = 'posts';
52 52
 	}
53 53
 
54
-	$args     = apply_filters( 'give_get_payments_args', $args );
55
-	$payments = new Give_Payments_Query( $args );
54
+	$args     = apply_filters('give_get_payments_args', $args);
55
+	$payments = new Give_Payments_Query($args);
56 56
 
57 57
 	return $payments->get_payments();
58 58
 }
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return mixed
69 69
  */
70
-function give_get_payment_by( $field = '', $value = '' ) {
70
+function give_get_payment_by($field = '', $value = '') {
71 71
 
72
-	if ( empty( $field ) || empty( $value ) ) {
72
+	if (empty($field) || empty($value)) {
73 73
 		return false;
74 74
 	}
75 75
 
76
-	switch ( strtolower( $field ) ) {
76
+	switch (strtolower($field)) {
77 77
 
78 78
 		case 'id':
79
-			$payment = new Give_Payment( $value );
79
+			$payment = new Give_Payment($value);
80 80
 			$id      = $payment->ID;
81 81
 
82
-			if ( empty( $id ) ) {
82
+			if (empty($id)) {
83 83
 				return false;
84 84
 			}
85 85
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 				)
96 96
 			);
97 97
 
98
-			if ( $payment ) {
99
-				$payment = new Give_Payment( $payment[0] );
98
+			if ($payment) {
99
+				$payment = new Give_Payment($payment[0]);
100 100
 			}
101 101
 
102 102
 			break;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 				)
112 112
 			);
113 113
 
114
-			if ( $payment ) {
115
-				$payment = new Give_Payment( $payment[0] );
114
+			if ($payment) {
115
+				$payment = new Give_Payment($payment[0]);
116 116
 			}
117 117
 
118 118
 			break;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			return false;
122 122
 	}// End switch().
123 123
 
124
-	if ( $payment ) {
124
+	if ($payment) {
125 125
 		return $payment;
126 126
 	}
127 127
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
  *
138 138
  * @return int|bool Payment ID if payment is inserted, false otherwise.
139 139
  */
140
-function give_insert_payment( $payment_data = array() ) {
140
+function give_insert_payment($payment_data = array()) {
141 141
 
142
-	if ( empty( $payment_data ) ) {
142
+	if (empty($payment_data)) {
143 143
 		return false;
144 144
 	}
145 145
 
@@ -150,35 +150,35 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param array $payment_data Arguments passed.
152 152
 	 */
153
-	$payment_data = apply_filters( 'give_pre_insert_payment', $payment_data );
153
+	$payment_data = apply_filters('give_pre_insert_payment', $payment_data);
154 154
 
155 155
 	$payment    = new Give_Payment();
156
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
157
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? give_clean( $_POST['give-gateway'] ) : $gateway; // WPCS: input var ok, sanitization ok, CSRF ok.
158
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
159
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
160
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
156
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
157
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? give_clean($_POST['give-gateway']) : $gateway; // WPCS: input var ok, sanitization ok, CSRF ok.
158
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
159
+	$price_id   = give_get_payment_meta_price_id($payment_data);
160
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
161 161
 
162 162
 	// Set properties.
163 163
 	$payment->total          = $payment_data['price'];
164
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
165
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data );
164
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
165
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data);
166 166
 	$payment->user_info      = $payment_data['user_info'];
167 167
 	$payment->gateway        = $gateway;
168 168
 	$payment->form_title     = $form_title;
169 169
 	$payment->form_id        = $form_id;
170 170
 	$payment->price_id       = $price_id;
171
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
171
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
172 172
 	$payment->user_id        = $payment_data['user_info']['id'];
173 173
 	$payment->email          = $payment_data['user_email'];
174 174
 	$payment->first_name     = $payment_data['user_info']['first_name'];
175 175
 	$payment->last_name      = $payment_data['user_info']['last_name'];
176
-	$payment->title_prefix   = ! empty( $payment_data['user_info']['title'] ) ? $payment_data['user_info']['title'] : '';
176
+	$payment->title_prefix   = ! empty($payment_data['user_info']['title']) ? $payment_data['user_info']['title'] : '';
177 177
 	$payment->email          = $payment_data['user_info']['email'];
178 178
 	$payment->ip             = give_get_ip();
179 179
 	$payment->key            = $payment_data['purchase_key'];
180
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
181
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
180
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
181
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
182 182
 
183 183
 	// Add the donation.
184 184
 	$args = array(
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 		'price_id' => $payment->price_id,
187 187
 	);
188 188
 
189
-	$payment->add_donation( $payment->form_id, $args );
189
+	$payment->add_donation($payment->form_id, $args);
190 190
 
191 191
 	// Set date if present.
192
-	if ( isset( $payment_data['post_date'] ) ) {
192
+	if (isset($payment_data['post_date'])) {
193 193
 		$payment->date = $payment_data['post_date'];
194 194
 	}
195 195
 
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 * @param int   $payment_id   The payment ID.
208 208
 	 * @param array $payment_data Arguments passed.
209 209
 	 */
210
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
210
+	do_action('give_insert_payment', $payment->ID, $payment_data);
211 211
 
212 212
 	// Return payment ID upon success.
213
-	if ( ! empty( $payment->ID ) ) {
213
+	if ( ! empty($payment->ID)) {
214 214
 		return $payment->ID;
215 215
 	}
216 216
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @return bool|int
228 228
  */
229
-function give_create_payment( $payment_data ) {
229
+function give_create_payment($payment_data) {
230 230
 
231
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
232
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
231
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
232
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
233 233
 
234 234
 	// Collect payment data.
235 235
 	$insert_payment_data = array(
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		'date'            => $payment_data['date'],
241 241
 		'user_email'      => $payment_data['user_email'],
242 242
 		'purchase_key'    => $payment_data['purchase_key'],
243
-		'currency'        => give_get_currency( $form_id, $payment_data ),
243
+		'currency'        => give_get_currency($form_id, $payment_data),
244 244
 		'user_info'       => $payment_data['user_info'],
245 245
 		'status'          => 'pending',
246 246
 		'gateway'         => 'paypal',
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @param array $insert_payment_data
255 255
 	 */
256
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
256
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
257 257
 
258 258
 	// Record the pending payment.
259
-	return give_insert_payment( $insert_payment_data );
259
+	return give_insert_payment($insert_payment_data);
260 260
 }
261 261
 
262 262
 /**
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return bool
271 271
  */
272
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
272
+function give_update_payment_status($payment_id, $new_status = 'publish') {
273 273
 
274 274
 	$updated = false;
275
-	$payment = new Give_Payment( $payment_id );
275
+	$payment = new Give_Payment($payment_id);
276 276
 
277
-	if ( $payment && $payment->ID > 0 ) {
277
+	if ($payment && $payment->ID > 0) {
278 278
 
279 279
 		$payment->status = $new_status;
280 280
 		$updated         = $payment->save();
@@ -295,17 +295,17 @@  discard block
 block discarded – undo
295 295
  *
296 296
  * @return void
297 297
  */
298
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
299
-	$payment = new Give_Payment( $payment_id );
298
+function give_delete_donation($payment_id = 0, $update_donor = true) {
299
+	$payment = new Give_Payment($payment_id);
300 300
 
301 301
 	// Bailout.
302
-	if ( ! $payment->ID ) {
302
+	if ( ! $payment->ID) {
303 303
 		return;
304 304
 	}
305 305
 
306
-	$amount = give_donation_amount( $payment_id );
306
+	$amount = give_donation_amount($payment_id);
307 307
 	$status = $payment->post_status;
308
-	$donor  = new Give_Donor( $payment->donor_id );
308
+	$donor  = new Give_Donor($payment->donor_id);
309 309
 
310 310
 	// Only undo donations that aren't these statuses.
311 311
 	$dont_undo_statuses = apply_filters(
@@ -315,26 +315,26 @@  discard block
 block discarded – undo
315 315
 		)
316 316
 	);
317 317
 
318
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
319
-		give_undo_donation( $payment_id );
318
+	if ( ! in_array($status, $dont_undo_statuses)) {
319
+		give_undo_donation($payment_id);
320 320
 	}
321 321
 
322 322
 	// Only undo donations that aren't these statuses.
323
-	$status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) );
323
+	$status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish'));
324 324
 
325
-	if ( in_array( $status, $status_to_decrease_stats ) ) {
325
+	if (in_array($status, $status_to_decrease_stats)) {
326 326
 
327 327
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
328
-		give_decrease_total_earnings( $amount );
328
+		give_decrease_total_earnings($amount);
329 329
 
330 330
 		// @todo: Refresh only range related stat cache
331 331
 		give_delete_donation_stats();
332 332
 
333
-		if ( $donor->id && $update_donor ) {
333
+		if ($donor->id && $update_donor) {
334 334
 
335 335
 			// Decrement the stats for the donor.
336 336
 			$donor->decrease_donation_count();
337
-			$donor->decrease_value( $amount );
337
+			$donor->decrease_value($amount);
338 338
 
339 339
 		}
340 340
 	}
@@ -346,20 +346,20 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @since 1.0
348 348
 	 */
349
-	do_action( 'give_payment_delete', $payment_id );
349
+	do_action('give_payment_delete', $payment_id);
350 350
 
351
-	if ( $donor->id && $update_donor ) {
351
+	if ($donor->id && $update_donor) {
352 352
 		// Remove the payment ID from the donor.
353
-		$donor->remove_payment( $payment_id );
353
+		$donor->remove_payment($payment_id);
354 354
 	}
355 355
 
356 356
 	// Remove the payment.
357
-	wp_delete_post( $payment_id, true );
357
+	wp_delete_post($payment_id, true);
358 358
 
359
-	Give()->payment_meta->delete_all_meta( $payment_id );
359
+	Give()->payment_meta->delete_all_meta($payment_id);
360 360
 
361 361
 	// Remove related sale log entries.
362
-	Give()->logs->delete_logs( $payment_id );
362
+	Give()->logs->delete_logs($payment_id);
363 363
 
364 364
 	/**
365 365
 	 * Fires after payment deleted.
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @since 1.0
370 370
 	 */
371
-	do_action( 'give_payment_deleted', $payment_id );
371
+	do_action('give_payment_deleted', $payment_id);
372 372
 }
373 373
 
374 374
 /**
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
  *
384 384
  * @return void
385 385
  */
386
-function give_undo_donation( $payment_id ) {
386
+function give_undo_donation($payment_id) {
387 387
 
388
-	$payment = new Give_Payment( $payment_id );
388
+	$payment = new Give_Payment($payment_id);
389 389
 
390
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
391
-	if ( true === $maybe_decrease_earnings ) {
390
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
391
+	if (true === $maybe_decrease_earnings) {
392 392
 		// Decrease earnings.
393
-		give_decrease_form_earnings( $payment->form_id, $payment->total, $payment_id );
393
+		give_decrease_form_earnings($payment->form_id, $payment->total, $payment_id);
394 394
 	}
395 395
 
396
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
397
-	if ( true === $maybe_decrease_donations ) {
396
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
397
+	if (true === $maybe_decrease_donations) {
398 398
 		// Decrease donation count.
399
-		give_decrease_donation_count( $payment->form_id );
399
+		give_decrease_donation_count($payment->form_id);
400 400
 	}
401 401
 
402 402
 }
@@ -413,21 +413,21 @@  discard block
 block discarded – undo
413 413
  *
414 414
  * @return object $stats Contains the number of payments per payment status.
415 415
  */
416
-function give_count_payments( $args = array() ) {
416
+function give_count_payments($args = array()) {
417 417
 	// Backward compatibility.
418
-	if ( ! empty( $args['start-date'] ) ) {
418
+	if ( ! empty($args['start-date'])) {
419 419
 		$args['start_date'] = $args['start-date'];
420
-		unset( $args['start-date'] );
420
+		unset($args['start-date']);
421 421
 	}
422 422
 
423
-	if ( ! empty( $args['end-date'] ) ) {
423
+	if ( ! empty($args['end-date'])) {
424 424
 		$args['end_date'] = $args['end-date'];
425
-		unset( $args['end-date'] );
425
+		unset($args['end-date']);
426 426
 	}
427 427
 
428
-	if ( ! empty( $args['form_id'] ) ) {
428
+	if ( ! empty($args['form_id'])) {
429 429
 		$args['give_forms'] = $args['form_id'];
430
-		unset( $args['form_id'] );
430
+		unset($args['form_id']);
431 431
 	}
432 432
 
433 433
 	// Extract all donations
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	$args['group_by'] = 'post_status';
436 436
 	$args['count']    = 'true';
437 437
 
438
-	$donations_obj   = new Give_Payments_Query( $args );
438
+	$donations_obj   = new Give_Payments_Query($args);
439 439
 	$donations_count = $donations_obj->get_payment_by_group();
440 440
 
441 441
 	/**
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @since 1.0
445 445
 	 */
446
-	return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj );
446
+	return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj);
447 447
 }
448 448
 
449 449
 
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
  *
457 457
  * @return bool $exists True if payment exists, false otherwise.
458 458
  */
459
-function give_check_for_existing_payment( $payment_id ) {
459
+function give_check_for_existing_payment($payment_id) {
460 460
 	global $wpdb;
461 461
 
462 462
 	return (bool) $wpdb->get_var(
@@ -484,9 +484,9 @@  discard block
 block discarded – undo
484 484
  *
485 485
  * @return bool|mixed True if payment status exists, false otherwise.
486 486
  */
487
-function give_get_payment_status( $payment_id, $return_label = false ) {
487
+function give_get_payment_status($payment_id, $return_label = false) {
488 488
 
489
-	if ( ! is_numeric( $payment_id ) ) {
489
+	if ( ! is_numeric($payment_id)) {
490 490
 		if (
491 491
 			$payment_id instanceof  Give_Payment
492 492
 			|| $payment_id instanceof WP_Post
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
 		}
496 496
 	}
497 497
 
498
-	if ( ! $payment_id > 0 ) {
498
+	if ( ! $payment_id > 0) {
499 499
 		return false;
500 500
 	}
501 501
 
502
-	$payment_status = get_post_status( $payment_id );
502
+	$payment_status = get_post_status($payment_id);
503 503
 
504 504
 	$statuses = give_get_payment_statuses();
505 505
 
506
-	if ( empty( $payment_status ) || ! is_array( $statuses ) || empty( $statuses ) ) {
506
+	if (empty($payment_status) || ! is_array($statuses) || empty($statuses)) {
507 507
 		return false;
508 508
 	}
509 509
 
510
-	if ( array_key_exists( $payment_status, $statuses ) ) {
511
-		if ( true === $return_label ) {
510
+	if (array_key_exists($payment_status, $statuses)) {
511
+		if (true === $return_label) {
512 512
 			// Return translated status label.
513
-			return $statuses[ $payment_status ];
513
+			return $statuses[$payment_status];
514 514
 		} else {
515 515
 			// Account that our 'publish' status is labeled 'Complete'
516 516
 			$post_status = 'publish' === $payment_status ? 'Complete' : $payment_status;
517 517
 
518 518
 			// Make sure we're matching cases, since they matter
519
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
519
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
520 520
 		}
521 521
 	}
522 522
 
@@ -532,18 +532,18 @@  discard block
 block discarded – undo
532 532
  */
533 533
 function give_get_payment_statuses() {
534 534
 	$payment_statuses = array(
535
-		'pending'     => __( 'Pending', 'give' ),
536
-		'publish'     => __( 'Complete', 'give' ),
537
-		'refunded'    => __( 'Refunded', 'give' ),
538
-		'failed'      => __( 'Failed', 'give' ),
539
-		'cancelled'   => __( 'Cancelled', 'give' ),
540
-		'abandoned'   => __( 'Abandoned', 'give' ),
541
-		'preapproval' => __( 'Pre-Approved', 'give' ),
542
-		'processing'  => __( 'Processing', 'give' ),
543
-		'revoked'     => __( 'Revoked', 'give' ),
535
+		'pending'     => __('Pending', 'give'),
536
+		'publish'     => __('Complete', 'give'),
537
+		'refunded'    => __('Refunded', 'give'),
538
+		'failed'      => __('Failed', 'give'),
539
+		'cancelled'   => __('Cancelled', 'give'),
540
+		'abandoned'   => __('Abandoned', 'give'),
541
+		'preapproval' => __('Pre-Approved', 'give'),
542
+		'processing'  => __('Processing', 'give'),
543
+		'revoked'     => __('Revoked', 'give'),
544 544
 	);
545 545
 
546
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
546
+	return apply_filters('give_payment_statuses', $payment_statuses);
547 547
 }
548 548
 
549 549
 /**
@@ -556,10 +556,10 @@  discard block
 block discarded – undo
556 556
  * @return array $payment_status All the available payment statuses.
557 557
  */
558 558
 function give_get_payment_status_keys() {
559
-	$statuses = array_keys( give_get_payment_statuses() );
560
-	asort( $statuses );
559
+	$statuses = array_keys(give_get_payment_statuses());
560
+	asort($statuses);
561 561
 
562
-	return array_values( $statuses );
562
+	return array_values($statuses);
563 563
 }
564 564
 
565 565
 /**
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
  *
575 575
  * @return int $earnings Earnings
576 576
  */
577
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
577
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
578 578
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
579 579
 	global $wpdb;
580 580
 
@@ -583,37 +583,37 @@  discard block
 block discarded – undo
583 583
 		'nopaging'               => true,
584 584
 		'year'                   => $year,
585 585
 		'monthnum'               => $month_num,
586
-		'post_status'            => array( 'publish' ),
586
+		'post_status'            => array('publish'),
587 587
 		'fields'                 => 'ids',
588 588
 		'update_post_term_cache' => false,
589 589
 	);
590
-	if ( ! empty( $day ) ) {
590
+	if ( ! empty($day)) {
591 591
 		$args['day'] = $day;
592 592
 	}
593 593
 
594
-	if ( isset( $hour ) ) {
594
+	if (isset($hour)) {
595 595
 		$args['hour'] = $hour;
596 596
 	}
597 597
 
598
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
599
-	$key  = Give_Cache::get_key( 'give_stats', $args );
598
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
599
+	$key  = Give_Cache::get_key('give_stats', $args);
600 600
 
601
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
601
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
602 602
 		$earnings = false;
603 603
 	} else {
604
-		$earnings = Give_Cache::get( $key );
604
+		$earnings = Give_Cache::get($key);
605 605
 	}
606 606
 
607
-	if ( false === $earnings ) {
608
-		$donations = get_posts( $args );
607
+	if (false === $earnings) {
608
+		$donations = get_posts($args);
609 609
 		$earnings  = 0;
610 610
 
611 611
 		$donation_table     = Give()->payment_meta->table_name;
612
-		$donation_table_col = Give()->payment_meta->get_meta_type() . '_id';
612
+		$donation_table_col = Give()->payment_meta->get_meta_type().'_id';
613 613
 
614
-		if ( $donations ) {
615
-			$donations      = implode( ',', $donations );
616
-			$earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM {$donation_table} WHERE meta_key = '_give_payment_total' AND {$donation_table_col} IN ({$donations})" );
614
+		if ($donations) {
615
+			$donations      = implode(',', $donations);
616
+			$earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM {$donation_table} WHERE meta_key = '_give_payment_total' AND {$donation_table_col} IN ({$donations})");
617 617
 
618 618
 			/**
619 619
 			 * Filter The earnings by dates.
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 			 * @param array $donations      Donations lists.
625 625
 			 * @param array $args           Donation query args.
626 626
 			 */
627
-			$earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args );
627
+			$earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args);
628 628
 		}
629 629
 		// Cache the results for one hour.
630
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
630
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
631 631
 	}
632 632
 
633
-	return round( $earnings, 2 );
633
+	return round($earnings, 2);
634 634
 }
635 635
 
636 636
 /**
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
  *
646 646
  * @return int $count Sales
647 647
  */
648
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
648
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
649 649
 
650 650
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
651 651
 	$args = array(
@@ -653,14 +653,14 @@  discard block
 block discarded – undo
653 653
 		'nopaging'               => true,
654 654
 		'year'                   => $year,
655 655
 		'fields'                 => 'ids',
656
-		'post_status'            => array( 'publish' ),
656
+		'post_status'            => array('publish'),
657 657
 		'update_post_meta_cache' => false,
658 658
 		'update_post_term_cache' => false,
659 659
 	);
660 660
 
661
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
661
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
662 662
 
663
-	if ( false === $show_free ) {
663
+	if (false === $show_free) {
664 664
 		$args['meta_query'] = array(
665 665
 			array(
666 666
 				'key'     => '_give_payment_total',
@@ -671,33 +671,33 @@  discard block
 block discarded – undo
671 671
 		);
672 672
 	}
673 673
 
674
-	if ( ! empty( $month_num ) ) {
674
+	if ( ! empty($month_num)) {
675 675
 		$args['monthnum'] = $month_num;
676 676
 	}
677 677
 
678
-	if ( ! empty( $day ) ) {
678
+	if ( ! empty($day)) {
679 679
 		$args['day'] = $day;
680 680
 	}
681 681
 
682
-	if ( isset( $hour ) ) {
682
+	if (isset($hour)) {
683 683
 		$args['hour'] = $hour;
684 684
 	}
685 685
 
686
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
686
+	$args = apply_filters('give_get_sales_by_date_args', $args);
687 687
 
688
-	$key = Give_Cache::get_key( 'give_stats', $args );
688
+	$key = Give_Cache::get_key('give_stats', $args);
689 689
 
690
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
690
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
691 691
 		$count = false;
692 692
 	} else {
693
-		$count = Give_Cache::get( $key );
693
+		$count = Give_Cache::get($key);
694 694
 	}
695 695
 
696
-	if ( false === $count ) {
697
-		$donations = new WP_Query( $args );
696
+	if (false === $count) {
697
+		$donations = new WP_Query($args);
698 698
 		$count     = (int) $donations->post_count;
699 699
 		// Cache the results for one hour.
700
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
700
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
701 701
 	}
702 702
 
703 703
 	return $count;
@@ -712,14 +712,14 @@  discard block
 block discarded – undo
712 712
  *
713 713
  * @return bool $ret True if complete, false otherwise.
714 714
  */
715
-function give_is_payment_complete( $payment_id ) {
715
+function give_is_payment_complete($payment_id) {
716 716
 	$ret            = false;
717 717
 	$payment_status = '';
718 718
 
719
-	if ( $payment_id > 0 && 'give_payment' === get_post_type( $payment_id ) ) {
720
-		$payment_status = get_post_status( $payment_id );
719
+	if ($payment_id > 0 && 'give_payment' === get_post_type($payment_id)) {
720
+		$payment_status = get_post_status($payment_id);
721 721
 
722
-		if ( 'publish' === $payment_status ) {
722
+		if ('publish' === $payment_status) {
723 723
 			$ret = true;
724 724
 		}
725 725
 	}
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	 *
730 730
 	 * @since 1.0
731 731
 	 */
732
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment_status );
732
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment_status);
733 733
 }
734 734
 
735 735
 /**
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
  *
756 756
  * @return float $total Total earnings.
757 757
  */
758
-function give_get_total_earnings( $recalculate = false ) {
758
+function give_get_total_earnings($recalculate = false) {
759 759
 
760
-	$total      = get_option( 'give_earnings_total', 0 );
761
-	$meta_table = __give_v20_bc_table_details( 'payment' );
760
+	$total      = get_option('give_earnings_total', 0);
761
+	$meta_table = __give_v20_bc_table_details('payment');
762 762
 
763 763
 	// Calculate total earnings.
764
-	if ( ! $total || $recalculate ) {
764
+	if ( ! $total || $recalculate) {
765 765
 		global $wpdb;
766 766
 
767 767
 		$total = (float) 0;
@@ -769,38 +769,38 @@  discard block
 block discarded – undo
769 769
 		$args = apply_filters(
770 770
 			'give_get_total_earnings_args', array(
771 771
 				'offset' => 0,
772
-				'number' => - 1,
773
-				'status' => array( 'publish' ),
772
+				'number' => -1,
773
+				'status' => array('publish'),
774 774
 				'fields' => 'ids',
775 775
 			)
776 776
 		);
777 777
 
778
-		$payments = give_get_payments( $args );
779
-		if ( $payments ) {
778
+		$payments = give_get_payments($args);
779
+		if ($payments) {
780 780
 
781 781
 			/**
782 782
 			 * If performing a donation, we need to skip the very last payment in the database,
783 783
 			 * since it calls give_increase_total_earnings() on completion,
784 784
 			 * which results in duplicated earnings for the very first donation.
785 785
 			 */
786
-			if ( did_action( 'give_update_payment_status' ) ) {
787
-				array_pop( $payments );
786
+			if (did_action('give_update_payment_status')) {
787
+				array_pop($payments);
788 788
 			}
789 789
 
790
-			if ( ! empty( $payments ) ) {
791
-				$payments = implode( ',', $payments );
792
-				$total   += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" );
790
+			if ( ! empty($payments)) {
791
+				$payments = implode(',', $payments);
792
+				$total   += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})");
793 793
 			}
794 794
 		}
795 795
 
796
-		update_option( 'give_earnings_total', $total, false );
796
+		update_option('give_earnings_total', $total, false);
797 797
 	}
798 798
 
799
-	if ( $total < 0 ) {
799
+	if ($total < 0) {
800 800
 		$total = 0; // Don't ever show negative earnings.
801 801
 	}
802 802
 
803
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
803
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
804 804
 }
805 805
 
806 806
 /**
@@ -812,10 +812,10 @@  discard block
 block discarded – undo
812 812
  *
813 813
  * @return float $total Total earnings.
814 814
  */
815
-function give_increase_total_earnings( $amount = 0 ) {
815
+function give_increase_total_earnings($amount = 0) {
816 816
 	$total  = give_get_total_earnings();
817 817
 	$total += $amount;
818
-	update_option( 'give_earnings_total', $total, false );
818
+	update_option('give_earnings_total', $total, false);
819 819
 
820 820
 	return $total;
821 821
 }
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
  *
830 830
  * @return float $total Total earnings.
831 831
  */
832
-function give_decrease_total_earnings( $amount = 0 ) {
832
+function give_decrease_total_earnings($amount = 0) {
833 833
 	$total  = give_get_total_earnings();
834 834
 	$total -= $amount;
835
-	if ( $total < 0 ) {
835
+	if ($total < 0) {
836 836
 		$total = 0;
837 837
 	}
838
-	update_option( 'give_earnings_total', $total, false );
838
+	update_option('give_earnings_total', $total, false);
839 839
 
840 840
 	return $total;
841 841
 }
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
  *
852 852
  * @return mixed $meta Payment Meta.
853 853
  */
854
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
855
-	return give_get_meta( $payment_id, $meta_key, $single );
854
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
855
+	return give_get_meta($payment_id, $meta_key, $single);
856 856
 }
857 857
 
858 858
 /**
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
  *
866 866
  * @return mixed Meta ID if successful, false if unsuccessful.
867 867
  */
868
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
869
-	return give_update_meta( $payment_id, $meta_key, $meta_value );
868
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
869
+	return give_update_meta($payment_id, $meta_key, $meta_value);
870 870
 }
871 871
 
872 872
 /**
@@ -878,34 +878,34 @@  discard block
 block discarded – undo
878 878
  *
879 879
  * @return array $user_info User Info Meta Values.
880 880
  */
881
-function give_get_payment_meta_user_info( $payment_id ) {
881
+function give_get_payment_meta_user_info($payment_id) {
882 882
 	$donor_id   = 0;
883 883
 	$donor_info = array(
884
-		'first_name' => give_get_meta( $payment_id, '_give_donor_billing_first_name', true ),
885
-		'last_name'  => give_get_meta( $payment_id, '_give_donor_billing_last_name', true ),
886
-		'email'      => give_get_meta( $payment_id, '_give_donor_billing_donor_email', true ),
884
+		'first_name' => give_get_meta($payment_id, '_give_donor_billing_first_name', true),
885
+		'last_name'  => give_get_meta($payment_id, '_give_donor_billing_last_name', true),
886
+		'email'      => give_get_meta($payment_id, '_give_donor_billing_donor_email', true),
887 887
 	);
888 888
 
889
-	if ( empty( $donor_info['first_name'] ) ) {
890
-		$donor_id                 = give_get_payment_donor_id( $payment_id );
891
-		$donor_info['first_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_first_name', true );
889
+	if (empty($donor_info['first_name'])) {
890
+		$donor_id                 = give_get_payment_donor_id($payment_id);
891
+		$donor_info['first_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_first_name', true);
892 892
 	}
893 893
 
894
-	if ( empty( $donor_info['last_name'] ) ) {
895
-		$donor_id                = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id );
896
-		$donor_info['last_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_last_name', true );
894
+	if (empty($donor_info['last_name'])) {
895
+		$donor_id                = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id);
896
+		$donor_info['last_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_last_name', true);
897 897
 	}
898 898
 
899
-	if ( empty( $donor_info['email'] ) ) {
900
-		$donor_id            = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id );
901
-		$donor_info['email'] = Give()->donors->get_column_by( 'email', 'id', $donor_id );
899
+	if (empty($donor_info['email'])) {
900
+		$donor_id            = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id);
901
+		$donor_info['email'] = Give()->donors->get_column_by('email', 'id', $donor_id);
902 902
 	}
903 903
 
904
-	$donor_info['title'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_title_prefix', true );
904
+	$donor_info['title'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_title_prefix', true);
905 905
 
906
-	$donor_info['address']  = give_get_donation_address( $payment_id );
907
-	$donor_info['id']       = give_get_payment_user_id( $payment_id );
908
-	$donor_info['donor_id'] = give_get_payment_donor_id( $payment_id );
906
+	$donor_info['address']  = give_get_donation_address($payment_id);
907
+	$donor_info['id']       = give_get_payment_user_id($payment_id);
908
+	$donor_info['donor_id'] = give_get_payment_donor_id($payment_id);
909 909
 
910 910
 	return $donor_info;
911 911
 }
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
  *
922 922
  * @return int $form_id Form ID.
923 923
  */
924
-function give_get_payment_form_id( $payment_id ) {
925
-	return (int) give_get_meta( $payment_id, '_give_payment_form_id', true );
924
+function give_get_payment_form_id($payment_id) {
925
+	return (int) give_get_meta($payment_id, '_give_payment_form_id', true);
926 926
 }
927 927
 
928 928
 /**
@@ -934,11 +934,11 @@  discard block
 block discarded – undo
934 934
  *
935 935
  * @return string $email User email.
936 936
  */
937
-function give_get_payment_user_email( $payment_id ) {
938
-	$email = give_get_meta( $payment_id, '_give_payment_donor_email', true );
937
+function give_get_payment_user_email($payment_id) {
938
+	$email = give_get_meta($payment_id, '_give_payment_donor_email', true);
939 939
 
940
-	if ( empty( $email ) && ( $donor_id = give_get_payment_donor_id( $payment_id ) ) ) {
941
-		$email = Give()->donors->get_column( 'email', $donor_id );
940
+	if (empty($email) && ($donor_id = give_get_payment_donor_id($payment_id))) {
941
+		$email = Give()->donors->get_column('email', $donor_id);
942 942
 	}
943 943
 
944 944
 	return $email;
@@ -953,11 +953,11 @@  discard block
 block discarded – undo
953 953
  *
954 954
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
955 955
  */
956
-function give_is_guest_payment( $payment_id ) {
957
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
958
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
956
+function give_is_guest_payment($payment_id) {
957
+	$payment_user_id  = give_get_payment_user_id($payment_id);
958
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
959 959
 
960
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
960
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
961 961
 }
962 962
 
963 963
 /**
@@ -969,10 +969,10 @@  discard block
 block discarded – undo
969 969
  *
970 970
  * @return int $user_id User ID.
971 971
  */
972
-function give_get_payment_user_id( $payment_id ) {
972
+function give_get_payment_user_id($payment_id) {
973 973
 	global $wpdb;
974 974
 	$paymentmeta_table = Give()->payment_meta->table_name;
975
-	$donationmeta_primary_key = Give()->payment_meta->get_meta_type() . '_id';
975
+	$donationmeta_primary_key = Give()->payment_meta->get_meta_type().'_id';
976 976
 
977 977
 	return (int) $wpdb->get_var(
978 978
 		$wpdb->prepare(
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
  *
1002 1002
  * @return int $payment->customer_id Donor ID.
1003 1003
  */
1004
-function give_get_payment_donor_id( $payment_id ) {
1005
-	return give_get_meta( $payment_id, '_give_payment_donor_id', true );
1004
+function give_get_payment_donor_id($payment_id) {
1005
+	return give_get_meta($payment_id, '_give_payment_donor_id', true);
1006 1006
 }
1007 1007
 
1008 1008
 /**
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
  *
1015 1015
  * @return string
1016 1016
  */
1017
-function give_get_donation_donor_email( $payment_id ) {
1018
-	return give_get_meta( $payment_id, '_give_payment_donor_email', true );
1017
+function give_get_donation_donor_email($payment_id) {
1018
+	return give_get_meta($payment_id, '_give_payment_donor_email', true);
1019 1019
 }
1020 1020
 
1021 1021
 /**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
  *
1028 1028
  * @return string $ip User IP.
1029 1029
  */
1030
-function give_get_payment_user_ip( $payment_id ) {
1031
-	return give_get_meta( $payment_id, '_give_payment_donor_ip', true );
1030
+function give_get_payment_user_ip($payment_id) {
1031
+	return give_get_meta($payment_id, '_give_payment_donor_ip', true);
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
  *
1041 1041
  * @return string $date The date the payment was completed.
1042 1042
  */
1043
-function give_get_payment_completed_date( $payment_id = 0 ) {
1044
-	return give_get_meta( $payment_id, '_give_completed_date', true );
1043
+function give_get_payment_completed_date($payment_id = 0) {
1044
+	return give_get_meta($payment_id, '_give_completed_date', true);
1045 1045
 }
1046 1046
 
1047 1047
 /**
@@ -1053,8 +1053,8 @@  discard block
 block discarded – undo
1053 1053
  *
1054 1054
  * @return string $gateway Gateway.
1055 1055
  */
1056
-function give_get_payment_gateway( $payment_id ) {
1057
-	return give_get_meta( $payment_id, '_give_payment_gateway', true );
1056
+function give_get_payment_gateway($payment_id) {
1057
+	return give_get_meta($payment_id, '_give_payment_gateway', true);
1058 1058
 }
1059 1059
 
1060 1060
 /**
@@ -1067,10 +1067,9 @@  discard block
 block discarded – undo
1067 1067
  *
1068 1068
  * @return bool
1069 1069
  */
1070
-function give_has_payment_gateway( $donation_id, $gateway_id ) {
1070
+function give_has_payment_gateway($donation_id, $gateway_id) {
1071 1071
 	$donation_gateway = $donation_id instanceof Give_Payment ?
1072
-		$donation_id->gateway :
1073
-		give_get_payment_gateway( $donation_id );
1072
+		$donation_id->gateway : give_get_payment_gateway($donation_id);
1074 1073
 
1075 1074
 	return $gateway_id === $donation_gateway;
1076 1075
 }
@@ -1084,8 +1083,8 @@  discard block
 block discarded – undo
1084 1083
  *
1085 1084
  * @return string $currency The currency code.
1086 1085
  */
1087
-function give_get_payment_currency_code( $payment_id = 0 ) {
1088
-	return give_get_meta( $payment_id, '_give_payment_currency', true );
1086
+function give_get_payment_currency_code($payment_id = 0) {
1087
+	return give_get_meta($payment_id, '_give_payment_currency', true);
1089 1088
 }
1090 1089
 
1091 1090
 /**
@@ -1097,10 +1096,10 @@  discard block
 block discarded – undo
1097 1096
  *
1098 1097
  * @return string $currency The currency name.
1099 1098
  */
1100
-function give_get_payment_currency( $payment_id = 0 ) {
1101
-	$currency = give_get_payment_currency_code( $payment_id );
1099
+function give_get_payment_currency($payment_id = 0) {
1100
+	$currency = give_get_payment_currency_code($payment_id);
1102 1101
 
1103
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1102
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1104 1103
 }
1105 1104
 
1106 1105
 /**
@@ -1112,8 +1111,8 @@  discard block
 block discarded – undo
1112 1111
  *
1113 1112
  * @return string $key Donation key.
1114 1113
  */
1115
-function give_get_payment_key( $payment_id = 0 ) {
1116
-	return give_get_meta( $payment_id, '_give_payment_purchase_key', true );
1114
+function give_get_payment_key($payment_id = 0) {
1115
+	return give_get_meta($payment_id, '_give_payment_purchase_key', true);
1117 1116
 }
1118 1117
 
1119 1118
 /**
@@ -1127,8 +1126,8 @@  discard block
 block discarded – undo
1127 1126
  *
1128 1127
  * @return string $number Payment order number.
1129 1128
  */
1130
-function give_get_payment_number( $payment_id = 0 ) {
1131
-	return Give()->seq_donation_number->get_serial_code( $payment_id );
1129
+function give_get_payment_number($payment_id = 0) {
1130
+	return Give()->seq_donation_number->get_serial_code($payment_id);
1132 1131
 }
1133 1132
 
1134 1133
 
@@ -1146,17 +1145,17 @@  discard block
 block discarded – undo
1146 1145
  *
1147 1146
  * @return string $amount Fully formatted donation amount.
1148 1147
  */
1149
-function give_donation_amount( $donation_id, $format_args = array() ) {
1150
-	if ( ! $donation_id ) {
1148
+function give_donation_amount($donation_id, $format_args = array()) {
1149
+	if ( ! $donation_id) {
1151 1150
 		return '';
1152
-	} elseif ( ! is_numeric( $donation_id ) && ( $donation_id instanceof Give_Payment ) ) {
1151
+	} elseif ( ! is_numeric($donation_id) && ($donation_id instanceof Give_Payment)) {
1153 1152
 		$donation_id = $donation_id->ID;
1154 1153
 	}
1155 1154
 
1156
-	$amount        = $formatted_amount = give_get_payment_total( $donation_id );
1157
-	$currency_code = give_get_payment_currency_code( $donation_id );
1155
+	$amount        = $formatted_amount = give_get_payment_total($donation_id);
1156
+	$currency_code = give_get_payment_currency_code($donation_id);
1158 1157
 
1159
-	if ( is_bool( $format_args ) ) {
1158
+	if (is_bool($format_args)) {
1160 1159
 		$format_args = array(
1161 1160
 			'currency' => (bool) $format_args,
1162 1161
 			'amount'   => (bool) $format_args,
@@ -1179,27 +1178,25 @@  discard block
 block discarded – undo
1179 1178
 		)
1180 1179
 	);
1181 1180
 
1182
-	if ( $format_args['amount'] || $format_args['currency'] ) {
1181
+	if ($format_args['amount'] || $format_args['currency']) {
1183 1182
 
1184
-		if ( $format_args['amount'] ) {
1183
+		if ($format_args['amount']) {
1185 1184
 
1186 1185
 			$formatted_amount = give_format_amount(
1187 1186
 				$amount,
1188
-				! is_array( $format_args['amount'] ) ?
1187
+				! is_array($format_args['amount']) ?
1189 1188
 					array(
1190 1189
 						'sanitize' => false,
1191 1190
 						'currency' => $currency_code,
1192
-					) :
1193
-					$format_args['amount']
1191
+					) : $format_args['amount']
1194 1192
 			);
1195 1193
 		}
1196 1194
 
1197
-		if ( $format_args['currency'] ) {
1195
+		if ($format_args['currency']) {
1198 1196
 			$formatted_amount = give_currency_filter(
1199 1197
 				$formatted_amount,
1200
-				! is_array( $format_args['currency'] ) ?
1201
-					array( 'currency_code' => $currency_code ) :
1202
-					$format_args['currency']
1198
+				! is_array($format_args['currency']) ?
1199
+					array('currency_code' => $currency_code) : $format_args['currency']
1203 1200
 			);
1204 1201
 		}
1205 1202
 	}
@@ -1214,7 +1211,7 @@  discard block
 block discarded – undo
1214 1211
 	 * @param int    $donation_id      Donation ID.
1215 1212
 	 * @param string $type             Donation amount type.
1216 1213
 	 */
1217
-	return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args );
1214
+	return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args);
1218 1215
 }
1219 1216
 
1220 1217
 /**
@@ -1231,10 +1228,10 @@  discard block
 block discarded – undo
1231 1228
  *
1232 1229
  * @return array Fully formatted payment subtotal.
1233 1230
  */
1234
-function give_payment_subtotal( $payment_id = 0 ) {
1235
-	$subtotal = give_get_payment_subtotal( $payment_id );
1231
+function give_payment_subtotal($payment_id = 0) {
1232
+	$subtotal = give_get_payment_subtotal($payment_id);
1236 1233
 
1237
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) );
1234
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id)));
1238 1235
 }
1239 1236
 
1240 1237
 /**
@@ -1248,8 +1245,8 @@  discard block
 block discarded – undo
1248 1245
  *
1249 1246
  * @return float $subtotal Subtotal for payment (non formatted).
1250 1247
  */
1251
-function give_get_payment_subtotal( $payment_id = 0 ) {
1252
-	$payment = new Give_Payment( $payment_id );
1248
+function give_get_payment_subtotal($payment_id = 0) {
1249
+	$payment = new Give_Payment($payment_id);
1253 1250
 
1254 1251
 	return $payment->subtotal;
1255 1252
 }
@@ -1263,12 +1260,12 @@  discard block
 block discarded – undo
1263 1260
  *
1264 1261
  * @return string The donation ID.
1265 1262
  */
1266
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1267
-	$transaction_id = give_get_meta( $payment_id, '_give_payment_transaction_id', true );
1263
+function give_get_payment_transaction_id($payment_id = 0) {
1264
+	$transaction_id = give_get_meta($payment_id, '_give_payment_transaction_id', true);
1268 1265
 
1269
-	if ( empty( $transaction_id ) ) {
1270
-		$gateway        = give_get_payment_gateway( $payment_id );
1271
-		$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $payment_id );
1266
+	if (empty($transaction_id)) {
1267
+		$gateway        = give_get_payment_gateway($payment_id);
1268
+		$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $payment_id);
1272 1269
 	}
1273 1270
 
1274 1271
 	return $transaction_id;
@@ -1284,15 +1281,15 @@  discard block
 block discarded – undo
1284 1281
  *
1285 1282
  * @return bool|mixed
1286 1283
  */
1287
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1284
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1288 1285
 
1289
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1286
+	if (empty($payment_id) || empty($transaction_id)) {
1290 1287
 		return false;
1291 1288
 	}
1292 1289
 
1293
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1290
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1294 1291
 
1295
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1292
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1296 1293
 }
1297 1294
 
1298 1295
 /**
@@ -1305,10 +1302,10 @@  discard block
 block discarded – undo
1305 1302
  *
1306 1303
  * @return int $purchase Donation ID.
1307 1304
  */
1308
-function give_get_donation_id_by_key( $key ) {
1305
+function give_get_donation_id_by_key($key) {
1309 1306
 	global $wpdb;
1310 1307
 
1311
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1308
+	$meta_table = __give_v20_bc_table_details('payment');
1312 1309
 
1313 1310
 	$purchase = $wpdb->get_var(
1314 1311
 		$wpdb->prepare(
@@ -1324,7 +1321,7 @@  discard block
 block discarded – undo
1324 1321
 		)
1325 1322
 	);
1326 1323
 
1327
-	if ( $purchase != null ) {
1324
+	if ($purchase != null) {
1328 1325
 		return $purchase;
1329 1326
 	}
1330 1327
 
@@ -1342,13 +1339,13 @@  discard block
 block discarded – undo
1342 1339
  *
1343 1340
  * @return int $purchase Donation ID.
1344 1341
  */
1345
-function give_get_purchase_id_by_transaction_id( $key ) {
1342
+function give_get_purchase_id_by_transaction_id($key) {
1346 1343
 	global $wpdb;
1347
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1344
+	$meta_table = __give_v20_bc_table_details('payment');
1348 1345
 
1349
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1346
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1350 1347
 
1351
-	if ( $purchase != null ) {
1348
+	if ($purchase != null) {
1352 1349
 		return $purchase;
1353 1350
 	}
1354 1351
 
@@ -1365,8 +1362,8 @@  discard block
 block discarded – undo
1365 1362
  *
1366 1363
  * @return array $notes Donation Notes
1367 1364
  */
1368
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1369
-	return Give_Comment::get( $payment_id,'payment', array(), $search );
1365
+function give_get_payment_notes($payment_id = 0, $search = '') {
1366
+	return Give_Comment::get($payment_id, 'payment', array(), $search);
1370 1367
 }
1371 1368
 
1372 1369
 
@@ -1380,8 +1377,8 @@  discard block
 block discarded – undo
1380 1377
  *
1381 1378
  * @return int The new note ID
1382 1379
  */
1383
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1384
-	return Give_Comment::add( $payment_id, $note, 'payment' );
1380
+function give_insert_payment_note($payment_id = 0, $note = '') {
1381
+	return Give_Comment::add($payment_id, $note, 'payment');
1385 1382
 }
1386 1383
 
1387 1384
 /**
@@ -1394,8 +1391,8 @@  discard block
 block discarded – undo
1394 1391
  *
1395 1392
  * @return bool True on success, false otherwise.
1396 1393
  */
1397
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1398
-	return Give_Comment::delete( $comment_id, $payment_id, 'payment' );
1394
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1395
+	return Give_Comment::delete($comment_id, $payment_id, 'payment');
1399 1396
 }
1400 1397
 
1401 1398
 /**
@@ -1408,20 +1405,20 @@  discard block
 block discarded – undo
1408 1405
  *
1409 1406
  * @return string
1410 1407
  */
1411
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1408
+function give_get_payment_note_html($note, $payment_id = 0) {
1412 1409
 
1413
-	if ( is_numeric( $note ) ) {
1414
-		$note = get_comment( $note );
1410
+	if (is_numeric($note)) {
1411
+		$note = get_comment($note);
1415 1412
 	}
1416 1413
 
1417
-	if ( ! empty( $note->user_id ) ) {
1418
-		$user = get_userdata( $note->user_id );
1414
+	if ( ! empty($note->user_id)) {
1415
+		$user = get_userdata($note->user_id);
1419 1416
 		$user = $user->display_name;
1420 1417
 	} else {
1421
-		$user = __( 'System', 'give' );
1418
+		$user = __('System', 'give');
1422 1419
 	}
1423 1420
 
1424
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1421
+	$date_format = give_date_format().', '.get_option('time_format');
1425 1422
 
1426 1423
 	$delete_note_url = wp_nonce_url(
1427 1424
 		add_query_arg(
@@ -1430,14 +1427,14 @@  discard block
 block discarded – undo
1430 1427
 				'note_id'     => $note->comment_ID,
1431 1428
 				'payment_id'  => $payment_id,
1432 1429
 			)
1433
-		), 'give_delete_payment_note_' . $note->comment_ID
1430
+		), 'give_delete_payment_note_'.$note->comment_ID
1434 1431
 	);
1435 1432
 
1436
-	$note_html  = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1433
+	$note_html  = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1437 1434
 	$note_html .= '<p>';
1438
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1435
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1439 1436
 	$note_html .= $note->comment_content;
1440
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1437
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>';
1441 1438
 	$note_html .= '</p>';
1442 1439
 	$note_html .= '</div>';
1443 1440
 
@@ -1456,9 +1453,9 @@  discard block
 block discarded – undo
1456 1453
  *
1457 1454
  * @return string $where Modified where clause.
1458 1455
  */
1459
-function give_filter_where_older_than_week( $where = '' ) {
1456
+function give_filter_where_older_than_week($where = '') {
1460 1457
 	// Payments older than one week.
1461
-	$start  = date( 'Y-m-d', strtotime( '-7 days' ) );
1458
+	$start  = date('Y-m-d', strtotime('-7 days'));
1462 1459
 	$where .= " AND post_date <= '{$start}'";
1463 1460
 
1464 1461
 	return $where;
@@ -1479,13 +1476,13 @@  discard block
 block discarded – undo
1479 1476
  *
1480 1477
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1481 1478
  */
1482
-function give_get_donation_form_title( $donation_id, $args = array() ) {
1479
+function give_get_donation_form_title($donation_id, $args = array()) {
1483 1480
 	// Backward compatibility.
1484
-	if ( ! is_numeric( $donation_id ) && $donation_id instanceof Give_Payment ) {
1481
+	if ( ! is_numeric($donation_id) && $donation_id instanceof Give_Payment) {
1485 1482
 		$donation_id = $donation_id->ID;
1486 1483
 	}
1487 1484
 
1488
-	if ( ! $donation_id ) {
1485
+	if ( ! $donation_id) {
1489 1486
 		return '';
1490 1487
 	}
1491 1488
 
@@ -1494,11 +1491,11 @@  discard block
 block discarded – undo
1494 1491
 		'separator'  => '',
1495 1492
 	);
1496 1493
 
1497
-	$args = wp_parse_args( $args, $defaults );
1494
+	$args = wp_parse_args($args, $defaults);
1498 1495
 
1499
-	$form_id     = give_get_payment_form_id( $donation_id );
1500
-	$price_id    = give_get_meta( $donation_id, '_give_payment_price_id', true );
1501
-	$form_title  = give_get_meta( $donation_id, '_give_payment_form_title', true );
1496
+	$form_id     = give_get_payment_form_id($donation_id);
1497
+	$price_id    = give_get_meta($donation_id, '_give_payment_price_id', true);
1498
+	$form_title  = give_get_meta($donation_id, '_give_payment_form_title', true);
1502 1499
 	$only_level  = $args['only_level'];
1503 1500
 	$separator   = $args['separator'];
1504 1501
 	$level_label = '';
@@ -1514,38 +1511,38 @@  discard block
 block discarded – undo
1514 1511
 		), false
1515 1512
 	);
1516 1513
 
1517
-	$form_title_html = Give_Cache::get_db_query( $cache_key );
1514
+	$form_title_html = Give_Cache::get_db_query($cache_key);
1518 1515
 
1519
-	if ( is_null( $form_title_html ) ) {
1520
-		if ( true === $only_level ) {
1516
+	if (is_null($form_title_html)) {
1517
+		if (true === $only_level) {
1521 1518
 			$form_title = '';
1522 1519
 		}
1523 1520
 
1524 1521
 		$form_title_html = $form_title;
1525 1522
 
1526
-		if ( 'custom' === $price_id ) {
1523
+		if ('custom' === $price_id) {
1527 1524
 
1528
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1529
-			$level_label        = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1525
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1526
+			$level_label        = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1530 1527
 
1531 1528
 			// Show custom amount level only in backend otherwise hide it.
1532
-			if ( 'set' === give_get_meta( $form_id, '_give_price_option', true ) && ! is_admin() ) {
1529
+			if ('set' === give_get_meta($form_id, '_give_price_option', true) && ! is_admin()) {
1533 1530
 				$level_label = '';
1534 1531
 			}
1535
-		} elseif ( give_has_variable_prices( $form_id ) ) {
1536
-			$level_label = give_get_price_option_name( $form_id, $price_id, $donation_id, false );
1532
+		} elseif (give_has_variable_prices($form_id)) {
1533
+			$level_label = give_get_price_option_name($form_id, $price_id, $donation_id, false);
1537 1534
 		}
1538 1535
 
1539 1536
 		// Only add separator if there is a form title.
1540 1537
 		if (
1541
-			! empty( $form_title_html ) &&
1542
-			! empty( $level_label )
1538
+			! empty($form_title_html) &&
1539
+			! empty($level_label)
1543 1540
 		) {
1544 1541
 			$form_title_html .= " {$separator} ";
1545 1542
 		}
1546 1543
 
1547 1544
 		$form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>";
1548
-		Give_Cache::set_db_query( $cache_key, $form_title_html );
1545
+		Give_Cache::set_db_query($cache_key, $form_title_html);
1549 1546
 	}
1550 1547
 
1551 1548
 	/**
@@ -1554,7 +1551,7 @@  discard block
 block discarded – undo
1554 1551
 	 * @since 1.0
1555 1552
 	 * @todo: remove third param after 2.1.0
1556 1553
 	 */
1557
-	return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation_id, '' );
1554
+	return apply_filters('give_get_donation_form_title', $form_title_html, $donation_id, '');
1558 1555
 }
1559 1556
 
1560 1557
 /**
@@ -1567,19 +1564,19 @@  discard block
 block discarded – undo
1567 1564
  *
1568 1565
  * @return string $price_id
1569 1566
  */
1570
-function give_get_price_id( $form_id, $price ) {
1567
+function give_get_price_id($form_id, $price) {
1571 1568
 	$price_id = null;
1572 1569
 
1573
-	if ( give_has_variable_prices( $form_id ) ) {
1570
+	if (give_has_variable_prices($form_id)) {
1574 1571
 
1575
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1572
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1576 1573
 
1577
-		foreach ( $levels as $level ) {
1574
+		foreach ($levels as $level) {
1578 1575
 
1579
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1576
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1580 1577
 
1581 1578
 			// Check that this indeed the recurring price.
1582
-			if ( $level_amount == $price ) {
1579
+			if ($level_amount == $price) {
1583 1580
 
1584 1581
 				$price_id = $level['_give_id']['level_id'];
1585 1582
 				break;
@@ -1587,13 +1584,13 @@  discard block
 block discarded – undo
1587 1584
 			}
1588 1585
 		}
1589 1586
 
1590
-		if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1587
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1591 1588
 			$price_id = 'custom';
1592 1589
 		}
1593 1590
 	}
1594 1591
 
1595 1592
 	// Price ID must be numeric or string.
1596
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1593
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1597 1594
 
1598 1595
 	/**
1599 1596
 	 * Filter the price id
@@ -1603,7 +1600,7 @@  discard block
 block discarded – undo
1603 1600
 	 * @param string $price_id
1604 1601
 	 * @param int    $form_id
1605 1602
 	 */
1606
-	return apply_filters( 'give_get_price_id', $price_id, $form_id );
1603
+	return apply_filters('give_get_price_id', $price_id, $form_id);
1607 1604
 }
1608 1605
 
1609 1606
 /**
@@ -1619,10 +1616,10 @@  discard block
 block discarded – undo
1619 1616
  *
1620 1617
  * @return string
1621 1618
  */
1622
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1623
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1619
+function give_get_form_dropdown($args = array(), $echo = false) {
1620
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1624 1621
 
1625
-	if ( ! $echo ) {
1622
+	if ( ! $echo) {
1626 1623
 		return $form_dropdown_html;
1627 1624
 	}
1628 1625
 
@@ -1639,17 +1636,17 @@  discard block
 block discarded – undo
1639 1636
  *
1640 1637
  * @return string|bool
1641 1638
  */
1642
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1639
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1643 1640
 
1644 1641
 	// Check for give form id.
1645
-	if ( empty( $args['id'] ) ) {
1642
+	if (empty($args['id'])) {
1646 1643
 		return false;
1647 1644
 	}
1648 1645
 
1649
-	$form = new Give_Donate_Form( $args['id'] );
1646
+	$form = new Give_Donate_Form($args['id']);
1650 1647
 
1651 1648
 	// Check if form has variable prices or not.
1652
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1649
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1653 1650
 		return false;
1654 1651
 	}
1655 1652
 
@@ -1657,13 +1654,13 @@  discard block
 block discarded – undo
1657 1654
 	$variable_price_options = array();
1658 1655
 
1659 1656
 	// Check if multi donation form support custom donation or not.
1660
-	if ( $form->is_custom_price_mode() ) {
1661
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1657
+	if ($form->is_custom_price_mode()) {
1658
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1662 1659
 	}
1663 1660
 
1664 1661
 	// Get variable price and ID from variable price array.
1665
-	foreach ( $variable_prices as $variable_price ) {
1666
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1662
+	foreach ($variable_prices as $variable_price) {
1663
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1667 1664
 	}
1668 1665
 
1669 1666
 	// Update options.
@@ -1674,9 +1671,9 @@  discard block
 block discarded – undo
1674 1671
 	);
1675 1672
 
1676 1673
 	// Generate select html.
1677
-	$form_dropdown_html = Give()->html->select( $args );
1674
+	$form_dropdown_html = Give()->html->select($args);
1678 1675
 
1679
-	if ( ! $echo ) {
1676
+	if ( ! $echo) {
1680 1677
 		return $form_dropdown_html;
1681 1678
 	}
1682 1679
 
@@ -1695,14 +1692,14 @@  discard block
 block discarded – undo
1695 1692
  *
1696 1693
  * @return string
1697 1694
  */
1698
-function give_get_payment_meta_price_id( $payment_meta ) {
1695
+function give_get_payment_meta_price_id($payment_meta) {
1699 1696
 
1700
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1697
+	if (isset($payment_meta['give_price_id'])) {
1701 1698
 		$price_id = $payment_meta['give_price_id'];
1702
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1699
+	} elseif (isset($payment_meta['price_id'])) {
1703 1700
 		$price_id = $payment_meta['price_id'];
1704 1701
 	} else {
1705
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1702
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1706 1703
 	}
1707 1704
 
1708 1705
 	/**
@@ -1713,7 +1710,7 @@  discard block
 block discarded – undo
1713 1710
 	 * @param string $price_id
1714 1711
 	 * @param array  $payment_meta
1715 1712
 	 */
1716
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta );
1713
+	return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta);
1717 1714
 
1718 1715
 }
1719 1716
 
@@ -1727,10 +1724,10 @@  discard block
 block discarded – undo
1727 1724
  *
1728 1725
  * @return float
1729 1726
  */
1730
-function give_get_payment_total( $payment_id = 0 ) {
1727
+function give_get_payment_total($payment_id = 0) {
1731 1728
 	return round(
1732
-		floatval( give_get_meta( $payment_id, '_give_payment_total', true ) ),
1733
-		give_get_price_decimals( $payment_id )
1729
+		floatval(give_get_meta($payment_id, '_give_payment_total', true)),
1730
+		give_get_price_decimals($payment_id)
1734 1731
 	);
1735 1732
 }
1736 1733
 
@@ -1743,13 +1740,13 @@  discard block
 block discarded – undo
1743 1740
  *
1744 1741
  * @return array
1745 1742
  */
1746
-function give_get_donation_address( $donation_id ) {
1747
-	$address['line1']   = give_get_meta( $donation_id, '_give_donor_billing_address1', true, '' );
1748
-	$address['line2']   = give_get_meta( $donation_id, '_give_donor_billing_address2', true, '' );
1749
-	$address['city']    = give_get_meta( $donation_id, '_give_donor_billing_city', true, '' );
1750
-	$address['state']   = give_get_meta( $donation_id, '_give_donor_billing_state', true, '' );
1751
-	$address['zip']     = give_get_meta( $donation_id, '_give_donor_billing_zip', true, '' );
1752
-	$address['country'] = give_get_meta( $donation_id, '_give_donor_billing_country', true, '' );
1743
+function give_get_donation_address($donation_id) {
1744
+	$address['line1']   = give_get_meta($donation_id, '_give_donor_billing_address1', true, '');
1745
+	$address['line2']   = give_get_meta($donation_id, '_give_donor_billing_address2', true, '');
1746
+	$address['city']    = give_get_meta($donation_id, '_give_donor_billing_city', true, '');
1747
+	$address['state']   = give_get_meta($donation_id, '_give_donor_billing_state', true, '');
1748
+	$address['zip']     = give_get_meta($donation_id, '_give_donor_billing_zip', true, '');
1749
+	$address['country'] = give_get_meta($donation_id, '_give_donor_billing_country', true, '');
1753 1750
 
1754 1751
 	return $address;
1755 1752
 }
@@ -1764,7 +1761,7 @@  discard block
 block discarded – undo
1764 1761
  *
1765 1762
  * @return bool
1766 1763
  */
1767
-function give_is_donation_completed( $donation_id ) {
1764
+function give_is_donation_completed($donation_id) {
1768 1765
 	global $wpdb;
1769 1766
 
1770 1767
 	/**
@@ -1805,10 +1802,10 @@  discard block
 block discarded – undo
1805 1802
  *
1806 1803
  * @return bool
1807 1804
  */
1808
-function give_is_anonymous_donation( $donation_id ) {
1805
+function give_is_anonymous_donation($donation_id) {
1809 1806
 	$value = false;
1810 1807
 
1811
-	if( (int) give_get_meta( $donation_id, '_give_anonymous_donation', true ) ){
1808
+	if ((int) give_get_meta($donation_id, '_give_anonymous_donation', true)) {
1812 1809
 		$value = true;
1813 1810
 	}
1814 1811
 
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 1 patch
Spacing   +281 added lines, -282 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
 
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
 	 *
408 408
 	 * @return mixed void|false
409 409
 	 */
410
-	public function __construct( $payment_id = false ) {
410
+	public function __construct($payment_id = false) {
411 411
 
412
-		if ( empty( $payment_id ) ) {
412
+		if (empty($payment_id)) {
413 413
 			return false;
414 414
 		}
415 415
 
416
-		$this->setup_payment( $payment_id );
416
+		$this->setup_payment($payment_id);
417 417
 	}
418 418
 
419 419
 	/**
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 	 *
427 427
 	 * @return mixed        The value.
428 428
 	 */
429
-	public function __get( $key ) {
429
+	public function __get($key) {
430 430
 
431
-		if ( method_exists( $this, 'get_' . $key ) ) {
431
+		if (method_exists($this, 'get_'.$key)) {
432 432
 
433
-			$value = call_user_func( array( $this, 'get_' . $key ) );
433
+			$value = call_user_func(array($this, 'get_'.$key));
434 434
 
435 435
 		} else {
436 436
 
@@ -452,18 +452,18 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $key   The property name.
453 453
 	 * @param  mixed  $value The value of the property.
454 454
 	 */
455
-	public function __set( $key, $value ) {
456
-		$ignore = array( '_ID' );
455
+	public function __set($key, $value) {
456
+		$ignore = array('_ID');
457 457
 
458
-		if ( 'status' === $key ) {
458
+		if ('status' === $key) {
459 459
 			$this->old_status = $this->status;
460 460
 		}
461 461
 
462
-		if ( ! in_array( $key, $ignore ) ) {
463
-			$this->pending[ $key ] = $value;
462
+		if ( ! in_array($key, $ignore)) {
463
+			$this->pending[$key] = $value;
464 464
 		}
465 465
 
466
-		if ( '_ID' !== $key ) {
466
+		if ('_ID' !== $key) {
467 467
 			$this->$key = $value;
468 468
 		}
469 469
 	}
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
 	 *
479 479
 	 * @return boolean|null       If the item is set or not
480 480
 	 */
481
-	public function __isset( $name ) {
482
-		if ( property_exists( $this, $name ) ) {
483
-			return false === empty( $this->$name );
481
+	public function __isset($name) {
482
+		if (property_exists($this, $name)) {
483
+			return false === empty($this->$name);
484 484
 		} else {
485 485
 			return null;
486 486
 		}
@@ -496,20 +496,20 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @return bool            If the setup was successful or not
498 498
 	 */
499
-	private function setup_payment( $payment_id ) {
499
+	private function setup_payment($payment_id) {
500 500
 		$this->pending = array();
501 501
 
502
-		if ( empty( $payment_id ) ) {
502
+		if (empty($payment_id)) {
503 503
 			return false;
504 504
 		}
505 505
 
506
-		$payment = get_post( absint( $payment_id ) );
506
+		$payment = get_post(absint($payment_id));
507 507
 
508
-		if ( ! $payment || is_wp_error( $payment ) ) {
508
+		if ( ! $payment || is_wp_error($payment)) {
509 509
 			return false;
510 510
 		}
511 511
 
512
-		if ( 'give_payment' !== $payment->post_type ) {
512
+		if ('give_payment' !== $payment->post_type) {
513 513
 			return false;
514 514
 		}
515 515
 
@@ -523,17 +523,17 @@  discard block
 block discarded – undo
523 523
 		 * @param Give_Payment $this       Payment object.
524 524
 		 * @param int          $payment_id The ID of the payment.
525 525
 		 */
526
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
526
+		do_action('give_pre_setup_payment', $this, $payment_id);
527 527
 
528 528
 		// Get payment from cache.
529
-		$donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' );
529
+		$donation_vars = Give_Cache::get_group($payment_id, 'give-donations');
530 530
 
531
-		if ( is_null( $donation_vars ) ) {
531
+		if (is_null($donation_vars)) {
532 532
 			// Primary Identifier.
533
-			$this->ID = absint( $payment_id );
533
+			$this->ID = absint($payment_id);
534 534
 
535 535
 			// Protected ID that can never be changed.
536
-			$this->_ID = absint( $payment_id );
536
+			$this->_ID = absint($payment_id);
537 537
 
538 538
 			// We have a payment, get the generic payment_meta item to reduce calls to it.
539 539
 			$this->payment_meta = $this->get_meta();
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 			$this->parent_payment = $payment->post_parent;
550 550
 
551 551
 			$all_payment_statuses  = give_get_payment_statuses();
552
-			$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
552
+			$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
553 553
 
554 554
 			// Currency Based.
555 555
 			$this->total    = $this->setup_total();
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 			$this->address      = $this->setup_address();
571 571
 			$this->first_name   = $this->user_info['first_name'];
572 572
 			$this->last_name    = $this->user_info['last_name'];
573
-			$this->title_prefix = isset( $this->user_info['title'] ) ? $this->user_info['title'] : '';
573
+			$this->title_prefix = isset($this->user_info['title']) ? $this->user_info['title'] : '';
574 574
 
575 575
 			// Other Identifiers.
576 576
 			$this->form_title = $this->setup_form_title();
@@ -579,10 +579,10 @@  discard block
 block discarded – undo
579 579
 			$this->key        = $this->setup_payment_key();
580 580
 			$this->number     = $this->setup_payment_number();
581 581
 
582
-			Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' );
582
+			Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations');
583 583
 		} else {
584 584
 
585
-			foreach ( $donation_vars as $donation_var => $value ) {
585
+			foreach ($donation_vars as $donation_var => $value) {
586 586
 				$this->$donation_var = $value;
587 587
 			}
588 588
 		} // End if().
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		 * @param Give_Payment $this       Payment object.
598 598
 		 * @param int          $payment_id The ID of the payment.
599 599
 		 */
600
-		do_action( 'give_setup_payment', $this, $payment_id );
600
+		do_action('give_setup_payment', $this, $payment_id);
601 601
 
602 602
 		return true;
603 603
 	}
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
 	 *
617 617
 	 * @return void
618 618
 	 */
619
-	public function update_payment_setup( $payment_id ) {
619
+	public function update_payment_setup($payment_id) {
620 620
 		// Delete cache.
621
-		Give_Cache::delete_group( $this->ID,'give-donations' );
621
+		Give_Cache::delete_group($this->ID, 'give-donations');
622 622
 
623
-		$this->setup_payment( $payment_id );
623
+		$this->setup_payment($payment_id);
624 624
 	}
625 625
 
626 626
 	/**
@@ -635,24 +635,24 @@  discard block
 block discarded – undo
635 635
 
636 636
 		// Construct the payment title.
637 637
 		$payment_title = '';
638
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
639
-			$payment_title = $this->first_name . ' ' . $this->last_name;
640
-		} elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
638
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
639
+			$payment_title = $this->first_name.' '.$this->last_name;
640
+		} elseif ( ! empty($this->first_name) && empty($this->last_name)) {
641 641
 			$payment_title = $this->first_name;
642
-		} elseif ( ! empty( $this->email ) && is_email( $this->email ) ) {
642
+		} elseif ( ! empty($this->email) && is_email($this->email)) {
643 643
 			$payment_title = $this->email;
644 644
 		}
645 645
 
646 646
 		// Set Key.
647
-		if ( empty( $this->key ) ) {
647
+		if (empty($this->key)) {
648 648
 
649
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
650
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key.
649
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
650
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key.
651 651
 			$this->pending['key'] = $this->key;
652 652
 		}
653 653
 
654 654
 		// Set IP.
655
-		if ( empty( $this->ip ) ) {
655
+		if (empty($this->ip)) {
656 656
 
657 657
 			$this->ip            = give_get_ip();
658 658
 			$this->pending['ip'] = $this->ip;
@@ -682,19 +682,19 @@  discard block
 block discarded – undo
682 682
 			'status'       => $this->status,
683 683
 		);
684 684
 
685
-		$args = apply_filters( 'give_insert_payment_args', array(
685
+		$args = apply_filters('give_insert_payment_args', array(
686 686
 			'post_title'    => $payment_title,
687 687
 			'post_status'   => $this->status,
688 688
 			'post_type'     => 'give_payment',
689
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
690
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
689
+			'post_date'     => ! empty($this->date) ? $this->date : null,
690
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
691 691
 			'post_parent'   => $this->parent_payment,
692
-		), $payment_data );
692
+		), $payment_data);
693 693
 
694 694
 		// Create a blank payment.
695
-		$payment_id = wp_insert_post( $args );
695
+		$payment_id = wp_insert_post($args);
696 696
 
697
-		if ( ! empty( $payment_id ) ) {
697
+		if ( ! empty($payment_id)) {
698 698
 
699 699
 			$this->ID  = $payment_id;
700 700
 			$this->_ID = $payment_id;
@@ -706,43 +706,43 @@  discard block
 block discarded – undo
706 706
 			 *
707 707
 			 * @since 1.8.13
708 708
 			 */
709
-			$donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args );
709
+			$donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args);
710 710
 
711
-			if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
712
-				$donor = new Give_Donor( get_current_user_id(), true );
711
+			if (did_action('give_pre_process_donation') && is_user_logged_in()) {
712
+				$donor = new Give_Donor(get_current_user_id(), true);
713 713
 
714 714
 				// Donor is logged in but used a different email to purchase with so assign to their donor record.
715
-				if ( ! empty( $donor->id ) && $this->email !== $donor->email ) {
716
-					$donor->add_email( $this->email );
715
+				if ( ! empty($donor->id) && $this->email !== $donor->email) {
716
+					$donor->add_email($this->email);
717 717
 				}
718 718
 			}
719 719
 
720
-			if ( empty( $donor->id ) ) {
721
-				$donor = new Give_Donor( $this->email );
720
+			if (empty($donor->id)) {
721
+				$donor = new Give_Donor($this->email);
722 722
 			}
723 723
 
724
-			if ( empty( $donor->id ) ) {
724
+			if (empty($donor->id)) {
725 725
 
726 726
 				$donor_data = array(
727
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
727
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
728 728
 					'email'   => $this->email,
729 729
 					'user_id' => $this->user_id,
730 730
 				);
731 731
 
732
-				$donor->create( $donor_data );
732
+				$donor->create($donor_data);
733 733
 
734 734
 			}
735 735
 
736 736
 			// Update Donor Meta once donor is created.
737
-			$donor->update_meta( '_give_donor_first_name', $this->first_name );
738
-			$donor->update_meta( '_give_donor_last_name', $this->last_name );
739
-			$donor->update_meta( '_give_donor_title_prefix', $this->title_prefix );
737
+			$donor->update_meta('_give_donor_first_name', $this->first_name);
738
+			$donor->update_meta('_give_donor_last_name', $this->last_name);
739
+			$donor->update_meta('_give_donor_title_prefix', $this->title_prefix);
740 740
 
741 741
 			$this->customer_id            = $donor->id;
742 742
 			$this->pending['customer_id'] = $this->customer_id;
743
-			$donor->attach_payment( $this->ID, false );
743
+			$donor->attach_payment($this->ID, false);
744 744
 
745
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
745
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
746 746
 
747 747
 			/*
748 748
 			 * _give_payment_meta backward compatibility.
@@ -750,25 +750,25 @@  discard block
 block discarded – undo
750 750
 			 * @since 2.0.1
751 751
 			 */
752 752
 			$custom_payment_meta = array_diff(
753
-				array_map( 'maybe_serialize', $this->payment_meta ),
754
-				array_map( 'maybe_serialize', $payment_data )
753
+				array_map('maybe_serialize', $this->payment_meta),
754
+				array_map('maybe_serialize', $payment_data)
755 755
 			);
756 756
 
757
-			if ( ! empty( $custom_payment_meta ) ) {
758
-				give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give' ), '2.0.0' );
757
+			if ( ! empty($custom_payment_meta)) {
758
+				give_doing_it_wrong('_give_payment_meta', __('This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give'), '2.0.0');
759 759
 
760
-				$this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) );
760
+				$this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta));
761 761
 			}
762 762
 
763
-			$give_company = ( ! empty( $_REQUEST['give_company_name'] ) ? give_clean( $_REQUEST['give_company_name'] ) : '' );
763
+			$give_company = ( ! empty($_REQUEST['give_company_name']) ? give_clean($_REQUEST['give_company_name']) : '');
764 764
 
765 765
 			// Check $page_url is not empty.
766
-			if ( $give_company ) {
767
-				give_update_meta( $payment_id, '_give_donation_company', $give_company );
766
+			if ($give_company) {
767
+				give_update_meta($payment_id, '_give_donation_company', $give_company);
768 768
 
769
-				$donor_id = absint( $donor->id );
770
-				if ( ! empty( $donor_id ) ) {
771
-					Give()->donor_meta->update_meta( $donor_id, '_give_donor_company', $give_company );
769
+				$donor_id = absint($donor->id);
770
+				if ( ! empty($donor_id)) {
771
+					Give()->donor_meta->update_meta($donor_id, '_give_donor_company', $give_company);
772 772
 				}
773 773
 			}
774 774
 
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
 		$saved = false;
793 793
 
794 794
 		// Must have an ID.
795
-		if ( empty( $this->ID ) ) {
795
+		if (empty($this->ID)) {
796 796
 
797 797
 			$payment_id = $this->insert_payment();
798 798
 
799
-			if ( false === $payment_id ) {
799
+			if (false === $payment_id) {
800 800
 				$saved = false;
801 801
 			} else {
802 802
 				$this->ID = $payment_id;
@@ -804,42 +804,42 @@  discard block
 block discarded – undo
804 804
 		}
805 805
 
806 806
 		// Set ID if not matching.
807
-		if ( $this->ID !== $this->_ID ) {
807
+		if ($this->ID !== $this->_ID) {
808 808
 			$this->ID = $this->_ID;
809 809
 		}
810 810
 
811 811
 		// If we have something pending, let's save it.
812
-		if ( ! empty( $this->pending ) ) {
812
+		if ( ! empty($this->pending)) {
813 813
 
814 814
 			$total_increase = 0;
815 815
 			$total_decrease = 0;
816 816
 
817
-			foreach ( $this->pending as $key => $value ) {
817
+			foreach ($this->pending as $key => $value) {
818 818
 
819
-				switch ( $key ) {
819
+				switch ($key) {
820 820
 
821 821
 					case 'donations':
822 822
 						// Update totals for pending donations.
823
-						foreach ( $this->pending[ $key ] as $item ) {
823
+						foreach ($this->pending[$key] as $item) {
824 824
 
825
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
826
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
825
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
826
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
827 827
 
828
-							switch ( $item['action'] ) {
828
+							switch ($item['action']) {
829 829
 
830 830
 								case 'add':
831 831
 
832 832
 									$price = $item['price'];
833 833
 
834
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
834
+									if ('publish' === $this->status || 'complete' === $this->status) {
835 835
 
836 836
 										// Add donation to logs.
837
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
838
-										give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
837
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
838
+										give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
839 839
 
840
-										$form = new Give_Donate_Form( $item['id'] );
841
-										$form->increase_sales( $quantity );
842
-										$form->increase_earnings( $price, $this->ID );
840
+										$form = new Give_Donate_Form($item['id']);
841
+										$form->increase_sales($quantity);
842
+										$form->increase_earnings($price, $this->ID);
843 843
 
844 844
 										$total_increase += $price;
845 845
 									}
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
 
848 848
 								case 'remove':
849 849
 									$this->delete_sales_logs();
850
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
851
-										$form = new Give_Donate_Form( $item['id'] );
852
-										$form->decrease_sales( $quantity );
853
-										$form->decrease_earnings( $item['amount'], $this->ID );
850
+									if ('publish' === $this->status || 'complete' === $this->status) {
851
+										$form = new Give_Donate_Form($item['id']);
852
+										$form->decrease_sales($quantity);
853
+										$form->decrease_earnings($item['amount'], $this->ID);
854 854
 
855 855
 										$total_decrease += $item['amount'];
856 856
 									}
@@ -861,103 +861,103 @@  discard block
 block discarded – undo
861 861
 						break;
862 862
 
863 863
 					case 'status':
864
-						$this->update_status( $this->status );
864
+						$this->update_status($this->status);
865 865
 						break;
866 866
 
867 867
 					case 'gateway':
868
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
868
+						$this->update_meta('_give_payment_gateway', $this->gateway);
869 869
 						break;
870 870
 
871 871
 					case 'mode':
872
-						$this->update_meta( '_give_payment_mode', $this->mode );
872
+						$this->update_meta('_give_payment_mode', $this->mode);
873 873
 						break;
874 874
 
875 875
 					case 'transaction_id':
876
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
876
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
877 877
 						break;
878 878
 
879 879
 					case 'ip':
880
-						$this->update_meta( '_give_payment_donor_ip', $this->ip );
880
+						$this->update_meta('_give_payment_donor_ip', $this->ip);
881 881
 						break;
882 882
 
883 883
 					case 'customer_id':
884
-						$this->update_meta( '_give_payment_donor_id', $this->customer_id );
884
+						$this->update_meta('_give_payment_donor_id', $this->customer_id);
885 885
 						break;
886 886
 
887 887
 					case 'form_title':
888
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
888
+						$this->update_meta('_give_payment_form_title', $this->form_title);
889 889
 						break;
890 890
 
891 891
 					case 'form_id':
892
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
892
+						$this->update_meta('_give_payment_form_id', $this->form_id);
893 893
 						break;
894 894
 
895 895
 					case 'price_id':
896
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
896
+						$this->update_meta('_give_payment_price_id', $this->price_id);
897 897
 						break;
898 898
 
899 899
 					case 'first_name':
900
-						$this->update_meta( '_give_donor_billing_first_name', $this->first_name );
900
+						$this->update_meta('_give_donor_billing_first_name', $this->first_name);
901 901
 						break;
902 902
 
903 903
 					case 'last_name':
904
-						$this->update_meta( '_give_donor_billing_last_name', $this->last_name );
904
+						$this->update_meta('_give_donor_billing_last_name', $this->last_name);
905 905
 						break;
906 906
 
907 907
 					case 'currency':
908
-						$this->update_meta( '_give_payment_currency', $this->currency );
908
+						$this->update_meta('_give_payment_currency', $this->currency);
909 909
 						break;
910 910
 
911 911
 					case 'address':
912
-						if ( ! empty( $this->address ) ) {
913
-							foreach ( $this->address as $address_name => $address ) {
914
-								switch ( $address_name ) {
912
+						if ( ! empty($this->address)) {
913
+							foreach ($this->address as $address_name => $address) {
914
+								switch ($address_name) {
915 915
 									case 'line1':
916
-										$this->update_meta( '_give_donor_billing_address1', $address );
916
+										$this->update_meta('_give_donor_billing_address1', $address);
917 917
 										break;
918 918
 
919 919
 									case 'line2':
920
-										$this->update_meta( '_give_donor_billing_address2', $address );
920
+										$this->update_meta('_give_donor_billing_address2', $address);
921 921
 										break;
922 922
 
923 923
 									default:
924
-										$this->update_meta( "_give_donor_billing_{$address_name}", $address );
924
+										$this->update_meta("_give_donor_billing_{$address_name}", $address);
925 925
 								}
926 926
 							}
927 927
 						}
928 928
 						break;
929 929
 
930 930
 					case 'email':
931
-						$this->update_meta( '_give_payment_donor_email', $this->email );
931
+						$this->update_meta('_give_payment_donor_email', $this->email);
932 932
 						break;
933 933
 
934 934
 					case 'title_prefix':
935
-						$this->update_meta( '_give_payment_donor_title_prefix', $this->title_prefix );
935
+						$this->update_meta('_give_payment_donor_title_prefix', $this->title_prefix);
936 936
 						break;
937 937
 
938 938
 					case 'key':
939
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
939
+						$this->update_meta('_give_payment_purchase_key', $this->key);
940 940
 						break;
941 941
 
942 942
 					case 'number':
943 943
 						// @todo: remove unused meta data.
944 944
 						// Core is using post_title to store donation serial code ( fi enabled ) instead this meta key.
945 945
 						// Do not use this meta key in your logic, can be remove in future
946
-						$this->update_meta( '_give_payment_number', $this->number );
946
+						$this->update_meta('_give_payment_number', $this->number);
947 947
 						break;
948 948
 
949 949
 					case 'date':
950 950
 						$args = array(
951 951
 							'ID'        => $this->ID,
952
-							'post_date' => date( 'Y-m-d H:i:s', strtotime( $this->date ) ),
952
+							'post_date' => date('Y-m-d H:i:s', strtotime($this->date)),
953 953
 							'edit_date' => true,
954 954
 						);
955 955
 
956
-						wp_update_post( $args );
956
+						wp_update_post($args);
957 957
 						break;
958 958
 
959 959
 					case 'completed_date':
960
-						$this->update_meta( '_give_completed_date', $this->completed_date );
960
+						$this->update_meta('_give_completed_date', $this->completed_date);
961 961
 						break;
962 962
 
963 963
 					case 'parent_payment':
@@ -966,11 +966,11 @@  discard block
 block discarded – undo
966 966
 							'post_parent' => $this->parent_payment,
967 967
 						);
968 968
 
969
-						wp_update_post( $args );
969
+						wp_update_post($args);
970 970
 						break;
971 971
 
972 972
 					case 'total':
973
-						$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
973
+						$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
974 974
 						break;
975 975
 
976 976
 					default:
@@ -981,46 +981,46 @@  discard block
 block discarded – undo
981 981
 						 *
982 982
 						 * @param Give_Payment $this Payment object.
983 983
 						 */
984
-						do_action( 'give_payment_save', $this, $key );
984
+						do_action('give_payment_save', $this, $key);
985 985
 						break;
986 986
 				} // End switch().
987 987
 			} // End foreach().
988 988
 
989
-			if ( 'pending' !== $this->status ) {
989
+			if ('pending' !== $this->status) {
990 990
 
991
-				$donor = new Give_Donor( $this->customer_id );
991
+				$donor = new Give_Donor($this->customer_id);
992 992
 
993 993
 				$total_change = $total_increase - $total_decrease;
994
-				if ( $total_change < 0 ) {
994
+				if ($total_change < 0) {
995 995
 
996
-					$total_change = - ( $total_change );
996
+					$total_change = - ($total_change);
997 997
 
998 998
 					// Decrease the donor's donation stats.
999
-					$donor->decrease_value( $total_change );
1000
-					give_decrease_total_earnings( $total_change );
999
+					$donor->decrease_value($total_change);
1000
+					give_decrease_total_earnings($total_change);
1001 1001
 
1002 1002
 					$donor->decrease_donation_count();
1003 1003
 
1004
-				} elseif ( $total_change > 0 ) {
1004
+				} elseif ($total_change > 0) {
1005 1005
 
1006 1006
 					// Increase the donor's donation stats.
1007
-					$donor->increase_value( $total_change );
1008
-					give_increase_total_earnings( $total_change );
1007
+					$donor->increase_value($total_change);
1008
+					give_increase_total_earnings($total_change);
1009 1009
 
1010 1010
 					$donor->increase_purchase_count();
1011 1011
 
1012 1012
 				}
1013 1013
 
1014 1014
 				// Verify and update form meta based on the form status.
1015
-				give_set_form_closed_status( $this->form_id );
1015
+				give_set_form_closed_status($this->form_id);
1016 1016
 			}
1017 1017
 
1018 1018
 			$this->pending = array();
1019 1019
 			$saved         = true;
1020 1020
 		} // End if().
1021 1021
 
1022
-		if ( true === $saved ) {
1023
-			$this->setup_payment( $this->ID );
1022
+		if (true === $saved) {
1023
+			$this->setup_payment($this->ID);
1024 1024
 		}
1025 1025
 
1026 1026
 		return $saved;
@@ -1038,12 +1038,12 @@  discard block
 block discarded – undo
1038 1038
 	 *
1039 1039
 	 * @return bool           True when successful, false otherwise
1040 1040
 	 */
1041
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1041
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1042 1042
 
1043
-		$donation = new Give_Donate_Form( $form_id );
1043
+		$donation = new Give_Donate_Form($form_id);
1044 1044
 
1045 1045
 		// Bail if this post isn't a give donation form.
1046
-		if ( ! $donation || 'give_forms' !== $donation->post_type ) {
1046
+		if ( ! $donation || 'give_forms' !== $donation->post_type) {
1047 1047
 			return false;
1048 1048
 		}
1049 1049
 
@@ -1053,25 +1053,25 @@  discard block
 block discarded – undo
1053 1053
 			'price_id' => false,
1054 1054
 		);
1055 1055
 
1056
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1056
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1057 1057
 
1058 1058
 		// Allow overriding the price.
1059
-		if ( false !== $args['price'] ) {
1059
+		if (false !== $args['price']) {
1060 1060
 			$donation_amount = $args['price'];
1061 1061
 		} else {
1062 1062
 
1063 1063
 			// Deal with variable pricing.
1064
-			if ( give_has_variable_prices( $donation->ID ) ) {
1065
-				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1064
+			if (give_has_variable_prices($donation->ID)) {
1065
+				$prices          = give_get_meta($form_id, '_give_donation_levels', true);
1066 1066
 				$donation_amount = '';
1067 1067
 
1068 1068
 				// Loop through prices.
1069
-				foreach ( $prices as $price ) {
1069
+				foreach ($prices as $price) {
1070 1070
 					// Find a match between price_id and level_id.
1071 1071
 					// First verify array keys exists THEN make the match.
1072 1072
 					if (
1073
-						isset( $args['price_id'] ) &&
1074
-						isset( $price['_give_id']['level_id'] ) &&
1073
+						isset($args['price_id']) &&
1074
+						isset($price['_give_id']['level_id']) &&
1075 1075
 						$args['price_id'] === (int) $price['_give_id']['level_id']
1076 1076
 					) {
1077 1077
 						$donation_amount = $price['_give_amount'];
@@ -1079,37 +1079,37 @@  discard block
 block discarded – undo
1079 1079
 				}
1080 1080
 
1081 1081
 				// Fallback to the lowest price point.
1082
-				if ( '' === $donation_amount ) {
1083
-					$donation_amount  = give_get_lowest_price_option( $donation->ID );
1084
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1082
+				if ('' === $donation_amount) {
1083
+					$donation_amount  = give_get_lowest_price_option($donation->ID);
1084
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1085 1085
 				}
1086 1086
 			} else {
1087 1087
 				// Simple form price.
1088
-				$donation_amount = give_get_form_price( $donation->ID );
1088
+				$donation_amount = give_get_form_price($donation->ID);
1089 1089
 			}
1090 1090
 		}
1091 1091
 
1092 1092
 		// Sanitizing the price here so we don't have a dozen calls later.
1093
-		$donation_amount = give_maybe_sanitize_amount( $donation_amount );
1094
-		$total           = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1093
+		$donation_amount = give_maybe_sanitize_amount($donation_amount);
1094
+		$total           = round($donation_amount, give_get_price_decimals($this->ID));
1095 1095
 
1096 1096
 		// Add Options.
1097 1097
 		$default_options = array();
1098
-		if ( false !== $args['price_id'] ) {
1098
+		if (false !== $args['price_id']) {
1099 1099
 			$default_options['price_id'] = (int) $args['price_id'];
1100 1100
 		}
1101
-		$options = wp_parse_args( $options, $default_options );
1101
+		$options = wp_parse_args($options, $default_options);
1102 1102
 
1103 1103
 		// Do not allow totals to go negative.
1104
-		if ( $total < 0 ) {
1104
+		if ($total < 0) {
1105 1105
 			$total = 0;
1106 1106
 		}
1107 1107
 
1108 1108
 		$donation = array(
1109 1109
 			'name'     => $donation->post_title,
1110 1110
 			'id'       => $donation->ID,
1111
-			'price'    => round( $total, give_get_price_decimals( $this->ID ) ),
1112
-			'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1111
+			'price'    => round($total, give_get_price_decimals($this->ID)),
1112
+			'subtotal' => round($total, give_get_price_decimals($this->ID)),
1113 1113
 			'price_id' => $args['price_id'],
1114 1114
 			'action'   => 'add',
1115 1115
 			'options'  => $options,
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 
1118 1118
 		$this->pending['donations'][] = $donation;
1119 1119
 
1120
-		$this->increase_subtotal( $total );
1120
+		$this->increase_subtotal($total);
1121 1121
 
1122 1122
 		return true;
1123 1123
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @return bool           If the item was removed or not
1136 1136
 	 */
1137
-	public function remove_donation( $form_id, $args = array() ) {
1137
+	public function remove_donation($form_id, $args = array()) {
1138 1138
 
1139 1139
 		// Set some defaults.
1140 1140
 		$defaults = array(
@@ -1142,12 +1142,12 @@  discard block
 block discarded – undo
1142 1142
 			'price'    => false,
1143 1143
 			'price_id' => false,
1144 1144
 		);
1145
-		$args     = wp_parse_args( $args, $defaults );
1145
+		$args = wp_parse_args($args, $defaults);
1146 1146
 
1147
-		$form = new Give_Donate_Form( $form_id );
1147
+		$form = new Give_Donate_Form($form_id);
1148 1148
 
1149 1149
 		// Bail if this post isn't a valid give donation form.
1150
-		if ( ! $form || 'give_forms' !== $form->post_type ) {
1150
+		if ( ! $form || 'give_forms' !== $form->post_type) {
1151 1151
 			return false;
1152 1152
 		}
1153 1153
 
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 
1161 1161
 		$this->pending['donations'][] = $pending_args;
1162 1162
 
1163
-		$this->decrease_subtotal( $this->total );
1163
+		$this->decrease_subtotal($this->total);
1164 1164
 
1165 1165
 		return true;
1166 1166
 	}
@@ -1176,13 +1176,13 @@  discard block
 block discarded – undo
1176 1176
 	 *
1177 1177
 	 * @return bool           If the note was specified or not
1178 1178
 	 */
1179
-	public function add_note( $note = false ) {
1179
+	public function add_note($note = false) {
1180 1180
 		// Bail if no note specified.
1181
-		if ( ! $note ) {
1181
+		if ( ! $note) {
1182 1182
 			return false;
1183 1183
 		}
1184 1184
 
1185
-		give_insert_payment_note( $this->ID, $note );
1185
+		give_insert_payment_note($this->ID, $note);
1186 1186
 	}
1187 1187
 
1188 1188
 	/**
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
 	 *
1196 1196
 	 * @return void
1197 1197
 	 */
1198
-	private function increase_subtotal( $amount = 0.00 ) {
1199
-		$amount         = (float) $amount;
1198
+	private function increase_subtotal($amount = 0.00) {
1199
+		$amount = (float) $amount;
1200 1200
 		$this->subtotal += $amount;
1201 1201
 
1202 1202
 		$this->recalculate_total();
@@ -1212,11 +1212,11 @@  discard block
 block discarded – undo
1212 1212
 	 *
1213 1213
 	 * @return void
1214 1214
 	 */
1215
-	private function decrease_subtotal( $amount = 0.00 ) {
1216
-		$amount         = (float) $amount;
1215
+	private function decrease_subtotal($amount = 0.00) {
1216
+		$amount = (float) $amount;
1217 1217
 		$this->subtotal -= $amount;
1218 1218
 
1219
-		if ( $this->subtotal < 0 ) {
1219
+		if ($this->subtotal < 0) {
1220 1220
 			$this->subtotal = 0;
1221 1221
 		}
1222 1222
 
@@ -1246,24 +1246,24 @@  discard block
 block discarded – undo
1246 1246
 	 *
1247 1247
 	 * @return bool   $updated Returns if the status was successfully updated.
1248 1248
 	 */
1249
-	public function update_status( $status = false ) {
1249
+	public function update_status($status = false) {
1250 1250
 
1251 1251
 		// standardize the 'complete(d)' status.
1252
-		if ( 'completed' === $status || 'complete' === $status ) {
1252
+		if ('completed' === $status || 'complete' === $status) {
1253 1253
 			$status = 'publish';
1254 1254
 		}
1255 1255
 
1256
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1256
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1257 1257
 
1258
-		if ( $old_status === $status ) {
1258
+		if ($old_status === $status) {
1259 1259
 			return false; // Don't permit status changes that aren't changes.
1260 1260
 		}
1261 1261
 
1262
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1262
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1263 1263
 
1264 1264
 		$updated = false;
1265 1265
 
1266
-		if ( $do_change ) {
1266
+		if ($do_change) {
1267 1267
 
1268 1268
 			/**
1269 1269
 			 * Fires before changing payment status.
@@ -1274,21 +1274,21 @@  discard block
 block discarded – undo
1274 1274
 			 * @param string $status     The new status.
1275 1275
 			 * @param string $old_status The old status.
1276 1276
 			 */
1277
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1277
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1278 1278
 
1279 1279
 			$update_fields = array(
1280 1280
 				'ID'          => $this->ID,
1281 1281
 				'post_status' => $status,
1282
-				'edit_date'   => current_time( 'mysql' ),
1282
+				'edit_date'   => current_time('mysql'),
1283 1283
 			);
1284 1284
 
1285
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1285
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1286 1286
 
1287 1287
 			$all_payment_statuses  = give_get_payment_statuses();
1288
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1288
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1289 1289
 
1290 1290
 			// Process any specific status functions.
1291
-			$this->process_status( $status );
1291
+			$this->process_status($status);
1292 1292
 
1293 1293
 			/**
1294 1294
 			 * Fires after changing payment status.
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 			 * @param string $status     The new status.
1300 1300
 			 * @param string $old_status The old status.
1301 1301
 			 */
1302
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1302
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1303 1303
 
1304 1304
 		} // End if().
1305 1305
 
@@ -1334,27 +1334,27 @@  discard block
 block discarded – undo
1334 1334
 	 *
1335 1335
 	 * @return mixed             The value from the post meta
1336 1336
 	 */
1337
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1337
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1338 1338
 		if (
1339
-			! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) &&
1340
-			! doing_filter( 'get_post_metadata' )
1339
+			! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') &&
1340
+			! doing_filter('get_post_metadata')
1341 1341
 		) {
1342
-			add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
1342
+			add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
1343 1343
 		}
1344 1344
 
1345
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1345
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1346 1346
 
1347 1347
 		/**
1348 1348
 		 * Filter the specific meta key value.
1349 1349
 		 *
1350 1350
 		 * @since 1.5
1351 1351
 		 */
1352
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1352
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1353 1353
 
1354 1354
 		// Security check.
1355
-		if ( is_serialized( $meta ) ) {
1356
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1357
-			if ( ! empty( $matches ) ) {
1355
+		if (is_serialized($meta)) {
1356
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches);
1357
+			if ( ! empty($matches)) {
1358 1358
 				$meta = array();
1359 1359
 			}
1360 1360
 		}
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 		 *
1365 1365
 		 * @since 1.5
1366 1366
 		 */
1367
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1367
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1368 1368
 	}
1369 1369
 
1370 1370
 	/**
@@ -1379,8 +1379,8 @@  discard block
 block discarded – undo
1379 1379
 	 *
1380 1380
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1381 1381
 	 */
1382
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1383
-		if ( empty( $meta_key ) ) {
1382
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1383
+		if (empty($meta_key)) {
1384 1384
 			return false;
1385 1385
 		}
1386 1386
 
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 		 *
1391 1391
 		 * @since 1.5
1392 1392
 		 */
1393
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1393
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1394 1394
 
1395
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1395
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1396 1396
 	}
1397 1397
 
1398 1398
 	/**
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 	 *
1406 1406
 	 * @return void
1407 1407
 	 */
1408
-	private function process_status( $status ) {
1408
+	private function process_status($status) {
1409 1409
 		$process = true;
1410 1410
 
1411 1411
 		// Bailout, if changed from completed to preapproval/processing.
@@ -1420,9 +1420,9 @@  discard block
 block discarded – undo
1420 1420
 		}
1421 1421
 
1422 1422
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1423
-		$process = apply_filters( "give_should_process_{$status}", $process, $this );
1423
+		$process = apply_filters("give_should_process_{$status}", $process, $this);
1424 1424
 
1425
-		if ( false === $process ) {
1425
+		if (false === $process) {
1426 1426
 			return;
1427 1427
 		}
1428 1428
 
@@ -1433,13 +1433,13 @@  discard block
 block discarded – undo
1433 1433
 		 *
1434 1434
 		 * @since 1.5
1435 1435
 		 */
1436
-		do_action( "give_pre_{$status}_payment", $this );
1436
+		do_action("give_pre_{$status}_payment", $this);
1437 1437
 
1438
-		$decrease_earnings       = apply_filters( "give_decrease_earnings_on_{$status}", true, $this );
1439
-		$decrease_donor_value    = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this );
1440
-		$decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this );
1438
+		$decrease_earnings       = apply_filters("give_decrease_earnings_on_{$status}", true, $this);
1439
+		$decrease_donor_value    = apply_filters("give_decrease_donor_value_on_{$status}", true, $this);
1440
+		$decrease_donation_count = apply_filters("give_decrease_donors_donation_count_on_{$status}", true, $this);
1441 1441
 
1442
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1442
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1443 1443
 		$this->delete_sales_logs();
1444 1444
 
1445 1445
 		// @todo: Refresh only range related stat cache
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 		 *
1453 1453
 		 * @since 1.5
1454 1454
 		 */
1455
-		do_action( "give_post_{$status}_payment", $this );
1455
+		do_action("give_post_{$status}_payment", $this);
1456 1456
 	}
1457 1457
 
1458 1458
 	/**
@@ -1467,25 +1467,25 @@  discard block
 block discarded – undo
1467 1467
 	 *
1468 1468
 	 * @return void
1469 1469
 	 */
1470
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1470
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1471 1471
 
1472
-		give_undo_donation( $this->ID );
1472
+		give_undo_donation($this->ID);
1473 1473
 
1474 1474
 		// Decrease store earnings.
1475
-		if ( true === $alter_store_earnings ) {
1476
-			give_decrease_total_earnings( $this->total );
1475
+		if (true === $alter_store_earnings) {
1476
+			give_decrease_total_earnings($this->total);
1477 1477
 		}
1478 1478
 
1479 1479
 		// Decrement the stats for the donor.
1480
-		if ( ! empty( $this->customer_id ) ) {
1480
+		if ( ! empty($this->customer_id)) {
1481 1481
 
1482
-			$donor = new Give_Donor( $this->customer_id );
1482
+			$donor = new Give_Donor($this->customer_id);
1483 1483
 
1484
-			if ( true === $alter_customer_value ) {
1485
-				$donor->decrease_value( $this->total );
1484
+			if (true === $alter_customer_value) {
1485
+				$donor->decrease_value($this->total);
1486 1486
 			}
1487 1487
 
1488
-			if ( true === $alter_customer_purchase_count ) {
1488
+			if (true === $alter_customer_purchase_count) {
1489 1489
 				$donor->decrease_donation_count();
1490 1490
 			}
1491 1491
 		}
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 	 */
1503 1503
 	private function delete_sales_logs() {
1504 1504
 		// Remove related sale log entries.
1505
-		Give()->logs->delete_logs( $this->ID );
1505
+		Give()->logs->delete_logs($this->ID);
1506 1506
 	}
1507 1507
 
1508 1508
 	/**
@@ -1523,13 +1523,13 @@  discard block
 block discarded – undo
1523 1523
 	 * @return string The date the payment was completed
1524 1524
 	 */
1525 1525
 	private function setup_completed_date() {
1526
-		$payment = get_post( $this->ID );
1526
+		$payment = get_post($this->ID);
1527 1527
 
1528
-		if ( 'pending' === $payment->post_status || 'preapproved' === $payment->post_status ) {
1528
+		if ('pending' === $payment->post_status || 'preapproved' === $payment->post_status) {
1529 1529
 			return false; // This payment was never completed.
1530 1530
 		}
1531 1531
 
1532
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1532
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1533 1533
 
1534 1534
 		return $date;
1535 1535
 	}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 	 * @return string The payment mode
1544 1544
 	 */
1545 1545
 	private function setup_mode() {
1546
-		return $this->get_meta( '_give_payment_mode' );
1546
+		return $this->get_meta('_give_payment_mode');
1547 1547
 	}
1548 1548
 
1549 1549
 	/**
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 	 * @return bool The payment import
1556 1556
 	 */
1557 1557
 	private function setup_import() {
1558
-		return (bool) $this->get_meta( '_give_payment_import' );
1558
+		return (bool) $this->get_meta('_give_payment_import');
1559 1559
 	}
1560 1560
 
1561 1561
 	/**
@@ -1567,9 +1567,9 @@  discard block
 block discarded – undo
1567 1567
 	 * @return float The payment total
1568 1568
 	 */
1569 1569
 	private function setup_total() {
1570
-		$amount = $this->get_meta( '_give_payment_total', true );
1570
+		$amount = $this->get_meta('_give_payment_total', true);
1571 1571
 
1572
-		return round( floatval( $amount ), give_get_price_decimals( $this->ID ) );
1572
+		return round(floatval($amount), give_get_price_decimals($this->ID));
1573 1573
 	}
1574 1574
 
1575 1575
 	/**
@@ -1596,17 +1596,16 @@  discard block
 block discarded – undo
1596 1596
 	 * @return string The currency for the payment
1597 1597
 	 */
1598 1598
 	private function setup_currency() {
1599
-		$currency = $this->get_meta( '_give_payment_currency', true );
1600
-		$currency = ! empty( $currency ) ?
1601
-			$currency :
1602
-			/**
1599
+		$currency = $this->get_meta('_give_payment_currency', true);
1600
+		$currency = ! empty($currency) ?
1601
+			$currency : /**
1603 1602
 			 * Filter the default donation currency
1604 1603
 			 *
1605 1604
 			 * @since 1.5
1606 1605
 			 */
1607 1606
 			apply_filters(
1608 1607
 				'give_payment_currency_default',
1609
-				give_get_currency( $this->form_id, $this ),
1608
+				give_get_currency($this->form_id, $this),
1610 1609
 				$this
1611 1610
 			);
1612 1611
 
@@ -1622,7 +1621,7 @@  discard block
 block discarded – undo
1622 1621
 	 * @return string The gateway
1623 1622
 	 */
1624 1623
 	private function setup_gateway() {
1625
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1624
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1626 1625
 
1627 1626
 		return $gateway;
1628 1627
 	}
@@ -1636,11 +1635,11 @@  discard block
 block discarded – undo
1636 1635
 	 * @return string The donation ID
1637 1636
 	 */
1638 1637
 	private function setup_transaction_id() {
1639
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1638
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1640 1639
 
1641
-		if ( empty( $transaction_id ) ) {
1640
+		if (empty($transaction_id)) {
1642 1641
 			$gateway        = $this->gateway;
1643
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1642
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1644 1643
 		}
1645 1644
 
1646 1645
 		return $transaction_id;
@@ -1656,7 +1655,7 @@  discard block
 block discarded – undo
1656 1655
 	 * @return string The IP address for the payment
1657 1656
 	 */
1658 1657
 	private function setup_ip() {
1659
-		$ip = $this->get_meta( '_give_payment_donor_ip', true );
1658
+		$ip = $this->get_meta('_give_payment_donor_ip', true);
1660 1659
 
1661 1660
 		return $ip;
1662 1661
 	}
@@ -1671,7 +1670,7 @@  discard block
 block discarded – undo
1671 1670
 	 * @return int The Donor ID.
1672 1671
 	 */
1673 1672
 	private function setup_donor_id() {
1674
-		$donor_id = $this->get_meta( '_give_payment_donor_id', true );
1673
+		$donor_id = $this->get_meta('_give_payment_donor_id', true);
1675 1674
 
1676 1675
 		return $donor_id;
1677 1676
 	}
@@ -1688,8 +1687,8 @@  discard block
 block discarded – undo
1688 1687
 	 */
1689 1688
 	private function setup_user_id() {
1690 1689
 
1691
-		$donor   = Give()->customers->get_customer_by( 'id', $this->customer_id );
1692
-		$user_id = $donor ? absint( $donor->user_id ) : 0;
1690
+		$donor   = Give()->customers->get_customer_by('id', $this->customer_id);
1691
+		$user_id = $donor ? absint($donor->user_id) : 0;
1693 1692
 
1694 1693
 
1695 1694
 		return $user_id;
@@ -1706,10 +1705,10 @@  discard block
 block discarded – undo
1706 1705
 	 * @return string The email address for the payment.
1707 1706
 	 */
1708 1707
 	private function setup_email() {
1709
-		$email = $this->get_meta( '_give_payment_donor_email', true );
1708
+		$email = $this->get_meta('_give_payment_donor_email', true);
1710 1709
 
1711
-		if ( empty( $email ) && $this->customer_id ) {
1712
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1710
+		if (empty($email) && $this->customer_id) {
1711
+			$email = Give()->donors->get_column('email', $this->customer_id);
1713 1712
 		}
1714 1713
 
1715 1714
 		return $email;
@@ -1730,22 +1729,22 @@  discard block
 block discarded – undo
1730 1729
 			'last_name'  => $this->last_name,
1731 1730
 		);
1732 1731
 
1733
-		$user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1732
+		$user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array();
1734 1733
 
1735
-		if ( is_serialized( $user_info ) ) {
1736
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1737
-			if ( ! empty( $matches ) ) {
1734
+		if (is_serialized($user_info)) {
1735
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
1736
+			if ( ! empty($matches)) {
1738 1737
 				$user_info = array();
1739 1738
 			}
1740 1739
 		}
1741 1740
 
1742
-		$user_info = wp_parse_args( $user_info, $defaults );
1741
+		$user_info = wp_parse_args($user_info, $defaults);
1743 1742
 
1744
-		if ( empty( $user_info ) ) {
1743
+		if (empty($user_info)) {
1745 1744
 			// Get the donor, but only if it's been created.
1746
-			$donor = new Give_Donor( $this->customer_id );
1745
+			$donor = new Give_Donor($this->customer_id);
1747 1746
 
1748
-			if ( $donor->id > 0 ) {
1747
+			if ($donor->id > 0) {
1749 1748
 				$user_info = array(
1750 1749
 					'first_name' => $donor->get_first_name(),
1751 1750
 					'last_name'  => $donor->get_last_name(),
@@ -1755,29 +1754,29 @@  discard block
 block discarded – undo
1755 1754
 			}
1756 1755
 		} else {
1757 1756
 			// Get the donor, but only if it's been created.
1758
-			$donor = new Give_Donor( $this->customer_id );
1757
+			$donor = new Give_Donor($this->customer_id);
1759 1758
 
1760
-			if ( $donor->id > 0 ) {
1761
-				foreach ( $user_info as $key => $value ) {
1762
-					if ( ! empty( $value ) ) {
1759
+			if ($donor->id > 0) {
1760
+				foreach ($user_info as $key => $value) {
1761
+					if ( ! empty($value)) {
1763 1762
 						continue;
1764 1763
 					}
1765 1764
 
1766
-					switch ( $key ) {
1765
+					switch ($key) {
1767 1766
 						case 'title':
1768
-							$user_info[ $key ] = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
1767
+							$user_info[$key] = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true);
1769 1768
 							break;
1770 1769
 
1771 1770
 						case 'first_name':
1772
-							$user_info[ $key ] = $donor->get_first_name();
1771
+							$user_info[$key] = $donor->get_first_name();
1773 1772
 							break;
1774 1773
 
1775 1774
 						case 'last_name':
1776
-							$user_info[ $key ] = $donor->get_last_name();
1775
+							$user_info[$key] = $donor->get_last_name();
1777 1776
 							break;
1778 1777
 
1779 1778
 						case 'email':
1780
-							$user_info[ $key ] = $donor->email;
1779
+							$user_info[$key] = $donor->email;
1781 1780
 							break;
1782 1781
 					}
1783 1782
 				}
@@ -1797,12 +1796,12 @@  discard block
 block discarded – undo
1797 1796
 	 * @return array The Address information for the payment.
1798 1797
 	 */
1799 1798
 	private function setup_address() {
1800
-		$address['line1']   = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' );
1801
-		$address['line2']   = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' );
1802
-		$address['city']    = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' );
1803
-		$address['state']   = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' );
1804
-		$address['zip']     = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' );
1805
-		$address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' );
1799
+		$address['line1']   = give_get_meta($this->ID, '_give_donor_billing_address1', true, '');
1800
+		$address['line2']   = give_get_meta($this->ID, '_give_donor_billing_address2', true, '');
1801
+		$address['city']    = give_get_meta($this->ID, '_give_donor_billing_city', true, '');
1802
+		$address['state']   = give_get_meta($this->ID, '_give_donor_billing_state', true, '');
1803
+		$address['zip']     = give_get_meta($this->ID, '_give_donor_billing_zip', true, '');
1804
+		$address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, '');
1806 1805
 
1807 1806
 		return $address;
1808 1807
 	}
@@ -1817,7 +1816,7 @@  discard block
 block discarded – undo
1817 1816
 	 */
1818 1817
 	private function setup_form_title() {
1819 1818
 
1820
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1819
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1821 1820
 
1822 1821
 		return $form_id;
1823 1822
 	}
@@ -1832,7 +1831,7 @@  discard block
 block discarded – undo
1832 1831
 	 */
1833 1832
 	private function setup_form_id() {
1834 1833
 
1835
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1834
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1836 1835
 
1837 1836
 		return $form_id;
1838 1837
 	}
@@ -1846,7 +1845,7 @@  discard block
 block discarded – undo
1846 1845
 	 * @return int The Form Price ID.
1847 1846
 	 */
1848 1847
 	private function setup_price_id() {
1849
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1848
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1850 1849
 
1851 1850
 		return $price_id;
1852 1851
 	}
@@ -1860,7 +1859,7 @@  discard block
 block discarded – undo
1860 1859
 	 * @return string The Payment Key.
1861 1860
 	 */
1862 1861
 	private function setup_payment_key() {
1863
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1862
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1864 1863
 
1865 1864
 		return $key;
1866 1865
 	}
@@ -1885,7 +1884,7 @@  discard block
 block discarded – undo
1885 1884
 	 * @return array The payment object as an array.
1886 1885
 	 */
1887 1886
 	public function array_convert() {
1888
-		return get_object_vars( $this );
1887
+		return get_object_vars($this);
1889 1888
 	}
1890 1889
 
1891 1890
 
@@ -1898,7 +1897,7 @@  discard block
 block discarded – undo
1898 1897
 	 * @return bool
1899 1898
 	 */
1900 1899
 	public function is_completed() {
1901
-		return ( 'publish' === $this->status && $this->completed_date );
1900
+		return ('publish' === $this->status && $this->completed_date);
1902 1901
 	}
1903 1902
 
1904 1903
 	/**
@@ -1910,7 +1909,7 @@  discard block
 block discarded – undo
1910 1909
 	 * @return string Date payment was completed.
1911 1910
 	 */
1912 1911
 	private function get_completed_date() {
1913
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
1912
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
1914 1913
 	}
1915 1914
 
1916 1915
 	/**
@@ -1922,7 +1921,7 @@  discard block
 block discarded – undo
1922 1921
 	 * @return float Payment subtotal.
1923 1922
 	 */
1924 1923
 	private function get_subtotal() {
1925
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
1924
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
1926 1925
 	}
1927 1926
 
1928 1927
 	/**
@@ -1934,7 +1933,7 @@  discard block
 block discarded – undo
1934 1933
 	 * @return string Payment currency code.
1935 1934
 	 */
1936 1935
 	private function get_currency() {
1937
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
1936
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
1938 1937
 	}
1939 1938
 
1940 1939
 	/**
@@ -1946,7 +1945,7 @@  discard block
 block discarded – undo
1946 1945
 	 * @return string Gateway used.
1947 1946
 	 */
1948 1947
 	private function get_gateway() {
1949
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
1948
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
1950 1949
 	}
1951 1950
 
1952 1951
 	/**
@@ -1958,7 +1957,7 @@  discard block
 block discarded – undo
1958 1957
 	 * @return string Donation ID from merchant processor.
1959 1958
 	 */
1960 1959
 	private function get_transaction_id() {
1961
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
1960
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
1962 1961
 	}
1963 1962
 
1964 1963
 	/**
@@ -1970,7 +1969,7 @@  discard block
 block discarded – undo
1970 1969
 	 * @return string Payment IP address
1971 1970
 	 */
1972 1971
 	private function get_ip() {
1973
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
1972
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
1974 1973
 	}
1975 1974
 
1976 1975
 	/**
@@ -1982,7 +1981,7 @@  discard block
 block discarded – undo
1982 1981
 	 * @return int Payment donor ID.
1983 1982
 	 */
1984 1983
 	private function get_donor_id() {
1985
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
1984
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
1986 1985
 	}
1987 1986
 
1988 1987
 	/**
@@ -1994,7 +1993,7 @@  discard block
 block discarded – undo
1994 1993
 	 * @return int Payment user ID.
1995 1994
 	 */
1996 1995
 	private function get_user_id() {
1997
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
1996
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
1998 1997
 	}
1999 1998
 
2000 1999
 	/**
@@ -2006,7 +2005,7 @@  discard block
 block discarded – undo
2006 2005
 	 * @return string Payment donor email.
2007 2006
 	 */
2008 2007
 	private function get_email() {
2009
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2008
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2010 2009
 	}
2011 2010
 
2012 2011
 	/**
@@ -2018,7 +2017,7 @@  discard block
 block discarded – undo
2018 2017
 	 * @return array Payment user info.
2019 2018
 	 */
2020 2019
 	private function get_user_info() {
2021
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2020
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2022 2021
 	}
2023 2022
 
2024 2023
 	/**
@@ -2030,7 +2029,7 @@  discard block
 block discarded – undo
2030 2029
 	 * @return array Payment billing address.
2031 2030
 	 */
2032 2031
 	private function get_address() {
2033
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2032
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2034 2033
 	}
2035 2034
 
2036 2035
 	/**
@@ -2042,7 +2041,7 @@  discard block
 block discarded – undo
2042 2041
 	 * @return string Payment key.
2043 2042
 	 */
2044 2043
 	private function get_key() {
2045
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2044
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2046 2045
 	}
2047 2046
 
2048 2047
 	/**
@@ -2054,7 +2053,7 @@  discard block
 block discarded – undo
2054 2053
 	 * @return string Payment form id
2055 2054
 	 */
2056 2055
 	private function get_form_id() {
2057
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2056
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2058 2057
 	}
2059 2058
 
2060 2059
 	/**
@@ -2066,7 +2065,7 @@  discard block
 block discarded – undo
2066 2065
 	 * @return int|string Payment number
2067 2066
 	 */
2068 2067
 	private function get_number() {
2069
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2068
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2070 2069
 	}
2071 2070
 
2072 2071
 	/**
@@ -2078,7 +2077,7 @@  discard block
 block discarded – undo
2078 2077
 	 *
2079 2078
 	 * @return string
2080 2079
 	 */
2081
-	public function get_serial_code( $args = array() ) {
2082
-		return Give()->seq_donation_number->get_serial_code( $this, $args );
2080
+	public function get_serial_code($args = array()) {
2081
+		return Give()->seq_donation_number->get_serial_code($this, $args);
2083 2082
 	}
2084 2083
 }
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +60 added lines, -60 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
 
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
  * @global     $wpdb
29 29
  * @return void
30 30
  */
31
-function give_install( $network_wide = false ) {
31
+function give_install($network_wide = false) {
32 32
 
33 33
 	global $wpdb;
34 34
 
35
-	if ( is_multisite() && $network_wide ) {
35
+	if (is_multisite() && $network_wide) {
36 36
 
37
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
37
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
38 38
 
39
-			switch_to_blog( $blog_id );
39
+			switch_to_blog($blog_id);
40 40
 			give_run_install();
41 41
 			restore_current_blog();
42 42
 
@@ -63,31 +63,31 @@  discard block
 block discarded – undo
63 63
 	give_setup_post_types();
64 64
 
65 65
 	// Add Upgraded From Option.
66
-	$current_version = get_option( 'give_version' );
67
-	if ( $current_version ) {
68
-		update_option( 'give_version_upgraded_from', $current_version, false );
66
+	$current_version = get_option('give_version');
67
+	if ($current_version) {
68
+		update_option('give_version_upgraded_from', $current_version, false);
69 69
 	}
70 70
 
71 71
 	// Setup some default options.
72 72
 	$options = array();
73 73
 
74 74
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
75
-	if ( empty( $current_version ) ) {
76
-		$options = array_merge( $options, give_get_default_settings() );
75
+	if (empty($current_version)) {
76
+		$options = array_merge($options, give_get_default_settings());
77 77
 	}
78 78
 
79 79
 	// Populate the default values.
80
-	update_option( 'give_settings', array_merge( $give_options, $options ), false );
80
+	update_option('give_settings', array_merge($give_options, $options), false);
81 81
 
82 82
 	/**
83 83
 	 * Run plugin upgrades.
84 84
 	 *
85 85
 	 * @since 1.8
86 86
 	 */
87
-	do_action( 'give_upgrades' );
87
+	do_action('give_upgrades');
88 88
 
89
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
90
-		update_option( 'give_version', GIVE_VERSION, false );
89
+	if (GIVE_VERSION !== get_option('give_version')) {
90
+		update_option('give_version', GIVE_VERSION, false);
91 91
 	}
92 92
 
93 93
 	// Create Give roles.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	// Set api version, end point and refresh permalink.
99 99
 	$api = new Give_API();
100 100
 	$api->add_endpoint();
101
-	update_option( 'give_default_api_version', 'v' . $api->get_version(), false );
101
+	update_option('give_default_api_version', 'v'.$api->get_version(), false);
102 102
 
103 103
 	flush_rewrite_rules();
104 104
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	$donor_meta->create_table();
110 110
 
111 111
 	// Add a temporary option to note that Give pages have been created.
112
-	Give_Cache::set( '_give_installed', $options, 30, true );
112
+	Give_Cache::set('_give_installed', $options, 30, true);
113 113
 
114
-	if ( ! $current_version ) {
114
+	if ( ! $current_version) {
115 115
 
116
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
116
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
117 117
 
118 118
 		// When new upgrade routines are added, mark them as complete on fresh install.
119 119
 		$upgrade_routines = array(
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 			'v224_update_donor_meta'
150 150
 		);
151 151
 
152
-		foreach ( $upgrade_routines as $upgrade ) {
153
-			give_set_upgrade_complete( $upgrade );
152
+		foreach ($upgrade_routines as $upgrade) {
153
+			give_set_upgrade_complete($upgrade);
154 154
 		}
155 155
 	}
156 156
 
157 157
 	// Bail if activating from network, or bulk.
158
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
158
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
159 159
 		return;
160 160
 	}
161 161
 
162 162
 	// Add the transient to redirect.
163
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
163
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
164 164
 }
165 165
 
166 166
 /**
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  * @param  int    $site_id The Site ID.
179 179
  * @param  array  $meta    Blog Meta.
180 180
  */
181
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
181
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
182 182
 
183
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
183
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
184 184
 
185
-		switch_to_blog( $blog_id );
185
+		switch_to_blog($blog_id);
186 186
 		give_install();
187 187
 		restore_current_blog();
188 188
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
 }
192 192
 
193
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
193
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
194 194
 
195 195
 
196 196
 /**
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
  *
204 204
  * @return array          The tables to drop.
205 205
  */
206
-function give_wpmu_drop_tables( $tables, $blog_id ) {
206
+function give_wpmu_drop_tables($tables, $blog_id) {
207 207
 
208
-	switch_to_blog( $blog_id );
208
+	switch_to_blog($blog_id);
209 209
 	$donors_db     = new Give_DB_Donors();
210 210
 	$donor_meta_db = new Give_DB_Donor_Meta();
211 211
 
212
-	if ( $donors_db->installed() ) {
212
+	if ($donors_db->installed()) {
213 213
 		$tables[] = $donors_db->table_name;
214 214
 		$tables[] = $donor_meta_db->table_name;
215 215
 	}
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 }
221 221
 
222
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
222
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
223 223
 
224 224
 /**
225 225
  * Post-installation
@@ -231,16 +231,16 @@  discard block
 block discarded – undo
231 231
  */
232 232
 function give_after_install() {
233 233
 
234
-	if ( ! is_admin() ) {
234
+	if ( ! is_admin()) {
235 235
 		return;
236 236
 	}
237 237
 
238
-	$give_options     = Give_Cache::get( '_give_installed', true );
239
-	$give_table_check = get_option( '_give_table_check', false );
238
+	$give_options     = Give_Cache::get('_give_installed', true);
239
+	$give_table_check = get_option('_give_table_check', false);
240 240
 
241
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
241
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
242 242
 
243
-		if ( ! @Give()->donor_meta->installed() ) {
243
+		if ( ! @Give()->donor_meta->installed()) {
244 244
 
245 245
 			// Create the donor meta database.
246 246
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 		}
250 250
 
251
-		if ( ! @Give()->donors->installed() ) {
251
+		if ( ! @Give()->donors->installed()) {
252 252
 			// Create the donor database.
253 253
 			// (this ensures it creates it on multisite instances where it is network activated).
254 254
 			@Give()->donors->create_table();
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
 			 *
261 261
 			 * @param array $give_options Give plugin options.
262 262
 			 */
263
-			do_action( 'give_after_install', $give_options );
263
+			do_action('give_after_install', $give_options);
264 264
 		}
265 265
 
266
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ), false );
266
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS), false);
267 267
 
268 268
 	}
269 269
 
270 270
 	// Delete the transient
271
-	if ( false !== $give_options ) {
272
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
271
+	if (false !== $give_options) {
272
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
273 273
 	}
274 274
 
275 275
 
276 276
 }
277 277
 
278
-add_action( 'admin_init', 'give_after_install' );
278
+add_action('admin_init', 'give_after_install');
279 279
 
280 280
 
281 281
 /**
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 
291 291
 	global $wp_roles;
292 292
 
293
-	if ( ! is_object( $wp_roles ) ) {
293
+	if ( ! is_object($wp_roles)) {
294 294
 		return;
295 295
 	}
296 296
 
297
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
297
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
298 298
 
299 299
 		// Create Give plugin roles
300 300
 		$roles = new Give_Roles();
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
 }
307 307
 
308
-add_action( 'admin_init', 'give_install_roles_on_network' );
308
+add_action('admin_init', 'give_install_roles_on_network');
309 309
 
310 310
 /**
311 311
  * Default core setting values.
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
 		'uninstall_on_delete'                         => 'disabled',
348 348
 		'the_content_filter'                          => 'enabled',
349 349
 		'scripts_footer'                              => 'disabled',
350
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
350
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
351 351
 		'agreement_text'                              => give_get_default_agreement_text(),
352 352
 
353 353
 		// Paypal IPN verification.
354 354
 		'paypal_verification'                         => 'enabled',
355 355
 
356 356
 		// Default is manual gateway.
357
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
357
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
358 358
 		'default_gateway'                             => 'manual',
359 359
 
360 360
 		// Offline gateway setup.
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
  */
383 383
 function give_get_default_agreement_text() {
384 384
 
385
-	$org_name = get_bloginfo( 'name' );
385
+	$org_name = get_bloginfo('name');
386 386
 
387 387
 	$agreement = sprintf(
388 388
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		$org_name
397 397
 	);
398 398
 
399
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
399
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
400 400
 }
401 401
 
402 402
 
@@ -410,19 +410,19 @@  discard block
 block discarded – undo
410 410
 function give_create_pages() {
411 411
 
412 412
 	// Bailout if pages already created.
413
-	if ( get_option( 'give_install_pages_created' ) ) {
413
+	if (get_option('give_install_pages_created')) {
414 414
 		return false;
415 415
 	}
416 416
 
417 417
 	$options = array();
418 418
 
419 419
 	// Checks if the Success Page option exists AND that the page exists.
420
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
420
+	if ( ! get_post(give_get_option('success_page'))) {
421 421
 
422 422
 		// Donation Confirmation (Success) Page
423 423
 		$success = wp_insert_post(
424 424
 			array(
425
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
425
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
426 426
 				'post_content'   => '[give_receipt]',
427 427
 				'post_status'    => 'publish',
428 428
 				'post_author'    => 1,
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
 	}
437 437
 
438 438
 	// Checks if the Failure Page option exists AND that the page exists.
439
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
439
+	if ( ! get_post(give_get_option('failure_page'))) {
440 440
 
441 441
 		// Failed Donation Page
442 442
 		$failed = wp_insert_post(
443 443
 			array(
444
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
445
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
444
+				'post_title'     => esc_html__('Donation Failed', 'give'),
445
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
446 446
 				'post_status'    => 'publish',
447 447
 				'post_author'    => 1,
448 448
 				'post_type'      => 'page',
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 	}
455 455
 
456 456
 	// Checks if the History Page option exists AND that the page exists.
457
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
457
+	if ( ! get_post(give_get_option('history_page'))) {
458 458
 		// Donation History Page
459 459
 		$history = wp_insert_post(
460 460
 			array(
461
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
461
+				'post_title'     => esc_html__('Donation History', 'give'),
462 462
 				'post_content'   => '[donation_history]',
463 463
 				'post_status'    => 'publish',
464 464
 				'post_author'    => 1,
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
 		$options['history_page'] = $history;
471 471
 	}
472 472
 
473
-	if ( ! empty( $options ) ) {
474
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ), false );
473
+	if ( ! empty($options)) {
474
+		update_option('give_settings', array_merge(give_get_settings(), $options), false);
475 475
 	}
476 476
 
477
-	add_option( 'give_install_pages_created', 1, '', false );
477
+	add_option('give_install_pages_created', 1, '', false);
478 478
 }
479 479
 
480
-add_action( 'admin_init', 'give_create_pages', - 1 );
480
+add_action('admin_init', 'give_create_pages', - 1);
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -168,25 +168,25 @@  discard block
 block discarded – undo
168 168
 
169 169
 			$this->file             = $_file;
170 170
 			$this->item_name        = $_item_name;
171
-			$this->item_shortname   = self::get_short_name( $this->item_name );
171
+			$this->item_shortname   = self::get_short_name($this->item_name);
172 172
 			$this->version          = $_version;
173
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
174
-			$this->license_data     = __give_get_active_license_info( $this->item_shortname );
173
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
174
+			$this->license_data     = __give_get_active_license_info($this->item_shortname);
175 175
 			$this->author           = $_author;
176
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
177
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
178
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
176
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
177
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
178
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
179 179
 			$this->auto_updater_obj = null;
180 180
 
181 181
 			// Add Setting for Give Add-on activation status.
182
-			$is_addon_activated = get_option( 'give_is_addon_activated' );
183
-			if ( ! $is_addon_activated && is_object( $this ) ) {
184
-				update_option( 'give_is_addon_activated', true, false );
185
-				Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS );
182
+			$is_addon_activated = get_option('give_is_addon_activated');
183
+			if ( ! $is_addon_activated && is_object($this)) {
184
+				update_option('give_is_addon_activated', true, false);
185
+				Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS);
186 186
 			}
187 187
 
188 188
 			// Add plugin to registered licenses list.
189
-			array_push( self::$licensed_addons, plugin_basename( $this->file ) );
189
+			array_push(self::$licensed_addons, plugin_basename($this->file));
190 190
 
191 191
 			// Setup hooks
192 192
 			$this->includes();
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 		 *
206 206
 		 * @return string
207 207
 		 */
208
-		public static function get_short_name( $plugin_name ) {
209
-			$plugin_name = trim( str_replace( 'Give - ', '', $plugin_name ) );
210
-			$plugin_name = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) );
208
+		public static function get_short_name($plugin_name) {
209
+			$plugin_name = trim(str_replace('Give - ', '', $plugin_name));
210
+			$plugin_name = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name)));
211 211
 
212 212
 			return $plugin_name;
213 213
 		}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		 */
225 225
 		private function includes() {
226 226
 
227
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
227
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
228 228
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
229 229
 			}
230 230
 		}
@@ -242,28 +242,28 @@  discard block
 block discarded – undo
242 242
 		private function hooks() {
243 243
 
244 244
 			// Register settings.
245
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
245
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
246 246
 
247 247
 			// Activate license key on settings save.
248
-			add_action( 'admin_init', array( $this, 'activate_license' ), 10 );
248
+			add_action('admin_init', array($this, 'activate_license'), 10);
249 249
 
250 250
 			// Deactivate license key.
251
-			add_action( 'admin_init', array( $this, 'deactivate_license' ), 11 );
251
+			add_action('admin_init', array($this, 'deactivate_license'), 11);
252 252
 
253 253
 			// Updater.
254
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
255
-			add_action( 'admin_notices', array( $this, 'notices' ) );
254
+			add_action('admin_init', array($this, 'auto_updater'), 0);
255
+			add_action('admin_notices', array($this, 'notices'));
256 256
 
257 257
 			// Check license weekly.
258
-			Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) );
258
+			Give_Cron::add_weekly_event(array($this, 'weekly_license_check'));
259 259
 
260 260
 			// Check subscription weekly.
261
-			Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) );
261
+			Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check'));
262 262
 
263 263
 			// Show addon notice on plugin page.
264
-			$plugin_name = explode( 'plugins/', $this->file );
265
-			$plugin_name = end( $plugin_name );
266
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
264
+			$plugin_name = explode('plugins/', $this->file);
265
+			$plugin_name = end($plugin_name);
266
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
267 267
 
268 268
 		}
269 269
 
@@ -303,16 +303,16 @@  discard block
 block discarded – undo
303 303
 		 *
304 304
 		 * @return array           License settings.
305 305
 		 */
306
-		public function settings( $settings ) {
306
+		public function settings($settings) {
307 307
 
308 308
 			$give_license_settings = array(
309 309
 				array(
310 310
 					'name'    => $this->item_name,
311
-					'id'      => $this->item_shortname . '_license_key',
311
+					'id'      => $this->item_shortname.'_license_key',
312 312
 					'desc'    => '',
313 313
 					'type'    => 'license_key',
314 314
 					'options' => array(
315
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
315
+						'license'      => get_option($this->item_shortname.'_license_active'),
316 316
 						'shortname'    => $this->item_shortname,
317 317
 						'item_name'    => $this->item_name,
318 318
 						'api_url'      => $this->api_url,
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 				),
324 324
 			);
325 325
 
326
-			return array_merge( $settings, $give_license_settings );
326
+			return array_merge($settings, $give_license_settings);
327 327
 		}
328 328
 
329 329
 		/**
@@ -338,18 +338,18 @@  discard block
 block discarded – undo
338 338
 		 *
339 339
 		 * @return array           License settings content.
340 340
 		 */
341
-		public function license_settings_content( $settings ) {
341
+		public function license_settings_content($settings) {
342 342
 
343 343
 			$give_license_settings = array(
344 344
 				array(
345
-					'name' => __( 'Add-on Licenses', 'give' ),
345
+					'name' => __('Add-on Licenses', 'give'),
346 346
 					'desc' => '<hr>',
347 347
 					'type' => 'give_title',
348 348
 					'id'   => 'give_title',
349 349
 				),
350 350
 			);
351 351
 
352
-			return array_merge( $settings, $give_license_settings );
352
+			return array_merge($settings, $give_license_settings);
353 353
 		}
354 354
 
355 355
 		/**
@@ -364,62 +364,62 @@  discard block
 block discarded – undo
364 364
 		 */
365 365
 		public function activate_license() {
366 366
 			// Bailout.
367
-			if ( ! $this->__is_user_can_edit_license() ) {
367
+			if ( ! $this->__is_user_can_edit_license()) {
368 368
 				return;
369 369
 			}
370 370
 
371 371
 			// Allow third party addon developers to handle license activation.
372
-			if ( $this->__is_third_party_addon() ) {
373
-				do_action( 'give_activate_license', $this );
372
+			if ($this->__is_third_party_addon()) {
373
+				do_action('give_activate_license', $this);
374 374
 
375 375
 				return;
376 376
 			}
377 377
 
378 378
 			// Delete previous license setting if a empty license key submitted.
379
-			if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) {
379
+			if (empty($_POST["{$this->item_shortname}_license_key"])) {
380 380
 				$this->unset_license();
381 381
 
382 382
 				return;
383 383
 			}
384 384
 
385 385
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
386
-			if ( $this->is_deactivating_license() ) {
386
+			if ($this->is_deactivating_license()) {
387 387
 				return;
388 388
 			}
389 389
 
390 390
 			// Check if plugin previously installed.
391
-			if ( $this->is_valid_license() ) {
391
+			if ($this->is_valid_license()) {
392 392
 				return;
393 393
 			}
394 394
 
395 395
 			// Get license key.
396
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
396
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
397 397
 
398 398
 			// Delete previous license key from subscription if previously added.
399 399
 			$this->__remove_license_key_from_subscriptions();
400 400
 
401 401
 			// Make sure there are no api errors.
402
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
402
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
403 403
 				return;
404 404
 			}
405 405
 
406 406
 			// Make sure license is valid.
407 407
 			// return because admin will want to activate license again.
408
-			if ( ! $this->is_license( $license_data ) ) {
408
+			if ( ! $this->is_license($license_data)) {
409 409
 				// Add license key.
410
-				give_update_option( "{$this->item_shortname}_license_key", $this->license );
410
+				give_update_option("{$this->item_shortname}_license_key", $this->license);
411 411
 
412 412
 				return;
413 413
 			}
414 414
 
415 415
 			// Tell WordPress to look for updates.
416
-			set_site_transient( 'update_plugins', null );
416
+			set_site_transient('update_plugins', null);
417 417
 
418 418
 			// Add license data.
419
-			update_option( "{$this->item_shortname}_license_active", $license_data, false );
419
+			update_option("{$this->item_shortname}_license_active", $license_data, false);
420 420
 
421 421
 			// Add license key.
422
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
422
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
423 423
 
424 424
 			// Check subscription for license key and store this to db (if any).
425 425
 			$this->__single_subscription_check();
@@ -437,19 +437,19 @@  discard block
 block discarded – undo
437 437
 		 */
438 438
 		public function deactivate_license() {
439 439
 			// Bailout.
440
-			if ( ! $this->__is_user_can_edit_license() ) {
440
+			if ( ! $this->__is_user_can_edit_license()) {
441 441
 				return;
442 442
 			}
443 443
 
444 444
 			// Allow third party add-on developers to handle license deactivation.
445
-			if ( $this->__is_third_party_addon() ) {
446
-				do_action( 'give_deactivate_license', $this );
445
+			if ($this->__is_third_party_addon()) {
446
+				do_action('give_deactivate_license', $this);
447 447
 
448 448
 				return;
449 449
 			}
450 450
 
451 451
 			// Run on deactivate button press.
452
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
452
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
453 453
 				$this->unset_license();
454 454
 			}
455 455
 		}
@@ -465,30 +465,30 @@  discard block
 block discarded – undo
465 465
 		public function weekly_license_check() {
466 466
 
467 467
 			if (
468
-				! empty( $_POST['give_settings'] ) ||
469
-				empty( $this->license )
468
+				! empty($_POST['give_settings']) ||
469
+				empty($this->license)
470 470
 			) {
471 471
 				return;
472 472
 			}
473 473
 
474 474
 			// Allow third party add-on developers to handle their license check.
475
-			if ( $this->__is_third_party_addon() ) {
476
-				do_action( 'give_weekly_license_check', $this );
475
+			if ($this->__is_third_party_addon()) {
476
+				do_action('give_weekly_license_check', $this);
477 477
 
478 478
 				return;
479 479
 			}
480 480
 
481 481
 			// Make sure there are no api errors.
482
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
482
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
483 483
 				return;
484 484
 			}
485 485
 
486 486
 			// Bailout.
487
-			if ( ! $this->is_license( $license_data ) ) {
487
+			if ( ! $this->is_license($license_data)) {
488 488
 				return;
489 489
 			}
490 490
 
491
-			update_option( $this->item_shortname . '_license_active', $license_data, false );
491
+			update_option($this->item_shortname.'_license_active', $license_data, false);
492 492
 
493 493
 			return;
494 494
 		}
@@ -504,21 +504,21 @@  discard block
 block discarded – undo
504 504
 		public function weekly_subscription_check() {
505 505
 			// Bailout.
506 506
 			if (
507
-				! empty( $_POST['give_settings'] )
508
-				|| empty( $this->license )
507
+				! empty($_POST['give_settings'])
508
+				|| empty($this->license)
509 509
 			) {
510 510
 				return;
511 511
 			}
512 512
 
513 513
 			// Remove old subscription data.
514
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
515
-				delete_option( 'give_subscriptions' );
516
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ), false );
514
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
515
+				delete_option('give_subscriptions');
516
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)), false);
517 517
 			}
518 518
 
519 519
 			// Allow third party add-on developers to handle their subscription check.
520
-			if ( $this->__is_third_party_addon() ) {
521
-				do_action( 'give_weekly_subscription_check', $this );
520
+			if ($this->__is_third_party_addon()) {
521
+				do_action('give_weekly_subscription_check', $this);
522 522
 
523 523
 				return;
524 524
 			}
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 		 * @return void
536 536
 		 */
537 537
 		private function __single_subscription_check() {
538
-			if ( empty( $this->license ) ) {
538
+			if (empty($this->license)) {
539 539
 				return;
540 540
 			}
541 541
 
@@ -546,26 +546,26 @@  discard block
 block discarded – undo
546 546
 			 * By default edd software licensing api does not have api to check subscription.
547 547
 			 * This is a custom feature to check subscriptions.
548 548
 			 */
549
-			$subscription_data = $this->get_license_info( 'check_subscription', true );
549
+			$subscription_data = $this->get_license_info('check_subscription', true);
550 550
 
551
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
551
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
552 552
 
553
-				$subscriptions = get_option( 'give_subscriptions', array() );
553
+				$subscriptions = get_option('give_subscriptions', array());
554 554
 
555 555
 				// Update subscription data only if subscription does not exist already.
556
-				$subscriptions[ $subscription_data['id'] ] = $subscription_data;
556
+				$subscriptions[$subscription_data['id']] = $subscription_data;
557 557
 
558 558
 				// Initiate default set of license for subscription.
559
-				if ( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
560
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
559
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
560
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
561 561
 				}
562 562
 
563 563
 				// Store licenses for subscription.
564
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
565
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
564
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
565
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
566 566
 				}
567 567
 
568
-				update_option( 'give_subscriptions', $subscriptions, false );
568
+				update_option('give_subscriptions', $subscriptions, false);
569 569
 			}
570 570
 		}
571 571
 
@@ -579,12 +579,12 @@  discard block
 block discarded – undo
579 579
 		 */
580 580
 		public function notices() {
581 581
 
582
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
582
+			if ( ! current_user_can('manage_give_settings')) {
583 583
 				return;
584 584
 			}
585 585
 
586 586
 			// Do not show licenses notices on license tab.
587
-			if ( 'licenses' === give_get_current_setting_tab() ) {
587
+			if ('licenses' === give_get_current_setting_tab()) {
588 588
 				return;
589 589
 			}
590 590
 
@@ -593,17 +593,17 @@  discard block
 block discarded – undo
593 593
 			static $addon_license_key_in_subscriptions;
594 594
 
595 595
 			// Set default value.
596
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
596
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
597 597
 			$messages                           = array();
598 598
 
599 599
 			// Check whether admin has Give Add-on activated since 24 hours?
600
-			$is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' );
600
+			$is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation');
601 601
 
602 602
 			// Display Invalid License notice, if its more than 24 hours since first Give Add-on activation.
603 603
 			if (
604
-				empty( $this->license )
605
-				&& empty( $showed_invalid_message )
606
-				&& ( false === $is_license_notice_hidden )
604
+				empty($this->license)
605
+				&& empty($showed_invalid_message)
606
+				&& (false === $is_license_notice_hidden)
607 607
 			) {
608 608
 
609 609
 				Give()->notices->register_notice(
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
 						'id'               => 'give-invalid-license',
612 612
 						'type'             => 'error',
613 613
 						'description'      => sprintf(
614
-							__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
615
-							admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
614
+							__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
615
+							admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
616 616
 						),
617 617
 						'dismissible_type' => 'user',
618 618
 						'dismiss_interval' => 'shortly',
@@ -624,39 +624,39 @@  discard block
 block discarded – undo
624 624
 			}
625 625
 
626 626
 			// Get subscriptions.
627
-			$subscriptions = get_option( 'give_subscriptions' );
627
+			$subscriptions = get_option('give_subscriptions');
628 628
 
629 629
 			// Show subscription messages.
630
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
630
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
631 631
 
632
-				foreach ( $subscriptions as $subscription ) {
632
+				foreach ($subscriptions as $subscription) {
633 633
 					// Subscription expires timestamp.
634
-					$subscription_expires = strtotime( $subscription['expires'] );
634
+					$subscription_expires = strtotime($subscription['expires']);
635 635
 
636 636
 					// Start showing subscriptions message before one week of renewal date.
637
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
637
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
638 638
 						continue;
639 639
 					}
640 640
 
641 641
 					// Check if subscription message already exist in messages.
642
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
642
+					if (array_key_exists($subscription['id'], $messages)) {
643 643
 						continue;
644 644
 					}
645 645
 
646 646
 					// Check if license already expired.
647
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
647
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
648 648
 						Give()->notices->register_notice(
649 649
 							array(
650 650
 								'id'               => "give-expired-subscription-{$subscription['id']}",
651 651
 								'type'             => 'error',
652 652
 								'description'      => sprintf(
653
-									__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
654
-									urldecode( $subscription['invoice_url'] ),
653
+									__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
654
+									urldecode($subscription['invoice_url']),
655 655
 									$subscription['payment_id'],
656 656
 									"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
657 657
 									Give()->notices->get_dismiss_link(
658 658
 										array(
659
-											'title'            => __( 'Click here if already renewed', 'give' ),
659
+											'title'            => __('Click here if already renewed', 'give'),
660 660
 											'dismissible_type' => 'user',
661 661
 											'dismiss_interval' => 'permanent',
662 662
 										)
@@ -672,14 +672,14 @@  discard block
 block discarded – undo
672 672
 								'id'               => "give-expires-subscription-{$subscription['id']}",
673 673
 								'type'             => 'error',
674 674
 								'description'      => sprintf(
675
-									__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
676
-									human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
677
-									urldecode( $subscription['invoice_url'] ),
675
+									__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
676
+									human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
677
+									urldecode($subscription['invoice_url']),
678 678
 									$subscription['payment_id'],
679 679
 									"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
680 680
 									Give()->notices->get_dismiss_link(
681 681
 										array(
682
-											'title'            => __( 'Click here if already renewed', 'give' ),
682
+											'title'            => __('Click here if already renewed', 'give'),
683 683
 											'dismissible_type' => 'user',
684 684
 											'dismiss_interval' => 'permanent',
685 685
 										)
@@ -692,16 +692,16 @@  discard block
 block discarded – undo
692 692
 					}
693 693
 
694 694
 					// Stop validation for these license keys.
695
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
695
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
696 696
 				}// End foreach().
697 697
 				$showed_subscriptions_message = true;
698 698
 			}// End if().
699 699
 
700 700
 			// Show Non Subscription Give Add-on messages.
701 701
 			if (
702
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
703
-				&& ! empty( $this->license )
704
-				&& empty( $showed_invalid_message )
702
+				! in_array($this->license, $addon_license_key_in_subscriptions)
703
+				&& ! empty($this->license)
704
+				&& empty($showed_invalid_message)
705 705
 				&& ! $this->is_valid_license()
706 706
 			) {
707 707
 
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
 						'id'               => 'give-invalid-license',
711 711
 						'type'             => 'error',
712 712
 						'description'      => sprintf(
713
-							__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
714
-							admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
713
+							__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
714
+							admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
715 715
 						),
716 716
 						'dismissible_type' => 'user',
717 717
 						'dismiss_interval' => 'shortly',
@@ -733,10 +733,10 @@  discard block
 block discarded – undo
733 733
 		 *
734 734
 		 * @return bool
735 735
 		 */
736
-		public function is_valid_license( $licence_data = null ) {
737
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
736
+		public function is_valid_license($licence_data = null) {
737
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
738 738
 
739
-			if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) {
739
+			if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) {
740 740
 				return true;
741 741
 			}
742 742
 
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
 		 *
755 755
 		 * @return bool
756 756
 		 */
757
-		public function is_license( $licence_data = null ) {
758
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
757
+		public function is_license($licence_data = null) {
758
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
759 759
 
760
-			if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) {
760
+			if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) {
761 761
 				return true;
762 762
 			}
763 763
 
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		 * @return bool
774 774
 		 */
775 775
 		private function __is_third_party_addon() {
776
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
776
+			return (false === strpos($this->api_url, 'givewp.com/'));
777 777
 		}
778 778
 
779 779
 		/**
@@ -788,25 +788,25 @@  discard block
 block discarded – undo
788 788
 		 * @return bool
789 789
 		 */
790 790
 		private function __remove_license_key_from_subscriptions() {
791
-			$subscriptions = get_option( 'give_subscriptions', array() );
791
+			$subscriptions = get_option('give_subscriptions', array());
792 792
 
793 793
 			// Bailout.
794
-			if ( empty( $this->license ) ) {
794
+			if (empty($this->license)) {
795 795
 				return false;
796 796
 			}
797 797
 
798
-			if ( ! empty( $subscriptions ) ) {
799
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
800
-					$license_index = array_search( $this->license, $subscription['licenses'] );
801
-					if ( false !== $license_index ) {
798
+			if ( ! empty($subscriptions)) {
799
+				foreach ($subscriptions as $subscription_id => $subscription) {
800
+					$license_index = array_search($this->license, $subscription['licenses']);
801
+					if (false !== $license_index) {
802 802
 						// Remove license key.
803
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
803
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
804 804
 
805 805
 						// Rearrange license keys.
806
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
806
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
807 807
 
808 808
 						// Update subscription information.
809
-						update_option( 'give_subscriptions', $subscriptions, false );
809
+						update_option('give_subscriptions', $subscriptions, false);
810 810
 						break;
811 811
 					}
812 812
 				}
@@ -822,17 +822,17 @@  discard block
 block discarded – undo
822 822
 		 *
823 823
 		 * @return bool
824 824
 		 */
825
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
825
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
826 826
 			// Bailout.
827
-			if ( $this->is_valid_license() ) {
827
+			if ($this->is_valid_license()) {
828 828
 				return false;
829 829
 			}
830 830
 
831 831
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
832 832
 			$message            = $this->license_state_message();
833 833
 
834
-			if ( ! empty( $message['message'] ) ) {
835
-				echo sprintf( $update_notice_wrap, $message['message'] );
834
+			if ( ! empty($message['message'])) {
835
+				echo sprintf($update_notice_wrap, $message['message']);
836 836
 			}
837 837
 		}
838 838
 
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 		public function license_state_message() {
848 848
 			$message_data = array();
849 849
 
850
-			if ( ! $this->is_valid_license() ) {
850
+			if ( ! $this->is_valid_license()) {
851 851
 
852 852
 				$message_data['message'] = sprintf(
853 853
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
854
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
854
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
855 855
 					$this->item_name
856 856
 				);
857 857
 			}
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			// Bailout.
872 872
 			if (
873 873
 				! Give_Admin_Settings::verify_nonce()
874
-				|| ! current_user_can( 'manage_give_settings' )
874
+				|| ! current_user_can('manage_give_settings')
875 875
 				|| 'licenses' !== give_get_current_setting_tab()
876 876
 			) {
877 877
 				return false;
@@ -879,10 +879,10 @@  discard block
 block discarded – undo
879 879
 
880 880
 			// Security check.
881 881
 			if (
882
-				isset( $_POST[ $this->item_shortname . '_license_key-nonce' ] )
883
-				&& ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' )
882
+				isset($_POST[$this->item_shortname.'_license_key-nonce'])
883
+				&& ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')
884 884
 			) {
885
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
885
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
886 886
 			}
887 887
 
888 888
 			return true;
@@ -900,9 +900,9 @@  discard block
 block discarded – undo
900 900
 		 *
901 901
 		 * @return mixed
902 902
 		 */
903
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
903
+		public function get_license_info($edd_action = '', $response_in_array = false) {
904 904
 
905
-			if ( empty( $edd_action ) ) {
905
+			if (empty($edd_action)) {
906 906
 				return false;
907 907
 			}
908 908
 
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			$api_params = array(
911 911
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
912 912
 				'license'    => $this->license,
913
-				'item_name'  => urlencode( $this->item_name ),
913
+				'item_name'  => urlencode($this->item_name),
914 914
 				'url'        => home_url(),
915 915
 			);
916 916
 
@@ -925,11 +925,11 @@  discard block
 block discarded – undo
925 925
 			);
926 926
 
927 927
 			// Make sure there are no errors.
928
-			if ( is_wp_error( $response ) ) {
928
+			if (is_wp_error($response)) {
929 929
 				return false;
930 930
 			}
931 931
 
932
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
932
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
933 933
 		}
934 934
 
935 935
 
@@ -945,9 +945,9 @@  discard block
 block discarded – undo
945 945
 			$this->__remove_license_key_from_subscriptions();
946 946
 
947 947
 			// Remove license from database.
948
-			delete_option( "{$this->item_shortname}_license_active" );
949
-			give_delete_option( "{$this->item_shortname}_license_key" );
950
-			unset( $_POST["{$this->item_shortname}_license_key"] );
948
+			delete_option("{$this->item_shortname}_license_active");
949
+			give_delete_option("{$this->item_shortname}_license_key");
950
+			unset($_POST["{$this->item_shortname}_license_key"]);
951 951
 
952 952
 			// Unset license param.
953 953
 			$this->license = '';
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 		private function is_deactivating_license() {
966 966
 			$status = false;
967 967
 
968
-			foreach ( $_POST as $key => $value ) {
969
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
968
+			foreach ($_POST as $key => $value) {
969
+				if (false !== strpos($key, 'license_key_deactivate')) {
970 970
 					$status = true;
971 971
 					break;
972 972
 				}
Please login to merge, or discard this patch.