Completed
Pull Request — master (#893)
by Rami
20:06
created
includes/payments/class-give-payment.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param int $payment_id A given payment
295 295
 	 *
296
-	 * @return mixed void|false
296
+	 * @return false|null void|false
297 297
 	 */
298 298
 	public function __construct( $payment_id = false ) {
299 299
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @param  string $name The attribute to get
363 363
 	 *
364
-	 * @return boolean       If the item is set or not
364
+	 * @return boolean|null       If the item is set or not
365 365
 	 */
366 366
 	public function __isset( $name ) {
367 367
 		if ( property_exists( $this, $name ) ) {
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 	 *
1150 1150
 	 * @param string $note The note to add
1151 1151
 	 *
1152
-	 * @return void
1152
+	 * @return false|null
1153 1153
 	 */
1154 1154
 	public function add_note( $note = false ) {
1155 1155
 		// Bail if no note specified
Please login to merge, or discard this patch.
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -513,22 +513,22 @@  discard block
 block discarded – undo
513 513
 		return true;
514 514
 	}
515 515
 
516
-    /**
517
-     * Payment class object is storing various meta value in object parameter.
518
-     * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically
519
-     * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data.
520
-     * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ).
521
-     *  
522
-     * @since  1.6
523
-     * @access public
524
-     * 
525
-     * @param  int $payment_id Payment ID.
526
-     * 
527
-     * @return void
528
-     */
529
-    public function update_payment_setup( $payment_id ){
530
-        $this->setup_payment( $payment_id );
531
-    }
516
+	/**
517
+	 * Payment class object is storing various meta value in object parameter.
518
+	 * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically
519
+	 * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data.
520
+	 * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ).
521
+	 *  
522
+	 * @since  1.6
523
+	 * @access public
524
+	 * 
525
+	 * @param  int $payment_id Payment ID.
526
+	 * 
527
+	 * @return void
528
+	 */
529
+	public function update_payment_setup( $payment_id ){
530
+		$this->setup_payment( $payment_id );
531
+	}
532 532
 
533 533
 	/**
534 534
 	 * Create the base of a payment.
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 *
651 651
 	 * Once items have been set, an update is needed to save them to the database.
652 652
 	 *
653
-     * @access public
653
+	 * @access public
654 654
 	 *
655 655
 	 * @return bool  True of the save occurred, false if it failed or wasn't needed
656 656
 	 */
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 	 * Add a donation to a given payment
938 938
 	 *
939 939
 	 * @since  1.5
940
-     * @access public
940
+	 * @access public
941 941
 	 *
942 942
 	 * @param  int   $form_id The donation form to add
943 943
 	 * @param  array $args    Other arguments to pass to the function
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 					//Find a match between price_id and level_id
978 978
 					//First verify array keys exists THEN make the match
979 979
 					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
980
-					     && $args['price_id'] == $price['_give_id']['level_id']
980
+						 && $args['price_id'] == $price['_give_id']['level_id']
981 981
 					) {
982 982
 						$item_price = $price['_give_amount'];
983 983
 					}
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	 * Remove a donation from the payment
1034 1034
 	 *
1035 1035
 	 * @since  1.5
1036
-     * @access public
1036
+	 * @access public
1037 1037
 	 *
1038 1038
 	 * @param  int   $form_id The form ID to remove
1039 1039
 	 * @param  array $args    Arguments to pass to identify (quantity, amount, price_id)
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 	 * Add a fee to a given payment
1076 1076
 	 *
1077 1077
 	 * @since  1.5
1078
-     * @access public
1078
+	 * @access public
1079 1079
 	 *
1080 1080
 	 * @param  array $args   Array of arguments for the fee to add
1081 1081
 	 * @param  bool  $global
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 	 * Remove a fee from the payment
1111 1111
 	 *
1112 1112
 	 * @since  1.5
1113
-     * @access public
1113
+	 * @access public
1114 1114
 	 *
1115 1115
 	 * @param  int $key The array key index to remove
1116 1116
 	 *
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	 * Remove a fee by the defined attributed
1131 1131
 	 *
1132 1132
 	 * @since  1.5
1133
-     * @access public
1133
+	 * @access public
1134 1134
 	 *
1135 1135
 	 * @param  string     $key    The key to remove by
1136 1136
 	 * @param  int|string $value  The value to search for
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 	 * Get the fees, filterable by type
1201 1201
 	 *
1202 1202
 	 * @since  1.5
1203
-     * @access public
1203
+	 * @access public
1204 1204
 	 *
1205 1205
 	 * @param  string $type All, item, fee
1206 1206
 	 *
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 	 * Add a note to a payment
1231 1231
 	 *
1232 1232
 	 * @since  1.0
1233
-     * @access public
1233
+	 * @access public
1234 1234
 	 *
1235 1235
 	 * @param  string $note The note to add
1236 1236
 	 *
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 	 * Increase the payment's subtotal
1250 1250
 	 *
1251 1251
 	 * @since  1.5
1252
-     * @access private
1252
+	 * @access private
1253 1253
 	 *
1254 1254
 	 * @param  float $amount The amount to increase the payment subtotal by
1255 1255
 	 *
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 	 * Decrease the payment's subtotal
1267 1267
 	 *
1268 1268
 	 * @since  1.5
1269
-     * @access private
1269
+	 * @access private
1270 1270
 	 *
1271 1271
 	 * @param  float $amount The amount to decrease the payment subtotal by
1272 1272
 	 *
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 	 * Increase the payment's subtotal
1288 1288
 	 *
1289 1289
 	 * @since  1.5
1290
-     * @access private
1290
+	 * @access private
1291 1291
 	 *
1292 1292
 	 * @param  float $amount The amount to increase the payment subtotal by
1293 1293
 	 *
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 	 * Decrease the payment's subtotal
1305 1305
 	 *
1306 1306
 	 * @since  1.5
1307
-     * @access private
1307
+	 * @access private
1308 1308
 	 *
1309 1309
 	 * @param  float $amount The amount to decrease the payment subtotal by
1310 1310
 	 *
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 	 * Set or update the total for a payment
1326 1326
 	 *
1327 1327
 	 * @since  1.0
1328
-     * @access private
1328
+	 * @access private
1329 1329
 	 *
1330 1330
 	 * @return void
1331 1331
 	 */
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
 	 * Set the payment status and run any status specific changes necessary
1338 1338
 	 *
1339 1339
 	 * @since  1.0
1340
-     * @access public
1340
+	 * @access public
1341 1341
 	 *
1342 1342
 	 * @param  string $status  The status to set the payment to
1343 1343
 	 *
@@ -1387,12 +1387,12 @@  discard block
 block discarded – undo
1387 1387
 				case 'pending':
1388 1388
 					$this->process_pending();
1389 1389
 					break;
1390
-                case 'cancelled':
1391
-                    $this->process_cancelled();
1392
-                    break;
1393
-                case 'revoked':
1394
-                    $this->process_revoked();
1395
-                    break;
1390
+				case 'cancelled':
1391
+					$this->process_cancelled();
1392
+					break;
1393
+				case 'revoked':
1394
+					$this->process_revoked();
1395
+					break;
1396 1396
 			}
1397 1397
 
1398 1398
 			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	 * Change the status of the payment to refunded, and run the necessary changes
1408 1408
 	 *
1409 1409
 	 * @since  1.5
1410
-     * @access public
1410
+	 * @access public
1411 1411
 	 *
1412 1412
 	 * @return void
1413 1413
 	 */
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 	 * Get a post meta item for the payment
1424 1424
 	 *
1425 1425
 	 * @since  1.5
1426
-     * @access public
1426
+	 * @access public
1427 1427
 	 *
1428 1428
 	 * @param  string  $meta_key The Meta Key
1429 1429
 	 * @param  boolean $single   Return single item or array
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 	 * Update the post meta
1463 1463
 	 *
1464 1464
 	 * @since  1.5
1465
-     * @access public
1465
+	 * @access public
1466 1466
 	 *
1467 1467
 	 * @param  string $meta_key   The meta key to update
1468 1468
 	 * @param  string $meta_value The meta value
@@ -1588,77 +1588,77 @@  discard block
 block discarded – undo
1588 1588
 		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1589 1589
 	}
1590 1590
 
1591
-    /**
1592
-     * Process when a payment moves to cancelled
1593
-     *
1594
-     * @since  1.5
1591
+	/**
1592
+	 * Process when a payment moves to cancelled
1593
+	 *
1594
+	 * @since  1.5
1595 1595
 	 * @access private
1596 1596
 	 *
1597
-     * @return void
1598
-     */
1599
-    private function process_cancelled() {
1600
-        $process_cancelled = true;
1597
+	 * @return void
1598
+	 */
1599
+	private function process_cancelled() {
1600
+		$process_cancelled = true;
1601 1601
 
1602
-        // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1603
-        if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1604
-            $process_cancelled = false;
1605
-        }
1602
+		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1603
+		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1604
+			$process_cancelled = false;
1605
+		}
1606 1606
 
1607
-        // Allow extensions to filter for their own payment types, Example: Recurring Payments
1608
-        $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1607
+		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1608
+		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1609 1609
 
1610
-        if ( false === $process_cancelled ) {
1611
-            return;
1612
-        }
1610
+		if ( false === $process_cancelled ) {
1611
+			return;
1612
+		}
1613 1613
 
1614
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1615
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1616
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1614
+		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1615
+		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1616
+		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1617 1617
 
1618
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1619
-        $this->delete_sales_logs();
1618
+		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1619
+		$this->delete_sales_logs();
1620 1620
 
1621
-        $this->completed_date = false;
1622
-        $this->update_meta( '_give_completed_date', '' );
1621
+		$this->completed_date = false;
1622
+		$this->update_meta( '_give_completed_date', '' );
1623 1623
 
1624
-        // Clear the This Month earnings (this_monththis_month is NOT a typo)
1625
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1626
-    }
1624
+		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1625
+		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1626
+	}
1627 1627
 
1628
-    /**
1629
-     * Process when a payment moves to revoked
1630
-     *
1631
-     * @since  1.5
1632
-     * @return void
1633
-     */
1634
-    private function process_revoked() {
1635
-        $process_revoked = true;
1628
+	/**
1629
+	 * Process when a payment moves to revoked
1630
+	 *
1631
+	 * @since  1.5
1632
+	 * @return void
1633
+	 */
1634
+	private function process_revoked() {
1635
+		$process_revoked = true;
1636 1636
 
1637
-        // If the payment was not in publish, don't decrement stats as they were never incremented
1638
-        if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1639
-            $process_revoked = false;
1640
-        }
1637
+		// If the payment was not in publish, don't decrement stats as they were never incremented
1638
+		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1639
+			$process_revoked = false;
1640
+		}
1641 1641
 
1642
-        // Allow extensions to filter for their own payment types, Example: Recurring Payments
1643
-        $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1642
+		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1643
+		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1644 1644
 
1645
-        if ( false === $process_revoked ) {
1646
-            return;
1647
-        }
1645
+		if ( false === $process_revoked ) {
1646
+			return;
1647
+		}
1648 1648
 
1649
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this );
1650
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this );
1651
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this );
1649
+		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this );
1650
+		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this );
1651
+		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this );
1652 1652
 
1653
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1654
-        $this->delete_sales_logs();
1653
+		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1654
+		$this->delete_sales_logs();
1655 1655
 
1656
-        $this->completed_date = false;
1657
-        $this->update_meta( '_give_completed_date', '' );
1656
+		$this->completed_date = false;
1657
+		$this->update_meta( '_give_completed_date', '' );
1658 1658
 
1659
-        // Clear the This Month earnings (this_monththis_month is NOT a typo)
1660
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1661
-    }
1659
+		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1660
+		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1661
+	}
1662 1662
 
1663 1663
 	/**
1664 1664
 	 * Used during the process of moving to refunded or pending, to decrement stats
Please login to merge, or discard this patch.
Spacing   +322 added lines, -322 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
 
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return mixed void|false
349 349
 	 */
350
-	public function __construct( $payment_id = false ) {
350
+	public function __construct($payment_id = false) {
351 351
 
352
-		if ( empty( $payment_id ) ) {
352
+		if (empty($payment_id)) {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		$this->setup_payment( $payment_id );
356
+		$this->setup_payment($payment_id);
357 357
 	}
358 358
 
359 359
 	/**
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @return mixed        The value
368 368
 	 */
369
-	public function __get( $key ) {
369
+	public function __get($key) {
370 370
 
371
-		if ( method_exists( $this, 'get_' . $key ) ) {
371
+		if (method_exists($this, 'get_'.$key)) {
372 372
 
373
-			$value = call_user_func( array( $this, 'get_' . $key ) );
373
+			$value = call_user_func(array($this, 'get_'.$key));
374 374
 
375 375
 		} else {
376 376
 
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 	 * @param  string $key The property name
393 393
 	 * @param  mixed $value The value of the property
394 394
 	 */
395
-	public function __set( $key, $value ) {
396
-		$ignore = array( '_ID' );
395
+	public function __set($key, $value) {
396
+		$ignore = array('_ID');
397 397
 
398
-		if ( $key === 'status' ) {
398
+		if ($key === 'status') {
399 399
 			$this->old_status = $this->status;
400 400
 		}
401 401
 
402
-		if ( ! in_array( $key, $ignore ) ) {
403
-			$this->pending[ $key ] = $value;
402
+		if ( ! in_array($key, $ignore)) {
403
+			$this->pending[$key] = $value;
404 404
 		}
405 405
 
406
-		if ( '_ID' !== $key ) {
406
+		if ('_ID' !== $key) {
407 407
 			$this->$key = $value;
408 408
 		}
409 409
 	}
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @return boolean       If the item is set or not
420 420
 	 */
421
-	public function __isset( $name ) {
422
-		if ( property_exists( $this, $name ) ) {
423
-			return false === empty( $this->$name );
421
+	public function __isset($name) {
422
+		if (property_exists($this, $name)) {
423
+			return false === empty($this->$name);
424 424
 		} else {
425 425
 			return null;
426 426
 		}
@@ -436,31 +436,31 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return bool            If the setup was successful or not
438 438
 	 */
439
-	private function setup_payment( $payment_id ) {
439
+	private function setup_payment($payment_id) {
440 440
 		$this->pending = array();
441 441
 
442
-		if ( empty( $payment_id ) ) {
442
+		if (empty($payment_id)) {
443 443
 			return false;
444 444
 		}
445 445
 
446
-		$payment = get_post( $payment_id );
446
+		$payment = get_post($payment_id);
447 447
 
448
-		if ( ! $payment || is_wp_error( $payment ) ) {
448
+		if ( ! $payment || is_wp_error($payment)) {
449 449
 			return false;
450 450
 		}
451 451
 
452
-		if ( 'give_payment' !== $payment->post_type ) {
452
+		if ('give_payment' !== $payment->post_type) {
453 453
 			return false;
454 454
 		}
455 455
 
456 456
 		// Allow extensions to perform actions before the payment is loaded
457
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
457
+		do_action('give_pre_setup_payment', $this, $payment_id);
458 458
 
459 459
 		// Primary Identifier
460
-		$this->ID = absint( $payment_id );
460
+		$this->ID = absint($payment_id);
461 461
 
462 462
 		// Protected ID that can never be changed
463
-		$this->_ID = absint( $payment_id );
463
+		$this->_ID = absint($payment_id);
464 464
 
465 465
 		// We have a payment, get the generic payment_meta item to reduce calls to it
466 466
 		$this->payment_meta = $this->get_meta();
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		$this->parent_payment = $payment->post_parent;
476 476
 
477 477
 		$all_payment_statuses  = give_get_payment_statuses();
478
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
478
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
479 479
 
480 480
 		// Items
481 481
 		$this->fees = $this->setup_fees();
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		$this->number     = $this->setup_payment_number();
509 509
 
510 510
 		// Allow extensions to add items to this object via hook
511
-		do_action( 'give_setup_payment', $this, $payment_id );
511
+		do_action('give_setup_payment', $this, $payment_id);
512 512
 
513 513
 		return true;
514 514
 	}
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
      * 
527 527
      * @return void
528 528
      */
529
-    public function update_payment_setup( $payment_id ){
530
-        $this->setup_payment( $payment_id );
529
+    public function update_payment_setup($payment_id) {
530
+        $this->setup_payment($payment_id);
531 531
     }
532 532
 
533 533
 	/**
@@ -542,24 +542,24 @@  discard block
 block discarded – undo
542 542
 
543 543
 		// Construct the payment title
544 544
 		$payment_title = '';
545
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
546
-			$payment_title = $this->first_name . ' ' . $this->last_name;
547
-		} else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
545
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
546
+			$payment_title = $this->first_name.' '.$this->last_name;
547
+		} else if ( ! empty($this->first_name) && empty($this->last_name)) {
548 548
 			$payment_title = $this->first_name;
549
-		} else if ( ! empty( $this->email ) && is_email( $this->email ) ) {
549
+		} else if ( ! empty($this->email) && is_email($this->email)) {
550 550
 			$payment_title = $this->email;
551 551
 		}
552 552
 
553 553
 		//Set Key
554
-		if ( empty( $this->key ) ) {
554
+		if (empty($this->key)) {
555 555
 
556
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
557
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
556
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
557
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
558 558
 			$this->pending['key'] = $this->key;
559 559
 		}
560 560
 
561 561
 		//Set IP
562
-		if ( empty( $this->ip ) ) {
562
+		if (empty($this->ip)) {
563 563
 
564 564
 			$this->ip            = give_get_ip();
565 565
 			$this->pending['ip'] = $this->ip;
@@ -586,58 +586,58 @@  discard block
 block discarded – undo
586 586
 			'fees'         => $this->fees,
587 587
 		);
588 588
 
589
-		$args = apply_filters( 'give_insert_payment_args', array(
589
+		$args = apply_filters('give_insert_payment_args', array(
590 590
 			'post_title'    => $payment_title,
591 591
 			'post_status'   => $this->status,
592 592
 			'post_type'     => 'give_payment',
593
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
594
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
593
+			'post_date'     => ! empty($this->date) ? $this->date : null,
594
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
595 595
 			'post_parent'   => $this->parent_payment,
596
-		), $payment_data );
596
+		), $payment_data);
597 597
 
598 598
 		// Create a blank payment
599
-		$payment_id = wp_insert_post( $args );
599
+		$payment_id = wp_insert_post($args);
600 600
 
601
-		if ( ! empty( $payment_id ) ) {
601
+		if ( ! empty($payment_id)) {
602 602
 
603 603
 			$this->ID  = $payment_id;
604 604
 			$this->_ID = $payment_id;
605 605
 
606 606
 			$customer = new stdClass;
607 607
 
608
-			if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) {
609
-				$customer = new Give_Customer( get_current_user_id(), true );
608
+			if (did_action('give_pre_process_purchase') && is_user_logged_in()) {
609
+				$customer = new Give_Customer(get_current_user_id(), true);
610 610
 			}
611 611
 
612
-			if ( empty( $customer->id ) ) {
613
-				$customer = new Give_Customer( $this->email );
612
+			if (empty($customer->id)) {
613
+				$customer = new Give_Customer($this->email);
614 614
 			}
615 615
 
616
-			if ( empty( $customer->id ) ) {
616
+			if (empty($customer->id)) {
617 617
 
618 618
 				$customer_data = array(
619
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
619
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
620 620
 					'email'   => $this->email,
621 621
 					'user_id' => $this->user_id,
622 622
 				);
623 623
 
624
-				$customer->create( $customer_data );
624
+				$customer->create($customer_data);
625 625
 
626 626
 			}
627 627
 
628 628
 			$this->customer_id            = $customer->id;
629 629
 			$this->pending['customer_id'] = $this->customer_id;
630
-			$customer->attach_payment( $this->ID, false );
630
+			$customer->attach_payment($this->ID, false);
631 631
 
632
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
633
-			if ( ! empty( $this->payment_meta['fees'] ) ) {
634
-				$this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
635
-				foreach ( $this->fees as $fee ) {
636
-					$this->increase_fees( $fee['amount'] );
632
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
633
+			if ( ! empty($this->payment_meta['fees'])) {
634
+				$this->fees = array_merge($this->fees, $this->payment_meta['fees']);
635
+				foreach ($this->fees as $fee) {
636
+					$this->increase_fees($fee['amount']);
637 637
 				}
638 638
 			}
639 639
 
640
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
640
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
641 641
 			$this->new = true;
642 642
 		}
643 643
 
@@ -659,11 +659,11 @@  discard block
 block discarded – undo
659 659
 		$saved = false;
660 660
 
661 661
 		//Must have an ID 
662
-		if ( empty( $this->ID ) ) {
662
+		if (empty($this->ID)) {
663 663
 
664 664
 			$payment_id = $this->insert_payment();
665 665
 
666
-			if ( false === $payment_id ) {
666
+			if (false === $payment_id) {
667 667
 				$saved = false;
668 668
 			} else {
669 669
 				$this->ID = $payment_id;
@@ -672,48 +672,48 @@  discard block
 block discarded – undo
672 672
 		}
673 673
 
674 674
 		//Set ID if not matching
675
-		if ( $this->ID !== $this->_ID ) {
675
+		if ($this->ID !== $this->_ID) {
676 676
 			$this->ID = $this->_ID;
677 677
 		}
678 678
 
679 679
 		// If we have something pending, let's save it
680
-		if ( ! empty( $this->pending ) ) {
680
+		if ( ! empty($this->pending)) {
681 681
 
682 682
 			$total_increase = 0;
683 683
 			$total_decrease = 0;
684 684
 
685
-			foreach ( $this->pending as $key => $value ) {
685
+			foreach ($this->pending as $key => $value) {
686 686
 
687
-				switch ( $key ) {
687
+				switch ($key) {
688 688
 
689 689
 					case 'donations':
690 690
 						// Update totals for pending donations
691
-						foreach ( $this->pending[ $key ] as $item ) {
691
+						foreach ($this->pending[$key] as $item) {
692 692
 
693
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
694
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
693
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
694
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
695 695
 
696
-							switch ( $item['action'] ) {
696
+							switch ($item['action']) {
697 697
 
698 698
 								case 'add':
699 699
 
700 700
 									$price = $item['price'];
701 701
 
702
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
702
+									if ('publish' === $this->status || 'complete' === $this->status) {
703 703
 
704 704
 										// Add sales logs
705
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
705
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
706 706
 
707 707
 										$y = 0;
708
-										while ( $y < $quantity ) {
708
+										while ($y < $quantity) {
709 709
 
710
-											give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date );
711
-											$y ++;
710
+											give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date);
711
+											$y++;
712 712
 										}
713 713
 
714
-										$form = new Give_Donate_Form( $item['id'] );
715
-										$form->increase_sales( $quantity );
716
-										$form->increase_earnings( $price );
714
+										$form = new Give_Donate_Form($item['id']);
715
+										$form->increase_sales($quantity);
716
+										$form->increase_earnings($price);
717 717
 
718 718
 										$total_increase += $price;
719 719
 									}
@@ -738,15 +738,15 @@  discard block
 block discarded – undo
738 738
 										)
739 739
 									);
740 740
 
741
-									$found_logs = get_posts( $log_args );
742
-									foreach ( $found_logs as $log ) {
743
-										wp_delete_post( $log->ID, true );
741
+									$found_logs = get_posts($log_args);
742
+									foreach ($found_logs as $log) {
743
+										wp_delete_post($log->ID, true);
744 744
 									}
745 745
 
746
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
747
-										$form = new Give_Donate_Form( $item['id'] );
748
-										$form->decrease_sales( $quantity );
749
-										$form->decrease_earnings( $item['amount'] );
746
+									if ('publish' === $this->status || 'complete' === $this->status) {
747
+										$form = new Give_Donate_Form($item['id']);
748
+										$form->decrease_sales($quantity);
749
+										$form->decrease_earnings($item['amount']);
750 750
 
751 751
 										$total_decrease += $item['amount'];
752 752
 									}
@@ -759,17 +759,17 @@  discard block
 block discarded – undo
759 759
 
760 760
 					case 'fees':
761 761
 
762
-						if ( 'publish' !== $this->status && 'complete' !== $this->status ) {
762
+						if ('publish' !== $this->status && 'complete' !== $this->status) {
763 763
 							break;
764 764
 						}
765 765
 
766
-						if ( empty( $this->pending[ $key ] ) ) {
766
+						if (empty($this->pending[$key])) {
767 767
 							break;
768 768
 						}
769 769
 
770
-						foreach ( $this->pending[ $key ] as $fee ) {
770
+						foreach ($this->pending[$key] as $fee) {
771 771
 
772
-							switch ( $fee['action'] ) {
772
+							switch ($fee['action']) {
773 773
 
774 774
 								case 'add':
775 775
 									$total_increase += $fee['amount'];
@@ -786,43 +786,43 @@  discard block
 block discarded – undo
786 786
 						break;
787 787
 
788 788
 					case 'status':
789
-						$this->update_status( $this->status );
789
+						$this->update_status($this->status);
790 790
 						break;
791 791
 
792 792
 					case 'gateway':
793
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
793
+						$this->update_meta('_give_payment_gateway', $this->gateway);
794 794
 						break;
795 795
 
796 796
 					case 'mode':
797
-						$this->update_meta( '_give_payment_mode', $this->mode );
797
+						$this->update_meta('_give_payment_mode', $this->mode);
798 798
 						break;
799 799
 
800 800
 					case 'transaction_id':
801
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
801
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
802 802
 						break;
803 803
 
804 804
 					case 'ip':
805
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
805
+						$this->update_meta('_give_payment_user_ip', $this->ip);
806 806
 						break;
807 807
 
808 808
 					case 'customer_id':
809
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
809
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
810 810
 						break;
811 811
 
812 812
 					case 'user_id':
813
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
813
+						$this->update_meta('_give_payment_user_id', $this->user_id);
814 814
 						break;
815 815
 
816 816
 					case 'form_title':
817
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
817
+						$this->update_meta('_give_payment_form_title', $this->form_title);
818 818
 						break;
819 819
 
820 820
 					case 'form_id':
821
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
821
+						$this->update_meta('_give_payment_form_id', $this->form_id);
822 822
 						break;
823 823
 
824 824
 					case 'price_id':
825
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
825
+						$this->update_meta('_give_payment_price_id', $this->price_id);
826 826
 						break;
827 827
 
828 828
 					case 'first_name':
@@ -838,15 +838,15 @@  discard block
 block discarded – undo
838 838
 						break;
839 839
 
840 840
 					case 'email':
841
-						$this->update_meta( '_give_payment_user_email', $this->email );
841
+						$this->update_meta('_give_payment_user_email', $this->email);
842 842
 						break;
843 843
 
844 844
 					case 'key':
845
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
845
+						$this->update_meta('_give_payment_purchase_key', $this->key);
846 846
 						break;
847 847
 
848 848
 					case 'number':
849
-						$this->update_meta( '_give_payment_number', $this->number );
849
+						$this->update_meta('_give_payment_number', $this->number);
850 850
 						break;
851 851
 
852 852
 					case 'date':
@@ -856,11 +856,11 @@  discard block
 block discarded – undo
856 856
 							'edit_date' => true,
857 857
 						);
858 858
 
859
-						wp_update_post( $args );
859
+						wp_update_post($args);
860 860
 						break;
861 861
 
862 862
 					case 'completed_date':
863
-						$this->update_meta( '_give_completed_date', $this->completed_date );
863
+						$this->update_meta('_give_completed_date', $this->completed_date);
864 864
 						break;
865 865
 
866 866
 					case 'parent_payment':
@@ -869,38 +869,38 @@  discard block
 block discarded – undo
869 869
 							'post_parent' => $this->parent_payment,
870 870
 						);
871 871
 
872
-						wp_update_post( $args );
872
+						wp_update_post($args);
873 873
 						break;
874 874
 
875 875
 					default:
876
-						do_action( 'give_payment_save', $this, $key );
876
+						do_action('give_payment_save', $this, $key);
877 877
 						break;
878 878
 				}
879 879
 			}
880 880
 
881
-			if ( 'pending' !== $this->status ) {
881
+			if ('pending' !== $this->status) {
882 882
 
883
-				$customer = new Give_Customer( $this->customer_id );
883
+				$customer = new Give_Customer($this->customer_id);
884 884
 
885 885
 				$total_change = $total_increase - $total_decrease;
886
-				if ( $total_change < 0 ) {
886
+				if ($total_change < 0) {
887 887
 
888
-					$total_change = - ( $total_change );
888
+					$total_change = - ($total_change);
889 889
 					// Decrease the customer's purchase stats
890
-					$customer->decrease_value( $total_change );
891
-					give_decrease_total_earnings( $total_change );
890
+					$customer->decrease_value($total_change);
891
+					give_decrease_total_earnings($total_change);
892 892
 
893
-				} else if ( $total_change > 0 ) {
893
+				} else if ($total_change > 0) {
894 894
 
895 895
 					// Increase the customer's purchase stats
896
-					$customer->increase_value( $total_change );
897
-					give_increase_total_earnings( $total_change );
896
+					$customer->increase_value($total_change);
897
+					give_increase_total_earnings($total_change);
898 898
 
899 899
 				}
900 900
 
901 901
 			}
902 902
 
903
-			$this->update_meta( '_give_payment_total', $this->total );
903
+			$this->update_meta('_give_payment_total', $this->total);
904 904
 
905 905
 			$new_meta = array(
906 906
 				'form_title' => $this->form_title,
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 			);
913 913
 
914 914
 			$meta        = $this->get_meta();
915
-			$merged_meta = array_merge( $meta, $new_meta );
915
+			$merged_meta = array_merge($meta, $new_meta);
916 916
 
917 917
 			// Only save the payment meta if it's changed
918
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
919
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
920
-				if ( false !== $updated ) {
918
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
919
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
920
+				if (false !== $updated) {
921 921
 					$saved = true;
922 922
 				}
923 923
 			}
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 			$saved         = true;
927 927
 		}
928 928
 
929
-		if ( true === $saved ) {
930
-			$this->setup_payment( $this->ID );
929
+		if (true === $saved) {
930
+			$this->setup_payment($this->ID);
931 931
 		}
932 932
 
933 933
 		return $saved;
@@ -945,12 +945,12 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return bool           True when successful, false otherwise
947 947
 	 */
948
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
948
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
949 949
 
950
-		$donation = new Give_Donate_Form( $form_id );
950
+		$donation = new Give_Donate_Form($form_id);
951 951
 
952 952
 		// Bail if this post isn't a give donation form
953
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
953
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
954 954
 			return false;
955 955
 		}
956 956
 
@@ -961,60 +961,60 @@  discard block
 block discarded – undo
961 961
 			'fees'     => array(),
962 962
 		);
963 963
 
964
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
964
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
965 965
 
966 966
 		// Allow overriding the price
967
-		if ( false !== $args['price'] ) {
967
+		if (false !== $args['price']) {
968 968
 			$item_price = $args['price'];
969 969
 		} else {
970 970
 
971 971
 			// Deal with variable pricing
972
-			if ( give_has_variable_prices( $donation->ID ) ) {
973
-				$prices     = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
972
+			if (give_has_variable_prices($donation->ID)) {
973
+				$prices     = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
974 974
 				$item_price = '';
975 975
 				//Loop through prices
976
-				foreach ( $prices as $price ) {
976
+				foreach ($prices as $price) {
977 977
 					//Find a match between price_id and level_id
978 978
 					//First verify array keys exists THEN make the match
979
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
979
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
980 980
 					     && $args['price_id'] == $price['_give_id']['level_id']
981 981
 					) {
982 982
 						$item_price = $price['_give_amount'];
983 983
 					}
984 984
 				}
985 985
 				//Fallback to the lowest price point
986
-				if ( $item_price == '' ) {
987
-					$item_price       = give_get_lowest_price_option( $donation->ID );
988
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
986
+				if ($item_price == '') {
987
+					$item_price       = give_get_lowest_price_option($donation->ID);
988
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
989 989
 				}
990 990
 			} else {
991 991
 				//Simple form price
992
-				$item_price = give_get_form_price( $donation->ID );
992
+				$item_price = give_get_form_price($donation->ID);
993 993
 			}
994 994
 
995 995
 		}
996 996
 
997 997
 		// Sanitizing the price here so we don't have a dozen calls later
998
-		$item_price = give_sanitize_amount( $item_price );
999
-		$total      = round( $item_price, give_currency_decimal_filter() );
998
+		$item_price = give_sanitize_amount($item_price);
999
+		$total      = round($item_price, give_currency_decimal_filter());
1000 1000
 
1001 1001
 		//Add Options
1002 1002
 		$default_options = array();
1003
-		if ( false !== $args['price_id'] ) {
1003
+		if (false !== $args['price_id']) {
1004 1004
 			$default_options['price_id'] = (int) $args['price_id'];
1005 1005
 		}
1006
-		$options = wp_parse_args( $options, $default_options );
1006
+		$options = wp_parse_args($options, $default_options);
1007 1007
 
1008 1008
 		// Do not allow totals to go negative
1009
-		if ( $total < 0 ) {
1009
+		if ($total < 0) {
1010 1010
 			$total = 0;
1011 1011
 		}
1012 1012
 
1013 1013
 		$donation = array(
1014 1014
 			'name'     => $donation->post_title,
1015 1015
 			'id'       => $donation->ID,
1016
-			'price'    => round( $total, give_currency_decimal_filter() ),
1017
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
1016
+			'price'    => round($total, give_currency_decimal_filter()),
1017
+			'subtotal' => round($total, give_currency_decimal_filter()),
1018 1018
 			'fees'     => $args['fees'],
1019 1019
 			'price_id' => $args['price_id'],
1020 1020
 			'action'   => 'add',
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
 		$this->pending['donations'][] = $donation;
1025 1025
 
1026
-		$this->increase_subtotal( $total );
1026
+		$this->increase_subtotal($total);
1027 1027
 
1028 1028
 		return true;
1029 1029
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 	 *
1041 1041
 	 * @return bool           If the item was removed or not
1042 1042
 	 */
1043
-	public function remove_donation( $form_id, $args = array() ) {
1043
+	public function remove_donation($form_id, $args = array()) {
1044 1044
 
1045 1045
 		// Set some defaults
1046 1046
 		$defaults = array(
@@ -1048,12 +1048,12 @@  discard block
 block discarded – undo
1048 1048
 			'price'    => false,
1049 1049
 			'price_id' => false,
1050 1050
 		);
1051
-		$args     = wp_parse_args( $args, $defaults );
1051
+		$args = wp_parse_args($args, $defaults);
1052 1052
 
1053
-		$form = new Give_Donate_Form( $form_id );
1053
+		$form = new Give_Donate_Form($form_id);
1054 1054
 
1055 1055
 		// Bail if this post isn't a valid give donation form
1056
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1056
+		if ( ! $form || $form->post_type !== 'give_forms') {
1057 1057
 			return false;
1058 1058
 		}
1059 1059
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 
1067 1067
 		$this->pending['donations'][] = $pending_args;
1068 1068
 
1069
-		$this->decrease_subtotal( $this->total );
1069
+		$this->decrease_subtotal($this->total);
1070 1070
 
1071 1071
 		return true;
1072 1072
 	}
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	 *
1083 1083
 	 * @return bool          If the fee was added
1084 1084
 	 */
1085
-	public function add_fee( $args, $global = true ) {
1085
+	public function add_fee($args, $global = true) {
1086 1086
 
1087 1087
 		$default_args = array(
1088 1088
 			'label'    => '',
@@ -1092,16 +1092,16 @@  discard block
 block discarded – undo
1092 1092
 			'price_id' => 0,
1093 1093
 		);
1094 1094
 
1095
-		$fee          = wp_parse_args( $args, $default_args );
1095
+		$fee          = wp_parse_args($args, $default_args);
1096 1096
 		$this->fees[] = $fee;
1097 1097
 
1098 1098
 
1099 1099
 		$added_fee               = $fee;
1100 1100
 		$added_fee['action']     = 'add';
1101 1101
 		$this->pending['fees'][] = $added_fee;
1102
-		reset( $this->fees );
1102
+		reset($this->fees);
1103 1103
 
1104
-		$this->increase_fees( $fee['amount'] );
1104
+		$this->increase_fees($fee['amount']);
1105 1105
 
1106 1106
 		return true;
1107 1107
 	}
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
 	 *
1117 1117
 	 * @return bool     If the fee was removed successfully
1118 1118
 	 */
1119
-	public function remove_fee( $key ) {
1119
+	public function remove_fee($key) {
1120 1120
 		$removed = false;
1121 1121
 
1122
-		if ( is_numeric( $key ) ) {
1123
-			$removed = $this->remove_fee_by( 'index', $key );
1122
+		if (is_numeric($key)) {
1123
+			$removed = $this->remove_fee_by('index', $key);
1124 1124
 		}
1125 1125
 
1126 1126
 		return $removed;
@@ -1139,47 +1139,47 @@  discard block
 block discarded – undo
1139 1139
 	 *
1140 1140
 	 * @return boolean            If the item is removed
1141 1141
 	 */
1142
-	public function remove_fee_by( $key, $value, $global = false ) {
1142
+	public function remove_fee_by($key, $value, $global = false) {
1143 1143
 
1144
-		$allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array(
1144
+		$allowed_fee_keys = apply_filters('give_payment_fee_keys', array(
1145 1145
 			'index',
1146 1146
 			'label',
1147 1147
 			'amount',
1148 1148
 			'type',
1149
-		) );
1149
+		));
1150 1150
 
1151
-		if ( ! in_array( $key, $allowed_fee_keys ) ) {
1151
+		if ( ! in_array($key, $allowed_fee_keys)) {
1152 1152
 			return false;
1153 1153
 		}
1154 1154
 
1155 1155
 		$removed = false;
1156
-		if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1156
+		if ('index' === $key && array_key_exists($value, $this->fees)) {
1157 1157
 
1158
-			$removed_fee             = $this->fees[ $value ];
1158
+			$removed_fee             = $this->fees[$value];
1159 1159
 			$removed_fee['action']   = 'remove';
1160 1160
 			$this->pending['fees'][] = $removed_fee;
1161 1161
 
1162
-			$this->decrease_fees( $removed_fee['amount'] );
1162
+			$this->decrease_fees($removed_fee['amount']);
1163 1163
 
1164
-			unset( $this->fees[ $value ] );
1164
+			unset($this->fees[$value]);
1165 1165
 			$removed = true;
1166 1166
 
1167
-		} else if ( 'index' !== $key ) {
1167
+		} else if ('index' !== $key) {
1168 1168
 
1169
-			foreach ( $this->fees as $index => $fee ) {
1169
+			foreach ($this->fees as $index => $fee) {
1170 1170
 
1171
-				if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1171
+				if (isset($fee[$key]) && $fee[$key] == $value) {
1172 1172
 
1173 1173
 					$removed_fee             = $fee;
1174 1174
 					$removed_fee['action']   = 'remove';
1175 1175
 					$this->pending['fees'][] = $removed_fee;
1176 1176
 
1177
-					$this->decrease_fees( $removed_fee['amount'] );
1177
+					$this->decrease_fees($removed_fee['amount']);
1178 1178
 
1179
-					unset( $this->fees[ $index ] );
1179
+					unset($this->fees[$index]);
1180 1180
 					$removed = true;
1181 1181
 
1182
-					if ( false === $global ) {
1182
+					if (false === $global) {
1183 1183
 						break;
1184 1184
 					}
1185 1185
 
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 		}
1191 1191
 
1192
-		if ( true === $removed ) {
1193
-			$this->fees = array_values( $this->fees );
1192
+		if (true === $removed) {
1193
+			$this->fees = array_values($this->fees);
1194 1194
 		}
1195 1195
 
1196 1196
 		return $removed;
@@ -1206,14 +1206,14 @@  discard block
 block discarded – undo
1206 1206
 	 *
1207 1207
 	 * @return array        The Fees for the type specified
1208 1208
 	 */
1209
-	public function get_fees( $type = 'all' ) {
1209
+	public function get_fees($type = 'all') {
1210 1210
 		$fees = array();
1211 1211
 
1212
-		if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1212
+		if ( ! empty($this->fees) && is_array($this->fees)) {
1213 1213
 
1214
-			foreach ( $this->fees as $fee_id => $fee ) {
1214
+			foreach ($this->fees as $fee_id => $fee) {
1215 1215
 
1216
-				if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1216
+				if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1217 1217
 					continue;
1218 1218
 				}
1219 1219
 
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			}
1224 1224
 		}
1225 1225
 
1226
-		return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this );
1226
+		return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
1227 1227
 	}
1228 1228
 
1229 1229
 	/**
@@ -1236,13 +1236,13 @@  discard block
 block discarded – undo
1236 1236
 	 *
1237 1237
 	 * @return void
1238 1238
 	 */
1239
-	public function add_note( $note = false ) {
1239
+	public function add_note($note = false) {
1240 1240
 		// Bail if no note specified
1241
-		if ( ! $note ) {
1241
+		if ( ! $note) {
1242 1242
 			return false;
1243 1243
 		}
1244 1244
 
1245
-		give_insert_payment_note( $this->ID, $note );
1245
+		give_insert_payment_note($this->ID, $note);
1246 1246
 	}
1247 1247
 
1248 1248
 	/**
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 	 *
1256 1256
 	 * @return void
1257 1257
 	 */
1258
-	private function increase_subtotal( $amount = 0.00 ) {
1258
+	private function increase_subtotal($amount = 0.00) {
1259 1259
 		$amount = (float) $amount;
1260 1260
 		$this->subtotal += $amount;
1261 1261
 
@@ -1272,11 +1272,11 @@  discard block
 block discarded – undo
1272 1272
 	 *
1273 1273
 	 * @return void
1274 1274
 	 */
1275
-	private function decrease_subtotal( $amount = 0.00 ) {
1275
+	private function decrease_subtotal($amount = 0.00) {
1276 1276
 		$amount = (float) $amount;
1277 1277
 		$this->subtotal -= $amount;
1278 1278
 
1279
-		if ( $this->subtotal < 0 ) {
1279
+		if ($this->subtotal < 0) {
1280 1280
 			$this->subtotal = 0;
1281 1281
 		}
1282 1282
 
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 	 *
1294 1294
 	 * @return void
1295 1295
 	 */
1296
-	private function increase_fees( $amount = 0.00 ) {
1296
+	private function increase_fees($amount = 0.00) {
1297 1297
 		$amount = (float) $amount;
1298 1298
 		$this->fees_total += $amount;
1299 1299
 
@@ -1310,11 +1310,11 @@  discard block
 block discarded – undo
1310 1310
 	 *
1311 1311
 	 * @return void
1312 1312
 	 */
1313
-	private function decrease_fees( $amount = 0.00 ) {
1313
+	private function decrease_fees($amount = 0.00) {
1314 1314
 		$amount = (float) $amount;
1315 1315
 		$this->fees_total -= $amount;
1316 1316
 
1317
-		if ( $this->fees_total < 0 ) {
1317
+		if ($this->fees_total < 0) {
1318 1318
 			$this->fees_total = 0;
1319 1319
 		}
1320 1320
 
@@ -1343,41 +1343,41 @@  discard block
 block discarded – undo
1343 1343
 	 *
1344 1344
 	 * @return bool   $updated Returns if the status was successfully updated
1345 1345
 	 */
1346
-	public function update_status( $status = false ) {
1346
+	public function update_status($status = false) {
1347 1347
 
1348 1348
 		//standardize the 'complete(d)' status
1349
-		if ( $status == 'completed' || $status == 'complete' ) {
1349
+		if ($status == 'completed' || $status == 'complete') {
1350 1350
 			$status = 'publish';
1351 1351
 		}
1352 1352
 
1353
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1353
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1354 1354
 
1355
-		if ( $old_status === $status ) {
1355
+		if ($old_status === $status) {
1356 1356
 			return false; // Don't permit status changes that aren't changes
1357 1357
 		}
1358 1358
 
1359
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1359
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1360 1360
 
1361 1361
 		$updated = false;
1362 1362
 
1363 1363
 
1364
-		if ( $do_change ) {
1364
+		if ($do_change) {
1365 1365
 
1366
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1366
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1367 1367
 
1368 1368
 			$update_fields = array(
1369 1369
 				'ID'          => $this->ID,
1370 1370
 				'post_status' => $status,
1371
-				'edit_date'   => current_time( 'mysql' )
1371
+				'edit_date'   => current_time('mysql')
1372 1372
 			);
1373 1373
 
1374
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1374
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1375 1375
 
1376 1376
 			$all_payment_statuses  = give_get_payment_statuses();
1377
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1377
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1378 1378
 
1379 1379
 			// Process any specific status functions
1380
-			switch ( $status ) {
1380
+			switch ($status) {
1381 1381
 				case 'refunded':
1382 1382
 					$this->process_refund();
1383 1383
 					break;
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
                     break;
1396 1396
 			}
1397 1397
 
1398
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1398
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1399 1399
 
1400 1400
 		}
1401 1401
 
@@ -1430,32 +1430,32 @@  discard block
 block discarded – undo
1430 1430
 	 *
1431 1431
 	 * @return mixed             The value from the post meta
1432 1432
 	 */
1433
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1433
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1434 1434
 
1435
-		$meta = get_post_meta( $this->ID, $meta_key, $single );
1435
+		$meta = get_post_meta($this->ID, $meta_key, $single);
1436 1436
 
1437
-		if ( $meta_key === '_give_payment_meta' ) {
1437
+		if ($meta_key === '_give_payment_meta') {
1438 1438
 
1439
-			if ( empty( $meta['key'] ) ) {
1439
+			if (empty($meta['key'])) {
1440 1440
 				$meta['key'] = $this->setup_payment_key();
1441 1441
 			}
1442 1442
 
1443
-			if ( empty( $meta['form_title'] ) ) {
1443
+			if (empty($meta['form_title'])) {
1444 1444
 				$meta['form_title'] = $this->setup_form_title();
1445 1445
 			}
1446 1446
 
1447
-			if ( empty( $meta['email'] ) ) {
1447
+			if (empty($meta['email'])) {
1448 1448
 				$meta['email'] = $this->setup_email();
1449 1449
 			}
1450 1450
 
1451
-			if ( empty( $meta['date'] ) ) {
1452
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1451
+			if (empty($meta['date'])) {
1452
+				$meta['date'] = get_post_field('post_date', $this->ID);
1453 1453
 			}
1454 1454
 		}
1455 1455
 
1456
-		$meta = apply_filters( 'give_get_payment_meta_' . $meta_key, $meta, $this->ID );
1456
+		$meta = apply_filters('give_get_payment_meta_'.$meta_key, $meta, $this->ID);
1457 1457
 
1458
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1458
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1459 1459
 	}
1460 1460
 
1461 1461
 	/**
@@ -1470,23 +1470,23 @@  discard block
 block discarded – undo
1470 1470
 	 *
1471 1471
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1472 1472
 	 */
1473
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1474
-		if ( empty( $meta_key ) ) {
1473
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1474
+		if (empty($meta_key)) {
1475 1475
 			return false;
1476 1476
 		}
1477 1477
 
1478
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1478
+		if ($meta_key == 'key' || $meta_key == 'date') {
1479 1479
 
1480 1480
 			$current_meta              = $this->get_meta();
1481
-			$current_meta[ $meta_key ] = $meta_value;
1481
+			$current_meta[$meta_key] = $meta_value;
1482 1482
 
1483 1483
 			$meta_key   = '_give_payment_meta';
1484 1484
 			$meta_value = $current_meta;
1485 1485
 
1486
-		} else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1486
+		} else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1487 1487
 
1488
-			$meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1489
-			update_post_meta( $this->ID, '_give_payment_user_email', $meta_value );
1488
+			$meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $this->ID);
1489
+			update_post_meta($this->ID, '_give_payment_user_email', $meta_value);
1490 1490
 
1491 1491
 			$current_meta                       = $this->get_meta();
1492 1492
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1496,9 +1496,9 @@  discard block
 block discarded – undo
1496 1496
 
1497 1497
 		}
1498 1498
 
1499
-		$meta_value = apply_filters( 'give_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1499
+		$meta_value = apply_filters('give_update_payment_meta_'.$meta_key, $meta_value, $this->ID);
1500 1500
 
1501
-		return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1501
+		return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1502 1502
 	}
1503 1503
 
1504 1504
 	/**
@@ -1513,30 +1513,30 @@  discard block
 block discarded – undo
1513 1513
 		$process_refund = true;
1514 1514
 
1515 1515
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1516
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1516
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1517 1517
 			$process_refund = false;
1518 1518
 		}
1519 1519
 
1520 1520
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1521
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1521
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1522 1522
 
1523
-		if ( false === $process_refund ) {
1523
+		if (false === $process_refund) {
1524 1524
 			return;
1525 1525
 		}
1526 1526
 
1527
-		do_action( 'give_pre_refund_payment', $this );
1527
+		do_action('give_pre_refund_payment', $this);
1528 1528
 
1529
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1530
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1531
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1529
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1530
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1531
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1532 1532
 
1533
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1533
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1534 1534
 		$this->delete_sales_logs();
1535 1535
 
1536 1536
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1537
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1537
+		delete_transient(md5('give_earnings_this_monththis_month'));
1538 1538
 
1539
-		do_action( 'give_post_refund_payment', $this );
1539
+		do_action('give_post_refund_payment', $this);
1540 1540
 	}
1541 1541
 
1542 1542
 	/**
@@ -1563,29 +1563,29 @@  discard block
 block discarded – undo
1563 1563
 		$process_pending = true;
1564 1564
 
1565 1565
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1566
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1566
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1567 1567
 			$process_pending = false;
1568 1568
 		}
1569 1569
 
1570 1570
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1571
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1571
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1572 1572
 
1573
-		if ( false === $process_pending ) {
1573
+		if (false === $process_pending) {
1574 1574
 			return;
1575 1575
 		}
1576 1576
 
1577
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this );
1578
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this );
1579
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this );
1577
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this);
1578
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this);
1579
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this);
1580 1580
 
1581
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1581
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1582 1582
 		$this->delete_sales_logs();
1583 1583
 
1584 1584
 		$this->completed_date = false;
1585
-		$this->update_meta( '_give_completed_date', '' );
1585
+		$this->update_meta('_give_completed_date', '');
1586 1586
 
1587 1587
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1588
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1588
+		delete_transient(md5('give_earnings_this_monththis_month'));
1589 1589
 	}
1590 1590
 
1591 1591
     /**
@@ -1600,29 +1600,29 @@  discard block
 block discarded – undo
1600 1600
         $process_cancelled = true;
1601 1601
 
1602 1602
         // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1603
-        if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1603
+        if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1604 1604
             $process_cancelled = false;
1605 1605
         }
1606 1606
 
1607 1607
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1608
-        $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1608
+        $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1609 1609
 
1610
-        if ( false === $process_cancelled ) {
1610
+        if (false === $process_cancelled) {
1611 1611
             return;
1612 1612
         }
1613 1613
 
1614
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1615
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1616
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1614
+        $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this);
1615
+        $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this);
1616
+        $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this);
1617 1617
 
1618
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1618
+        $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1619 1619
         $this->delete_sales_logs();
1620 1620
 
1621 1621
         $this->completed_date = false;
1622
-        $this->update_meta( '_give_completed_date', '' );
1622
+        $this->update_meta('_give_completed_date', '');
1623 1623
 
1624 1624
         // Clear the This Month earnings (this_monththis_month is NOT a typo)
1625
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1625
+        delete_transient(md5('give_earnings_this_monththis_month'));
1626 1626
     }
1627 1627
 
1628 1628
     /**
@@ -1635,29 +1635,29 @@  discard block
 block discarded – undo
1635 1635
         $process_revoked = true;
1636 1636
 
1637 1637
         // If the payment was not in publish, don't decrement stats as they were never incremented
1638
-        if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1638
+        if ('publish' != $this->old_status || 'revoked' != $this->status) {
1639 1639
             $process_revoked = false;
1640 1640
         }
1641 1641
 
1642 1642
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1643
-        $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1643
+        $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1644 1644
 
1645
-        if ( false === $process_revoked ) {
1645
+        if (false === $process_revoked) {
1646 1646
             return;
1647 1647
         }
1648 1648
 
1649
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this );
1650
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this );
1651
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this );
1649
+        $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this);
1650
+        $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this);
1651
+        $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this);
1652 1652
 
1653
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1653
+        $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1654 1654
         $this->delete_sales_logs();
1655 1655
 
1656 1656
         $this->completed_date = false;
1657
-        $this->update_meta( '_give_completed_date', '' );
1657
+        $this->update_meta('_give_completed_date', '');
1658 1658
 
1659 1659
         // Clear the This Month earnings (this_monththis_month is NOT a typo)
1660
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1660
+        delete_transient(md5('give_earnings_this_monththis_month'));
1661 1661
     }
1662 1662
 
1663 1663
 	/**
@@ -1672,25 +1672,25 @@  discard block
 block discarded – undo
1672 1672
 	 *
1673 1673
 	 * @return void
1674 1674
 	 */
1675
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1675
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1676 1676
 
1677
-		give_undo_purchase( false, $this->ID );
1677
+		give_undo_purchase(false, $this->ID);
1678 1678
 
1679 1679
 		// Decrease store earnings
1680
-		if ( true === $alter_store_earnings ) {
1681
-			give_decrease_total_earnings( $this->total );
1680
+		if (true === $alter_store_earnings) {
1681
+			give_decrease_total_earnings($this->total);
1682 1682
 		}
1683 1683
 
1684 1684
 		// Decrement the stats for the customer
1685
-		if ( ! empty( $this->customer_id ) ) {
1685
+		if ( ! empty($this->customer_id)) {
1686 1686
 
1687
-			$customer = new Give_Customer( $this->customer_id );
1687
+			$customer = new Give_Customer($this->customer_id);
1688 1688
 
1689
-			if ( true === $alter_customer_value ) {
1690
-				$customer->decrease_value( $this->total );
1689
+			if (true === $alter_customer_value) {
1690
+				$customer->decrease_value($this->total);
1691 1691
 			}
1692 1692
 
1693
-			if ( true === $alter_customer_purchase_count ) {
1693
+			if (true === $alter_customer_purchase_count) {
1694 1694
 				$customer->decrease_purchase_count();
1695 1695
 			}
1696 1696
 
@@ -1740,13 +1740,13 @@  discard block
 block discarded – undo
1740 1740
 	 * @return string The date the payment was completed
1741 1741
 	 */
1742 1742
 	private function setup_completed_date() {
1743
-		$payment = get_post( $this->ID );
1743
+		$payment = get_post($this->ID);
1744 1744
 
1745
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1745
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1746 1746
 			return false; // This payment was never completed
1747 1747
 		}
1748 1748
 
1749
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1749
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1750 1750
 
1751 1751
 		return $date;
1752 1752
 	}
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 	 * @return string The payment mode
1761 1761
 	 */
1762 1762
 	private function setup_mode() {
1763
-		return $this->get_meta( '_give_payment_mode' );
1763
+		return $this->get_meta('_give_payment_mode');
1764 1764
 	}
1765 1765
 
1766 1766
 	/**
@@ -1772,13 +1772,13 @@  discard block
 block discarded – undo
1772 1772
 	 * @return float The payment total
1773 1773
 	 */
1774 1774
 	private function setup_total() {
1775
-		$amount = $this->get_meta( '_give_payment_total', true );
1775
+		$amount = $this->get_meta('_give_payment_total', true);
1776 1776
 
1777
-		if ( empty( $amount ) && '0.00' != $amount ) {
1778
-			$meta = $this->get_meta( '_give_payment_meta', true );
1779
-			$meta = maybe_unserialize( $meta );
1777
+		if (empty($amount) && '0.00' != $amount) {
1778
+			$meta = $this->get_meta('_give_payment_meta', true);
1779
+			$meta = maybe_unserialize($meta);
1780 1780
 
1781
-			if ( isset( $meta['amount'] ) ) {
1781
+			if (isset($meta['amount'])) {
1782 1782
 				$amount = $meta['amount'];
1783 1783
 			}
1784 1784
 		}
@@ -1811,9 +1811,9 @@  discard block
 block discarded – undo
1811 1811
 	private function setup_fees_total() {
1812 1812
 		$fees_total = (float) 0.00;
1813 1813
 
1814
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1815
-		if ( ! empty( $payment_fees ) ) {
1816
-			foreach ( $payment_fees as $fee ) {
1814
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1815
+		if ( ! empty($payment_fees)) {
1816
+			foreach ($payment_fees as $fee) {
1817 1817
 				$fees_total += (float) $fee['amount'];
1818 1818
 			}
1819 1819
 		}
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
 	 * @return string The currency for the payment
1832 1832
 	 */
1833 1833
 	private function setup_currency() {
1834
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this );
1834
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this);
1835 1835
 
1836 1836
 		return $currency;
1837 1837
 	}
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
 	 * @return array The Fees
1846 1846
 	 */
1847 1847
 	private function setup_fees() {
1848
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1848
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1849 1849
 
1850 1850
 		return $payment_fees;
1851 1851
 	}
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
 	 * @return string The gateway
1860 1860
 	 */
1861 1861
 	private function setup_gateway() {
1862
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1862
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1863 1863
 
1864 1864
 		return $gateway;
1865 1865
 	}
@@ -1873,12 +1873,12 @@  discard block
 block discarded – undo
1873 1873
 	 * @return string The transaction ID for the payment
1874 1874
 	 */
1875 1875
 	private function setup_transaction_id() {
1876
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1876
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1877 1877
 
1878
-		if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
1878
+		if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
1879 1879
 
1880 1880
 			$gateway        = $this->gateway;
1881
-			$transaction_id = apply_filters( 'give_get_payment_transaction_id-' . $gateway, $this->ID );
1881
+			$transaction_id = apply_filters('give_get_payment_transaction_id-'.$gateway, $this->ID);
1882 1882
 
1883 1883
 		}
1884 1884
 
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
 	 * @return string The IP address for the payment
1895 1895
 	 */
1896 1896
 	private function setup_ip() {
1897
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
1897
+		$ip = $this->get_meta('_give_payment_user_ip', true);
1898 1898
 
1899 1899
 		return $ip;
1900 1900
 	}
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
 	 * @return int The Customer ID
1909 1909
 	 */
1910 1910
 	private function setup_customer_id() {
1911
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
1911
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
1912 1912
 
1913 1913
 		return $customer_id;
1914 1914
 	}
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 	 * @return int The User ID
1923 1923
 	 */
1924 1924
 	private function setup_user_id() {
1925
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
1925
+		$user_id = $this->get_meta('_give_payment_user_id', true);
1926 1926
 
1927 1927
 		return $user_id;
1928 1928
 	}
@@ -1936,10 +1936,10 @@  discard block
 block discarded – undo
1936 1936
 	 * @return string The email address for the payment
1937 1937
 	 */
1938 1938
 	private function setup_email() {
1939
-		$email = $this->get_meta( '_give_payment_user_email', true );
1939
+		$email = $this->get_meta('_give_payment_user_email', true);
1940 1940
 
1941
-		if ( empty( $email ) ) {
1942
-			$email = Give()->customers->get_column( 'email', $this->customer_id );
1941
+		if (empty($email)) {
1942
+			$email = Give()->customers->get_column('email', $this->customer_id);
1943 1943
 		}
1944 1944
 
1945 1945
 		return $email;
@@ -1959,15 +1959,15 @@  discard block
 block discarded – undo
1959 1959
 			'last_name'  => $this->last_name,
1960 1960
 		);
1961 1961
 
1962
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
1963
-		$user_info = wp_parse_args( $user_info, $defaults );
1962
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
1963
+		$user_info = wp_parse_args($user_info, $defaults);
1964 1964
 
1965
-		if ( empty( $user_info ) ) {
1965
+		if (empty($user_info)) {
1966 1966
 			// Get the customer, but only if it's been created
1967
-			$customer = new Give_Customer( $this->customer_id );
1967
+			$customer = new Give_Customer($this->customer_id);
1968 1968
 
1969
-			if ( $customer->id > 0 ) {
1970
-				$name      = explode( ' ', $customer->name, 2 );
1969
+			if ($customer->id > 0) {
1970
+				$name      = explode(' ', $customer->name, 2);
1971 1971
 				$user_info = array(
1972 1972
 					'first_name' => $name[0],
1973 1973
 					'last_name'  => $name[1],
@@ -1977,29 +1977,29 @@  discard block
 block discarded – undo
1977 1977
 			}
1978 1978
 		} else {
1979 1979
 			// Get the customer, but only if it's been created
1980
-			$customer = new Give_Customer( $this->customer_id );
1981
-			if ( $customer->id > 0 ) {
1982
-				foreach ( $user_info as $key => $value ) {
1983
-					if ( ! empty( $value ) ) {
1980
+			$customer = new Give_Customer($this->customer_id);
1981
+			if ($customer->id > 0) {
1982
+				foreach ($user_info as $key => $value) {
1983
+					if ( ! empty($value)) {
1984 1984
 						continue;
1985 1985
 					}
1986 1986
 
1987
-					switch ( $key ) {
1987
+					switch ($key) {
1988 1988
 						case 'first_name':
1989
-							$name = explode( ' ', $customer->name, 2 );
1989
+							$name = explode(' ', $customer->name, 2);
1990 1990
 
1991
-							$user_info[ $key ] = $name[0];
1991
+							$user_info[$key] = $name[0];
1992 1992
 							break;
1993 1993
 
1994 1994
 						case 'last_name':
1995
-							$name      = explode( ' ', $customer->name, 2 );
1996
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
1995
+							$name      = explode(' ', $customer->name, 2);
1996
+							$last_name = ! empty($name[1]) ? $name[1] : '';
1997 1997
 
1998
-							$user_info[ $key ] = $last_name;
1998
+							$user_info[$key] = $last_name;
1999 1999
 							break;
2000 2000
 
2001 2001
 						case 'email':
2002
-							$user_info[ $key ] = $customer->email;
2002
+							$user_info[$key] = $customer->email;
2003 2003
 							break;
2004 2004
 					}
2005 2005
 				}
@@ -2021,7 +2021,7 @@  discard block
 block discarded – undo
2021 2021
 	 */
2022 2022
 	private function setup_address() {
2023 2023
 
2024
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
2024
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
2025 2025
 			'line1'   => '',
2026 2026
 			'line2'   => '',
2027 2027
 			'city'    => '',
@@ -2043,7 +2043,7 @@  discard block
 block discarded – undo
2043 2043
 	 */
2044 2044
 	private function setup_form_title() {
2045 2045
 
2046
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
2046
+		$form_id = $this->get_meta('_give_payment_form_title', true);
2047 2047
 
2048 2048
 		return $form_id;
2049 2049
 	}
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 	 */
2059 2059
 	private function setup_form_id() {
2060 2060
 
2061
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
2061
+		$form_id = $this->get_meta('_give_payment_form_id', true);
2062 2062
 
2063 2063
 		return $form_id;
2064 2064
 	}
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
 	 * @return int The Form Price ID
2073 2073
 	 */
2074 2074
 	private function setup_price_id() {
2075
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
2075
+		$price_id = $this->get_meta('_give_payment_price_id', true);
2076 2076
 
2077 2077
 		return $price_id;
2078 2078
 	}
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
 	 * @return string The Payment Key
2087 2087
 	 */
2088 2088
 	private function setup_payment_key() {
2089
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
2089
+		$key = $this->get_meta('_give_payment_purchase_key', true);
2090 2090
 
2091 2091
 		return $key;
2092 2092
 	}
@@ -2102,11 +2102,11 @@  discard block
 block discarded – undo
2102 2102
 	private function setup_payment_number() {
2103 2103
 		$number = $this->ID;
2104 2104
 
2105
-		if ( give_get_option( 'enable_sequential' ) ) {
2105
+		if (give_get_option('enable_sequential')) {
2106 2106
 
2107
-			$number = $this->get_meta( '_give_payment_number', true );
2107
+			$number = $this->get_meta('_give_payment_number', true);
2108 2108
 
2109
-			if ( ! $number ) {
2109
+			if ( ! $number) {
2110 2110
 
2111 2111
 				$number = $this->ID;
2112 2112
 
@@ -2125,7 +2125,7 @@  discard block
 block discarded – undo
2125 2125
 	 * @return array The payment object as an array
2126 2126
 	 */
2127 2127
 	public function array_convert() {
2128
-		return get_object_vars( $this );
2128
+		return get_object_vars($this);
2129 2129
 	}
2130 2130
 
2131 2131
 	/**
@@ -2137,7 +2137,7 @@  discard block
 block discarded – undo
2137 2137
 	 * @return string Date payment was completed
2138 2138
 	 */
2139 2139
 	private function get_completed_date() {
2140
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
2140
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
2141 2141
 	}
2142 2142
 
2143 2143
 	/**
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
 	 * @return float Payment subtotal
2150 2150
 	 */
2151 2151
 	private function get_subtotal() {
2152
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2152
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2153 2153
 	}
2154 2154
 
2155 2155
 	/**
@@ -2161,7 +2161,7 @@  discard block
 block discarded – undo
2161 2161
 	 * @return string Payment currency code
2162 2162
 	 */
2163 2163
 	private function get_currency() {
2164
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
2164
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
2165 2165
 	}
2166 2166
 
2167 2167
 	/**
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
 	 * @return string Gateway used
2174 2174
 	 */
2175 2175
 	private function get_gateway() {
2176
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2176
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2177 2177
 	}
2178 2178
 
2179 2179
 	/**
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
 	 * @return string Transaction ID from merchant processor
2186 2186
 	 */
2187 2187
 	private function get_transaction_id() {
2188
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2188
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2189 2189
 	}
2190 2190
 
2191 2191
 	/**
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
 	 * @return string Payment IP address
2198 2198
 	 */
2199 2199
 	private function get_ip() {
2200
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2200
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2201 2201
 	}
2202 2202
 
2203 2203
 	/**
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 	 * @return int Payment customer ID
2210 2210
 	 */
2211 2211
 	private function get_customer_id() {
2212
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2212
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2213 2213
 	}
2214 2214
 
2215 2215
 	/**
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 	 * @return int Payment user ID
2222 2222
 	 */
2223 2223
 	private function get_user_id() {
2224
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2224
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2225 2225
 	}
2226 2226
 
2227 2227
 	/**
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
 	 * @return string Payment customer email
2234 2234
 	 */
2235 2235
 	private function get_email() {
2236
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2236
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2237 2237
 	}
2238 2238
 
2239 2239
 	/**
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
 	 * @return array Payment user info
2246 2246
 	 */
2247 2247
 	private function get_user_info() {
2248
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2248
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2249 2249
 	}
2250 2250
 
2251 2251
 	/**
@@ -2257,7 +2257,7 @@  discard block
 block discarded – undo
2257 2257
 	 * @return array Payment billing address
2258 2258
 	 */
2259 2259
 	private function get_address() {
2260
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2260
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2261 2261
 	}
2262 2262
 
2263 2263
 	/**
@@ -2269,7 +2269,7 @@  discard block
 block discarded – undo
2269 2269
 	 * @return string Payment key
2270 2270
 	 */
2271 2271
 	private function get_key() {
2272
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2272
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2273 2273
 	}
2274 2274
 
2275 2275
 	/**
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 	 * @return string Payment form id
2282 2282
 	 */
2283 2283
 	private function get_form_id() {
2284
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2284
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2285 2285
 	}
2286 2286
 
2287 2287
 	/**
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
 	 * @return int|string Payment number
2294 2294
 	 */
2295 2295
 	private function get_number() {
2296
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2296
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2297 2297
 	}
2298 2298
 
2299 2299
 }
Please login to merge, or discard this patch.
includes/payments/class-payments-query.php 1 patch
Spacing   +112 added lines, -112 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
 
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @param $args array The array of arguments that can be passed in and used for setting up this payment query.
56 56
 	 */
57
-	public function __construct( $args = array() ) {
57
+	public function __construct($args = array()) {
58 58
 		$defaults = array(
59 59
 			'output'          => 'payments', // Use 'posts' to get standard post objects
60
-			'post_type'       => array( 'give_payment' ),
60
+			'post_type'       => array('give_payment'),
61 61
 			'start_date'      => false,
62 62
 			'end_date'        => false,
63 63
 			'number'          => 20,
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			'give_forms'      => null
78 78
 		);
79 79
 
80
-		$this->args = wp_parse_args( $args, $defaults );
80
+		$this->args = wp_parse_args($args, $defaults);
81 81
 
82 82
 		$this->init();
83 83
 	}
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 	 * @access public
89 89
 	 * @since  1.0
90 90
 	 */
91
-	public function __set( $query_var, $value ) {
92
-		if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) {
93
-			$this->args[ $query_var ][] = $value;
91
+	public function __set($query_var, $value) {
92
+		if (in_array($query_var, array('meta_query', 'tax_query'))) {
93
+			$this->args[$query_var][] = $value;
94 94
 		} else {
95
-			$this->args[ $query_var ] = $value;
95
+			$this->args[$query_var] = $value;
96 96
 		}
97 97
 	}
98 98
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @access public
103 103
 	 * @since  1.0
104 104
 	 */
105
-	public function __unset( $query_var ) {
106
-		unset( $this->args[ $query_var ] );
105
+	public function __unset($query_var) {
106
+		unset($this->args[$query_var]);
107 107
 	}
108 108
 
109 109
 	/**
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function init() {
117 117
 
118
-		add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) );
119
-		add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) );
120
-
121
-		add_action( 'give_pre_get_payments', array( $this, 'orderby' ) );
122
-		add_action( 'give_pre_get_payments', array( $this, 'status' ) );
123
-		add_action( 'give_pre_get_payments', array( $this, 'month' ) );
124
-		add_action( 'give_pre_get_payments', array( $this, 'per_page' ) );
125
-		add_action( 'give_pre_get_payments', array( $this, 'page' ) );
126
-		add_action( 'give_pre_get_payments', array( $this, 'user' ) );
127
-		add_action( 'give_pre_get_payments', array( $this, 'search' ) );
128
-		add_action( 'give_pre_get_payments', array( $this, 'mode' ) );
129
-		add_action( 'give_pre_get_payments', array( $this, 'children' ) );
130
-		add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) );
118
+		add_action('give_pre_get_payments', array($this, 'date_filter_pre'));
119
+		add_action('give_post_get_payments', array($this, 'date_filter_post'));
120
+
121
+		add_action('give_pre_get_payments', array($this, 'orderby'));
122
+		add_action('give_pre_get_payments', array($this, 'status'));
123
+		add_action('give_pre_get_payments', array($this, 'month'));
124
+		add_action('give_pre_get_payments', array($this, 'per_page'));
125
+		add_action('give_pre_get_payments', array($this, 'page'));
126
+		add_action('give_pre_get_payments', array($this, 'user'));
127
+		add_action('give_pre_get_payments', array($this, 'search'));
128
+		add_action('give_pre_get_payments', array($this, 'mode'));
129
+		add_action('give_pre_get_payments', array($this, 'children'));
130
+		add_action('give_pre_get_payments', array($this, 'give_forms'));
131 131
 	}
132 132
 
133 133
 	/**
@@ -143,33 +143,33 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function get_payments() {
145 145
 
146
-		do_action( 'give_pre_get_payments', $this );
146
+		do_action('give_pre_get_payments', $this);
147 147
 
148
-		$query = new WP_Query( $this->args );
148
+		$query = new WP_Query($this->args);
149 149
 
150 150
 		$custom_output = array(
151 151
 			'payments',
152 152
 			'give_payments',
153 153
 		);
154 154
 
155
-		if ( ! in_array( $this->args['output'], $custom_output ) ) {
155
+		if ( ! in_array($this->args['output'], $custom_output)) {
156 156
 			return $query->posts;
157 157
 		}
158 158
 
159
-		if ( $query->have_posts() ) {
160
-			while ( $query->have_posts() ) {
159
+		if ($query->have_posts()) {
160
+			while ($query->have_posts()) {
161 161
 				$query->the_post();
162 162
 
163 163
 				$payment_id = get_post()->ID;
164
-				$payment    = new Give_Payment( $payment_id );
164
+				$payment    = new Give_Payment($payment_id);
165 165
 
166
-				$this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this );
166
+				$this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this);
167 167
 			}
168 168
 
169 169
 			wp_reset_postdata();
170 170
 		}
171 171
 
172
-		do_action( 'give_post_get_payments', $this );
172
+		do_action('give_post_get_payments', $this);
173 173
 
174 174
 		return $this->payments;
175 175
 	}
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	 * @return void
183 183
 	 */
184 184
 	public function date_filter_pre() {
185
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
185
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
186 186
 			return;
187 187
 		}
188 188
 
189
-		$this->setup_dates( $this->args['start_date'], $this->args['end_date'] );
189
+		$this->setup_dates($this->args['start_date'], $this->args['end_date']);
190 190
 
191
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
191
+		add_filter('posts_where', array($this, 'payments_where'));
192 192
 	}
193 193
 
194 194
 	/**
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 	 * @return void
201 201
 	 */
202 202
 	public function date_filter_post() {
203
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
203
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
204 204
 			return;
205 205
 		}
206 206
 
207
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
207
+		remove_filter('posts_where', array($this, 'payments_where'));
208 208
 	}
209 209
 
210 210
 	/**
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 	 * @return void
216 216
 	 */
217 217
 	public function status() {
218
-		if ( ! isset ( $this->args['status'] ) ) {
218
+		if ( ! isset ($this->args['status'])) {
219 219
 			return;
220 220
 		}
221 221
 
222
-		$this->__set( 'post_status', $this->args['status'] );
223
-		$this->__unset( 'status' );
222
+		$this->__set('post_status', $this->args['status']);
223
+		$this->__unset('status');
224 224
 	}
225 225
 
226 226
 	/**
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 	 * @return void
232 232
 	 */
233 233
 	public function page() {
234
-		if ( ! isset ( $this->args['page'] ) ) {
234
+		if ( ! isset ($this->args['page'])) {
235 235
 			return;
236 236
 		}
237 237
 
238
-		$this->__set( 'paged', $this->args['page'] );
239
-		$this->__unset( 'page' );
238
+		$this->__set('paged', $this->args['page']);
239
+		$this->__unset('page');
240 240
 	}
241 241
 
242 242
 	/**
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function per_page() {
250 250
 
251
-		if ( ! isset( $this->args['number'] ) ) {
251
+		if ( ! isset($this->args['number'])) {
252 252
 			return;
253 253
 		}
254 254
 
255
-		if ( $this->args['number'] == - 1 ) {
256
-			$this->__set( 'nopaging', true );
255
+		if ($this->args['number'] == - 1) {
256
+			$this->__set('nopaging', true);
257 257
 		} else {
258
-			$this->__set( 'posts_per_page', $this->args['number'] );
258
+			$this->__set('posts_per_page', $this->args['number']);
259 259
 		}
260 260
 
261
-		$this->__unset( 'number' );
261
+		$this->__unset('number');
262 262
 	}
263 263
 
264 264
 	/**
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
 	 * @return void
270 270
 	 */
271 271
 	public function month() {
272
-		if ( ! isset ( $this->args['month'] ) ) {
272
+		if ( ! isset ($this->args['month'])) {
273 273
 			return;
274 274
 		}
275 275
 
276
-		$this->__set( 'monthnum', $this->args['month'] );
277
-		$this->__unset( 'month' );
276
+		$this->__set('monthnum', $this->args['month']);
277
+		$this->__unset('month');
278 278
 	}
279 279
 
280 280
 	/**
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * @return void
286 286
 	 */
287 287
 	public function orderby() {
288
-		switch ( $this->args['orderby'] ) {
288
+		switch ($this->args['orderby']) {
289 289
 			case 'amount' :
290
-				$this->__set( 'orderby', 'meta_value_num' );
291
-				$this->__set( 'meta_key', '_give_payment_total' );
290
+				$this->__set('orderby', 'meta_value_num');
291
+				$this->__set('meta_key', '_give_payment_total');
292 292
 				break;
293 293
 			default :
294
-				$this->__set( 'orderby', $this->args['orderby'] );
294
+				$this->__set('orderby', $this->args['orderby']);
295 295
 				break;
296 296
 		}
297 297
 	}
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
 	 * @return void
305 305
 	 */
306 306
 	public function user() {
307
-		if ( is_null( $this->args['user'] ) ) {
307
+		if (is_null($this->args['user'])) {
308 308
 			return;
309 309
 		}
310 310
 
311
-		if ( is_numeric( $this->args['user'] ) ) {
311
+		if (is_numeric($this->args['user'])) {
312 312
 			$user_key = '_give_payment_user_id';
313 313
 		} else {
314 314
 			$user_key = '_give_payment_user_email';
315 315
 		}
316 316
 
317
-		$this->__set( 'meta_query', array(
317
+		$this->__set('meta_query', array(
318 318
 			'key'   => $user_key,
319 319
 			'value' => $this->args['user']
320
-		) );
320
+		));
321 321
 	}
322 322
 
323 323
 	/**
@@ -329,33 +329,33 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public function search() {
331 331
 
332
-		if ( ! isset( $this->args['s'] ) ) {
332
+		if ( ! isset($this->args['s'])) {
333 333
 			return;
334 334
 		}
335 335
 
336
-		$search = trim( $this->args['s'] );
336
+		$search = trim($this->args['s']);
337 337
 
338
-		if ( empty( $search ) ) {
338
+		if (empty($search)) {
339 339
 			return;
340 340
 		}
341 341
 
342
-		$is_email = is_email( $search ) || strpos( $search, '@' ) !== false;
343
-		$is_user  = strpos( $search, strtolower( 'user:' ) ) !== false;
342
+		$is_email = is_email($search) || strpos($search, '@') !== false;
343
+		$is_user  = strpos($search, strtolower('user:')) !== false;
344 344
 
345
-		if ( ! empty( $this->args['search_in_notes'] ) ) {
345
+		if ( ! empty($this->args['search_in_notes'])) {
346 346
 
347
-			$notes = give_get_payment_notes( 0, $search );
347
+			$notes = give_get_payment_notes(0, $search);
348 348
 
349
-			if ( ! empty( $notes ) ) {
349
+			if ( ! empty($notes)) {
350 350
 
351
-				$payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' );
351
+				$payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID');
352 352
 
353
-				$this->__set( 'post__in', $payment_ids );
353
+				$this->__set('post__in', $payment_ids);
354 354
 			}
355 355
 
356
-			$this->__unset( 's' );
356
+			$this->__unset('s');
357 357
 
358
-		} elseif ( $is_email || strlen( $search ) == 32 ) {
358
+		} elseif ($is_email || strlen($search) == 32) {
359 359
 
360 360
 			$key         = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key';
361 361
 			$search_meta = array(
@@ -364,19 +364,19 @@  discard block
 block discarded – undo
364 364
 				'compare' => 'LIKE'
365 365
 			);
366 366
 
367
-			$this->__set( 'meta_query', $search_meta );
368
-			$this->__unset( 's' );
367
+			$this->__set('meta_query', $search_meta);
368
+			$this->__unset('s');
369 369
 
370
-		} elseif ( $is_user ) {
370
+		} elseif ($is_user) {
371 371
 
372 372
 			$search_meta = array(
373 373
 				'key'   => '_give_payment_user_id',
374
-				'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) )
374
+				'value' => trim(str_replace('user:', '', strtolower($search)))
375 375
 			);
376 376
 
377
-			$this->__set( 'meta_query', $search_meta );
377
+			$this->__set('meta_query', $search_meta);
378 378
 
379
-			if ( give_get_option( 'enable_sequential' ) ) {
379
+			if (give_get_option('enable_sequential')) {
380 380
 
381 381
 				$search_meta = array(
382 382
 					'key'     => '_give_payment_number',
@@ -384,19 +384,19 @@  discard block
 block discarded – undo
384 384
 					'compare' => 'LIKE'
385 385
 				);
386 386
 
387
-				$this->__set( 'meta_query', $search_meta );
387
+				$this->__set('meta_query', $search_meta);
388 388
 
389 389
 				$this->args['meta_query']['relation'] = 'OR';
390 390
 
391 391
 			}
392 392
 
393
-			$this->__unset( 's' );
393
+			$this->__unset('s');
394 394
 
395 395
 		} elseif (
396
-			give_get_option( 'enable_sequential' ) &&
396
+			give_get_option('enable_sequential') &&
397 397
 			(
398
-				false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) ||
399
-				false !== strpos( $search, give_get_option( 'sequential_postfix' ) )
398
+				false !== strpos($search, give_get_option('sequential_prefix')) ||
399
+				false !== strpos($search, give_get_option('sequential_postfix'))
400 400
 			)
401 401
 		) {
402 402
 
@@ -406,30 +406,30 @@  discard block
 block discarded – undo
406 406
 				'compare' => 'LIKE'
407 407
 			);
408 408
 
409
-			$this->__set( 'meta_query', $search_meta );
410
-			$this->__unset( 's' );
409
+			$this->__set('meta_query', $search_meta);
410
+			$this->__unset('s');
411 411
 
412
-		} elseif ( is_numeric( $search ) ) {
412
+		} elseif (is_numeric($search)) {
413 413
 
414
-			$post = get_post( $search );
414
+			$post = get_post($search);
415 415
 
416
-			if ( is_object( $post ) && $post->post_type == 'give_payment' ) {
416
+			if (is_object($post) && $post->post_type == 'give_payment') {
417 417
 
418 418
 				$arr   = array();
419 419
 				$arr[] = $search;
420
-				$this->__set( 'post__in', $arr );
421
-				$this->__unset( 's' );
420
+				$this->__set('post__in', $arr);
421
+				$this->__unset('s');
422 422
 			}
423 423
 
424
-		} elseif ( '#' == substr( $search, 0, 1 ) ) {
424
+		} elseif ('#' == substr($search, 0, 1)) {
425 425
 
426
-			$search = str_replace( '#:', '', $search );
427
-			$search = str_replace( '#', '', $search );
428
-			$this->__set( 'give_forms', $search );
429
-			$this->__unset( 's' );
426
+			$search = str_replace('#:', '', $search);
427
+			$search = str_replace('#', '', $search);
428
+			$this->__set('give_forms', $search);
429
+			$this->__unset('s');
430 430
 
431 431
 		} else {
432
-			$this->__set( 's', $search );
432
+			$this->__set('s', $search);
433 433
 
434 434
 		}
435 435
 
@@ -443,16 +443,16 @@  discard block
 block discarded – undo
443 443
 	 * @return void
444 444
 	 */
445 445
 	public function mode() {
446
-		if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) {
447
-			$this->__unset( 'mode' );
446
+		if (empty($this->args['mode']) || $this->args['mode'] == 'all') {
447
+			$this->__unset('mode');
448 448
 
449 449
 			return;
450 450
 		}
451 451
 
452
-		$this->__set( 'meta_query', array(
452
+		$this->__set('meta_query', array(
453 453
 			'key'   => '_give_payment_mode',
454 454
 			'value' => $this->args['mode']
455
-		) );
455
+		));
456 456
 	}
457 457
 
458 458
 	/**
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 	 * @return void
464 464
 	 */
465 465
 	public function children() {
466
-		if ( empty( $this->args['children'] ) ) {
467
-			$this->__set( 'post_parent', 0 );
466
+		if (empty($this->args['children'])) {
467
+			$this->__set('post_parent', 0);
468 468
 		}
469
-		$this->__unset( 'children' );
469
+		$this->__unset('children');
470 470
 	}
471 471
 
472 472
 	/**
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 */
479 479
 	public function give_forms() {
480 480
 
481
-		if ( empty( $this->args['give_forms'] ) ) {
481
+		if (empty($this->args['give_forms'])) {
482 482
 			return;
483 483
 		}
484 484
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		$args = array(
488 488
 			'post_parent'            => $this->args['give_forms'],
489 489
 			'log_type'               => 'sale',
490
-			'post_status'            => array( 'publish' ),
490
+			'post_status'            => array('publish'),
491 491
 			'nopaging'               => true,
492 492
 			'no_found_rows'          => true,
493 493
 			'update_post_term_cache' => false,
@@ -496,31 +496,31 @@  discard block
 block discarded – undo
496 496
 			'fields'                 => 'ids'
497 497
 		);
498 498
 
499
-		if ( is_array( $this->args['give_forms'] ) ) {
500
-			unset( $args['post_parent'] );
499
+		if (is_array($this->args['give_forms'])) {
500
+			unset($args['post_parent']);
501 501
 			$args['post_parent__in'] = $this->args['give_forms'];
502 502
 		}
503 503
 
504
-		$sales = $give_logs->get_connected_logs( $args );
504
+		$sales = $give_logs->get_connected_logs($args);
505 505
 
506
-		if ( ! empty( $sales ) ) {
506
+		if ( ! empty($sales)) {
507 507
 
508 508
 			$payments = array();
509 509
 
510
-			foreach ( $sales as $sale ) {
511
-				$payments[] = get_post_meta( $sale, '_give_log_payment_id', true );
510
+			foreach ($sales as $sale) {
511
+				$payments[] = get_post_meta($sale, '_give_log_payment_id', true);
512 512
 			}
513 513
 
514
-			$this->__set( 'post__in', $payments );
514
+			$this->__set('post__in', $payments);
515 515
 
516 516
 		} else {
517 517
 
518 518
 			// Set post_parent to something crazy so it doesn't find anything
519
-			$this->__set( 'post_parent', 999999999999999 );
519
+			$this->__set('post_parent', 999999999999999);
520 520
 
521 521
 		}
522 522
 
523
-		$this->__unset( 'give_forms' );
523
+		$this->__unset('give_forms');
524 524
 
525 525
 	}
526 526
 }
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +46 added lines, -46 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
 
@@ -39,35 +39,35 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return float|int  Total amount of donations based on the passed arguments.
41 41
 	 */
42
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
43 43
 
44
-		$this->setup_dates( $start_date, $end_date );
44
+		$this->setup_dates($start_date, $end_date);
45 45
 
46 46
 		// Make sure start date is valid
47
-		if ( is_wp_error( $this->start_date ) ) {
47
+		if (is_wp_error($this->start_date)) {
48 48
 			return $this->start_date;
49 49
 		}
50 50
 
51 51
 		// Make sure end date is valid
52
-		if ( is_wp_error( $this->end_date ) ) {
52
+		if (is_wp_error($this->end_date)) {
53 53
 			return $this->end_date;
54 54
 		}
55 55
 
56
-		if ( empty( $form_id ) ) {
56
+		if (empty($form_id)) {
57 57
 
58 58
 			// Global sale stats
59
-			add_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
59
+			add_filter('give_count_payments_where', array($this, 'count_where'));
60 60
 
61
-			if ( is_array( $status ) ) {
61
+			if (is_array($status)) {
62 62
 				$count = 0;
63
-				foreach ( $status as $payment_status ) {
63
+				foreach ($status as $payment_status) {
64 64
 					$count += give_count_payments()->$payment_status;
65 65
 				}
66 66
 			} else {
67 67
 				$count = give_count_payments()->$status;
68 68
 			}
69 69
 
70
-			remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
70
+			remove_filter('give_count_payments_where', array($this, 'count_where'));
71 71
 
72 72
 		} else {
73 73
 
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 			// Product specific stats
77 77
 			global $give_logs;
78 78
 
79
-			add_filter( 'posts_where', array( $this, 'payments_where' ) );
79
+			add_filter('posts_where', array($this, 'payments_where'));
80 80
 
81
-			$count = $give_logs->get_log_count( $form_id, 'sale' );
81
+			$count = $give_logs->get_log_count($form_id, 'sale');
82 82
 
83
-			remove_filter( 'posts_where', array( $this, 'payments_where' ) );
83
+			remove_filter('posts_where', array($this, 'payments_where'));
84 84
 
85 85
 		}
86 86
 
@@ -102,31 +102,31 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return float|int Total amount of donations based on the passed arguments.
104 104
 	 */
105
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
105
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
106 106
 
107 107
 		global $wpdb;
108 108
 
109
-		$this->setup_dates( $start_date, $end_date );
109
+		$this->setup_dates($start_date, $end_date);
110 110
 
111 111
 		// Make sure start date is valid
112
-		if ( is_wp_error( $this->start_date ) ) {
112
+		if (is_wp_error($this->start_date)) {
113 113
 			return $this->start_date;
114 114
 		}
115 115
 
116 116
 		// Make sure end date is valid
117
-		if ( is_wp_error( $this->end_date ) ) {
117
+		if (is_wp_error($this->end_date)) {
118 118
 			return $this->end_date;
119 119
 		}
120 120
 
121
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
121
+		add_filter('posts_where', array($this, 'payments_where'));
122 122
 
123
-		if ( empty( $form_id ) ) {
123
+		if (empty($form_id)) {
124 124
 
125 125
 			// Global earning stats
126 126
 			$args = array(
127 127
 				'post_type'              => 'give_payment',
128 128
 				'nopaging'               => true,
129
-				'post_status'            => array( 'publish' ),
129
+				'post_status'            => array('publish'),
130 130
 				'fields'                 => 'ids',
131 131
 				'update_post_term_cache' => false,
132 132
 				'suppress_filters'       => false,
@@ -138,24 +138,24 @@  discard block
 block discarded – undo
138 138
 			);
139 139
 
140 140
 			//Filter by Gateway ID meta_key
141
-			if ( $gateway_id !== false ) {
141
+			if ($gateway_id !== false) {
142 142
 				$args['meta_key']   = '_give_payment_gateway';
143 143
 				$args['meta_value'] = $gateway_id;
144 144
 			}
145 145
 
146
-			$args = apply_filters( 'give_stats_earnings_args', $args );
147
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
148
-			$earnings = get_transient( $key );
146
+			$args = apply_filters('give_stats_earnings_args', $args);
147
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
148
+			$earnings = get_transient($key);
149 149
 			
150
-			if ( false === $earnings ) {
151
-				$sales    = get_posts( $args );
150
+			if (false === $earnings) {
151
+				$sales    = get_posts($args);
152 152
 				$earnings = 0;
153
-				if ( $sales ) {
154
-					$sales = implode( ',', array_map('intval', $sales ) );
155
-					$earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" );
153
+				if ($sales) {
154
+					$sales = implode(',', array_map('intval', $sales));
155
+					$earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})");
156 156
 				}
157 157
 				// Cache the results for one hour
158
-				set_transient( $key, $earnings, HOUR_IN_SECONDS );
158
+				set_transient($key, $earnings, HOUR_IN_SECONDS);
159 159
 			}
160 160
 
161 161
 		} else {
@@ -175,37 +175,37 @@  discard block
 block discarded – undo
175 175
 				'give_transient_type' => 'give_earnings',
176 176
 				// This is not a valid query arg, but is used for cache keying
177 177
 			);
178
-			$args = apply_filters( 'give_stats_earnings_args', $args );
179
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
178
+			$args = apply_filters('give_stats_earnings_args', $args);
179
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
180 180
 			//Set transient for faster stats
181
-			$earnings = get_transient( $key );
181
+			$earnings = get_transient($key);
182 182
 
183
-			if ( false === $earnings ) {
183
+			if (false === $earnings) {
184 184
 
185 185
 				$this->timestamp = false;
186
-				$log_ids  = $give_logs->get_connected_logs( $args, 'sale' );
186
+				$log_ids  = $give_logs->get_connected_logs($args, 'sale');
187 187
 				$earnings = 0;
188 188
 
189
-				if ( $log_ids ) {
190
-					$log_ids     = implode( ',', array_map('intval', $log_ids ) );
191
-					$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" );
189
+				if ($log_ids) {
190
+					$log_ids     = implode(',', array_map('intval', $log_ids));
191
+					$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);");
192 192
 
193
-					foreach ( $payment_ids as $payment_id ) {
194
-						$earnings += give_get_payment_amount( $payment_id );
193
+					foreach ($payment_ids as $payment_id) {
194
+						$earnings += give_get_payment_amount($payment_id);
195 195
 					}
196 196
 					
197 197
 				}
198 198
 
199 199
 				// Cache the results for one hour
200
-				set_transient( $key, $earnings, 60 * 60 );
200
+				set_transient($key, $earnings, 60 * 60);
201 201
 			}
202 202
 		}
203 203
 
204 204
 		//remove our filter
205
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
205
+		remove_filter('posts_where', array($this, 'payments_where'));
206 206
 
207 207
 		//return earnings
208
-		return round( $earnings, give_currency_decimal_filter() );
208
+		return round($earnings, give_currency_decimal_filter());
209 209
 
210 210
 	}
211 211
 
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @return array
221 221
 	 */
222
-	public function get_best_selling( $number = 10 ) {
222
+	public function get_best_selling($number = 10) {
223 223
 
224 224
 		global $wpdb;
225 225
 
226
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
226
+		$give_forms = $wpdb->get_results($wpdb->prepare(
227 227
 			"SELECT post_id as form_id, max(meta_value) as sales
228 228
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
229 229
 				GROUP BY meta_value+0
230 230
 				DESC LIMIT %d;", $number
231
-		) );
231
+		));
232 232
 
233 233
 		return $give_forms;
234 234
 	}
Please login to merge, or discard this patch.
includes/deprecated-functions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return bool $ret True if guest checkout is enabled, false otherwise
30 30
  */
31
-function give_no_guest_checkout( $form_id ) {
31
+function give_no_guest_checkout($form_id) {
32 32
 
33 33
 	$backtrace = debug_backtrace();
34 34
 
35
-	_give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace );
35
+	_give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace);
36 36
 
37
-	$ret = get_post_meta( $form_id, '_give_logged_in_only', true );
37
+	$ret = get_post_meta($form_id, '_give_logged_in_only', true);
38 38
 
39
-	return (bool) apply_filters( 'give_no_guest_checkout', $ret );
39
+	return (bool) apply_filters('give_no_guest_checkout', $ret);
40 40
 }
41 41
 
42 42
 /**
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
  *
51 51
  * @return void
52 52
  */
53
-function give_undo_donation_on_refund( $payment_id, $new_status, $old_status ) {
53
+function give_undo_donation_on_refund($payment_id, $new_status, $old_status) {
54 54
 
55 55
 	$backtrace = debug_backtrace();
56
-	_give_deprecated_function( 'give_undo_purchase_on_refund', '1.5', 'Give_Payment->refund()', $backtrace );
56
+	_give_deprecated_function('give_undo_purchase_on_refund', '1.5', 'Give_Payment->refund()', $backtrace);
57 57
 
58
-	$payment = new Give_Payment( $payment_id );
58
+	$payment = new Give_Payment($payment_id);
59 59
 	$payment->refund();
60 60
 
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined( 'ABSPATH' ) ) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Give_API_V1 Class
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) exit;
15
+if ( ! defined('ABSPATH')) exit;
16 16
 
17 17
 /**
18 18
  * Give_Batch_Export Class
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	 * @param $_step int The step to process
105 105
 	 * @since 1.5
106 106
 	 */
107
-	public function __construct( $_step = 1 ) {
107
+	public function __construct($_step = 1) {
108 108
 
109 109
 		$upload_dir       = wp_upload_dir();
110 110
 		$this->filetype   = '.csv';
111
-		$this->filename   = 'give-' . $this->export_type . $this->filetype;
112
-		$this->file       = trailingslashit( $upload_dir['basedir'] ) . $this->filename;
111
+		$this->filename   = 'give-'.$this->export_type.$this->filetype;
112
+		$this->file       = trailingslashit($upload_dir['basedir']).$this->filename;
113 113
 
114
-		if ( ! is_writeable( $upload_dir['basedir'] ) ) {
114
+		if ( ! is_writeable($upload_dir['basedir'])) {
115 115
 			$this->is_writable = false;
116 116
 		}
117 117
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function process_step() {
129 129
 
130
-		if ( ! $this->can_export() ) {
131
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
130
+		if ( ! $this->can_export()) {
131
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
132 132
 		}
133 133
 
134
-		if( $this->step < 2 ) {
134
+		if ($this->step < 2) {
135 135
 
136 136
 			// Make sure we start with a fresh file on step 1
137
-			@unlink( $this->file );
137
+			@unlink($this->file);
138 138
 			$this->print_csv_cols();
139 139
 		}
140 140
 
141 141
 		$rows = $this->print_csv_rows();
142 142
 
143
-		if( $rows ) {
143
+		if ($rows) {
144 144
 			return true;
145 145
 		} else {
146 146
 			return false;
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 		$col_data = '';
161 161
 		$cols = $this->get_csv_cols();
162 162
 		$i = 1;
163
-		foreach( $cols as $col_id => $column ) {
164
-			$col_data .= '"' . addslashes( $column ) . '"';
165
-			$col_data .= $i == count( $cols ) ? '' : ',';
163
+		foreach ($cols as $col_id => $column) {
164
+			$col_data .= '"'.addslashes($column).'"';
165
+			$col_data .= $i == count($cols) ? '' : ',';
166 166
 			$i++;
167 167
 		}
168 168
 		$col_data .= "\r\n";
169 169
 
170
-		$this->stash_step_data( $col_data );
170
+		$this->stash_step_data($col_data);
171 171
 
172 172
 		return $col_data;
173 173
 
@@ -186,23 +186,23 @@  discard block
 block discarded – undo
186 186
 		$data     = $this->get_data();
187 187
 		$cols     = $this->get_csv_cols();
188 188
 
189
-		if( $data ) {
189
+		if ($data) {
190 190
 
191 191
 			// Output each row
192
-			foreach ( $data as $row ) {
192
+			foreach ($data as $row) {
193 193
 				$i = 1;
194
-				foreach ( $row as $col_id => $column ) {
194
+				foreach ($row as $col_id => $column) {
195 195
 					// Make sure the column is valid
196
-					if ( array_key_exists( $col_id, $cols ) ) {
197
-						$row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
198
-						$row_data .= $i == count( $cols ) ? '' : ',';
196
+					if (array_key_exists($col_id, $cols)) {
197
+						$row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"';
198
+						$row_data .= $i == count($cols) ? '' : ',';
199 199
 						$i++;
200 200
 					}
201 201
 				}
202 202
 				$row_data .= "\r\n";
203 203
 			}
204 204
 
205
-			$this->stash_step_data( $row_data );
205
+			$this->stash_step_data($row_data);
206 206
 
207 207
 			return $row_data;
208 208
 		}
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 
231 231
 		$file = '';
232 232
 
233
-		if ( @file_exists( $this->file ) ) {
233
+		if (@file_exists($this->file)) {
234 234
 
235
-			if ( ! is_writeable( $this->file ) ) {
235
+			if ( ! is_writeable($this->file)) {
236 236
 				$this->is_writable = false;
237 237
 			}
238 238
 
239
-			$file = @file_get_contents( $this->file );
239
+			$file = @file_get_contents($this->file);
240 240
 
241 241
 		} else {
242 242
 
243
-			@file_put_contents( $this->file, '' );
244
-			@chmod( $this->file, 0664 );
243
+			@file_put_contents($this->file, '');
244
+			@chmod($this->file, 0664);
245 245
 
246 246
 		}
247 247
 
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 	 * @param $data string The data to add to the file
256 256
 	 * @return void
257 257
 	 */
258
-	protected function stash_step_data( $data = '' ) {
258
+	protected function stash_step_data($data = '') {
259 259
 
260 260
 		$file = $this->get_file();
261 261
 		$file .= $data;
262
-		@file_put_contents( $this->file, $file );
262
+		@file_put_contents($this->file, $file);
263 263
 
264 264
 		// If we have no rows after this step, mark it as an empty export
265
-		$file_rows    = file( $this->file, FILE_SKIP_EMPTY_LINES);
265
+		$file_rows    = file($this->file, FILE_SKIP_EMPTY_LINES);
266 266
 		$default_cols = $this->get_csv_cols();
267
-		$default_cols = empty( $default_cols ) ? 0 : 1;
267
+		$default_cols = empty($default_cols) ? 0 : 1;
268 268
 
269
-		$this->is_empty = count( $file_rows ) == $default_cols ? true : false;
269
+		$this->is_empty = count($file_rows) == $default_cols ? true : false;
270 270
 
271 271
 	}
272 272
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 		$file = $this->get_file();
286 286
 
287
-		@unlink( $this->file );
287
+		@unlink($this->file);
288 288
 
289 289
 		echo $file;
290 290
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @since 1.5
298 298
 	 * @param array $request The Form Data passed into the batch processing
299 299
 	 */
300
-	public function set_properties( $request ) {}
300
+	public function set_properties($request) {}
301 301
 
302 302
 	/**
303 303
 	 * Allow for prefetching of data for the remainder of the exporter
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-recount-single-customer-stats.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,8 +188,8 @@
 block discarded – undo
188 188
 
189 189
 			$payment_ids = implode( ',', $payment_ids );
190 190
 			$customer->update( array( 'payment_ids'    => $payment_ids,
191
-			                          'purchase_count' => $purchase_count,
192
-			                          'purchase_value' => $pending_total
191
+									  'purchase_count' => $purchase_count,
192
+									  'purchase_value' => $pending_total
193 193
 			) );
194 194
 
195 195
 			$this->done    = true;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -54,39 +54,39 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function get_data() {
56 56
 
57
-		$customer = new Give_Customer( $this->customer_id );
58
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() );
57
+		$customer = new Give_Customer($this->customer_id);
58
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array());
59 59
 
60
-		$offset     = ( $this->step - 1 ) * $this->per_step;
61
-		$step_items = array_slice( $payments, $offset, $this->per_step );
60
+		$offset     = ($this->step - 1) * $this->per_step;
61
+		$step_items = array_slice($payments, $offset, $this->per_step);
62 62
 
63
-		if ( count( $step_items ) > 0 ) {
64
-			$pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
63
+		if (count($step_items) > 0) {
64
+			$pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
65 65
 			$step_total    = 0;
66 66
 
67
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() );
67
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array());
68 68
 
69
-			foreach ( $step_items as $payment ) {
70
-				$payment = get_post( $payment->ID );
69
+			foreach ($step_items as $payment) {
70
+				$payment = get_post($payment->ID);
71 71
 
72
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
72
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
73 73
 
74
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() );
74
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array());
75 75
 					$missing_payments[] = $payment->ID;
76
-					$this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments );
76
+					$this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments);
77 77
 
78 78
 					continue;
79 79
 				}
80 80
 
81 81
 				$should_process_payment = 'publish' == $payment->post_status || 'revoked' == $payment->post_status ? true : false;
82
-				$should_process_payment = apply_filters( 'give_customer_recount_should_process_payment', $should_process_payment, $payment );
82
+				$should_process_payment = apply_filters('give_customer_recount_should_process_payment', $should_process_payment, $payment);
83 83
 
84
-				if ( true === $should_process_payment ) {
84
+				if (true === $should_process_payment) {
85 85
 
86 86
 					$found_payment_ids[] = $payment->ID;
87 87
 
88
-					if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) {
89
-						$payment_amount = give_get_payment_amount( $payment->ID );
88
+					if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) {
89
+						$payment_amount = give_get_payment_amount($payment->ID);
90 90
 						$step_total += $payment_amount;
91 91
 					}
92 92
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 			}
96 96
 
97 97
 			$updated_total = $pending_total + $step_total;
98
-			$this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total );
99
-			$this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids );
98
+			$this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total);
99
+			$this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids);
100 100
 
101 101
 			return true;
102 102
 		}
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function get_percentage_complete() {
115 115
 
116
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id );
117
-		$total    = count( $payments );
116
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id);
117
+		$total    = count($payments);
118 118
 
119 119
 		$percentage = 100;
120 120
 
121
-		if ( $total > 0 ) {
122
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
121
+		if ($total > 0) {
122
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
123 123
 		}
124 124
 
125
-		if ( $percentage > 100 ) {
125
+		if ($percentage > 100) {
126 126
 			$percentage = 100;
127 127
 		}
128 128
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param array $request The Form Data passed into the batch processing
138 138
 	 */
139
-	public function set_properties( $request ) {
140
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
139
+	public function set_properties($request) {
140
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
141 141
 	}
142 142
 
143 143
 	/**
@@ -148,62 +148,62 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function process_step() {
150 150
 
151
-		if ( ! $this->can_export() ) {
152
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
151
+		if ( ! $this->can_export()) {
152
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
153 153
 		}
154 154
 
155 155
 		$had_data = $this->get_data();
156 156
 
157
-		if ( $had_data ) {
157
+		if ($had_data) {
158 158
 			$this->done = false;
159 159
 
160 160
 			return true;
161 161
 		} else {
162
-			$customer    = new Give_Customer( $this->customer_id );
163
-			$payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() );
164
-			$this->delete_data( 'give_stats_found_payments_' . $customer->id );
162
+			$customer    = new Give_Customer($this->customer_id);
163
+			$payment_ids = get_option('give_stats_found_payments_'.$customer->id, array());
164
+			$this->delete_data('give_stats_found_payments_'.$customer->id);
165 165
 
166
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) );
166
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array()));
167 167
 
168 168
 			// Find non-existing payments (deleted) and total up the purchase count
169 169
 			$purchase_count = 0;
170
-			foreach ( $payment_ids as $key => $payment_id ) {
171
-				if ( in_array( $payment_id, $removed_payments ) ) {
172
-					unset( $payment_ids[ $key ] );
170
+			foreach ($payment_ids as $key => $payment_id) {
171
+				if (in_array($payment_id, $removed_payments)) {
172
+					unset($payment_ids[$key]);
173 173
 					continue;
174 174
 				}
175 175
 
176
-				$payment = get_post( $payment_id );
177
-				if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) {
178
-					$purchase_count ++;
176
+				$payment = get_post($payment_id);
177
+				if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) {
178
+					$purchase_count++;
179 179
 				}
180 180
 			}
181 181
 
182
-			$this->delete_data( 'give_stats_missing_payments' . $customer->id );
182
+			$this->delete_data('give_stats_missing_payments'.$customer->id);
183 183
 
184
-			$pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
185
-			$this->delete_data( 'give_stats_customer_pending_total' . $customer->id );
186
-			$this->delete_data( 'give_recount_customer_stats_' . $customer->id );
187
-			$this->delete_data( 'give_recount_customer_payments_' . $this->customer_id );
184
+			$pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
185
+			$this->delete_data('give_stats_customer_pending_total'.$customer->id);
186
+			$this->delete_data('give_recount_customer_stats_'.$customer->id);
187
+			$this->delete_data('give_recount_customer_payments_'.$this->customer_id);
188 188
 
189
-			$payment_ids = implode( ',', $payment_ids );
190
-			$customer->update( array( 'payment_ids'    => $payment_ids,
189
+			$payment_ids = implode(',', $payment_ids);
190
+			$customer->update(array('payment_ids'    => $payment_ids,
191 191
 			                          'purchase_count' => $purchase_count,
192 192
 			                          'purchase_value' => $pending_total
193
-			) );
193
+			));
194 194
 
195 195
 			$this->done    = true;
196
-			$this->message = esc_html__( 'Donor stats successfully recounted.', 'give' );
196
+			$this->message = esc_html__('Donor stats successfully recounted.', 'give');
197 197
 
198 198
 			return false;
199 199
 		}
200 200
 	}
201 201
 
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @return void
231 231
 	 */
232 232
 	public function pre_fetch() {
233
-		if ( $this->step === 1 ) {
234
-			$allowed_payment_status = apply_filters( 'give_recount_customer_payment_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_customer_payment_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$customer = new Give_Customer( $this->customer_id );
238
-			$customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) );
237
+			$customer = new Give_Customer($this->customer_id);
238
+			$customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $customer->payment_ids );
240
+			$attached_payment_ids = explode(',', $customer->payment_ids);
241 241
 
242 242
 			$attached_args = array(
243 243
 				'post__in' => $attached_payment_ids,
244
-				'number'   => - 1,
244
+				'number'   => -1,
245 245
 				'status'   => $allowed_post_status,
246 246
 			);
247 247
 
248
-			$attached_payments = give_get_payments( $attached_args );
248
+			$attached_payments = give_get_payments($attached_args);
249 249
 
250 250
 			$unattached_args = array(
251 251
 				'post__not_in' => $attached_payment_ids,
252
-				'number'       => - 1,
252
+				'number'       => -1,
253 253
 				'status'       => $allowed_post_status,
254 254
 				'meta_query'   => array(
255 255
 					array(
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				),
260 260
 			);
261 261
 
262
-			$unattached_payments = give_get_payments( $unattached_args );
262
+			$unattached_payments = give_get_payments($unattached_args);
263 263
 
264
-			$payments = array_merge( $attached_payments, $unattached_payments );
264
+			$payments = array_merge($attached_payments, $unattached_payments);
265 265
 
266
-			$this->store_data( 'give_recount_customer_payments_' . $customer->id, $payments );
266
+			$this->store_data('give_recount_customer_payments_'.$customer->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed       Returns the data from the database
278 278
 	 */
279
-	private function get_stored_data( $key ) {
279
+	private function get_stored_data($key) {
280 280
 		global $wpdb;
281
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
281
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
282 282
 
283
-		return empty( $value ) ? false : maybe_unserialize( $value );
283
+		return empty($value) ? false : maybe_unserialize($value);
284 284
 	}
285 285
 
286 286
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return void
295 295
 	 */
296
-	private function store_data( $key, $value ) {
296
+	private function store_data($key, $value) {
297 297
 		global $wpdb;
298 298
 
299
-		$value = maybe_serialize( $value );
299
+		$value = maybe_serialize($value);
300 300
 
301 301
 		$data = array(
302 302
 			'option_name'  => $key,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'%s',
311 311
 		);
312 312
 
313
-		$wpdb->replace( $wpdb->options, $data, $formats );
313
+		$wpdb->replace($wpdb->options, $data, $formats);
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return void
324 324
 	 */
325
-	private function delete_data( $key ) {
325
+	private function delete_data($key) {
326 326
 		global $wpdb;
327
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
327
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
328 328
 	}
329 329
 
330 330
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/tools-actions.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
  * @since  1.5
20 20
  */
21 21
 function give_register_batch_recount_store_earnings_tool() {
22
-	add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 );
22
+	add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1);
23 23
 }
24 24
 
25
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 );
25
+add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10);
26 26
 
27 27
 /**
28 28
  * Loads the tools batch processing class for recounting store earnings
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * @return void
35 35
  */
36
-function give_include_recount_income_tool_batch_processor( $class ) {
36
+function give_include_recount_income_tool_batch_processor($class) {
37 37
 
38
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php';
38
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php';
39 39
 
40
-	if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) {
40
+	if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) {
41 41
 		require_once $file_path;
42 42
 	}
43 43
 
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
  * @since  1.5
50 50
  */
51 51
 function give_register_batch_recount_form_tool() {
52
-	add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 );
52
+	add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1);
53 53
 }
54 54
 
55
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 );
55
+add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10);
56 56
 
57 57
 /**
58 58
  * Loads the tools batch processing class for recounting download stats
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  *
64 64
  * @return void
65 65
  */
66
-function give_include_recount_form_tool_batch_processor( $class ) {
66
+function give_include_recount_form_tool_batch_processor($class) {
67 67
 
68
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php';
68
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php';
69 69
 
70
-	if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) {
70
+	if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) {
71 71
 		require_once $file_path;
72 72
 	}
73 73
 
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
  * @since  1.5
79 79
  */
80 80
 function give_register_batch_recount_all_tool() {
81
-	add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 );
81
+	add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1);
82 82
 }
83 83
 
84
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 );
84
+add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10);
85 85
 
86 86
 /**
87 87
  * Loads the tools batch processing class for recounting all stats
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return void
94 94
  */
95
-function give_include_recount_all_tool_batch_processor( $class ) {
96
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php';
97
-	if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) {
95
+function give_include_recount_all_tool_batch_processor($class) {
96
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php';
97
+	if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) {
98 98
 		require_once $file_path;
99 99
 	}
100 100
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
  * @since  1.5
107 107
  */
108 108
 function give_register_batch_reset_tool() {
109
-	add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 );
109
+	add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1);
110 110
 }
111 111
 
112
-add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 );
112
+add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10);
113 113
 
114 114
 /**
115 115
  * Loads the tools batch processing class for resetting store and product earnings
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return void
122 122
  */
123
-function give_include_reset_tool_batch_processor( $class ) {
123
+function give_include_reset_tool_batch_processor($class) {
124 124
 
125
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php';
125
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php';
126 126
 
127
-	if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) {
127
+	if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) {
128 128
 		require_once $file_path;
129 129
 	}
130 130
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
  * @since  1.5
136 136
  */
137 137
 function give_register_batch_customer_recount_tool() {
138
-	add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 );
138
+	add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1);
139 139
 }
140 140
 
141
-add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 );
141
+add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10);
142 142
 
143 143
 /**
144 144
  * Loads the tools batch processing class for resetting all customer stats
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
  *
150 150
  * @return void
151 151
  */
152
-function give_include_customer_recount_tool_batch_processor( $class ) {
152
+function give_include_customer_recount_tool_batch_processor($class) {
153 153
 
154
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php';
154
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php';
155 155
 
156
-	if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) {
156
+	if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) {
157 157
 		require_once $file_path;
158 158
 	}
159 159
 
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  * @since  1.5
165 165
  */
166 166
 function give_register_batch_delete_test_transactions_tool() {
167
-	add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 );
167
+	add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1);
168 168
 }
169 169
 
170
-add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 );
170
+add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10);
171 171
 
172 172
 /**
173 173
  * Loads the tools batch processing class for resetting all customer stats
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return void
180 180
  */
181
-function give_include_delete_test_transactions_batch_processor( $class ) {
181
+function give_include_delete_test_transactions_batch_processor($class) {
182 182
 
183
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php';
183
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php';
184 184
 
185
-	if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) {
185
+	if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) {
186 186
 		require_once $file_path;
187 187
 	}
188 188
 
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-delete-test-transactions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $wpdb;
57 57
 
58
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
58
+		$items = $this->get_stored_data('give_temp_reset_ids');
59 59
 
60
-		if ( ! is_array( $items ) ) {
60
+		if ( ! is_array($items)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$offset     = ( $this->step - 1 ) * $this->per_step;
65
-		$step_items = array_slice( $items, $offset, $this->per_step );
64
+		$offset     = ($this->step - 1) * $this->per_step;
65
+		$step_items = array_slice($items, $offset, $this->per_step);
66 66
 
67
-		if ( $step_items ) {
67
+		if ($step_items) {
68 68
 
69 69
 			$step_ids = array(
70 70
 				'other' => array(),
71 71
 			);
72 72
 
73
-			foreach ( $step_items as $item ) {
73
+			foreach ($step_items as $item) {
74 74
 
75 75
 				$step_ids['other'][] = $item['id'];
76 76
 
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 			$sql = array();
80 80
 
81
-			foreach ( $step_ids as $type => $ids ) {
81
+			foreach ($step_ids as $type => $ids) {
82 82
 
83
-				if ( empty( $ids ) ) {
83
+				if (empty($ids)) {
84 84
 					continue;
85 85
 				}
86 86
 
87
-				$ids = implode( ',', $ids );
87
+				$ids = implode(',', $ids);
88 88
 
89
-				switch ( $type ) {
89
+				switch ($type) {
90 90
 					case 'other':
91 91
 						$sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)";
92 92
 						$sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)";
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
 			}
99 99
 
100
-			if ( ! empty( $sql ) ) {
101
-				foreach ( $sql as $query ) {
102
-					$wpdb->query( $query );
100
+			if ( ! empty($sql)) {
101
+				foreach ($sql as $query) {
102
+					$wpdb->query($query);
103 103
 				}
104 104
 			}
105 105
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function get_percentage_complete() {
121 121
 
122
-		$items = $this->get_stored_data( 'give_temp_reset_ids', false );
123
-		$total = count( $items );
122
+		$items = $this->get_stored_data('give_temp_reset_ids', false);
123
+		$total = count($items);
124 124
 
125 125
 		$percentage = 100;
126 126
 
127
-		if ( $total > 0 ) {
128
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
127
+		if ($total > 0) {
128
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
129 129
 		}
130 130
 
131
-		if ( $percentage > 100 ) {
131
+		if ($percentage > 100) {
132 132
 			$percentage = 100;
133 133
 		}
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @param array $request The Form Data passed into the batch processing
144 144
 	 */
145
-	public function set_properties( $request ) {
145
+	public function set_properties($request) {
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,30 +153,30 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function process_step() {
155 155
 
156
-		if ( ! $this->can_export() ) {
157
-			wp_die( esc_html__( 'You do not have permission to delete test transactions.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
156
+		if ( ! $this->can_export()) {
157
+			wp_die(esc_html__('You do not have permission to delete test transactions.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
158 158
 		}
159 159
 
160 160
 		$had_data = $this->get_data();
161 161
 
162
-		if ( $had_data ) {
162
+		if ($had_data) {
163 163
 			$this->done = false;
164 164
 
165 165
 			return true;
166 166
 		} else {
167
-			update_option( 'give_earnings_total', 0 );
168
-			delete_transient( 'give_earnings_total' );
169
-			delete_transient( 'give_estimated_monthly_stats' . true );
170
-			delete_transient( 'give_estimated_monthly_stats' . false );
171
-			$this->delete_data( 'give_temp_reset_ids' );
167
+			update_option('give_earnings_total', 0);
168
+			delete_transient('give_earnings_total');
169
+			delete_transient('give_estimated_monthly_stats'.true);
170
+			delete_transient('give_estimated_monthly_stats'.false);
171
+			$this->delete_data('give_temp_reset_ids');
172 172
 
173 173
 			// Reset the sequential order numbers
174
-			if ( give_get_option( 'enable_sequential' ) ) {
175
-				delete_option( 'give_last_payment_number' );
174
+			if (give_get_option('enable_sequential')) {
175
+				delete_option('give_last_payment_number');
176 176
 			}
177 177
 
178 178
 			$this->done    = true;
179
-			$this->message = esc_html__( 'Test transactions successfully deleted.', 'give' );
179
+			$this->message = esc_html__('Test transactions successfully deleted.', 'give');
180 180
 
181 181
 			return false;
182 182
 		}
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	 * Headers
187 187
 	 */
188 188
 	public function headers() {
189
-		ignore_user_abort( true );
189
+		ignore_user_abort(true);
190 190
 
191
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
192
-			set_time_limit( 0 );
191
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
192
+			set_time_limit(0);
193 193
 		}
194 194
 	}
195 195
 
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	public function pre_fetch() {
215 215
 
216
-		if ( $this->step == 1 ) {
217
-			$this->delete_data( 'give_temp_reset_ids' );
216
+		if ($this->step == 1) {
217
+			$this->delete_data('give_temp_reset_ids');
218 218
 		}
219 219
 
220
-		$items = get_option( 'give_temp_reset_ids', false );
220
+		$items = get_option('give_temp_reset_ids', false);
221 221
 
222
-		if ( false === $items ) {
222
+		if (false === $items) {
223 223
 			$items = array();
224 224
 
225
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
225
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
226 226
 				'post_type'      => 'give_payment',
227 227
 				'post_status'    => 'any',
228
-				'posts_per_page' => - 1,
228
+				'posts_per_page' => -1,
229 229
 				//ONLY TEST MODE TRANSACTIONS!!!
230 230
 				'meta_key'   => '_give_payment_mode',
231 231
 				'meta_value' => 'test'
232
-			) );
232
+			));
233 233
 
234
-			$posts = get_posts( $args );
235
-			foreach ( $posts as $post ) {
234
+			$posts = get_posts($args);
235
+			foreach ($posts as $post) {
236 236
 				$items[] = array(
237 237
 					'id'   => (int) $post->ID,
238 238
 					'type' => $post->post_type,
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 
242 242
 			// Allow filtering of items to remove with an unassociative array for each item
243 243
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
244
-			$items = apply_filters( 'give_reset_store_items', $items );
244
+			$items = apply_filters('give_reset_store_items', $items);
245 245
 
246
-			$this->store_data( 'give_temp_reset_ids', $items );
246
+			$this->store_data('give_temp_reset_ids', $items);
247 247
 		}
248 248
 
249 249
 	}
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return mixed       Returns the data from the database
259 259
 	 */
260
-	private function get_stored_data( $key ) {
260
+	private function get_stored_data($key) {
261 261
 		global $wpdb;
262
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
262
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
263 263
 
264
-		return empty( $value ) ? false : maybe_unserialize( $value );
264
+		return empty($value) ? false : maybe_unserialize($value);
265 265
 	}
266 266
 
267 267
 	/**
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function store_data( $key, $value ) {
277
+	private function store_data($key, $value) {
278 278
 		global $wpdb;
279 279
 
280
-		$value = maybe_serialize( $value );
280
+		$value = maybe_serialize($value);
281 281
 
282 282
 		$data = array(
283 283
 			'option_name'  => $key,
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			'%s',
292 292
 		);
293 293
 
294
-		$wpdb->replace( $wpdb->options, $data, $formats );
294
+		$wpdb->replace($wpdb->options, $data, $formats);
295 295
 	}
296 296
 
297 297
 	/**
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return void
305 305
 	 */
306
-	private function delete_data( $key ) {
306
+	private function delete_data($key) {
307 307
 		global $wpdb;
308
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
308
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
309 309
 	}
310 310
 
311 311
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-all-stats.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,26 +55,26 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $give_logs, $wpdb;
57 57
 
58
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
59
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
60
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
61
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
58
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
59
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
60
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
61
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
62 62
 
63
-		if ( false === $totals ) {
63
+		if (false === $totals) {
64 64
 			$totals = array();
65 65
 		}
66 66
 
67
-		if ( false === $payment_items ) {
67
+		if (false === $payment_items) {
68 68
 			$payment_items = array();
69 69
 		}
70 70
 
71
-		if ( false === $processed_payments ) {
71
+		if (false === $processed_payments) {
72 72
 			$processed_payments = array();
73 73
 		}
74 74
 
75
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
75
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
76 76
 
77
-		$args = apply_filters( 'give_recount_form_stats_args', array(
77
+		$args = apply_filters('give_recount_form_stats_args', array(
78 78
 			'post_parent__in' => $all_forms,
79 79
 			'post_type'       => 'give_log',
80 80
 			'posts_per_page'  => $this->per_step,
@@ -82,73 +82,73 @@  discard block
 block discarded – undo
82 82
 			'paged'           => $this->step,
83 83
 			'log_type'        => 'sale',
84 84
 			'fields'          => 'ids',
85
-		) );
85
+		));
86 86
 
87
-		$log_ids = $give_logs->get_connected_logs( $args, 'sale' );
87
+		$log_ids = $give_logs->get_connected_logs($args, 'sale');
88 88
 
89
-		if ( $log_ids ) {
90
-			$log_ids = implode( ',', $log_ids );
89
+		if ($log_ids) {
90
+			$log_ids = implode(',', $log_ids);
91 91
 
92
-			$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
93
-			unset( $log_ids );
92
+			$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
93
+			unset($log_ids);
94 94
 
95
-			$payment_ids = implode( ',', $payment_ids );
96
-			$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
97
-			unset( $payment_ids );
95
+			$payment_ids = implode(',', $payment_ids);
96
+			$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
97
+			unset($payment_ids);
98 98
 
99 99
 			//Loop through payments
100
-			foreach ( $payments as $payment ) {
100
+			foreach ($payments as $payment) {
101 101
 
102 102
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
103
-				if ( in_array( $payment->ID, $processed_payments ) ) {
103
+				if (in_array($payment->ID, $processed_payments)) {
104 104
 					continue;
105 105
 				}
106 106
 
107 107
 				//Verify accepted status'
108
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
108
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
109 109
 					$processed_payments[] = $payment->ID;
110 110
 					continue;
111 111
 				}
112 112
 
113
-				$payment_item = $payment_items[ $payment->ID ];
113
+				$payment_item = $payment_items[$payment->ID];
114 114
 
115 115
 
116
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
116
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
117 117
 
118 118
 				//Must have a form ID
119
-				if ( empty( $form_id ) ) {
119
+				if (empty($form_id)) {
120 120
 					continue;
121 121
 				}
122 122
 
123 123
 				//Form ID must be within $all_forms array to be validated
124
-				if ( ! in_array( $form_id, $all_forms ) ) {
124
+				if ( ! in_array($form_id, $all_forms)) {
125 125
 					continue;
126 126
 				}
127 127
 
128 128
 				//If array key doesn't exist, create it
129
-				if ( ! array_key_exists( $form_id, $totals ) ) {
130
-					$totals[ $form_id ] = array(
129
+				if ( ! array_key_exists($form_id, $totals)) {
130
+					$totals[$form_id] = array(
131 131
 						'sales'    => (int) 0,
132 132
 						'earnings' => (float) 0,
133 133
 					);
134 134
 				}
135 135
 
136
-				$totals[ $form_id ]['sales'] ++;
137
-				$totals[ $form_id ]['earnings'] += $payment_item['price'];
136
+				$totals[$form_id]['sales']++;
137
+				$totals[$form_id]['earnings'] += $payment_item['price'];
138 138
 
139 139
 				$processed_payments[] = $payment->ID;
140 140
 
141 141
 			}
142 142
 
143
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
144
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
143
+			$this->store_data('give_temp_processed_payments', $processed_payments);
144
+			$this->store_data('give_temp_recount_all_stats', $totals);
145 145
 
146 146
 			return true;
147 147
 		}
148 148
 
149
-		foreach ( $totals as $key => $stats ) {
150
-			update_post_meta( $key, '_give_form_sales', $stats['sales'] );
151
-			update_post_meta( $key, '_give_form_earnings', $stats['earnings'] );
149
+		foreach ($totals as $key => $stats) {
150
+			update_post_meta($key, '_give_form_sales', $stats['sales']);
151
+			update_post_meta($key, '_give_form_earnings', $stats['earnings']);
152 152
 		}
153 153
 
154 154
 		return false;
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function get_percentage_complete() {
165 165
 
166
-		$total = $this->get_stored_data( 'give_recount_all_total', false );
166
+		$total = $this->get_stored_data('give_recount_all_total', false);
167 167
 
168
-		if ( false === $total ) {
168
+		if (false === $total) {
169 169
 			$this->pre_fetch();
170
-			$total = $this->get_stored_data( 'give_recount_all_total', 0 );
170
+			$total = $this->get_stored_data('give_recount_all_total', 0);
171 171
 		}
172 172
 
173 173
 		$percentage = 100;
174 174
 
175
-		if ( $total > 0 ) {
176
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
175
+		if ($total > 0) {
176
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
177 177
 		}
178 178
 
179
-		if ( $percentage > 100 ) {
179
+		if ($percentage > 100) {
180 180
 			$percentage = 100;
181 181
 		}
182 182
 
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @param array $request The Form Data passed into the batch processing
192 192
 	 */
193
-	public function set_properties( $request ) {
194
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
193
+	public function set_properties($request) {
194
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
195 195
 	}
196 196
 
197 197
 	/**
@@ -202,34 +202,34 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function process_step() {
204 204
 
205
-		if ( ! $this->can_export() ) {
206
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
205
+		if ( ! $this->can_export()) {
206
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
207 207
 		}
208 208
 
209 209
 		$had_data = $this->get_data();
210 210
 
211
-		if ( $had_data ) {
211
+		if ($had_data) {
212 212
 			$this->done = false;
213 213
 
214 214
 			return true;
215 215
 		} else {
216
-			$this->delete_data( 'give_recount_all_total' );
217
-			$this->delete_data( 'give_temp_recount_all_stats' );
218
-			$this->delete_data( 'give_temp_payment_items' );
219
-			$this->delete_data( 'give_temp_form_ids' );
220
-			$this->delete_data( 'give_temp_processed_payments' );
216
+			$this->delete_data('give_recount_all_total');
217
+			$this->delete_data('give_temp_recount_all_stats');
218
+			$this->delete_data('give_temp_payment_items');
219
+			$this->delete_data('give_temp_form_ids');
220
+			$this->delete_data('give_temp_processed_payments');
221 221
 			$this->done    = true;
222
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
222
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
223 223
 
224 224
 			return false;
225 225
 		}
226 226
 	}
227 227
 
228 228
 	public function headers() {
229
-		ignore_user_abort( true );
229
+		ignore_user_abort(true);
230 230
 
231
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
232
-			set_time_limit( 0 );
231
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
232
+			set_time_limit(0);
233 233
 		}
234 234
 	}
235 235
 
@@ -258,76 +258,76 @@  discard block
 block discarded – undo
258 258
 
259 259
 		global $give_logs, $wpdb;
260 260
 
261
-		if ( $this->step == 1 ) {
262
-			$this->delete_data( 'give_temp_recount_all_total' );
263
-			$this->delete_data( 'give_temp_recount_all_stats' );
264
-			$this->delete_data( 'give_temp_payment_items' );
265
-			$this->delete_data( 'give_temp_processed_payments' );
261
+		if ($this->step == 1) {
262
+			$this->delete_data('give_temp_recount_all_total');
263
+			$this->delete_data('give_temp_recount_all_stats');
264
+			$this->delete_data('give_temp_payment_items');
265
+			$this->delete_data('give_temp_processed_payments');
266 266
 		}
267 267
 
268
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
269
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
268
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
269
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
270 270
 
271
-		if ( false === $total ) {
271
+		if (false === $total) {
272 272
 			$total         = 0;
273
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
273
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
274 274
 
275
-			if ( false === $payment_items ) {
275
+			if (false === $payment_items) {
276 276
 				$payment_items = array();
277
-				$this->store_data( 'give_temp_payment_items', $payment_items );
277
+				$this->store_data('give_temp_payment_items', $payment_items);
278 278
 			}
279 279
 
280
-			$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
280
+			$all_forms = $this->get_stored_data('give_temp_form_ids');
281 281
 
282
-			if ( false === $all_forms ) {
282
+			if (false === $all_forms) {
283 283
 				$args = array(
284 284
 					'post_status'    => 'any',
285 285
 					'post_type'      => 'give_forms',
286
-					'posts_per_page' => - 1,
286
+					'posts_per_page' => -1,
287 287
 					'fields'         => 'ids',
288 288
 				);
289 289
 
290
-				$all_forms = get_posts( $args );
291
-				$this->store_data( 'give_temp_form_ids', $all_forms );
290
+				$all_forms = get_posts($args);
291
+				$this->store_data('give_temp_form_ids', $all_forms);
292 292
 			}
293 293
 
294
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
294
+			$args = apply_filters('give_recount_form_stats_total_args', array(
295 295
 				'post_parent__in' => $all_forms,
296 296
 				'post_type'       => 'give_log',
297 297
 				'post_status'     => 'publish',
298 298
 				'log_type'        => 'sale',
299 299
 				'fields'          => 'ids',
300 300
 				'nopaging'        => true,
301
-			) );
301
+			));
302 302
 
303
-			$all_logs = $give_logs->get_connected_logs( $args, 'sale' );
303
+			$all_logs = $give_logs->get_connected_logs($args, 'sale');
304 304
 
305
-			if ( $all_logs ) {
306
-				$log_ids     = implode( ',', $all_logs );
307
-				$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
308
-				unset( $log_ids );
305
+			if ($all_logs) {
306
+				$log_ids     = implode(',', $all_logs);
307
+				$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
308
+				unset($log_ids);
309 309
 
310
-				$payment_ids = implode( ',', $payment_ids );
311
-				$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
312
-				unset( $payment_ids );
310
+				$payment_ids = implode(',', $payment_ids);
311
+				$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
312
+				unset($payment_ids);
313 313
 
314
-				foreach ( $payments as $payment ) {
314
+				foreach ($payments as $payment) {
315 315
 
316
-					$payment = new Give_Payment( $payment->ID );
316
+					$payment = new Give_Payment($payment->ID);
317 317
 					$form_id = $payment->form_id;
318 318
 
319 319
 					//If for some reason somehow the form_ID isn't set check payment meta
320
-					if ( empty( $payment->form_id ) ) {
320
+					if (empty($payment->form_id)) {
321 321
 						$payment_meta = $payment->get_meta();
322
-						$form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
322
+						$form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
323 323
 					}
324 324
 
325
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
325
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
326 326
 						continue;
327 327
 					}
328 328
 
329
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
330
-						$payment_items[ $payment->ID ] = array(
329
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
330
+						$payment_items[$payment->ID] = array(
331 331
 							'id'         => $form_id,
332 332
 							'payment_id' => $payment->ID,
333 333
 							'price'      => $payment->total
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 
337 337
 				}
338 338
 
339
-				$total = count( $all_logs );
339
+				$total = count($all_logs);
340 340
 			}
341 341
 
342
-			$this->store_data( 'give_temp_payment_items', $payment_items );
343
-			$this->store_data( 'give_recount_all_total', $total );
342
+			$this->store_data('give_temp_payment_items', $payment_items);
343
+			$this->store_data('give_recount_all_total', $total);
344 344
 		}
345 345
 
346 346
 	}
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return mixed       Returns the data from the database
356 356
 	 */
357
-	private function get_stored_data( $key ) {
357
+	private function get_stored_data($key) {
358 358
 		global $wpdb;
359
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
359
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
360 360
 
361
-		return empty( $value ) ? false : maybe_unserialize( $value );
361
+		return empty($value) ? false : maybe_unserialize($value);
362 362
 	}
363 363
 
364 364
 	/**
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return void
373 373
 	 */
374
-	private function store_data( $key, $value ) {
374
+	private function store_data($key, $value) {
375 375
 		global $wpdb;
376 376
 
377
-		$value = maybe_serialize( $value );
377
+		$value = maybe_serialize($value);
378 378
 
379 379
 		$data = array(
380 380
 			'option_name'  => $key,
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 			'%s',
389 389
 		);
390 390
 
391
-		$wpdb->replace( $wpdb->options, $data, $formats );
391
+		$wpdb->replace($wpdb->options, $data, $formats);
392 392
 	}
393 393
 
394 394
 	/**
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @return void
402 402
 	 */
403
-	private function delete_data( $key ) {
403
+	private function delete_data($key) {
404 404
 		global $wpdb;
405
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
405
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
406 406
 	}
407 407
 
408 408
 }
Please login to merge, or discard this patch.