@@ -899,7 +899,7 @@ |
||
| 899 | 899 | //Find a match between price_id and level_id |
| 900 | 900 | //First verify array keys exists THEN make the match |
| 901 | 901 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
| 902 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 902 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 903 | 903 | ) { |
| 904 | 904 | $item_price = $price['_give_amount']; |
| 905 | 905 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 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 | |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | * |
| 354 | 354 | * @return mixed void|false |
| 355 | 355 | */ |
| 356 | - public function __construct( $payment_id = false ) { |
|
| 356 | + public function __construct($payment_id = false) { |
|
| 357 | 357 | |
| 358 | - if ( empty( $payment_id ) ) { |
|
| 358 | + if (empty($payment_id)) { |
|
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $this->setup_payment( $payment_id ); |
|
| 362 | + $this->setup_payment($payment_id); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @return mixed The value. |
| 374 | 374 | */ |
| 375 | - public function __get( $key ) { |
|
| 375 | + public function __get($key) { |
|
| 376 | 376 | |
| 377 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 377 | + if (method_exists($this, 'get_'.$key)) { |
|
| 378 | 378 | |
| 379 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 379 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
| 380 | 380 | |
| 381 | 381 | } else { |
| 382 | 382 | |
@@ -398,18 +398,18 @@ discard block |
||
| 398 | 398 | * @param string $key The property name |
| 399 | 399 | * @param mixed $value The value of the property |
| 400 | 400 | */ |
| 401 | - public function __set( $key, $value ) { |
|
| 402 | - $ignore = array( '_ID' ); |
|
| 401 | + public function __set($key, $value) { |
|
| 402 | + $ignore = array('_ID'); |
|
| 403 | 403 | |
| 404 | - if ( $key === 'status' ) { |
|
| 404 | + if ($key === 'status') { |
|
| 405 | 405 | $this->old_status = $this->status; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 409 | - $this->pending[ $key ] = $value; |
|
| 408 | + if ( ! in_array($key, $ignore)) { |
|
| 409 | + $this->pending[$key] = $value; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if ( '_ID' !== $key ) { |
|
| 412 | + if ('_ID' !== $key) { |
|
| 413 | 413 | $this->$key = $value; |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | * |
| 425 | 425 | * @return boolean If the item is set or not |
| 426 | 426 | */ |
| 427 | - public function __isset( $name ) { |
|
| 428 | - if ( property_exists( $this, $name ) ) { |
|
| 429 | - return false === empty( $this->$name ); |
|
| 427 | + public function __isset($name) { |
|
| 428 | + if (property_exists($this, $name)) { |
|
| 429 | + return false === empty($this->$name); |
|
| 430 | 430 | } else { |
| 431 | 431 | return null; |
| 432 | 432 | } |
@@ -442,31 +442,31 @@ discard block |
||
| 442 | 442 | * |
| 443 | 443 | * @return bool If the setup was successful or not |
| 444 | 444 | */ |
| 445 | - private function setup_payment( $payment_id ) { |
|
| 445 | + private function setup_payment($payment_id) { |
|
| 446 | 446 | $this->pending = array(); |
| 447 | 447 | |
| 448 | - if ( empty( $payment_id ) ) { |
|
| 448 | + if (empty($payment_id)) { |
|
| 449 | 449 | return false; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $payment = get_post( $payment_id ); |
|
| 452 | + $payment = get_post($payment_id); |
|
| 453 | 453 | |
| 454 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
| 454 | + if ( ! $payment || is_wp_error($payment)) { |
|
| 455 | 455 | return false; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if ( 'give_payment' !== $payment->post_type ) { |
|
| 458 | + if ('give_payment' !== $payment->post_type) { |
|
| 459 | 459 | return false; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | // Allow extensions to perform actions before the payment is loaded |
| 463 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
| 463 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
| 464 | 464 | |
| 465 | 465 | // Primary Identifier |
| 466 | - $this->ID = absint( $payment_id ); |
|
| 466 | + $this->ID = absint($payment_id); |
|
| 467 | 467 | |
| 468 | 468 | // Protected ID that can never be changed |
| 469 | - $this->_ID = absint( $payment_id ); |
|
| 469 | + $this->_ID = absint($payment_id); |
|
| 470 | 470 | |
| 471 | 471 | // We have a payment, get the generic payment_meta item to reduce calls to it |
| 472 | 472 | $this->payment_meta = $this->get_meta(); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $this->parent_payment = $payment->post_parent; |
| 482 | 482 | |
| 483 | 483 | $all_payment_statuses = give_get_payment_statuses(); |
| 484 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
| 484 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
| 485 | 485 | |
| 486 | 486 | // Items |
| 487 | 487 | $this->fees = $this->setup_fees(); |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | $this->number = $this->setup_payment_number(); |
| 515 | 515 | |
| 516 | 516 | // Allow extensions to add items to this object via hook |
| 517 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
| 517 | + do_action('give_setup_payment', $this, $payment_id); |
|
| 518 | 518 | |
| 519 | 519 | return true; |
| 520 | 520 | } |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @return void |
| 534 | 534 | */ |
| 535 | - public function update_payment_setup( $payment_id ) { |
|
| 536 | - $this->setup_payment( $payment_id ); |
|
| 535 | + public function update_payment_setup($payment_id) { |
|
| 536 | + $this->setup_payment($payment_id); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -548,24 +548,24 @@ discard block |
||
| 548 | 548 | |
| 549 | 549 | // Construct the payment title |
| 550 | 550 | $payment_title = ''; |
| 551 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
| 552 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
| 553 | - } else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
| 551 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
| 552 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
| 553 | + } else if ( ! empty($this->first_name) && empty($this->last_name)) { |
|
| 554 | 554 | $payment_title = $this->first_name; |
| 555 | - } else if ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
| 555 | + } else if ( ! empty($this->email) && is_email($this->email)) { |
|
| 556 | 556 | $payment_title = $this->email; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | //Set Key |
| 560 | - if ( empty( $this->key ) ) { |
|
| 560 | + if (empty($this->key)) { |
|
| 561 | 561 | |
| 562 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 563 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
| 562 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 563 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
| 564 | 564 | $this->pending['key'] = $this->key; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | //Set IP |
| 568 | - if ( empty( $this->ip ) ) { |
|
| 568 | + if (empty($this->ip)) { |
|
| 569 | 569 | |
| 570 | 570 | $this->ip = give_get_ip(); |
| 571 | 571 | $this->pending['ip'] = $this->ip; |
@@ -592,58 +592,58 @@ discard block |
||
| 592 | 592 | 'fees' => $this->fees, |
| 593 | 593 | ); |
| 594 | 594 | |
| 595 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
| 595 | + $args = apply_filters('give_insert_payment_args', array( |
|
| 596 | 596 | 'post_title' => $payment_title, |
| 597 | 597 | 'post_status' => $this->status, |
| 598 | 598 | 'post_type' => 'give_payment', |
| 599 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
| 600 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
| 599 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
| 600 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
| 601 | 601 | 'post_parent' => $this->parent_payment, |
| 602 | - ), $payment_data ); |
|
| 602 | + ), $payment_data); |
|
| 603 | 603 | |
| 604 | 604 | // Create a blank payment |
| 605 | - $payment_id = wp_insert_post( $args ); |
|
| 605 | + $payment_id = wp_insert_post($args); |
|
| 606 | 606 | |
| 607 | - if ( ! empty( $payment_id ) ) { |
|
| 607 | + if ( ! empty($payment_id)) { |
|
| 608 | 608 | |
| 609 | 609 | $this->ID = $payment_id; |
| 610 | 610 | $this->_ID = $payment_id; |
| 611 | 611 | |
| 612 | 612 | $customer = new stdClass; |
| 613 | 613 | |
| 614 | - if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) { |
|
| 615 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
| 614 | + if (did_action('give_pre_process_purchase') && is_user_logged_in()) { |
|
| 615 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if ( empty( $customer->id ) ) { |
|
| 619 | - $customer = new Give_Customer( $this->email ); |
|
| 618 | + if (empty($customer->id)) { |
|
| 619 | + $customer = new Give_Customer($this->email); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - if ( empty( $customer->id ) ) { |
|
| 622 | + if (empty($customer->id)) { |
|
| 623 | 623 | |
| 624 | 624 | $customer_data = array( |
| 625 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
| 625 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
| 626 | 626 | 'email' => $this->email, |
| 627 | 627 | 'user_id' => $this->user_id, |
| 628 | 628 | ); |
| 629 | 629 | |
| 630 | - $customer->create( $customer_data ); |
|
| 630 | + $customer->create($customer_data); |
|
| 631 | 631 | |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | $this->customer_id = $customer->id; |
| 635 | 635 | $this->pending['customer_id'] = $this->customer_id; |
| 636 | - $customer->attach_payment( $this->ID, false ); |
|
| 636 | + $customer->attach_payment($this->ID, false); |
|
| 637 | 637 | |
| 638 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
| 639 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
| 640 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
| 641 | - foreach ( $this->fees as $fee ) { |
|
| 642 | - $this->increase_fees( $fee['amount'] ); |
|
| 638 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
| 639 | + if ( ! empty($this->payment_meta['fees'])) { |
|
| 640 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
| 641 | + foreach ($this->fees as $fee) { |
|
| 642 | + $this->increase_fees($fee['amount']); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
| 646 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
| 647 | 647 | $this->new = true; |
| 648 | 648 | } |
| 649 | 649 | |
@@ -665,11 +665,11 @@ discard block |
||
| 665 | 665 | $saved = false; |
| 666 | 666 | |
| 667 | 667 | //Must have an ID |
| 668 | - if ( empty( $this->ID ) ) { |
|
| 668 | + if (empty($this->ID)) { |
|
| 669 | 669 | |
| 670 | 670 | $payment_id = $this->insert_payment(); |
| 671 | 671 | |
| 672 | - if ( false === $payment_id ) { |
|
| 672 | + if (false === $payment_id) { |
|
| 673 | 673 | $saved = false; |
| 674 | 674 | } else { |
| 675 | 675 | $this->ID = $payment_id; |
@@ -678,48 +678,48 @@ discard block |
||
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | //Set ID if not matching |
| 681 | - if ( $this->ID !== $this->_ID ) { |
|
| 681 | + if ($this->ID !== $this->_ID) { |
|
| 682 | 682 | $this->ID = $this->_ID; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // If we have something pending, let's save it |
| 686 | - if ( ! empty( $this->pending ) ) { |
|
| 686 | + if ( ! empty($this->pending)) { |
|
| 687 | 687 | |
| 688 | 688 | $total_increase = 0; |
| 689 | 689 | $total_decrease = 0; |
| 690 | 690 | |
| 691 | - foreach ( $this->pending as $key => $value ) { |
|
| 691 | + foreach ($this->pending as $key => $value) { |
|
| 692 | 692 | |
| 693 | - switch ( $key ) { |
|
| 693 | + switch ($key) { |
|
| 694 | 694 | |
| 695 | 695 | case 'donations': |
| 696 | 696 | // Update totals for pending donations |
| 697 | - foreach ( $this->pending[ $key ] as $item ) { |
|
| 697 | + foreach ($this->pending[$key] as $item) { |
|
| 698 | 698 | |
| 699 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 700 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
| 699 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
| 700 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
| 701 | 701 | |
| 702 | - switch ( $item['action'] ) { |
|
| 702 | + switch ($item['action']) { |
|
| 703 | 703 | |
| 704 | 704 | case 'add': |
| 705 | 705 | |
| 706 | 706 | $price = $item['price']; |
| 707 | 707 | |
| 708 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 708 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 709 | 709 | |
| 710 | 710 | // Add sales logs |
| 711 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
| 711 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
| 712 | 712 | |
| 713 | 713 | $y = 0; |
| 714 | - while ( $y < $quantity ) { |
|
| 714 | + while ($y < $quantity) { |
|
| 715 | 715 | |
| 716 | - give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
| 717 | - $y ++; |
|
| 716 | + give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
| 717 | + $y++; |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 721 | - $form->increase_sales( $quantity ); |
|
| 722 | - $form->increase_earnings( $price ); |
|
| 720 | + $form = new Give_Donate_Form($item['id']); |
|
| 721 | + $form->increase_sales($quantity); |
|
| 722 | + $form->increase_earnings($price); |
|
| 723 | 723 | |
| 724 | 724 | $total_increase += $price; |
| 725 | 725 | } |
@@ -744,15 +744,15 @@ discard block |
||
| 744 | 744 | ) |
| 745 | 745 | ); |
| 746 | 746 | |
| 747 | - $found_logs = get_posts( $log_args ); |
|
| 748 | - foreach ( $found_logs as $log ) { |
|
| 749 | - wp_delete_post( $log->ID, true ); |
|
| 747 | + $found_logs = get_posts($log_args); |
|
| 748 | + foreach ($found_logs as $log) { |
|
| 749 | + wp_delete_post($log->ID, true); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 753 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 754 | - $form->decrease_sales( $quantity ); |
|
| 755 | - $form->decrease_earnings( $item['amount'] ); |
|
| 752 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 753 | + $form = new Give_Donate_Form($item['id']); |
|
| 754 | + $form->decrease_sales($quantity); |
|
| 755 | + $form->decrease_earnings($item['amount']); |
|
| 756 | 756 | |
| 757 | 757 | $total_decrease += $item['amount']; |
| 758 | 758 | } |
@@ -765,17 +765,17 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | case 'fees': |
| 767 | 767 | |
| 768 | - if ( 'publish' !== $this->status && 'complete' !== $this->status ) { |
|
| 768 | + if ('publish' !== $this->status && 'complete' !== $this->status) { |
|
| 769 | 769 | break; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - if ( empty( $this->pending[ $key ] ) ) { |
|
| 772 | + if (empty($this->pending[$key])) { |
|
| 773 | 773 | break; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
| 776 | + foreach ($this->pending[$key] as $fee) { |
|
| 777 | 777 | |
| 778 | - switch ( $fee['action'] ) { |
|
| 778 | + switch ($fee['action']) { |
|
| 779 | 779 | |
| 780 | 780 | case 'add': |
| 781 | 781 | $total_increase += $fee['amount']; |
@@ -792,43 +792,43 @@ discard block |
||
| 792 | 792 | break; |
| 793 | 793 | |
| 794 | 794 | case 'status': |
| 795 | - $this->update_status( $this->status ); |
|
| 795 | + $this->update_status($this->status); |
|
| 796 | 796 | break; |
| 797 | 797 | |
| 798 | 798 | case 'gateway': |
| 799 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
| 799 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
| 800 | 800 | break; |
| 801 | 801 | |
| 802 | 802 | case 'mode': |
| 803 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
| 803 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
| 804 | 804 | break; |
| 805 | 805 | |
| 806 | 806 | case 'transaction_id': |
| 807 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
| 807 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
| 808 | 808 | break; |
| 809 | 809 | |
| 810 | 810 | case 'ip': |
| 811 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
| 811 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
| 812 | 812 | break; |
| 813 | 813 | |
| 814 | 814 | case 'customer_id': |
| 815 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
| 815 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
| 816 | 816 | break; |
| 817 | 817 | |
| 818 | 818 | case 'user_id': |
| 819 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
| 819 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
| 820 | 820 | break; |
| 821 | 821 | |
| 822 | 822 | case 'form_title': |
| 823 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
| 823 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
| 824 | 824 | break; |
| 825 | 825 | |
| 826 | 826 | case 'form_id': |
| 827 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
| 827 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
| 828 | 828 | break; |
| 829 | 829 | |
| 830 | 830 | case 'price_id': |
| 831 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
| 831 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | case 'first_name': |
@@ -844,15 +844,15 @@ discard block |
||
| 844 | 844 | break; |
| 845 | 845 | |
| 846 | 846 | case 'email': |
| 847 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
| 847 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
| 848 | 848 | break; |
| 849 | 849 | |
| 850 | 850 | case 'key': |
| 851 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
| 851 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
| 852 | 852 | break; |
| 853 | 853 | |
| 854 | 854 | case 'number': |
| 855 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
| 855 | + $this->update_meta('_give_payment_number', $this->number); |
|
| 856 | 856 | break; |
| 857 | 857 | |
| 858 | 858 | case 'date': |
@@ -862,11 +862,11 @@ discard block |
||
| 862 | 862 | 'edit_date' => true, |
| 863 | 863 | ); |
| 864 | 864 | |
| 865 | - wp_update_post( $args ); |
|
| 865 | + wp_update_post($args); |
|
| 866 | 866 | break; |
| 867 | 867 | |
| 868 | 868 | case 'completed_date': |
| 869 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
| 869 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
| 870 | 870 | break; |
| 871 | 871 | |
| 872 | 872 | case 'parent_payment': |
@@ -875,38 +875,38 @@ discard block |
||
| 875 | 875 | 'post_parent' => $this->parent_payment, |
| 876 | 876 | ); |
| 877 | 877 | |
| 878 | - wp_update_post( $args ); |
|
| 878 | + wp_update_post($args); |
|
| 879 | 879 | break; |
| 880 | 880 | |
| 881 | 881 | default: |
| 882 | - do_action( 'give_payment_save', $this, $key ); |
|
| 882 | + do_action('give_payment_save', $this, $key); |
|
| 883 | 883 | break; |
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - if ( 'pending' !== $this->status ) { |
|
| 887 | + if ('pending' !== $this->status) { |
|
| 888 | 888 | |
| 889 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 889 | + $customer = new Give_Customer($this->customer_id); |
|
| 890 | 890 | |
| 891 | 891 | $total_change = $total_increase - $total_decrease; |
| 892 | - if ( $total_change < 0 ) { |
|
| 892 | + if ($total_change < 0) { |
|
| 893 | 893 | |
| 894 | - $total_change = - ( $total_change ); |
|
| 894 | + $total_change = - ($total_change); |
|
| 895 | 895 | // Decrease the customer's purchase stats |
| 896 | - $customer->decrease_value( $total_change ); |
|
| 897 | - give_decrease_total_earnings( $total_change ); |
|
| 896 | + $customer->decrease_value($total_change); |
|
| 897 | + give_decrease_total_earnings($total_change); |
|
| 898 | 898 | |
| 899 | - } else if ( $total_change > 0 ) { |
|
| 899 | + } else if ($total_change > 0) { |
|
| 900 | 900 | |
| 901 | 901 | // Increase the customer's purchase stats |
| 902 | - $customer->increase_value( $total_change ); |
|
| 903 | - give_increase_total_earnings( $total_change ); |
|
| 902 | + $customer->increase_value($total_change); |
|
| 903 | + give_increase_total_earnings($total_change); |
|
| 904 | 904 | |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
| 909 | + $this->update_meta('_give_payment_total', $this->total); |
|
| 910 | 910 | |
| 911 | 911 | $new_meta = array( |
| 912 | 912 | 'form_title' => $this->form_title, |
@@ -918,12 +918,12 @@ discard block |
||
| 918 | 918 | ); |
| 919 | 919 | |
| 920 | 920 | $meta = $this->get_meta(); |
| 921 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
| 921 | + $merged_meta = array_merge($meta, $new_meta); |
|
| 922 | 922 | |
| 923 | 923 | // Only save the payment meta if it's changed |
| 924 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
| 925 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
| 926 | - if ( false !== $updated ) { |
|
| 924 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
| 925 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
| 926 | + if (false !== $updated) { |
|
| 927 | 927 | $saved = true; |
| 928 | 928 | } |
| 929 | 929 | } |
@@ -932,8 +932,8 @@ discard block |
||
| 932 | 932 | $saved = true; |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - if ( true === $saved ) { |
|
| 936 | - $this->setup_payment( $this->ID ); |
|
| 935 | + if (true === $saved) { |
|
| 936 | + $this->setup_payment($this->ID); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | return $saved; |
@@ -951,12 +951,12 @@ discard block |
||
| 951 | 951 | * |
| 952 | 952 | * @return bool True when successful, false otherwise |
| 953 | 953 | */ |
| 954 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
| 954 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
| 955 | 955 | |
| 956 | - $donation = new Give_Donate_Form( $form_id ); |
|
| 956 | + $donation = new Give_Donate_Form($form_id); |
|
| 957 | 957 | |
| 958 | 958 | // Bail if this post isn't a give donation form |
| 959 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
| 959 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
| 960 | 960 | return false; |
| 961 | 961 | } |
| 962 | 962 | |
@@ -967,60 +967,60 @@ discard block |
||
| 967 | 967 | 'fees' => array(), |
| 968 | 968 | ); |
| 969 | 969 | |
| 970 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
| 970 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
| 971 | 971 | |
| 972 | 972 | // Allow overriding the price |
| 973 | - if ( false !== $args['price'] ) { |
|
| 973 | + if (false !== $args['price']) { |
|
| 974 | 974 | $item_price = $args['price']; |
| 975 | 975 | } else { |
| 976 | 976 | |
| 977 | 977 | // Deal with variable pricing |
| 978 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
| 979 | - $prices = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
| 978 | + if (give_has_variable_prices($donation->ID)) { |
|
| 979 | + $prices = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
| 980 | 980 | $item_price = ''; |
| 981 | 981 | //Loop through prices |
| 982 | - foreach ( $prices as $price ) { |
|
| 982 | + foreach ($prices as $price) { |
|
| 983 | 983 | //Find a match between price_id and level_id |
| 984 | 984 | //First verify array keys exists THEN make the match |
| 985 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
| 985 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
| 986 | 986 | && $args['price_id'] == $price['_give_id']['level_id'] |
| 987 | 987 | ) { |
| 988 | 988 | $item_price = $price['_give_amount']; |
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | 991 | //Fallback to the lowest price point |
| 992 | - if ( $item_price == '' ) { |
|
| 993 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
| 994 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
| 992 | + if ($item_price == '') { |
|
| 993 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
| 994 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
| 995 | 995 | } |
| 996 | 996 | } else { |
| 997 | 997 | //Simple form price |
| 998 | - $item_price = give_get_form_price( $donation->ID ); |
|
| 998 | + $item_price = give_get_form_price($donation->ID); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | // Sanitizing the price here so we don't have a dozen calls later |
| 1004 | - $item_price = give_sanitize_amount( $item_price ); |
|
| 1005 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
| 1004 | + $item_price = give_sanitize_amount($item_price); |
|
| 1005 | + $total = round($item_price, give_currency_decimal_filter()); |
|
| 1006 | 1006 | |
| 1007 | 1007 | //Add Options |
| 1008 | 1008 | $default_options = array(); |
| 1009 | - if ( false !== $args['price_id'] ) { |
|
| 1009 | + if (false !== $args['price_id']) { |
|
| 1010 | 1010 | $default_options['price_id'] = (int) $args['price_id']; |
| 1011 | 1011 | } |
| 1012 | - $options = wp_parse_args( $options, $default_options ); |
|
| 1012 | + $options = wp_parse_args($options, $default_options); |
|
| 1013 | 1013 | |
| 1014 | 1014 | // Do not allow totals to go negative |
| 1015 | - if ( $total < 0 ) { |
|
| 1015 | + if ($total < 0) { |
|
| 1016 | 1016 | $total = 0; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | $donation = array( |
| 1020 | 1020 | 'name' => $donation->post_title, |
| 1021 | 1021 | 'id' => $donation->ID, |
| 1022 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
| 1023 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
| 1022 | + 'price' => round($total, give_currency_decimal_filter()), |
|
| 1023 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
| 1024 | 1024 | 'fees' => $args['fees'], |
| 1025 | 1025 | 'price_id' => $args['price_id'], |
| 1026 | 1026 | 'action' => 'add', |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | |
| 1030 | 1030 | $this->pending['donations'][] = $donation; |
| 1031 | 1031 | |
| 1032 | - $this->increase_subtotal( $total ); |
|
| 1032 | + $this->increase_subtotal($total); |
|
| 1033 | 1033 | |
| 1034 | 1034 | return true; |
| 1035 | 1035 | |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * |
| 1047 | 1047 | * @return bool If the item was removed or not |
| 1048 | 1048 | */ |
| 1049 | - public function remove_donation( $form_id, $args = array() ) { |
|
| 1049 | + public function remove_donation($form_id, $args = array()) { |
|
| 1050 | 1050 | |
| 1051 | 1051 | // Set some defaults |
| 1052 | 1052 | $defaults = array( |
@@ -1054,12 +1054,12 @@ discard block |
||
| 1054 | 1054 | 'price' => false, |
| 1055 | 1055 | 'price_id' => false, |
| 1056 | 1056 | ); |
| 1057 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1057 | + $args = wp_parse_args($args, $defaults); |
|
| 1058 | 1058 | |
| 1059 | - $form = new Give_Donate_Form( $form_id ); |
|
| 1059 | + $form = new Give_Donate_Form($form_id); |
|
| 1060 | 1060 | |
| 1061 | 1061 | // Bail if this post isn't a valid give donation form |
| 1062 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
| 1062 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
| 1063 | 1063 | return false; |
| 1064 | 1064 | } |
| 1065 | 1065 | |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | |
| 1073 | 1073 | $this->pending['donations'][] = $pending_args; |
| 1074 | 1074 | |
| 1075 | - $this->decrease_subtotal( $this->total ); |
|
| 1075 | + $this->decrease_subtotal($this->total); |
|
| 1076 | 1076 | |
| 1077 | 1077 | return true; |
| 1078 | 1078 | } |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | * |
| 1089 | 1089 | * @return bool If the fee was added |
| 1090 | 1090 | */ |
| 1091 | - public function add_fee( $args, $global = true ) { |
|
| 1091 | + public function add_fee($args, $global = true) { |
|
| 1092 | 1092 | |
| 1093 | 1093 | $default_args = array( |
| 1094 | 1094 | 'label' => '', |
@@ -1098,16 +1098,16 @@ discard block |
||
| 1098 | 1098 | 'price_id' => 0, |
| 1099 | 1099 | ); |
| 1100 | 1100 | |
| 1101 | - $fee = wp_parse_args( $args, $default_args ); |
|
| 1101 | + $fee = wp_parse_args($args, $default_args); |
|
| 1102 | 1102 | $this->fees[] = $fee; |
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | 1105 | $added_fee = $fee; |
| 1106 | 1106 | $added_fee['action'] = 'add'; |
| 1107 | 1107 | $this->pending['fees'][] = $added_fee; |
| 1108 | - reset( $this->fees ); |
|
| 1108 | + reset($this->fees); |
|
| 1109 | 1109 | |
| 1110 | - $this->increase_fees( $fee['amount'] ); |
|
| 1110 | + $this->increase_fees($fee['amount']); |
|
| 1111 | 1111 | |
| 1112 | 1112 | return true; |
| 1113 | 1113 | } |
@@ -1122,11 +1122,11 @@ discard block |
||
| 1122 | 1122 | * |
| 1123 | 1123 | * @return bool If the fee was removed successfully |
| 1124 | 1124 | */ |
| 1125 | - public function remove_fee( $key ) { |
|
| 1125 | + public function remove_fee($key) { |
|
| 1126 | 1126 | $removed = false; |
| 1127 | 1127 | |
| 1128 | - if ( is_numeric( $key ) ) { |
|
| 1129 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
| 1128 | + if (is_numeric($key)) { |
|
| 1129 | + $removed = $this->remove_fee_by('index', $key); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | return $removed; |
@@ -1145,47 +1145,47 @@ discard block |
||
| 1145 | 1145 | * |
| 1146 | 1146 | * @return boolean If the item is removed |
| 1147 | 1147 | */ |
| 1148 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
| 1148 | + public function remove_fee_by($key, $value, $global = false) { |
|
| 1149 | 1149 | |
| 1150 | - $allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array( |
|
| 1150 | + $allowed_fee_keys = apply_filters('give_payment_fee_keys', array( |
|
| 1151 | 1151 | 'index', |
| 1152 | 1152 | 'label', |
| 1153 | 1153 | 'amount', |
| 1154 | 1154 | 'type', |
| 1155 | - ) ); |
|
| 1155 | + )); |
|
| 1156 | 1156 | |
| 1157 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
| 1157 | + if ( ! in_array($key, $allowed_fee_keys)) { |
|
| 1158 | 1158 | return false; |
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | $removed = false; |
| 1162 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
| 1162 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
| 1163 | 1163 | |
| 1164 | - $removed_fee = $this->fees[ $value ]; |
|
| 1164 | + $removed_fee = $this->fees[$value]; |
|
| 1165 | 1165 | $removed_fee['action'] = 'remove'; |
| 1166 | 1166 | $this->pending['fees'][] = $removed_fee; |
| 1167 | 1167 | |
| 1168 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1168 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1169 | 1169 | |
| 1170 | - unset( $this->fees[ $value ] ); |
|
| 1170 | + unset($this->fees[$value]); |
|
| 1171 | 1171 | $removed = true; |
| 1172 | 1172 | |
| 1173 | - } else if ( 'index' !== $key ) { |
|
| 1173 | + } else if ('index' !== $key) { |
|
| 1174 | 1174 | |
| 1175 | - foreach ( $this->fees as $index => $fee ) { |
|
| 1175 | + foreach ($this->fees as $index => $fee) { |
|
| 1176 | 1176 | |
| 1177 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
| 1177 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
| 1178 | 1178 | |
| 1179 | 1179 | $removed_fee = $fee; |
| 1180 | 1180 | $removed_fee['action'] = 'remove'; |
| 1181 | 1181 | $this->pending['fees'][] = $removed_fee; |
| 1182 | 1182 | |
| 1183 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1183 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1184 | 1184 | |
| 1185 | - unset( $this->fees[ $index ] ); |
|
| 1185 | + unset($this->fees[$index]); |
|
| 1186 | 1186 | $removed = true; |
| 1187 | 1187 | |
| 1188 | - if ( false === $global ) { |
|
| 1188 | + if (false === $global) { |
|
| 1189 | 1189 | break; |
| 1190 | 1190 | } |
| 1191 | 1191 | |
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | |
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | - if ( true === $removed ) { |
|
| 1199 | - $this->fees = array_values( $this->fees ); |
|
| 1198 | + if (true === $removed) { |
|
| 1199 | + $this->fees = array_values($this->fees); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | return $removed; |
@@ -1212,14 +1212,14 @@ discard block |
||
| 1212 | 1212 | * |
| 1213 | 1213 | * @return array The Fees for the type specified |
| 1214 | 1214 | */ |
| 1215 | - public function get_fees( $type = 'all' ) { |
|
| 1215 | + public function get_fees($type = 'all') { |
|
| 1216 | 1216 | $fees = array(); |
| 1217 | 1217 | |
| 1218 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
| 1218 | + if ( ! empty($this->fees) && is_array($this->fees)) { |
|
| 1219 | 1219 | |
| 1220 | - foreach ( $this->fees as $fee_id => $fee ) { |
|
| 1220 | + foreach ($this->fees as $fee_id => $fee) { |
|
| 1221 | 1221 | |
| 1222 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 1222 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
| 1223 | 1223 | continue; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | - return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this ); |
|
| 1232 | + return apply_filters('give_get_payment_fees', $fees, $this->ID, $this); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | /** |
@@ -1242,13 +1242,13 @@ discard block |
||
| 1242 | 1242 | * |
| 1243 | 1243 | * @return void |
| 1244 | 1244 | */ |
| 1245 | - public function add_note( $note = false ) { |
|
| 1245 | + public function add_note($note = false) { |
|
| 1246 | 1246 | // Bail if no note specified |
| 1247 | - if ( ! $note ) { |
|
| 1247 | + if ( ! $note) { |
|
| 1248 | 1248 | return false; |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - give_insert_payment_note( $this->ID, $note ); |
|
| 1251 | + give_insert_payment_note($this->ID, $note); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | * |
| 1262 | 1262 | * @return void |
| 1263 | 1263 | */ |
| 1264 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 1264 | + private function increase_subtotal($amount = 0.00) { |
|
| 1265 | 1265 | $amount = (float) $amount; |
| 1266 | 1266 | $this->subtotal += $amount; |
| 1267 | 1267 | |
@@ -1278,11 +1278,11 @@ discard block |
||
| 1278 | 1278 | * |
| 1279 | 1279 | * @return void |
| 1280 | 1280 | */ |
| 1281 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 1281 | + private function decrease_subtotal($amount = 0.00) { |
|
| 1282 | 1282 | $amount = (float) $amount; |
| 1283 | 1283 | $this->subtotal -= $amount; |
| 1284 | 1284 | |
| 1285 | - if ( $this->subtotal < 0 ) { |
|
| 1285 | + if ($this->subtotal < 0) { |
|
| 1286 | 1286 | $this->subtotal = 0; |
| 1287 | 1287 | } |
| 1288 | 1288 | |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | * |
| 1300 | 1300 | * @return void |
| 1301 | 1301 | */ |
| 1302 | - private function increase_fees( $amount = 0.00 ) { |
|
| 1302 | + private function increase_fees($amount = 0.00) { |
|
| 1303 | 1303 | $amount = (float) $amount; |
| 1304 | 1304 | $this->fees_total += $amount; |
| 1305 | 1305 | |
@@ -1316,11 +1316,11 @@ discard block |
||
| 1316 | 1316 | * |
| 1317 | 1317 | * @return void |
| 1318 | 1318 | */ |
| 1319 | - private function decrease_fees( $amount = 0.00 ) { |
|
| 1319 | + private function decrease_fees($amount = 0.00) { |
|
| 1320 | 1320 | $amount = (float) $amount; |
| 1321 | 1321 | $this->fees_total -= $amount; |
| 1322 | 1322 | |
| 1323 | - if ( $this->fees_total < 0 ) { |
|
| 1323 | + if ($this->fees_total < 0) { |
|
| 1324 | 1324 | $this->fees_total = 0; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
@@ -1349,41 +1349,41 @@ discard block |
||
| 1349 | 1349 | * |
| 1350 | 1350 | * @return bool $updated Returns if the status was successfully updated |
| 1351 | 1351 | */ |
| 1352 | - public function update_status( $status = false ) { |
|
| 1352 | + public function update_status($status = false) { |
|
| 1353 | 1353 | |
| 1354 | 1354 | //standardize the 'complete(d)' status |
| 1355 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
| 1355 | + if ($status == 'completed' || $status == 'complete') { |
|
| 1356 | 1356 | $status = 'publish'; |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
| 1359 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
| 1360 | 1360 | |
| 1361 | - if ( $old_status === $status ) { |
|
| 1361 | + if ($old_status === $status) { |
|
| 1362 | 1362 | return false; // Don't permit status changes that aren't changes |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
| 1365 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
| 1366 | 1366 | |
| 1367 | 1367 | $updated = false; |
| 1368 | 1368 | |
| 1369 | 1369 | |
| 1370 | - if ( $do_change ) { |
|
| 1370 | + if ($do_change) { |
|
| 1371 | 1371 | |
| 1372 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
| 1372 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
| 1373 | 1373 | |
| 1374 | 1374 | $update_fields = array( |
| 1375 | 1375 | 'ID' => $this->ID, |
| 1376 | 1376 | 'post_status' => $status, |
| 1377 | - 'edit_date' => current_time( 'mysql' ) |
|
| 1377 | + 'edit_date' => current_time('mysql') |
|
| 1378 | 1378 | ); |
| 1379 | 1379 | |
| 1380 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
| 1380 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
| 1381 | 1381 | |
| 1382 | 1382 | $all_payment_statuses = give_get_payment_statuses(); |
| 1383 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
| 1383 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
| 1384 | 1384 | |
| 1385 | 1385 | // Process any specific status functions |
| 1386 | - switch ( $status ) { |
|
| 1386 | + switch ($status) { |
|
| 1387 | 1387 | case 'refunded': |
| 1388 | 1388 | $this->process_refund(); |
| 1389 | 1389 | break; |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | break; |
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
| 1404 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
| 1405 | 1405 | |
| 1406 | 1406 | } |
| 1407 | 1407 | |
@@ -1436,32 +1436,32 @@ discard block |
||
| 1436 | 1436 | * |
| 1437 | 1437 | * @return mixed The value from the post meta |
| 1438 | 1438 | */ |
| 1439 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
| 1439 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
| 1440 | 1440 | |
| 1441 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
| 1441 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
| 1442 | 1442 | |
| 1443 | - if ( $meta_key === '_give_payment_meta' ) { |
|
| 1443 | + if ($meta_key === '_give_payment_meta') { |
|
| 1444 | 1444 | |
| 1445 | - if ( empty( $meta['key'] ) ) { |
|
| 1445 | + if (empty($meta['key'])) { |
|
| 1446 | 1446 | $meta['key'] = $this->setup_payment_key(); |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - if ( empty( $meta['form_title'] ) ) { |
|
| 1449 | + if (empty($meta['form_title'])) { |
|
| 1450 | 1450 | $meta['form_title'] = $this->setup_form_title(); |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | - if ( empty( $meta['email'] ) ) { |
|
| 1453 | + if (empty($meta['email'])) { |
|
| 1454 | 1454 | $meta['email'] = $this->setup_email(); |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | - if ( empty( $meta['date'] ) ) { |
|
| 1458 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1457 | + if (empty($meta['date'])) { |
|
| 1458 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | - $meta = apply_filters( 'give_get_payment_meta_' . $meta_key, $meta, $this->ID ); |
|
| 1462 | + $meta = apply_filters('give_get_payment_meta_'.$meta_key, $meta, $this->ID); |
|
| 1463 | 1463 | |
| 1464 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
| 1464 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | /** |
@@ -1476,23 +1476,23 @@ discard block |
||
| 1476 | 1476 | * |
| 1477 | 1477 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
| 1478 | 1478 | */ |
| 1479 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 1480 | - if ( empty( $meta_key ) ) { |
|
| 1479 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 1480 | + if (empty($meta_key)) { |
|
| 1481 | 1481 | return false; |
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
| 1484 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
| 1485 | 1485 | |
| 1486 | 1486 | $current_meta = $this->get_meta(); |
| 1487 | - $current_meta[ $meta_key ] = $meta_value; |
|
| 1487 | + $current_meta[$meta_key] = $meta_value; |
|
| 1488 | 1488 | |
| 1489 | 1489 | $meta_key = '_give_payment_meta'; |
| 1490 | 1490 | $meta_value = $current_meta; |
| 1491 | 1491 | |
| 1492 | - } else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
| 1492 | + } else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
| 1493 | 1493 | |
| 1494 | - $meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 1495 | - update_post_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
| 1494 | + $meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $this->ID); |
|
| 1495 | + update_post_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
| 1496 | 1496 | |
| 1497 | 1497 | $current_meta = $this->get_meta(); |
| 1498 | 1498 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1502,9 +1502,9 @@ discard block |
||
| 1502 | 1502 | |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - $meta_value = apply_filters( 'give_update_payment_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 1505 | + $meta_value = apply_filters('give_update_payment_meta_'.$meta_key, $meta_value, $this->ID); |
|
| 1506 | 1506 | |
| 1507 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 1507 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | /** |
@@ -1519,30 +1519,30 @@ discard block |
||
| 1519 | 1519 | $process_refund = true; |
| 1520 | 1520 | |
| 1521 | 1521 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1522 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
| 1522 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
| 1523 | 1523 | $process_refund = false; |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1527 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
| 1527 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
| 1528 | 1528 | |
| 1529 | - if ( false === $process_refund ) { |
|
| 1529 | + if (false === $process_refund) { |
|
| 1530 | 1530 | return; |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - do_action( 'give_pre_refund_payment', $this ); |
|
| 1533 | + do_action('give_pre_refund_payment', $this); |
|
| 1534 | 1534 | |
| 1535 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
| 1536 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
| 1537 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
| 1535 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
| 1536 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
| 1537 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
| 1538 | 1538 | |
| 1539 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1539 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1540 | 1540 | $this->delete_sales_logs(); |
| 1541 | 1541 | |
| 1542 | 1542 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1543 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1543 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1544 | 1544 | |
| 1545 | - do_action( 'give_post_refund_payment', $this ); |
|
| 1545 | + do_action('give_post_refund_payment', $this); |
|
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | /** |
@@ -1569,29 +1569,29 @@ discard block |
||
| 1569 | 1569 | $process_pending = true; |
| 1570 | 1570 | |
| 1571 | 1571 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1572 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
| 1572 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
| 1573 | 1573 | $process_pending = false; |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1577 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
| 1577 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
| 1578 | 1578 | |
| 1579 | - if ( false === $process_pending ) { |
|
| 1579 | + if (false === $process_pending) { |
|
| 1580 | 1580 | return; |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this ); |
|
| 1584 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this ); |
|
| 1585 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this ); |
|
| 1583 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this); |
|
| 1584 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this); |
|
| 1585 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this); |
|
| 1586 | 1586 | |
| 1587 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1587 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1588 | 1588 | $this->delete_sales_logs(); |
| 1589 | 1589 | |
| 1590 | 1590 | $this->completed_date = false; |
| 1591 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1591 | + $this->update_meta('_give_completed_date', ''); |
|
| 1592 | 1592 | |
| 1593 | 1593 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1594 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1594 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1606,29 +1606,29 @@ discard block |
||
| 1606 | 1606 | $process_cancelled = true; |
| 1607 | 1607 | |
| 1608 | 1608 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1609 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
| 1609 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
| 1610 | 1610 | $process_cancelled = false; |
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1614 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1614 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
| 1615 | 1615 | |
| 1616 | - if ( false === $process_cancelled ) { |
|
| 1616 | + if (false === $process_cancelled) { |
|
| 1617 | 1617 | return; |
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
| 1621 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
| 1622 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
| 1620 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this); |
|
| 1621 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this); |
|
| 1622 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this); |
|
| 1623 | 1623 | |
| 1624 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1624 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1625 | 1625 | $this->delete_sales_logs(); |
| 1626 | 1626 | |
| 1627 | 1627 | $this->completed_date = false; |
| 1628 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1628 | + $this->update_meta('_give_completed_date', ''); |
|
| 1629 | 1629 | |
| 1630 | 1630 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1631 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1631 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | /** |
@@ -1641,29 +1641,29 @@ discard block |
||
| 1641 | 1641 | $process_revoked = true; |
| 1642 | 1642 | |
| 1643 | 1643 | // If the payment was not in publish, don't decrement stats as they were never incremented |
| 1644 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
| 1644 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
| 1645 | 1645 | $process_revoked = false; |
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1649 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
| 1649 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
| 1650 | 1650 | |
| 1651 | - if ( false === $process_revoked ) { |
|
| 1651 | + if (false === $process_revoked) { |
|
| 1652 | 1652 | return; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
| 1656 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
| 1657 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
| 1655 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this); |
|
| 1656 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this); |
|
| 1657 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this); |
|
| 1658 | 1658 | |
| 1659 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1659 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1660 | 1660 | $this->delete_sales_logs(); |
| 1661 | 1661 | |
| 1662 | 1662 | $this->completed_date = false; |
| 1663 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1663 | + $this->update_meta('_give_completed_date', ''); |
|
| 1664 | 1664 | |
| 1665 | 1665 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 1666 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1666 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | /** |
@@ -1678,25 +1678,25 @@ discard block |
||
| 1678 | 1678 | * |
| 1679 | 1679 | * @return void |
| 1680 | 1680 | */ |
| 1681 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
| 1681 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
| 1682 | 1682 | |
| 1683 | - give_undo_purchase( false, $this->ID ); |
|
| 1683 | + give_undo_purchase(false, $this->ID); |
|
| 1684 | 1684 | |
| 1685 | 1685 | // Decrease store earnings |
| 1686 | - if ( true === $alter_store_earnings ) { |
|
| 1687 | - give_decrease_total_earnings( $this->total ); |
|
| 1686 | + if (true === $alter_store_earnings) { |
|
| 1687 | + give_decrease_total_earnings($this->total); |
|
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | // Decrement the stats for the customer |
| 1691 | - if ( ! empty( $this->customer_id ) ) { |
|
| 1691 | + if ( ! empty($this->customer_id)) { |
|
| 1692 | 1692 | |
| 1693 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1693 | + $customer = new Give_Customer($this->customer_id); |
|
| 1694 | 1694 | |
| 1695 | - if ( true === $alter_customer_value ) { |
|
| 1696 | - $customer->decrease_value( $this->total ); |
|
| 1695 | + if (true === $alter_customer_value) { |
|
| 1696 | + $customer->decrease_value($this->total); |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | - if ( true === $alter_customer_purchase_count ) { |
|
| 1699 | + if (true === $alter_customer_purchase_count) { |
|
| 1700 | 1700 | $customer->decrease_purchase_count(); |
| 1701 | 1701 | } |
| 1702 | 1702 | |
@@ -1746,13 +1746,13 @@ discard block |
||
| 1746 | 1746 | * @return string The date the payment was completed |
| 1747 | 1747 | */ |
| 1748 | 1748 | private function setup_completed_date() { |
| 1749 | - $payment = get_post( $this->ID ); |
|
| 1749 | + $payment = get_post($this->ID); |
|
| 1750 | 1750 | |
| 1751 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
| 1751 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
| 1752 | 1752 | return false; // This payment was never completed |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
| 1755 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
| 1756 | 1756 | |
| 1757 | 1757 | return $date; |
| 1758 | 1758 | } |
@@ -1766,7 +1766,7 @@ discard block |
||
| 1766 | 1766 | * @return string The payment mode |
| 1767 | 1767 | */ |
| 1768 | 1768 | private function setup_mode() { |
| 1769 | - return $this->get_meta( '_give_payment_mode' ); |
|
| 1769 | + return $this->get_meta('_give_payment_mode'); |
|
| 1770 | 1770 | } |
| 1771 | 1771 | |
| 1772 | 1772 | /** |
@@ -1778,13 +1778,13 @@ discard block |
||
| 1778 | 1778 | * @return float The payment total |
| 1779 | 1779 | */ |
| 1780 | 1780 | private function setup_total() { |
| 1781 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
| 1781 | + $amount = $this->get_meta('_give_payment_total', true); |
|
| 1782 | 1782 | |
| 1783 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 1784 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
| 1785 | - $meta = maybe_unserialize( $meta ); |
|
| 1783 | + if (empty($amount) && '0.00' != $amount) { |
|
| 1784 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
| 1785 | + $meta = maybe_unserialize($meta); |
|
| 1786 | 1786 | |
| 1787 | - if ( isset( $meta['amount'] ) ) { |
|
| 1787 | + if (isset($meta['amount'])) { |
|
| 1788 | 1788 | $amount = $meta['amount']; |
| 1789 | 1789 | } |
| 1790 | 1790 | } |
@@ -1817,9 +1817,9 @@ discard block |
||
| 1817 | 1817 | private function setup_fees_total() { |
| 1818 | 1818 | $fees_total = (float) 0.00; |
| 1819 | 1819 | |
| 1820 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1821 | - if ( ! empty( $payment_fees ) ) { |
|
| 1822 | - foreach ( $payment_fees as $fee ) { |
|
| 1820 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1821 | + if ( ! empty($payment_fees)) { |
|
| 1822 | + foreach ($payment_fees as $fee) { |
|
| 1823 | 1823 | $fees_total += (float) $fee['amount']; |
| 1824 | 1824 | } |
| 1825 | 1825 | } |
@@ -1837,7 +1837,7 @@ discard block |
||
| 1837 | 1837 | * @return string The currency for the payment |
| 1838 | 1838 | */ |
| 1839 | 1839 | private function setup_currency() { |
| 1840 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
| 1840 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
| 1841 | 1841 | |
| 1842 | 1842 | return $currency; |
| 1843 | 1843 | } |
@@ -1851,7 +1851,7 @@ discard block |
||
| 1851 | 1851 | * @return array The Fees |
| 1852 | 1852 | */ |
| 1853 | 1853 | private function setup_fees() { |
| 1854 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1854 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1855 | 1855 | |
| 1856 | 1856 | return $payment_fees; |
| 1857 | 1857 | } |
@@ -1865,7 +1865,7 @@ discard block |
||
| 1865 | 1865 | * @return string The gateway |
| 1866 | 1866 | */ |
| 1867 | 1867 | private function setup_gateway() { |
| 1868 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
| 1868 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
| 1869 | 1869 | |
| 1870 | 1870 | return $gateway; |
| 1871 | 1871 | } |
@@ -1879,12 +1879,12 @@ discard block |
||
| 1879 | 1879 | * @return string The transaction ID for the payment |
| 1880 | 1880 | */ |
| 1881 | 1881 | private function setup_transaction_id() { |
| 1882 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
| 1882 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
| 1883 | 1883 | |
| 1884 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
| 1884 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
| 1885 | 1885 | |
| 1886 | 1886 | $gateway = $this->gateway; |
| 1887 | - $transaction_id = apply_filters( 'give_get_payment_transaction_id-' . $gateway, $this->ID ); |
|
| 1887 | + $transaction_id = apply_filters('give_get_payment_transaction_id-'.$gateway, $this->ID); |
|
| 1888 | 1888 | |
| 1889 | 1889 | } |
| 1890 | 1890 | |
@@ -1900,7 +1900,7 @@ discard block |
||
| 1900 | 1900 | * @return string The IP address for the payment |
| 1901 | 1901 | */ |
| 1902 | 1902 | private function setup_ip() { |
| 1903 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
| 1903 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
| 1904 | 1904 | |
| 1905 | 1905 | return $ip; |
| 1906 | 1906 | } |
@@ -1914,7 +1914,7 @@ discard block |
||
| 1914 | 1914 | * @return int The Customer ID |
| 1915 | 1915 | */ |
| 1916 | 1916 | private function setup_customer_id() { |
| 1917 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
| 1917 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
| 1918 | 1918 | |
| 1919 | 1919 | return $customer_id; |
| 1920 | 1920 | } |
@@ -1928,7 +1928,7 @@ discard block |
||
| 1928 | 1928 | * @return int The User ID |
| 1929 | 1929 | */ |
| 1930 | 1930 | private function setup_user_id() { |
| 1931 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
| 1931 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
| 1932 | 1932 | |
| 1933 | 1933 | return $user_id; |
| 1934 | 1934 | } |
@@ -1942,10 +1942,10 @@ discard block |
||
| 1942 | 1942 | * @return string The email address for the payment |
| 1943 | 1943 | */ |
| 1944 | 1944 | private function setup_email() { |
| 1945 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
| 1945 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
| 1946 | 1946 | |
| 1947 | - if ( empty( $email ) ) { |
|
| 1948 | - $email = Give()->customers->get_column( 'email', $this->customer_id ); |
|
| 1947 | + if (empty($email)) { |
|
| 1948 | + $email = Give()->customers->get_column('email', $this->customer_id); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | return $email; |
@@ -1965,15 +1965,15 @@ discard block |
||
| 1965 | 1965 | 'last_name' => $this->last_name, |
| 1966 | 1966 | ); |
| 1967 | 1967 | |
| 1968 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
| 1969 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 1968 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
| 1969 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 1970 | 1970 | |
| 1971 | - if ( empty( $user_info ) ) { |
|
| 1971 | + if (empty($user_info)) { |
|
| 1972 | 1972 | // Get the customer, but only if it's been created |
| 1973 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1973 | + $customer = new Give_Customer($this->customer_id); |
|
| 1974 | 1974 | |
| 1975 | - if ( $customer->id > 0 ) { |
|
| 1976 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 1975 | + if ($customer->id > 0) { |
|
| 1976 | + $name = explode(' ', $customer->name, 2); |
|
| 1977 | 1977 | $user_info = array( |
| 1978 | 1978 | 'first_name' => $name[0], |
| 1979 | 1979 | 'last_name' => $name[1], |
@@ -1983,29 +1983,29 @@ discard block |
||
| 1983 | 1983 | } |
| 1984 | 1984 | } else { |
| 1985 | 1985 | // Get the customer, but only if it's been created |
| 1986 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1987 | - if ( $customer->id > 0 ) { |
|
| 1988 | - foreach ( $user_info as $key => $value ) { |
|
| 1989 | - if ( ! empty( $value ) ) { |
|
| 1986 | + $customer = new Give_Customer($this->customer_id); |
|
| 1987 | + if ($customer->id > 0) { |
|
| 1988 | + foreach ($user_info as $key => $value) { |
|
| 1989 | + if ( ! empty($value)) { |
|
| 1990 | 1990 | continue; |
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | - switch ( $key ) { |
|
| 1993 | + switch ($key) { |
|
| 1994 | 1994 | case 'first_name': |
| 1995 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 1995 | + $name = explode(' ', $customer->name, 2); |
|
| 1996 | 1996 | |
| 1997 | - $user_info[ $key ] = $name[0]; |
|
| 1997 | + $user_info[$key] = $name[0]; |
|
| 1998 | 1998 | break; |
| 1999 | 1999 | |
| 2000 | 2000 | case 'last_name': |
| 2001 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2002 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
| 2001 | + $name = explode(' ', $customer->name, 2); |
|
| 2002 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
| 2003 | 2003 | |
| 2004 | - $user_info[ $key ] = $last_name; |
|
| 2004 | + $user_info[$key] = $last_name; |
|
| 2005 | 2005 | break; |
| 2006 | 2006 | |
| 2007 | 2007 | case 'email': |
| 2008 | - $user_info[ $key ] = $customer->email; |
|
| 2008 | + $user_info[$key] = $customer->email; |
|
| 2009 | 2009 | break; |
| 2010 | 2010 | } |
| 2011 | 2011 | } |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | */ |
| 2028 | 2028 | private function setup_address() { |
| 2029 | 2029 | |
| 2030 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2030 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2031 | 2031 | 'line1' => '', |
| 2032 | 2032 | 'line2' => '', |
| 2033 | 2033 | 'city' => '', |
@@ -2049,7 +2049,7 @@ discard block |
||
| 2049 | 2049 | */ |
| 2050 | 2050 | private function setup_form_title() { |
| 2051 | 2051 | |
| 2052 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
| 2052 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
| 2053 | 2053 | |
| 2054 | 2054 | return $form_id; |
| 2055 | 2055 | } |
@@ -2064,7 +2064,7 @@ discard block |
||
| 2064 | 2064 | */ |
| 2065 | 2065 | private function setup_form_id() { |
| 2066 | 2066 | |
| 2067 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
| 2067 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
| 2068 | 2068 | |
| 2069 | 2069 | return $form_id; |
| 2070 | 2070 | } |
@@ -2078,7 +2078,7 @@ discard block |
||
| 2078 | 2078 | * @return int The Form Price ID |
| 2079 | 2079 | */ |
| 2080 | 2080 | private function setup_price_id() { |
| 2081 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
| 2081 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
| 2082 | 2082 | |
| 2083 | 2083 | return $price_id; |
| 2084 | 2084 | } |
@@ -2092,7 +2092,7 @@ discard block |
||
| 2092 | 2092 | * @return string The Payment Key |
| 2093 | 2093 | */ |
| 2094 | 2094 | private function setup_payment_key() { |
| 2095 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
| 2095 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
| 2096 | 2096 | |
| 2097 | 2097 | return $key; |
| 2098 | 2098 | } |
@@ -2108,11 +2108,11 @@ discard block |
||
| 2108 | 2108 | private function setup_payment_number() { |
| 2109 | 2109 | $number = $this->ID; |
| 2110 | 2110 | |
| 2111 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 2111 | + if (give_get_option('enable_sequential')) { |
|
| 2112 | 2112 | |
| 2113 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
| 2113 | + $number = $this->get_meta('_give_payment_number', true); |
|
| 2114 | 2114 | |
| 2115 | - if ( ! $number ) { |
|
| 2115 | + if ( ! $number) { |
|
| 2116 | 2116 | |
| 2117 | 2117 | $number = $this->ID; |
| 2118 | 2118 | |
@@ -2131,7 +2131,7 @@ discard block |
||
| 2131 | 2131 | * @return array The payment object as an array |
| 2132 | 2132 | */ |
| 2133 | 2133 | public function array_convert() { |
| 2134 | - return get_object_vars( $this ); |
|
| 2134 | + return get_object_vars($this); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | /** |
@@ -2143,7 +2143,7 @@ discard block |
||
| 2143 | 2143 | * @return string Date payment was completed |
| 2144 | 2144 | */ |
| 2145 | 2145 | private function get_completed_date() { |
| 2146 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 2146 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | 2149 | /** |
@@ -2155,7 +2155,7 @@ discard block |
||
| 2155 | 2155 | * @return float Payment subtotal |
| 2156 | 2156 | */ |
| 2157 | 2157 | private function get_subtotal() { |
| 2158 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
| 2158 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
| 2159 | 2159 | } |
| 2160 | 2160 | |
| 2161 | 2161 | /** |
@@ -2167,7 +2167,7 @@ discard block |
||
| 2167 | 2167 | * @return string Payment currency code |
| 2168 | 2168 | */ |
| 2169 | 2169 | private function get_currency() { |
| 2170 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
| 2170 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | 2173 | /** |
@@ -2179,7 +2179,7 @@ discard block |
||
| 2179 | 2179 | * @return string Gateway used |
| 2180 | 2180 | */ |
| 2181 | 2181 | private function get_gateway() { |
| 2182 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
| 2182 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | 2185 | /** |
@@ -2191,7 +2191,7 @@ discard block |
||
| 2191 | 2191 | * @return string Transaction ID from merchant processor |
| 2192 | 2192 | */ |
| 2193 | 2193 | private function get_transaction_id() { |
| 2194 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 2194 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | 2197 | /** |
@@ -2203,7 +2203,7 @@ discard block |
||
| 2203 | 2203 | * @return string Payment IP address |
| 2204 | 2204 | */ |
| 2205 | 2205 | private function get_ip() { |
| 2206 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
| 2206 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | 2209 | /** |
@@ -2215,7 +2215,7 @@ discard block |
||
| 2215 | 2215 | * @return int Payment customer ID |
| 2216 | 2216 | */ |
| 2217 | 2217 | private function get_customer_id() { |
| 2218 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
| 2218 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
| 2219 | 2219 | } |
| 2220 | 2220 | |
| 2221 | 2221 | /** |
@@ -2227,7 +2227,7 @@ discard block |
||
| 2227 | 2227 | * @return int Payment user ID |
| 2228 | 2228 | */ |
| 2229 | 2229 | private function get_user_id() { |
| 2230 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
| 2230 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | /** |
@@ -2239,7 +2239,7 @@ discard block |
||
| 2239 | 2239 | * @return string Payment customer email |
| 2240 | 2240 | */ |
| 2241 | 2241 | private function get_email() { |
| 2242 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
| 2242 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | 2245 | /** |
@@ -2251,7 +2251,7 @@ discard block |
||
| 2251 | 2251 | * @return array Payment user info |
| 2252 | 2252 | */ |
| 2253 | 2253 | private function get_user_info() { |
| 2254 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
| 2254 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
| 2255 | 2255 | } |
| 2256 | 2256 | |
| 2257 | 2257 | /** |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | * @return array Payment billing address |
| 2264 | 2264 | */ |
| 2265 | 2265 | private function get_address() { |
| 2266 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
| 2266 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
| 2267 | 2267 | } |
| 2268 | 2268 | |
| 2269 | 2269 | /** |
@@ -2275,7 +2275,7 @@ discard block |
||
| 2275 | 2275 | * @return string Payment key |
| 2276 | 2276 | */ |
| 2277 | 2277 | private function get_key() { |
| 2278 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
| 2278 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
| 2279 | 2279 | } |
| 2280 | 2280 | |
| 2281 | 2281 | /** |
@@ -2287,7 +2287,7 @@ discard block |
||
| 2287 | 2287 | * @return string Payment form id |
| 2288 | 2288 | */ |
| 2289 | 2289 | private function get_form_id() { |
| 2290 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
| 2290 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | /** |
@@ -2299,7 +2299,7 @@ discard block |
||
| 2299 | 2299 | * @return int|string Payment number |
| 2300 | 2300 | */ |
| 2301 | 2301 | private function get_number() { |
| 2302 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
| 2302 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
| 2303 | 2303 | } |
| 2304 | 2304 | |
| 2305 | 2305 | } |