@@ -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 | |
@@ -394,13 +394,13 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return mixed void|false |
| 396 | 396 | */ |
| 397 | - public function __construct( $payment_id = false ) { |
|
| 397 | + public function __construct($payment_id = false) { |
|
| 398 | 398 | |
| 399 | - if ( empty( $payment_id ) ) { |
|
| 399 | + if (empty($payment_id)) { |
|
| 400 | 400 | return false; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - $this->setup_payment( $payment_id ); |
|
| 403 | + $this->setup_payment($payment_id); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -413,11 +413,11 @@ discard block |
||
| 413 | 413 | * |
| 414 | 414 | * @return mixed The value. |
| 415 | 415 | */ |
| 416 | - public function __get( $key ) { |
|
| 416 | + public function __get($key) { |
|
| 417 | 417 | |
| 418 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 418 | + if (method_exists($this, 'get_'.$key)) { |
|
| 419 | 419 | |
| 420 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 420 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
| 421 | 421 | |
| 422 | 422 | } else { |
| 423 | 423 | |
@@ -439,18 +439,18 @@ discard block |
||
| 439 | 439 | * @param string $key The property name |
| 440 | 440 | * @param mixed $value The value of the property |
| 441 | 441 | */ |
| 442 | - public function __set( $key, $value ) { |
|
| 443 | - $ignore = array( '_ID' ); |
|
| 442 | + public function __set($key, $value) { |
|
| 443 | + $ignore = array('_ID'); |
|
| 444 | 444 | |
| 445 | - if ( $key === 'status' ) { |
|
| 445 | + if ($key === 'status') { |
|
| 446 | 446 | $this->old_status = $this->status; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 450 | - $this->pending[ $key ] = $value; |
|
| 449 | + if ( ! in_array($key, $ignore)) { |
|
| 450 | + $this->pending[$key] = $value; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ( '_ID' !== $key ) { |
|
| 453 | + if ('_ID' !== $key) { |
|
| 454 | 454 | $this->$key = $value; |
| 455 | 455 | } |
| 456 | 456 | } |
@@ -465,9 +465,9 @@ discard block |
||
| 465 | 465 | * |
| 466 | 466 | * @return boolean If the item is set or not |
| 467 | 467 | */ |
| 468 | - public function __isset( $name ) { |
|
| 469 | - if ( property_exists( $this, $name ) ) { |
|
| 470 | - return false === empty( $this->$name ); |
|
| 468 | + public function __isset($name) { |
|
| 469 | + if (property_exists($this, $name)) { |
|
| 470 | + return false === empty($this->$name); |
|
| 471 | 471 | } else { |
| 472 | 472 | return null; |
| 473 | 473 | } |
@@ -483,20 +483,20 @@ discard block |
||
| 483 | 483 | * |
| 484 | 484 | * @return bool If the setup was successful or not |
| 485 | 485 | */ |
| 486 | - private function setup_payment( $payment_id ) { |
|
| 486 | + private function setup_payment($payment_id) { |
|
| 487 | 487 | $this->pending = array(); |
| 488 | 488 | |
| 489 | - if ( empty( $payment_id ) ) { |
|
| 489 | + if (empty($payment_id)) { |
|
| 490 | 490 | return false; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $payment = get_post( $payment_id ); |
|
| 493 | + $payment = get_post($payment_id); |
|
| 494 | 494 | |
| 495 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
| 495 | + if ( ! $payment || is_wp_error($payment)) { |
|
| 496 | 496 | return false; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - if ( 'give_payment' !== $payment->post_type ) { |
|
| 499 | + if ('give_payment' !== $payment->post_type) { |
|
| 500 | 500 | return false; |
| 501 | 501 | } |
| 502 | 502 | |
@@ -510,13 +510,13 @@ discard block |
||
| 510 | 510 | * @param Give_Payment $this Payment object. |
| 511 | 511 | * @param int $payment_id The ID of the payment. |
| 512 | 512 | */ |
| 513 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
| 513 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
| 514 | 514 | |
| 515 | 515 | // Primary Identifier. |
| 516 | - $this->ID = absint( $payment_id ); |
|
| 516 | + $this->ID = absint($payment_id); |
|
| 517 | 517 | |
| 518 | 518 | // Protected ID that can never be changed. |
| 519 | - $this->_ID = absint( $payment_id ); |
|
| 519 | + $this->_ID = absint($payment_id); |
|
| 520 | 520 | |
| 521 | 521 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
| 522 | 522 | $this->payment_meta = $this->get_meta(); |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | $this->parent_payment = $payment->post_parent; |
| 532 | 532 | |
| 533 | 533 | $all_payment_statuses = give_get_payment_statuses(); |
| 534 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
| 534 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
| 535 | 535 | |
| 536 | 536 | // Items. |
| 537 | 537 | $this->fees = $this->setup_fees(); |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * @param Give_Payment $this Payment object. |
| 574 | 574 | * @param int $payment_id The ID of the payment. |
| 575 | 575 | */ |
| 576 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
| 576 | + do_action('give_setup_payment', $this, $payment_id); |
|
| 577 | 577 | |
| 578 | 578 | return true; |
| 579 | 579 | } |
@@ -591,8 +591,8 @@ discard block |
||
| 591 | 591 | * |
| 592 | 592 | * @return void |
| 593 | 593 | */ |
| 594 | - public function update_payment_setup( $payment_id ) { |
|
| 595 | - $this->setup_payment( $payment_id ); |
|
| 594 | + public function update_payment_setup($payment_id) { |
|
| 595 | + $this->setup_payment($payment_id); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | /** |
@@ -607,24 +607,24 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | // Construct the payment title. |
| 609 | 609 | $payment_title = ''; |
| 610 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
| 611 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
| 612 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
| 610 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
| 611 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
| 612 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
| 613 | 613 | $payment_title = $this->first_name; |
| 614 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
| 614 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
| 615 | 615 | $payment_title = $this->email; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | // Set Key. |
| 619 | - if ( empty( $this->key ) ) { |
|
| 619 | + if (empty($this->key)) { |
|
| 620 | 620 | |
| 621 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 622 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
| 621 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 622 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
| 623 | 623 | $this->pending['key'] = $this->key; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // Set IP. |
| 627 | - if ( empty( $this->ip ) ) { |
|
| 627 | + if (empty($this->ip)) { |
|
| 628 | 628 | |
| 629 | 629 | $this->ip = give_get_ip(); |
| 630 | 630 | $this->pending['ip'] = $this->ip; |
@@ -651,63 +651,63 @@ discard block |
||
| 651 | 651 | 'fees' => $this->fees, |
| 652 | 652 | ); |
| 653 | 653 | |
| 654 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
| 654 | + $args = apply_filters('give_insert_payment_args', array( |
|
| 655 | 655 | 'post_title' => $payment_title, |
| 656 | 656 | 'post_status' => $this->status, |
| 657 | 657 | 'post_type' => 'give_payment', |
| 658 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
| 659 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
| 658 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
| 659 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
| 660 | 660 | 'post_parent' => $this->parent_payment, |
| 661 | - ), $payment_data ); |
|
| 661 | + ), $payment_data); |
|
| 662 | 662 | |
| 663 | 663 | // Create a blank payment |
| 664 | - $payment_id = wp_insert_post( $args ); |
|
| 664 | + $payment_id = wp_insert_post($args); |
|
| 665 | 665 | |
| 666 | - if ( ! empty( $payment_id ) ) { |
|
| 666 | + if ( ! empty($payment_id)) { |
|
| 667 | 667 | |
| 668 | 668 | $this->ID = $payment_id; |
| 669 | 669 | $this->_ID = $payment_id; |
| 670 | 670 | |
| 671 | 671 | $customer = new stdClass; |
| 672 | 672 | |
| 673 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
| 674 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
| 673 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
| 674 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
| 675 | 675 | |
| 676 | 676 | // Customer is logged in but used a different email to purchase with so assign to their customer record |
| 677 | - if ( ! empty( $customer->id ) && $this->email != $customer->email ) { |
|
| 678 | - $customer->add_email( $this->email ); |
|
| 677 | + if ( ! empty($customer->id) && $this->email != $customer->email) { |
|
| 678 | + $customer->add_email($this->email); |
|
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if ( empty( $customer->id ) ) { |
|
| 683 | - $customer = new Give_Customer( $this->email ); |
|
| 682 | + if (empty($customer->id)) { |
|
| 683 | + $customer = new Give_Customer($this->email); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if ( empty( $customer->id ) ) { |
|
| 686 | + if (empty($customer->id)) { |
|
| 687 | 687 | |
| 688 | 688 | $customer_data = array( |
| 689 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
| 689 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
| 690 | 690 | 'email' => $this->email, |
| 691 | 691 | 'user_id' => $this->user_id, |
| 692 | 692 | ); |
| 693 | 693 | |
| 694 | - $customer->create( $customer_data ); |
|
| 694 | + $customer->create($customer_data); |
|
| 695 | 695 | |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | $this->customer_id = $customer->id; |
| 699 | 699 | $this->pending['customer_id'] = $this->customer_id; |
| 700 | - $customer->attach_payment( $this->ID, false ); |
|
| 700 | + $customer->attach_payment($this->ID, false); |
|
| 701 | 701 | |
| 702 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
| 703 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
| 704 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
| 705 | - foreach ( $this->fees as $fee ) { |
|
| 706 | - $this->increase_fees( $fee['amount'] ); |
|
| 702 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
| 703 | + if ( ! empty($this->payment_meta['fees'])) { |
|
| 704 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
| 705 | + foreach ($this->fees as $fee) { |
|
| 706 | + $this->increase_fees($fee['amount']); |
|
| 707 | 707 | } |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
| 710 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
| 711 | 711 | $this->new = true; |
| 712 | 712 | } |
| 713 | 713 | |
@@ -729,11 +729,11 @@ discard block |
||
| 729 | 729 | $saved = false; |
| 730 | 730 | |
| 731 | 731 | // Must have an ID. |
| 732 | - if ( empty( $this->ID ) ) { |
|
| 732 | + if (empty($this->ID)) { |
|
| 733 | 733 | |
| 734 | 734 | $payment_id = $this->insert_payment(); |
| 735 | 735 | |
| 736 | - if ( false === $payment_id ) { |
|
| 736 | + if (false === $payment_id) { |
|
| 737 | 737 | $saved = false; |
| 738 | 738 | } else { |
| 739 | 739 | $this->ID = $payment_id; |
@@ -741,48 +741,48 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | // Set ID if not matching. |
| 744 | - if ( $this->ID !== $this->_ID ) { |
|
| 744 | + if ($this->ID !== $this->_ID) { |
|
| 745 | 745 | $this->ID = $this->_ID; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // If we have something pending, let's save it. |
| 749 | - if ( ! empty( $this->pending ) ) { |
|
| 749 | + if ( ! empty($this->pending)) { |
|
| 750 | 750 | |
| 751 | 751 | $total_increase = 0; |
| 752 | 752 | $total_decrease = 0; |
| 753 | 753 | |
| 754 | - foreach ( $this->pending as $key => $value ) { |
|
| 754 | + foreach ($this->pending as $key => $value) { |
|
| 755 | 755 | |
| 756 | - switch ( $key ) { |
|
| 756 | + switch ($key) { |
|
| 757 | 757 | |
| 758 | 758 | case 'donations': |
| 759 | 759 | // Update totals for pending donations. |
| 760 | - foreach ( $this->pending[ $key ] as $item ) { |
|
| 760 | + foreach ($this->pending[$key] as $item) { |
|
| 761 | 761 | |
| 762 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 763 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
| 762 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
| 763 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
| 764 | 764 | |
| 765 | - switch ( $item['action'] ) { |
|
| 765 | + switch ($item['action']) { |
|
| 766 | 766 | |
| 767 | 767 | case 'add': |
| 768 | 768 | |
| 769 | 769 | $price = $item['price']; |
| 770 | 770 | |
| 771 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 771 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 772 | 772 | |
| 773 | 773 | // Add sales logs. |
| 774 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
| 774 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
| 775 | 775 | |
| 776 | 776 | $y = 0; |
| 777 | - while ( $y < $quantity ) { |
|
| 777 | + while ($y < $quantity) { |
|
| 778 | 778 | |
| 779 | - give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
| 780 | - $y ++; |
|
| 779 | + give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
| 780 | + $y++; |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 784 | - $form->increase_sales( $quantity ); |
|
| 785 | - $form->increase_earnings( $price ); |
|
| 783 | + $form = new Give_Donate_Form($item['id']); |
|
| 784 | + $form->increase_sales($quantity); |
|
| 785 | + $form->increase_earnings($price); |
|
| 786 | 786 | |
| 787 | 787 | $total_increase += $price; |
| 788 | 788 | } |
@@ -807,15 +807,15 @@ discard block |
||
| 807 | 807 | ), |
| 808 | 808 | ); |
| 809 | 809 | |
| 810 | - $found_logs = get_posts( $log_args ); |
|
| 811 | - foreach ( $found_logs as $log ) { |
|
| 812 | - wp_delete_post( $log->ID, true ); |
|
| 810 | + $found_logs = get_posts($log_args); |
|
| 811 | + foreach ($found_logs as $log) { |
|
| 812 | + wp_delete_post($log->ID, true); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 816 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 817 | - $form->decrease_sales( $quantity ); |
|
| 818 | - $form->decrease_earnings( $item['amount'] ); |
|
| 815 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 816 | + $form = new Give_Donate_Form($item['id']); |
|
| 817 | + $form->decrease_sales($quantity); |
|
| 818 | + $form->decrease_earnings($item['amount']); |
|
| 819 | 819 | |
| 820 | 820 | $total_decrease += $item['amount']; |
| 821 | 821 | } |
@@ -827,17 +827,17 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | case 'fees': |
| 829 | 829 | |
| 830 | - if ( 'publish' !== $this->status && 'complete' !== $this->status ) { |
|
| 830 | + if ('publish' !== $this->status && 'complete' !== $this->status) { |
|
| 831 | 831 | break; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | - if ( empty( $this->pending[ $key ] ) ) { |
|
| 834 | + if (empty($this->pending[$key])) { |
|
| 835 | 835 | break; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
| 838 | + foreach ($this->pending[$key] as $fee) { |
|
| 839 | 839 | |
| 840 | - switch ( $fee['action'] ) { |
|
| 840 | + switch ($fee['action']) { |
|
| 841 | 841 | |
| 842 | 842 | case 'add': |
| 843 | 843 | $total_increase += $fee['amount']; |
@@ -853,43 +853,43 @@ discard block |
||
| 853 | 853 | break; |
| 854 | 854 | |
| 855 | 855 | case 'status': |
| 856 | - $this->update_status( $this->status ); |
|
| 856 | + $this->update_status($this->status); |
|
| 857 | 857 | break; |
| 858 | 858 | |
| 859 | 859 | case 'gateway': |
| 860 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
| 860 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
| 861 | 861 | break; |
| 862 | 862 | |
| 863 | 863 | case 'mode': |
| 864 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
| 864 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
| 865 | 865 | break; |
| 866 | 866 | |
| 867 | 867 | case 'transaction_id': |
| 868 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
| 868 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
| 869 | 869 | break; |
| 870 | 870 | |
| 871 | 871 | case 'ip': |
| 872 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
| 872 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
| 873 | 873 | break; |
| 874 | 874 | |
| 875 | 875 | case 'customer_id': |
| 876 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
| 876 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
| 877 | 877 | break; |
| 878 | 878 | |
| 879 | 879 | case 'user_id': |
| 880 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
| 880 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
| 881 | 881 | break; |
| 882 | 882 | |
| 883 | 883 | case 'form_title': |
| 884 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
| 884 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
| 885 | 885 | break; |
| 886 | 886 | |
| 887 | 887 | case 'form_id': |
| 888 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
| 888 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
| 889 | 889 | break; |
| 890 | 890 | |
| 891 | 891 | case 'price_id': |
| 892 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
| 892 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
| 893 | 893 | break; |
| 894 | 894 | |
| 895 | 895 | case 'first_name': |
@@ -905,15 +905,15 @@ discard block |
||
| 905 | 905 | break; |
| 906 | 906 | |
| 907 | 907 | case 'email': |
| 908 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
| 908 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
| 909 | 909 | break; |
| 910 | 910 | |
| 911 | 911 | case 'key': |
| 912 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
| 912 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
| 913 | 913 | break; |
| 914 | 914 | |
| 915 | 915 | case 'number': |
| 916 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
| 916 | + $this->update_meta('_give_payment_number', $this->number); |
|
| 917 | 917 | break; |
| 918 | 918 | |
| 919 | 919 | case 'date': |
@@ -923,11 +923,11 @@ discard block |
||
| 923 | 923 | 'edit_date' => true, |
| 924 | 924 | ); |
| 925 | 925 | |
| 926 | - wp_update_post( $args ); |
|
| 926 | + wp_update_post($args); |
|
| 927 | 927 | break; |
| 928 | 928 | |
| 929 | 929 | case 'completed_date': |
| 930 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
| 930 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
| 931 | 931 | break; |
| 932 | 932 | |
| 933 | 933 | case 'parent_payment': |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | 'post_parent' => $this->parent_payment, |
| 937 | 937 | ); |
| 938 | 938 | |
| 939 | - wp_update_post( $args ); |
|
| 939 | + wp_update_post($args); |
|
| 940 | 940 | break; |
| 941 | 941 | |
| 942 | 942 | default: |
@@ -947,33 +947,33 @@ discard block |
||
| 947 | 947 | * |
| 948 | 948 | * @param Give_Payment $this Payment object. |
| 949 | 949 | */ |
| 950 | - do_action( 'give_payment_save', $this, $key ); |
|
| 950 | + do_action('give_payment_save', $this, $key); |
|
| 951 | 951 | break; |
| 952 | 952 | } |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - if ( 'pending' !== $this->status ) { |
|
| 955 | + if ('pending' !== $this->status) { |
|
| 956 | 956 | |
| 957 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 957 | + $customer = new Give_Customer($this->customer_id); |
|
| 958 | 958 | |
| 959 | 959 | $total_change = $total_increase - $total_decrease; |
| 960 | - if ( $total_change < 0 ) { |
|
| 960 | + if ($total_change < 0) { |
|
| 961 | 961 | |
| 962 | - $total_change = - ( $total_change ); |
|
| 962 | + $total_change = - ($total_change); |
|
| 963 | 963 | // Decrease the customer's donation stats. |
| 964 | - $customer->decrease_value( $total_change ); |
|
| 965 | - give_decrease_total_earnings( $total_change ); |
|
| 964 | + $customer->decrease_value($total_change); |
|
| 965 | + give_decrease_total_earnings($total_change); |
|
| 966 | 966 | |
| 967 | - } elseif ( $total_change > 0 ) { |
|
| 967 | + } elseif ($total_change > 0) { |
|
| 968 | 968 | |
| 969 | 969 | // Increase the customer's donation stats. |
| 970 | - $customer->increase_value( $total_change ); |
|
| 971 | - give_increase_total_earnings( $total_change ); |
|
| 970 | + $customer->increase_value($total_change); |
|
| 971 | + give_increase_total_earnings($total_change); |
|
| 972 | 972 | |
| 973 | 973 | } |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
| 976 | + $this->update_meta('_give_payment_total', $this->total); |
|
| 977 | 977 | |
| 978 | 978 | $new_meta = array( |
| 979 | 979 | 'form_title' => $this->form_title, |
@@ -985,12 +985,12 @@ discard block |
||
| 985 | 985 | ); |
| 986 | 986 | |
| 987 | 987 | $meta = $this->get_meta(); |
| 988 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
| 988 | + $merged_meta = array_merge($meta, $new_meta); |
|
| 989 | 989 | |
| 990 | 990 | // Only save the payment meta if it's changed. |
| 991 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
| 992 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
| 993 | - if ( false !== $updated ) { |
|
| 991 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
| 992 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
| 993 | + if (false !== $updated) { |
|
| 994 | 994 | $saved = true; |
| 995 | 995 | } |
| 996 | 996 | } |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | $saved = true; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - if ( true === $saved ) { |
|
| 1003 | - $this->setup_payment( $this->ID ); |
|
| 1002 | + if (true === $saved) { |
|
| 1003 | + $this->setup_payment($this->ID); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | return $saved; |
@@ -1018,12 +1018,12 @@ discard block |
||
| 1018 | 1018 | * |
| 1019 | 1019 | * @return bool True when successful, false otherwise |
| 1020 | 1020 | */ |
| 1021 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
| 1021 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
| 1022 | 1022 | |
| 1023 | - $donation = new Give_Donate_Form( $form_id ); |
|
| 1023 | + $donation = new Give_Donate_Form($form_id); |
|
| 1024 | 1024 | |
| 1025 | 1025 | // Bail if this post isn't a give donation form. |
| 1026 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
| 1026 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
| 1027 | 1027 | return false; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
@@ -1034,59 +1034,59 @@ discard block |
||
| 1034 | 1034 | 'fees' => array(), |
| 1035 | 1035 | ); |
| 1036 | 1036 | |
| 1037 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
| 1037 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
| 1038 | 1038 | |
| 1039 | 1039 | // Allow overriding the price. |
| 1040 | - if ( false !== $args['price'] ) { |
|
| 1040 | + if (false !== $args['price']) { |
|
| 1041 | 1041 | $item_price = $args['price']; |
| 1042 | 1042 | } else { |
| 1043 | 1043 | |
| 1044 | 1044 | // Deal with variable pricing. |
| 1045 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
| 1046 | - $prices = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
| 1045 | + if (give_has_variable_prices($donation->ID)) { |
|
| 1046 | + $prices = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
| 1047 | 1047 | $item_price = ''; |
| 1048 | 1048 | // Loop through prices. |
| 1049 | - foreach ( $prices as $price ) { |
|
| 1049 | + foreach ($prices as $price) { |
|
| 1050 | 1050 | // Find a match between price_id and level_id. |
| 1051 | 1051 | // First verify array keys exists THEN make the match. |
| 1052 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
| 1052 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
| 1053 | 1053 | && $args['price_id'] == $price['_give_id']['level_id'] |
| 1054 | 1054 | ) { |
| 1055 | 1055 | $item_price = $price['_give_amount']; |
| 1056 | 1056 | } |
| 1057 | 1057 | } |
| 1058 | 1058 | // Fallback to the lowest price point. |
| 1059 | - if ( $item_price == '' ) { |
|
| 1060 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
| 1061 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
| 1059 | + if ($item_price == '') { |
|
| 1060 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
| 1061 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
| 1062 | 1062 | } |
| 1063 | 1063 | } else { |
| 1064 | 1064 | // Simple form price. |
| 1065 | - $item_price = give_get_form_price( $donation->ID ); |
|
| 1065 | + $item_price = give_get_form_price($donation->ID); |
|
| 1066 | 1066 | } |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | // Sanitizing the price here so we don't have a dozen calls later. |
| 1070 | - $item_price = give_sanitize_amount( $item_price ); |
|
| 1071 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
| 1070 | + $item_price = give_sanitize_amount($item_price); |
|
| 1071 | + $total = round($item_price, give_currency_decimal_filter()); |
|
| 1072 | 1072 | |
| 1073 | 1073 | // Add Options. |
| 1074 | 1074 | $default_options = array(); |
| 1075 | - if ( false !== $args['price_id'] ) { |
|
| 1075 | + if (false !== $args['price_id']) { |
|
| 1076 | 1076 | $default_options['price_id'] = (int) $args['price_id']; |
| 1077 | 1077 | } |
| 1078 | - $options = wp_parse_args( $options, $default_options ); |
|
| 1078 | + $options = wp_parse_args($options, $default_options); |
|
| 1079 | 1079 | |
| 1080 | 1080 | // Do not allow totals to go negative. |
| 1081 | - if ( $total < 0 ) { |
|
| 1081 | + if ($total < 0) { |
|
| 1082 | 1082 | $total = 0; |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | $donation = array( |
| 1086 | 1086 | 'name' => $donation->post_title, |
| 1087 | 1087 | 'id' => $donation->ID, |
| 1088 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
| 1089 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
| 1088 | + 'price' => round($total, give_currency_decimal_filter()), |
|
| 1089 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
| 1090 | 1090 | 'fees' => $args['fees'], |
| 1091 | 1091 | 'price_id' => $args['price_id'], |
| 1092 | 1092 | 'action' => 'add', |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | |
| 1096 | 1096 | $this->pending['donations'][] = $donation; |
| 1097 | 1097 | |
| 1098 | - $this->increase_subtotal( $total ); |
|
| 1098 | + $this->increase_subtotal($total); |
|
| 1099 | 1099 | |
| 1100 | 1100 | return true; |
| 1101 | 1101 | |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | * |
| 1113 | 1113 | * @return bool If the item was removed or not |
| 1114 | 1114 | */ |
| 1115 | - public function remove_donation( $form_id, $args = array() ) { |
|
| 1115 | + public function remove_donation($form_id, $args = array()) { |
|
| 1116 | 1116 | |
| 1117 | 1117 | // Set some defaults. |
| 1118 | 1118 | $defaults = array( |
@@ -1120,12 +1120,12 @@ discard block |
||
| 1120 | 1120 | 'price' => false, |
| 1121 | 1121 | 'price_id' => false, |
| 1122 | 1122 | ); |
| 1123 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1123 | + $args = wp_parse_args($args, $defaults); |
|
| 1124 | 1124 | |
| 1125 | - $form = new Give_Donate_Form( $form_id ); |
|
| 1125 | + $form = new Give_Donate_Form($form_id); |
|
| 1126 | 1126 | |
| 1127 | 1127 | // Bail if this post isn't a valid give donation form. |
| 1128 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
| 1128 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
| 1129 | 1129 | return false; |
| 1130 | 1130 | } |
| 1131 | 1131 | |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | |
| 1139 | 1139 | $this->pending['donations'][] = $pending_args; |
| 1140 | 1140 | |
| 1141 | - $this->decrease_subtotal( $this->total ); |
|
| 1141 | + $this->decrease_subtotal($this->total); |
|
| 1142 | 1142 | |
| 1143 | 1143 | return true; |
| 1144 | 1144 | } |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | * |
| 1155 | 1155 | * @return bool If the fee was added |
| 1156 | 1156 | */ |
| 1157 | - public function add_fee( $args, $global = true ) { |
|
| 1157 | + public function add_fee($args, $global = true) { |
|
| 1158 | 1158 | |
| 1159 | 1159 | $default_args = array( |
| 1160 | 1160 | 'label' => '', |
@@ -1164,15 +1164,15 @@ discard block |
||
| 1164 | 1164 | 'price_id' => 0, |
| 1165 | 1165 | ); |
| 1166 | 1166 | |
| 1167 | - $fee = wp_parse_args( $args, $default_args ); |
|
| 1167 | + $fee = wp_parse_args($args, $default_args); |
|
| 1168 | 1168 | $this->fees[] = $fee; |
| 1169 | 1169 | |
| 1170 | 1170 | $added_fee = $fee; |
| 1171 | 1171 | $added_fee['action'] = 'add'; |
| 1172 | 1172 | $this->pending['fees'][] = $added_fee; |
| 1173 | - reset( $this->fees ); |
|
| 1173 | + reset($this->fees); |
|
| 1174 | 1174 | |
| 1175 | - $this->increase_fees( $fee['amount'] ); |
|
| 1175 | + $this->increase_fees($fee['amount']); |
|
| 1176 | 1176 | |
| 1177 | 1177 | return true; |
| 1178 | 1178 | } |
@@ -1187,11 +1187,11 @@ discard block |
||
| 1187 | 1187 | * |
| 1188 | 1188 | * @return bool If the fee was removed successfully |
| 1189 | 1189 | */ |
| 1190 | - public function remove_fee( $key ) { |
|
| 1190 | + public function remove_fee($key) { |
|
| 1191 | 1191 | $removed = false; |
| 1192 | 1192 | |
| 1193 | - if ( is_numeric( $key ) ) { |
|
| 1194 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
| 1193 | + if (is_numeric($key)) { |
|
| 1194 | + $removed = $this->remove_fee_by('index', $key); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | return $removed; |
@@ -1210,55 +1210,55 @@ discard block |
||
| 1210 | 1210 | * |
| 1211 | 1211 | * @return boolean If the item is removed |
| 1212 | 1212 | */ |
| 1213 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
| 1213 | + public function remove_fee_by($key, $value, $global = false) { |
|
| 1214 | 1214 | |
| 1215 | - $allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array( |
|
| 1215 | + $allowed_fee_keys = apply_filters('give_payment_fee_keys', array( |
|
| 1216 | 1216 | 'index', |
| 1217 | 1217 | 'label', |
| 1218 | 1218 | 'amount', |
| 1219 | 1219 | 'type', |
| 1220 | - ) ); |
|
| 1220 | + )); |
|
| 1221 | 1221 | |
| 1222 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
| 1222 | + if ( ! in_array($key, $allowed_fee_keys)) { |
|
| 1223 | 1223 | return false; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | $removed = false; |
| 1227 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
| 1227 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
| 1228 | 1228 | |
| 1229 | - $removed_fee = $this->fees[ $value ]; |
|
| 1229 | + $removed_fee = $this->fees[$value]; |
|
| 1230 | 1230 | $removed_fee['action'] = 'remove'; |
| 1231 | 1231 | $this->pending['fees'][] = $removed_fee; |
| 1232 | 1232 | |
| 1233 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1233 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1234 | 1234 | |
| 1235 | - unset( $this->fees[ $value ] ); |
|
| 1235 | + unset($this->fees[$value]); |
|
| 1236 | 1236 | $removed = true; |
| 1237 | 1237 | |
| 1238 | - } elseif ( 'index' !== $key ) { |
|
| 1238 | + } elseif ('index' !== $key) { |
|
| 1239 | 1239 | |
| 1240 | - foreach ( $this->fees as $index => $fee ) { |
|
| 1240 | + foreach ($this->fees as $index => $fee) { |
|
| 1241 | 1241 | |
| 1242 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
| 1242 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
| 1243 | 1243 | |
| 1244 | 1244 | $removed_fee = $fee; |
| 1245 | 1245 | $removed_fee['action'] = 'remove'; |
| 1246 | 1246 | $this->pending['fees'][] = $removed_fee; |
| 1247 | 1247 | |
| 1248 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1248 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1249 | 1249 | |
| 1250 | - unset( $this->fees[ $index ] ); |
|
| 1250 | + unset($this->fees[$index]); |
|
| 1251 | 1251 | $removed = true; |
| 1252 | 1252 | |
| 1253 | - if ( false === $global ) { |
|
| 1253 | + if (false === $global) { |
|
| 1254 | 1254 | break; |
| 1255 | 1255 | } |
| 1256 | 1256 | } |
| 1257 | 1257 | } |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | - if ( true === $removed ) { |
|
| 1261 | - $this->fees = array_values( $this->fees ); |
|
| 1260 | + if (true === $removed) { |
|
| 1261 | + $this->fees = array_values($this->fees); |
|
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | 1264 | return $removed; |
@@ -1274,14 +1274,14 @@ discard block |
||
| 1274 | 1274 | * |
| 1275 | 1275 | * @return array The Fees for the type specified |
| 1276 | 1276 | */ |
| 1277 | - public function get_fees( $type = 'all' ) { |
|
| 1277 | + public function get_fees($type = 'all') { |
|
| 1278 | 1278 | $fees = array(); |
| 1279 | 1279 | |
| 1280 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
| 1280 | + if ( ! empty($this->fees) && is_array($this->fees)) { |
|
| 1281 | 1281 | |
| 1282 | - foreach ( $this->fees as $fee_id => $fee ) { |
|
| 1282 | + foreach ($this->fees as $fee_id => $fee) { |
|
| 1283 | 1283 | |
| 1284 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 1284 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
| 1285 | 1285 | continue; |
| 1286 | 1286 | } |
| 1287 | 1287 | |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | } |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this ); |
|
| 1294 | + return apply_filters('give_get_payment_fees', $fees, $this->ID, $this); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | /** |
@@ -1304,13 +1304,13 @@ discard block |
||
| 1304 | 1304 | * |
| 1305 | 1305 | * @return void |
| 1306 | 1306 | */ |
| 1307 | - public function add_note( $note = false ) { |
|
| 1307 | + public function add_note($note = false) { |
|
| 1308 | 1308 | // Bail if no note specified. |
| 1309 | - if ( ! $note ) { |
|
| 1309 | + if ( ! $note) { |
|
| 1310 | 1310 | return false; |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | - give_insert_payment_note( $this->ID, $note ); |
|
| 1313 | + give_insert_payment_note($this->ID, $note); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
@@ -1323,7 +1323,7 @@ discard block |
||
| 1323 | 1323 | * |
| 1324 | 1324 | * @return void |
| 1325 | 1325 | */ |
| 1326 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 1326 | + private function increase_subtotal($amount = 0.00) { |
|
| 1327 | 1327 | $amount = (float) $amount; |
| 1328 | 1328 | $this->subtotal += $amount; |
| 1329 | 1329 | |
@@ -1340,11 +1340,11 @@ discard block |
||
| 1340 | 1340 | * |
| 1341 | 1341 | * @return void |
| 1342 | 1342 | */ |
| 1343 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 1343 | + private function decrease_subtotal($amount = 0.00) { |
|
| 1344 | 1344 | $amount = (float) $amount; |
| 1345 | 1345 | $this->subtotal -= $amount; |
| 1346 | 1346 | |
| 1347 | - if ( $this->subtotal < 0 ) { |
|
| 1347 | + if ($this->subtotal < 0) { |
|
| 1348 | 1348 | $this->subtotal = 0; |
| 1349 | 1349 | } |
| 1350 | 1350 | |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | * |
| 1362 | 1362 | * @return void |
| 1363 | 1363 | */ |
| 1364 | - private function increase_fees( $amount = 0.00 ) { |
|
| 1364 | + private function increase_fees($amount = 0.00) { |
|
| 1365 | 1365 | $amount = (float) $amount; |
| 1366 | 1366 | $this->fees_total += $amount; |
| 1367 | 1367 | |
@@ -1378,11 +1378,11 @@ discard block |
||
| 1378 | 1378 | * |
| 1379 | 1379 | * @return void |
| 1380 | 1380 | */ |
| 1381 | - private function decrease_fees( $amount = 0.00 ) { |
|
| 1381 | + private function decrease_fees($amount = 0.00) { |
|
| 1382 | 1382 | $amount = (float) $amount; |
| 1383 | 1383 | $this->fees_total -= $amount; |
| 1384 | 1384 | |
| 1385 | - if ( $this->fees_total < 0 ) { |
|
| 1385 | + if ($this->fees_total < 0) { |
|
| 1386 | 1386 | $this->fees_total = 0; |
| 1387 | 1387 | } |
| 1388 | 1388 | |
@@ -1411,24 +1411,24 @@ discard block |
||
| 1411 | 1411 | * |
| 1412 | 1412 | * @return bool $updated Returns if the status was successfully updated. |
| 1413 | 1413 | */ |
| 1414 | - public function update_status( $status = false ) { |
|
| 1414 | + public function update_status($status = false) { |
|
| 1415 | 1415 | |
| 1416 | 1416 | // standardize the 'complete(d)' status. |
| 1417 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
| 1417 | + if ($status == 'completed' || $status == 'complete') { |
|
| 1418 | 1418 | $status = 'publish'; |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
| 1421 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
| 1422 | 1422 | |
| 1423 | - if ( $old_status === $status ) { |
|
| 1423 | + if ($old_status === $status) { |
|
| 1424 | 1424 | return false; // Don't permit status changes that aren't changes. |
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
| 1427 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
| 1428 | 1428 | |
| 1429 | 1429 | $updated = false; |
| 1430 | 1430 | |
| 1431 | - if ( $do_change ) { |
|
| 1431 | + if ($do_change) { |
|
| 1432 | 1432 | |
| 1433 | 1433 | /** |
| 1434 | 1434 | * Fires before changing payment status. |
@@ -1439,21 +1439,21 @@ discard block |
||
| 1439 | 1439 | * @param string $status The new status. |
| 1440 | 1440 | * @param string $old_status The old status. |
| 1441 | 1441 | */ |
| 1442 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
| 1442 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
| 1443 | 1443 | |
| 1444 | 1444 | $update_fields = array( |
| 1445 | 1445 | 'ID' => $this->ID, |
| 1446 | 1446 | 'post_status' => $status, |
| 1447 | - 'edit_date' => current_time( 'mysql' ), |
|
| 1447 | + 'edit_date' => current_time('mysql'), |
|
| 1448 | 1448 | ); |
| 1449 | 1449 | |
| 1450 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
| 1450 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
| 1451 | 1451 | |
| 1452 | 1452 | $all_payment_statuses = give_get_payment_statuses(); |
| 1453 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
| 1453 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
| 1454 | 1454 | |
| 1455 | 1455 | // Process any specific status functions. |
| 1456 | - switch ( $status ) { |
|
| 1456 | + switch ($status) { |
|
| 1457 | 1457 | case 'refunded': |
| 1458 | 1458 | $this->process_refund(); |
| 1459 | 1459 | break; |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | * @param string $status The new status. |
| 1481 | 1481 | * @param string $old_status The old status. |
| 1482 | 1482 | */ |
| 1483 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
| 1483 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
| 1484 | 1484 | |
| 1485 | 1485 | } |
| 1486 | 1486 | |
@@ -1515,33 +1515,33 @@ discard block |
||
| 1515 | 1515 | * |
| 1516 | 1516 | * @return mixed The value from the post meta |
| 1517 | 1517 | */ |
| 1518 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
| 1518 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
| 1519 | 1519 | |
| 1520 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
| 1520 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
| 1521 | 1521 | |
| 1522 | - if ( $meta_key === '_give_payment_meta' ) { |
|
| 1522 | + if ($meta_key === '_give_payment_meta') { |
|
| 1523 | 1523 | $meta = (array) $meta; |
| 1524 | 1524 | |
| 1525 | - if ( empty( $meta['key'] ) ) { |
|
| 1525 | + if (empty($meta['key'])) { |
|
| 1526 | 1526 | $meta['key'] = $this->setup_payment_key(); |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | - if ( empty( $meta['form_title'] ) ) { |
|
| 1529 | + if (empty($meta['form_title'])) { |
|
| 1530 | 1530 | $meta['form_title'] = $this->setup_form_title(); |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - if ( empty( $meta['email'] ) ) { |
|
| 1533 | + if (empty($meta['email'])) { |
|
| 1534 | 1534 | $meta['email'] = $this->setup_email(); |
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | - if ( empty( $meta['date'] ) ) { |
|
| 1538 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1537 | + if (empty($meta['date'])) { |
|
| 1538 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
| 1542 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
| 1543 | 1543 | |
| 1544 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
| 1544 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | /** |
@@ -1556,23 +1556,23 @@ discard block |
||
| 1556 | 1556 | * |
| 1557 | 1557 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
| 1558 | 1558 | */ |
| 1559 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 1560 | - if ( empty( $meta_key ) ) { |
|
| 1559 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 1560 | + if (empty($meta_key)) { |
|
| 1561 | 1561 | return false; |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
| 1564 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
| 1565 | 1565 | |
| 1566 | 1566 | $current_meta = $this->get_meta(); |
| 1567 | - $current_meta[ $meta_key ] = $meta_value; |
|
| 1567 | + $current_meta[$meta_key] = $meta_value; |
|
| 1568 | 1568 | |
| 1569 | 1569 | $meta_key = '_give_payment_meta'; |
| 1570 | 1570 | $meta_value = $current_meta; |
| 1571 | 1571 | |
| 1572 | - } elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
| 1572 | + } elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
| 1573 | 1573 | |
| 1574 | - $meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
| 1575 | - update_post_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
| 1574 | + $meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
| 1575 | + update_post_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
| 1576 | 1576 | |
| 1577 | 1577 | $current_meta = $this->get_meta(); |
| 1578 | 1578 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1582,9 +1582,9 @@ discard block |
||
| 1582 | 1582 | |
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
| 1585 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
| 1586 | 1586 | |
| 1587 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 1587 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | /** |
@@ -1599,14 +1599,14 @@ discard block |
||
| 1599 | 1599 | $process_refund = true; |
| 1600 | 1600 | |
| 1601 | 1601 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1602 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
| 1602 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
| 1603 | 1603 | $process_refund = false; |
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | 1606 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1607 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
| 1607 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
| 1608 | 1608 | |
| 1609 | - if ( false === $process_refund ) { |
|
| 1609 | + if (false === $process_refund) { |
|
| 1610 | 1610 | return; |
| 1611 | 1611 | } |
| 1612 | 1612 | |
@@ -1617,13 +1617,13 @@ discard block |
||
| 1617 | 1617 | * |
| 1618 | 1618 | * @param Give_Payment $this Payment object. |
| 1619 | 1619 | */ |
| 1620 | - do_action( 'give_pre_refund_payment', $this ); |
|
| 1620 | + do_action('give_pre_refund_payment', $this); |
|
| 1621 | 1621 | |
| 1622 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
| 1623 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
| 1624 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
| 1622 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
| 1623 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
| 1624 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
| 1625 | 1625 | |
| 1626 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1626 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1627 | 1627 | $this->delete_sales_logs(); |
| 1628 | 1628 | |
| 1629 | 1629 | // @todo: Refresh only range related stat cache |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | * |
| 1637 | 1637 | * @param Give_Payment $this Payment object. |
| 1638 | 1638 | */ |
| 1639 | - do_action( 'give_post_refund_payment', $this ); |
|
| 1639 | + do_action('give_post_refund_payment', $this); |
|
| 1640 | 1640 | } |
| 1641 | 1641 | |
| 1642 | 1642 | /** |
@@ -1663,26 +1663,26 @@ discard block |
||
| 1663 | 1663 | $process_pending = true; |
| 1664 | 1664 | |
| 1665 | 1665 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1666 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
| 1666 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
| 1667 | 1667 | $process_pending = false; |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | 1670 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1671 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
| 1671 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
| 1672 | 1672 | |
| 1673 | - if ( false === $process_pending ) { |
|
| 1673 | + if (false === $process_pending) { |
|
| 1674 | 1674 | return; |
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this ); |
|
| 1678 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this ); |
|
| 1679 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this ); |
|
| 1677 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this); |
|
| 1678 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this); |
|
| 1679 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this); |
|
| 1680 | 1680 | |
| 1681 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1681 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1682 | 1682 | $this->delete_sales_logs(); |
| 1683 | 1683 | |
| 1684 | 1684 | $this->completed_date = false; |
| 1685 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1685 | + $this->update_meta('_give_completed_date', ''); |
|
| 1686 | 1686 | |
| 1687 | 1687 | // @todo: Refresh only range related stat cache |
| 1688 | 1688 | give_delete_donation_stats(); |
@@ -1700,26 +1700,26 @@ discard block |
||
| 1700 | 1700 | $process_cancelled = true; |
| 1701 | 1701 | |
| 1702 | 1702 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1703 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
| 1703 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
| 1704 | 1704 | $process_cancelled = false; |
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1708 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1708 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
| 1709 | 1709 | |
| 1710 | - if ( false === $process_cancelled ) { |
|
| 1710 | + if (false === $process_cancelled) { |
|
| 1711 | 1711 | return; |
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
| 1715 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
| 1716 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
| 1714 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this); |
|
| 1715 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this); |
|
| 1716 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this); |
|
| 1717 | 1717 | |
| 1718 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1718 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1719 | 1719 | $this->delete_sales_logs(); |
| 1720 | 1720 | |
| 1721 | 1721 | $this->completed_date = false; |
| 1722 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1722 | + $this->update_meta('_give_completed_date', ''); |
|
| 1723 | 1723 | |
| 1724 | 1724 | // @todo: Refresh only range related stat cache |
| 1725 | 1725 | give_delete_donation_stats(); |
@@ -1735,26 +1735,26 @@ discard block |
||
| 1735 | 1735 | $process_revoked = true; |
| 1736 | 1736 | |
| 1737 | 1737 | // If the payment was not in publish, don't decrement stats as they were never incremented. |
| 1738 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
| 1738 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
| 1739 | 1739 | $process_revoked = false; |
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1743 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
| 1743 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
| 1744 | 1744 | |
| 1745 | - if ( false === $process_revoked ) { |
|
| 1745 | + if (false === $process_revoked) { |
|
| 1746 | 1746 | return; |
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
| 1750 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
| 1751 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
| 1749 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this); |
|
| 1750 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this); |
|
| 1751 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this); |
|
| 1752 | 1752 | |
| 1753 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1753 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1754 | 1754 | $this->delete_sales_logs(); |
| 1755 | 1755 | |
| 1756 | 1756 | $this->completed_date = false; |
| 1757 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1757 | + $this->update_meta('_give_completed_date', ''); |
|
| 1758 | 1758 | |
| 1759 | 1759 | // @todo: Refresh only range related stat cache |
| 1760 | 1760 | give_delete_donation_stats(); |
@@ -1772,25 +1772,25 @@ discard block |
||
| 1772 | 1772 | * |
| 1773 | 1773 | * @return void |
| 1774 | 1774 | */ |
| 1775 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
| 1775 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
| 1776 | 1776 | |
| 1777 | - give_undo_purchase( false, $this->ID ); |
|
| 1777 | + give_undo_purchase(false, $this->ID); |
|
| 1778 | 1778 | |
| 1779 | 1779 | // Decrease store earnings. |
| 1780 | - if ( true === $alter_store_earnings ) { |
|
| 1781 | - give_decrease_total_earnings( $this->total ); |
|
| 1780 | + if (true === $alter_store_earnings) { |
|
| 1781 | + give_decrease_total_earnings($this->total); |
|
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | 1784 | // Decrement the stats for the customer. |
| 1785 | - if ( ! empty( $this->customer_id ) ) { |
|
| 1785 | + if ( ! empty($this->customer_id)) { |
|
| 1786 | 1786 | |
| 1787 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1787 | + $customer = new Give_Customer($this->customer_id); |
|
| 1788 | 1788 | |
| 1789 | - if ( true === $alter_customer_value ) { |
|
| 1790 | - $customer->decrease_value( $this->total ); |
|
| 1789 | + if (true === $alter_customer_value) { |
|
| 1790 | + $customer->decrease_value($this->total); |
|
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | - if ( true === $alter_customer_purchase_count ) { |
|
| 1793 | + if (true === $alter_customer_purchase_count) { |
|
| 1794 | 1794 | $customer->decrease_purchase_count(); |
| 1795 | 1795 | } |
| 1796 | 1796 | } |
@@ -1839,13 +1839,13 @@ discard block |
||
| 1839 | 1839 | * @return string The date the payment was completed |
| 1840 | 1840 | */ |
| 1841 | 1841 | private function setup_completed_date() { |
| 1842 | - $payment = get_post( $this->ID ); |
|
| 1842 | + $payment = get_post($this->ID); |
|
| 1843 | 1843 | |
| 1844 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
| 1844 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
| 1845 | 1845 | return false; // This payment was never completed. |
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
| 1848 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
| 1849 | 1849 | |
| 1850 | 1850 | return $date; |
| 1851 | 1851 | } |
@@ -1859,7 +1859,7 @@ discard block |
||
| 1859 | 1859 | * @return string The payment mode |
| 1860 | 1860 | */ |
| 1861 | 1861 | private function setup_mode() { |
| 1862 | - return $this->get_meta( '_give_payment_mode' ); |
|
| 1862 | + return $this->get_meta('_give_payment_mode'); |
|
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | 1865 | /** |
@@ -1871,19 +1871,19 @@ discard block |
||
| 1871 | 1871 | * @return float The payment total |
| 1872 | 1872 | */ |
| 1873 | 1873 | private function setup_total() { |
| 1874 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
| 1874 | + $amount = $this->get_meta('_give_payment_total', true); |
|
| 1875 | 1875 | |
| 1876 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 1877 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
| 1878 | - $meta = maybe_unserialize( $meta ); |
|
| 1876 | + if (empty($amount) && '0.00' != $amount) { |
|
| 1877 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
| 1878 | + $meta = maybe_unserialize($meta); |
|
| 1879 | 1879 | |
| 1880 | - if ( isset( $meta['amount'] ) ) { |
|
| 1880 | + if (isset($meta['amount'])) { |
|
| 1881 | 1881 | $amount = $meta['amount']; |
| 1882 | 1882 | } |
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | 1885 | |
| 1886 | - return round( floatval( $amount ), give_currency_decimal_filter() ); |
|
| 1886 | + return round(floatval($amount), give_currency_decimal_filter()); |
|
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | 1889 | /** |
@@ -1911,9 +1911,9 @@ discard block |
||
| 1911 | 1911 | private function setup_fees_total() { |
| 1912 | 1912 | $fees_total = (float) 0.00; |
| 1913 | 1913 | |
| 1914 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1915 | - if ( ! empty( $payment_fees ) ) { |
|
| 1916 | - foreach ( $payment_fees as $fee ) { |
|
| 1914 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1915 | + if ( ! empty($payment_fees)) { |
|
| 1916 | + foreach ($payment_fees as $fee) { |
|
| 1917 | 1917 | $fees_total += (float) $fee['amount']; |
| 1918 | 1918 | } |
| 1919 | 1919 | } |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | * @return string The currency for the payment |
| 1932 | 1932 | */ |
| 1933 | 1933 | private function setup_currency() { |
| 1934 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
| 1934 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
| 1935 | 1935 | |
| 1936 | 1936 | return $currency; |
| 1937 | 1937 | } |
@@ -1945,7 +1945,7 @@ discard block |
||
| 1945 | 1945 | * @return array The Fees |
| 1946 | 1946 | */ |
| 1947 | 1947 | private function setup_fees() { |
| 1948 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1948 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1949 | 1949 | |
| 1950 | 1950 | return $payment_fees; |
| 1951 | 1951 | } |
@@ -1959,7 +1959,7 @@ discard block |
||
| 1959 | 1959 | * @return string The gateway |
| 1960 | 1960 | */ |
| 1961 | 1961 | private function setup_gateway() { |
| 1962 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
| 1962 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
| 1963 | 1963 | |
| 1964 | 1964 | return $gateway; |
| 1965 | 1965 | } |
@@ -1973,11 +1973,11 @@ discard block |
||
| 1973 | 1973 | * @return string The donation ID |
| 1974 | 1974 | */ |
| 1975 | 1975 | private function setup_transaction_id() { |
| 1976 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
| 1976 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
| 1977 | 1977 | |
| 1978 | - if ( empty( $transaction_id ) ) { |
|
| 1978 | + if (empty($transaction_id)) { |
|
| 1979 | 1979 | $gateway = $this->gateway; |
| 1980 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
| 1980 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | return $transaction_id; |
@@ -1992,7 +1992,7 @@ discard block |
||
| 1992 | 1992 | * @return string The IP address for the payment |
| 1993 | 1993 | */ |
| 1994 | 1994 | private function setup_ip() { |
| 1995 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
| 1995 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
| 1996 | 1996 | |
| 1997 | 1997 | return $ip; |
| 1998 | 1998 | } |
@@ -2006,7 +2006,7 @@ discard block |
||
| 2006 | 2006 | * @return int The Customer ID |
| 2007 | 2007 | */ |
| 2008 | 2008 | private function setup_customer_id() { |
| 2009 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
| 2009 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
| 2010 | 2010 | |
| 2011 | 2011 | return $customer_id; |
| 2012 | 2012 | } |
@@ -2020,7 +2020,7 @@ discard block |
||
| 2020 | 2020 | * @return int The User ID |
| 2021 | 2021 | */ |
| 2022 | 2022 | private function setup_user_id() { |
| 2023 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
| 2023 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
| 2024 | 2024 | |
| 2025 | 2025 | return $user_id; |
| 2026 | 2026 | } |
@@ -2034,10 +2034,10 @@ discard block |
||
| 2034 | 2034 | * @return string The email address for the payment |
| 2035 | 2035 | */ |
| 2036 | 2036 | private function setup_email() { |
| 2037 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
| 2037 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
| 2038 | 2038 | |
| 2039 | - if ( empty( $email ) ) { |
|
| 2040 | - $email = Give()->customers->get_column( 'email', $this->customer_id ); |
|
| 2039 | + if (empty($email)) { |
|
| 2040 | + $email = Give()->customers->get_column('email', $this->customer_id); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | return $email; |
@@ -2057,15 +2057,15 @@ discard block |
||
| 2057 | 2057 | 'last_name' => $this->last_name, |
| 2058 | 2058 | ); |
| 2059 | 2059 | |
| 2060 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
| 2061 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 2060 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
| 2061 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 2062 | 2062 | |
| 2063 | - if ( empty( $user_info ) ) { |
|
| 2063 | + if (empty($user_info)) { |
|
| 2064 | 2064 | // Get the customer, but only if it's been created. |
| 2065 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 2065 | + $customer = new Give_Customer($this->customer_id); |
|
| 2066 | 2066 | |
| 2067 | - if ( $customer->id > 0 ) { |
|
| 2068 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2067 | + if ($customer->id > 0) { |
|
| 2068 | + $name = explode(' ', $customer->name, 2); |
|
| 2069 | 2069 | $user_info = array( |
| 2070 | 2070 | 'first_name' => $name[0], |
| 2071 | 2071 | 'last_name' => $name[1], |
@@ -2075,29 +2075,29 @@ discard block |
||
| 2075 | 2075 | } |
| 2076 | 2076 | } else { |
| 2077 | 2077 | // Get the customer, but only if it's been created. |
| 2078 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 2079 | - if ( $customer->id > 0 ) { |
|
| 2080 | - foreach ( $user_info as $key => $value ) { |
|
| 2081 | - if ( ! empty( $value ) ) { |
|
| 2078 | + $customer = new Give_Customer($this->customer_id); |
|
| 2079 | + if ($customer->id > 0) { |
|
| 2080 | + foreach ($user_info as $key => $value) { |
|
| 2081 | + if ( ! empty($value)) { |
|
| 2082 | 2082 | continue; |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | - switch ( $key ) { |
|
| 2085 | + switch ($key) { |
|
| 2086 | 2086 | case 'first_name': |
| 2087 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2087 | + $name = explode(' ', $customer->name, 2); |
|
| 2088 | 2088 | |
| 2089 | - $user_info[ $key ] = $name[0]; |
|
| 2089 | + $user_info[$key] = $name[0]; |
|
| 2090 | 2090 | break; |
| 2091 | 2091 | |
| 2092 | 2092 | case 'last_name': |
| 2093 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2094 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
| 2093 | + $name = explode(' ', $customer->name, 2); |
|
| 2094 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
| 2095 | 2095 | |
| 2096 | - $user_info[ $key ] = $last_name; |
|
| 2096 | + $user_info[$key] = $last_name; |
|
| 2097 | 2097 | break; |
| 2098 | 2098 | |
| 2099 | 2099 | case 'email': |
| 2100 | - $user_info[ $key ] = $customer->email; |
|
| 2100 | + $user_info[$key] = $customer->email; |
|
| 2101 | 2101 | break; |
| 2102 | 2102 | } |
| 2103 | 2103 | } |
@@ -2118,7 +2118,7 @@ discard block |
||
| 2118 | 2118 | */ |
| 2119 | 2119 | private function setup_address() { |
| 2120 | 2120 | |
| 2121 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2121 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2122 | 2122 | 'line1' => '', |
| 2123 | 2123 | 'line2' => '', |
| 2124 | 2124 | 'city' => '', |
@@ -2140,7 +2140,7 @@ discard block |
||
| 2140 | 2140 | */ |
| 2141 | 2141 | private function setup_form_title() { |
| 2142 | 2142 | |
| 2143 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
| 2143 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
| 2144 | 2144 | |
| 2145 | 2145 | return $form_id; |
| 2146 | 2146 | } |
@@ -2155,7 +2155,7 @@ discard block |
||
| 2155 | 2155 | */ |
| 2156 | 2156 | private function setup_form_id() { |
| 2157 | 2157 | |
| 2158 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
| 2158 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
| 2159 | 2159 | |
| 2160 | 2160 | return $form_id; |
| 2161 | 2161 | } |
@@ -2169,7 +2169,7 @@ discard block |
||
| 2169 | 2169 | * @return int The Form Price ID |
| 2170 | 2170 | */ |
| 2171 | 2171 | private function setup_price_id() { |
| 2172 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
| 2172 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
| 2173 | 2173 | |
| 2174 | 2174 | return $price_id; |
| 2175 | 2175 | } |
@@ -2183,7 +2183,7 @@ discard block |
||
| 2183 | 2183 | * @return string The Payment Key |
| 2184 | 2184 | */ |
| 2185 | 2185 | private function setup_payment_key() { |
| 2186 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
| 2186 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
| 2187 | 2187 | |
| 2188 | 2188 | return $key; |
| 2189 | 2189 | } |
@@ -2199,11 +2199,11 @@ discard block |
||
| 2199 | 2199 | private function setup_payment_number() { |
| 2200 | 2200 | $number = $this->ID; |
| 2201 | 2201 | |
| 2202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 2202 | + if (give_get_option('enable_sequential')) { |
|
| 2203 | 2203 | |
| 2204 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
| 2204 | + $number = $this->get_meta('_give_payment_number', true); |
|
| 2205 | 2205 | |
| 2206 | - if ( ! $number ) { |
|
| 2206 | + if ( ! $number) { |
|
| 2207 | 2207 | |
| 2208 | 2208 | $number = $this->ID; |
| 2209 | 2209 | |
@@ -2221,7 +2221,7 @@ discard block |
||
| 2221 | 2221 | * @return array The payment object as an array |
| 2222 | 2222 | */ |
| 2223 | 2223 | public function array_convert() { |
| 2224 | - return get_object_vars( $this ); |
|
| 2224 | + return get_object_vars($this); |
|
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | |
@@ -2234,7 +2234,7 @@ discard block |
||
| 2234 | 2234 | * @return bool |
| 2235 | 2235 | */ |
| 2236 | 2236 | public function is_completed() { |
| 2237 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
| 2237 | + return ('publish' === $this->status && $this->completed_date); |
|
| 2238 | 2238 | } |
| 2239 | 2239 | |
| 2240 | 2240 | /** |
@@ -2246,7 +2246,7 @@ discard block |
||
| 2246 | 2246 | * @return string Date payment was completed |
| 2247 | 2247 | */ |
| 2248 | 2248 | private function get_completed_date() { |
| 2249 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 2249 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
| 2250 | 2250 | } |
| 2251 | 2251 | |
| 2252 | 2252 | /** |
@@ -2258,7 +2258,7 @@ discard block |
||
| 2258 | 2258 | * @return float Payment subtotal |
| 2259 | 2259 | */ |
| 2260 | 2260 | private function get_subtotal() { |
| 2261 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
| 2261 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
| 2262 | 2262 | } |
| 2263 | 2263 | |
| 2264 | 2264 | /** |
@@ -2270,7 +2270,7 @@ discard block |
||
| 2270 | 2270 | * @return string Payment currency code |
| 2271 | 2271 | */ |
| 2272 | 2272 | private function get_currency() { |
| 2273 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
| 2273 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | /** |
@@ -2282,7 +2282,7 @@ discard block |
||
| 2282 | 2282 | * @return string Gateway used |
| 2283 | 2283 | */ |
| 2284 | 2284 | private function get_gateway() { |
| 2285 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
| 2285 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
| 2286 | 2286 | } |
| 2287 | 2287 | |
| 2288 | 2288 | /** |
@@ -2294,7 +2294,7 @@ discard block |
||
| 2294 | 2294 | * @return string Donation ID from merchant processor |
| 2295 | 2295 | */ |
| 2296 | 2296 | private function get_transaction_id() { |
| 2297 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 2297 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 2298 | 2298 | } |
| 2299 | 2299 | |
| 2300 | 2300 | /** |
@@ -2306,7 +2306,7 @@ discard block |
||
| 2306 | 2306 | * @return string Payment IP address |
| 2307 | 2307 | */ |
| 2308 | 2308 | private function get_ip() { |
| 2309 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
| 2309 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | 2312 | /** |
@@ -2318,7 +2318,7 @@ discard block |
||
| 2318 | 2318 | * @return int Payment customer ID |
| 2319 | 2319 | */ |
| 2320 | 2320 | private function get_customer_id() { |
| 2321 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
| 2321 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
| 2322 | 2322 | } |
| 2323 | 2323 | |
| 2324 | 2324 | /** |
@@ -2330,7 +2330,7 @@ discard block |
||
| 2330 | 2330 | * @return int Payment user ID |
| 2331 | 2331 | */ |
| 2332 | 2332 | private function get_user_id() { |
| 2333 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
| 2333 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
| 2334 | 2334 | } |
| 2335 | 2335 | |
| 2336 | 2336 | /** |
@@ -2342,7 +2342,7 @@ discard block |
||
| 2342 | 2342 | * @return string Payment customer email |
| 2343 | 2343 | */ |
| 2344 | 2344 | private function get_email() { |
| 2345 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
| 2345 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
| 2346 | 2346 | } |
| 2347 | 2347 | |
| 2348 | 2348 | /** |
@@ -2354,7 +2354,7 @@ discard block |
||
| 2354 | 2354 | * @return array Payment user info |
| 2355 | 2355 | */ |
| 2356 | 2356 | private function get_user_info() { |
| 2357 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
| 2357 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
| 2358 | 2358 | } |
| 2359 | 2359 | |
| 2360 | 2360 | /** |
@@ -2366,7 +2366,7 @@ discard block |
||
| 2366 | 2366 | * @return array Payment billing address |
| 2367 | 2367 | */ |
| 2368 | 2368 | private function get_address() { |
| 2369 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
| 2369 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
| 2370 | 2370 | } |
| 2371 | 2371 | |
| 2372 | 2372 | /** |
@@ -2378,7 +2378,7 @@ discard block |
||
| 2378 | 2378 | * @return string Payment key |
| 2379 | 2379 | */ |
| 2380 | 2380 | private function get_key() { |
| 2381 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
| 2381 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
| 2382 | 2382 | } |
| 2383 | 2383 | |
| 2384 | 2384 | /** |
@@ -2390,7 +2390,7 @@ discard block |
||
| 2390 | 2390 | * @return string Payment form id |
| 2391 | 2391 | */ |
| 2392 | 2392 | private function get_form_id() { |
| 2393 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
| 2393 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
| 2394 | 2394 | } |
| 2395 | 2395 | |
| 2396 | 2396 | /** |
@@ -2402,7 +2402,7 @@ discard block |
||
| 2402 | 2402 | * @return int|string Payment number |
| 2403 | 2403 | */ |
| 2404 | 2404 | private function get_number() { |
| 2405 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
| 2405 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
| 2406 | 2406 | } |
| 2407 | 2407 | |
| 2408 | 2408 | } |
@@ -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 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | 25 | function give_get_price_decimals() { |
| 26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
| 26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed |
| 35 | 35 | */ |
| 36 | 36 | function give_get_price_thousand_separator() { |
| 37 | - return give_get_option( 'thousands_separator', ',' ); |
|
| 37 | + return give_get_option('thousands_separator', ','); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return mixed |
| 46 | 46 | */ |
| 47 | 47 | function give_get_price_decimal_separator() { |
| 48 | - return give_get_option( 'decimal_separator', '.' ); |
|
| 48 | + return give_get_option('decimal_separator', '.'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -61,67 +61,67 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return string $amount Newly sanitized amount |
| 63 | 63 | */ |
| 64 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
| 64 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
| 65 | 65 | |
| 66 | 66 | // Bailout. |
| 67 | - if ( empty( $number ) ) { |
|
| 67 | + if (empty($number)) { |
|
| 68 | 68 | return $number; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Remove slash from amount. |
| 72 | 72 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
| 73 | 73 | // To prevent notices and warning remove slash from amount/number. |
| 74 | - $number = wp_unslash( $number ); |
|
| 74 | + $number = wp_unslash($number); |
|
| 75 | 75 | |
| 76 | 76 | $thousand_separator = give_get_price_thousand_separator(); |
| 77 | 77 | |
| 78 | 78 | $locale = localeconv(); |
| 79 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
| 79 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
| 80 | 80 | |
| 81 | 81 | // Remove locale from string |
| 82 | - if ( ! is_float( $number ) ) { |
|
| 83 | - $number = str_replace( $decimals, '.', $number ); |
|
| 82 | + if ( ! is_float($number)) { |
|
| 83 | + $number = str_replace($decimals, '.', $number); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Remove thousand amount formatting if amount has. |
| 87 | 87 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
| 88 | 88 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
| 89 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 90 | - $number = str_replace( $thousand_separator, '', $number ); |
|
| 91 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
| 92 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
| 89 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
| 90 | + $number = str_replace($thousand_separator, '', $number); |
|
| 91 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
| 92 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Remove non numeric entity before decimal separator. |
| 96 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 96 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
| 97 | 97 | $default_dp = give_get_price_decimals(); |
| 98 | 98 | |
| 99 | 99 | // Reset negative amount to zero. |
| 100 | - if ( 0 > $number ) { |
|
| 101 | - $number = number_format( 0, $default_dp, '.' ); |
|
| 100 | + if (0 > $number) { |
|
| 101 | + $number = number_format(0, $default_dp, '.'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // If number does not have decimal then add number of decimals to it. |
| 105 | 105 | if ( |
| 106 | - false === strpos( $number, '.' ) |
|
| 107 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
| 106 | + false === strpos($number, '.') |
|
| 107 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
| 108 | 108 | ) { |
| 109 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
| 109 | + $number = number_format($number, $default_dp, '.', ''); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Format number by custom number of decimals. |
| 113 | - if ( false !== $dp ) { |
|
| 114 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
| 115 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 116 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 113 | + if (false !== $dp) { |
|
| 114 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
| 115 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
| 116 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Trim zeros. |
| 120 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
| 121 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 120 | + if ($trim_zeros && strstr($number, '.')) { |
|
| 121 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
| 124 | + return apply_filters('give_sanitize_amount', $number); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -134,22 +134,22 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return string $amount Newly formatted amount or Price Not Available |
| 136 | 136 | */ |
| 137 | -function give_format_amount( $amount, $decimals = true ) { |
|
| 138 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
| 139 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
| 137 | +function give_format_amount($amount, $decimals = true) { |
|
| 138 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
| 139 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
| 140 | 140 | |
| 141 | - if ( empty( $amount ) ) { |
|
| 141 | + if (empty($amount)) { |
|
| 142 | 142 | $amount = 0; |
| 143 | 143 | } else { |
| 144 | 144 | // Sanitize amount before formatting. |
| 145 | - $amount = give_sanitize_amount( $amount ); |
|
| 145 | + $amount = give_sanitize_amount($amount); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $decimals = $decimals ? give_get_price_decimals() : 0; |
| 149 | 149 | |
| 150 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 150 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 151 | 151 | |
| 152 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 152 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -166,33 +166,33 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return float|string formatted amount number with large number names. |
| 168 | 168 | */ |
| 169 | -function give_human_format_large_amount( $amount ) { |
|
| 169 | +function give_human_format_large_amount($amount) { |
|
| 170 | 170 | |
| 171 | 171 | // Get thousand separator. |
| 172 | 172 | $thousands_sep = give_get_price_thousand_separator(); |
| 173 | 173 | |
| 174 | 174 | // Sanitize amount. |
| 175 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
| 175 | + $sanitize_amount = give_sanitize_amount($amount); |
|
| 176 | 176 | |
| 177 | 177 | // Explode amount to calculate name of large numbers. |
| 178 | - $amount_array = explode( $thousands_sep, $amount ); |
|
| 178 | + $amount_array = explode($thousands_sep, $amount); |
|
| 179 | 179 | |
| 180 | 180 | // Calculate amount parts count. |
| 181 | - $amount_count_parts = count( $amount_array ); |
|
| 181 | + $amount_count_parts = count($amount_array); |
|
| 182 | 182 | |
| 183 | 183 | // Human format amount (default). |
| 184 | 184 | $human_format_amount = $amount; |
| 185 | 185 | |
| 186 | 186 | // Calculate large number formatted amount. |
| 187 | - if ( 4 < $amount_count_parts ) { |
|
| 188 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
| 189 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 190 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 191 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 192 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
| 187 | + if (4 < $amount_count_parts) { |
|
| 188 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
| 189 | + } elseif (3 < $amount_count_parts) { |
|
| 190 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 191 | + } elseif (2 < $amount_count_parts) { |
|
| 192 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
| 195 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return string $amount Newly formatted amount or Price Not Available |
| 207 | 207 | */ |
| 208 | -function give_format_decimal( $amount, $dp = false ) { |
|
| 208 | +function give_format_decimal($amount, $dp = false) { |
|
| 209 | 209 | $decimal_separator = give_get_price_decimal_separator(); |
| 210 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
| 210 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
| 211 | 211 | |
| 212 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 213 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 212 | + if (false !== strpos($formatted_amount, '.')) { |
|
| 213 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 216 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return mixed|string |
| 228 | 228 | */ |
| 229 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
| 229 | +function give_currency_filter($price = '', $currency = '') { |
|
| 230 | 230 | |
| 231 | - if ( empty( $currency ) ) { |
|
| 231 | + if (empty($currency)) { |
|
| 232 | 232 | $currency = give_get_currency(); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $position = give_get_option( 'currency_position', 'before' ); |
|
| 235 | + $position = give_get_option('currency_position', 'before'); |
|
| 236 | 236 | |
| 237 | 237 | $negative = $price < 0; |
| 238 | 238 | |
| 239 | - if ( $negative ) { |
|
| 239 | + if ($negative) { |
|
| 240 | 240 | // Remove proceeding "-". |
| 241 | - $price = substr( $price, 1 ); |
|
| 241 | + $price = substr($price, 1); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - $symbol = give_currency_symbol( $currency ); |
|
| 244 | + $symbol = give_currency_symbol($currency); |
|
| 245 | 245 | |
| 246 | - switch ( $currency ) : |
|
| 246 | + switch ($currency) : |
|
| 247 | 247 | case 'GBP' : |
| 248 | 248 | case 'BRL' : |
| 249 | 249 | case 'EUR' : |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | case 'MAD' : |
| 273 | 273 | case 'KRW' : |
| 274 | 274 | case 'ZAR' : |
| 275 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
| 275 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
| 276 | 276 | break; |
| 277 | 277 | case 'NOK' : |
| 278 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
| 278 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
| 279 | 279 | break; |
| 280 | 280 | default : |
| 281 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
| 281 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
| 282 | 282 | break; |
| 283 | 283 | endswitch; |
| 284 | 284 | |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | * and if currency is USD and currency position is after then |
| 294 | 294 | * filter name will be give_usd_currency_filter_after |
| 295 | 295 | */ |
| 296 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
| 296 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
| 297 | 297 | |
| 298 | - if ( $negative ) { |
|
| 298 | + if ($negative) { |
|
| 299 | 299 | // Prepend the minus sign before the currency sign. |
| 300 | - $formatted = '-' . $formatted; |
|
| 300 | + $formatted = '-'.$formatted; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | return $formatted; |
@@ -313,21 +313,21 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function give_currency_decimal_filter() { |
| 315 | 315 | |
| 316 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 316 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 317 | 317 | |
| 318 | 318 | // Set default number of decimals. |
| 319 | 319 | $decimals = give_get_price_decimals(); |
| 320 | 320 | |
| 321 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 321 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 322 | 322 | |
| 323 | 323 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
| 324 | - if ( 1 <= func_num_args() ) { |
|
| 325 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
| 324 | + if (1 <= func_num_args()) { |
|
| 325 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | $currency = give_get_currency(); |
| 329 | 329 | |
| 330 | - switch ( $currency ) { |
|
| 330 | + switch ($currency) { |
|
| 331 | 331 | case 'RIAL' : |
| 332 | 332 | case 'JPY' : |
| 333 | 333 | case 'TWD' : |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | break; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
| 340 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 344 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 343 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 344 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * |
| 354 | 354 | * @return string Date format string |
| 355 | 355 | */ |
| 356 | -function give_date_format( $date_context = '' ) { |
|
| 356 | +function give_date_format($date_context = '') { |
|
| 357 | 357 | /** |
| 358 | 358 | * Filter the date context |
| 359 | 359 | * |
@@ -374,19 +374,19 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * } |
| 376 | 376 | */ |
| 377 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
| 377 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
| 378 | 378 | |
| 379 | 379 | // Set date format to default date format. |
| 380 | - $date_format = get_option( 'date_format' ); |
|
| 380 | + $date_format = get_option('date_format'); |
|
| 381 | 381 | |
| 382 | 382 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
| 383 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
| 384 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
| 385 | - ? $date_format_contexts[ $date_context ] |
|
| 383 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
| 384 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
| 385 | + ? $date_format_contexts[$date_context] |
|
| 386 | 386 | : $date_format; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - return apply_filters( 'give_date_format', $date_format ); |
|
| 389 | + return apply_filters('give_date_format', $date_format); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return string |
| 402 | 402 | */ |
| 403 | -function give_get_cache_key( $action, $query_args ) { |
|
| 404 | - return Give_Cache::get_key( $action, $query_args ); |
|
| 403 | +function give_get_cache_key($action, $query_args) { |
|
| 404 | + return Give_Cache::get_key($action, $query_args); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | * |
| 415 | 415 | * @return string|array |
| 416 | 416 | */ |
| 417 | -function give_clean( $var ) { |
|
| 418 | - if ( is_array( $var ) ) { |
|
| 419 | - return array_map( 'give_clean', $var ); |
|
| 417 | +function give_clean($var) { |
|
| 418 | + if (is_array($var)) { |
|
| 419 | + return array_map('give_clean', $var); |
|
| 420 | 420 | } else { |
| 421 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 421 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | * |
| 432 | 432 | * @return int |
| 433 | 433 | */ |
| 434 | -function give_let_to_num( $size ) { |
|
| 435 | - $l = substr( $size, - 1 ); |
|
| 436 | - $ret = substr( $size, 0, - 1 ); |
|
| 437 | - switch ( strtoupper( $l ) ) { |
|
| 434 | +function give_let_to_num($size) { |
|
| 435 | + $l = substr($size, - 1); |
|
| 436 | + $ret = substr($size, 0, - 1); |
|
| 437 | + switch (strtoupper($l)) { |
|
| 438 | 438 | case 'P': |
| 439 | 439 | $ret *= 1024; |
| 440 | 440 | case 'T': |
@@ -459,17 +459,17 @@ discard block |
||
| 459 | 459 | * @param int $action |
| 460 | 460 | * @param array $wp_die_args |
| 461 | 461 | */ |
| 462 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
| 462 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
| 463 | 463 | |
| 464 | 464 | $default_wp_die_args = array( |
| 465 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
| 466 | - 'title' => esc_html__( 'Error', 'give' ), |
|
| 467 | - 'args' => array( 'response' => 403 ), |
|
| 465 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
| 466 | + 'title' => esc_html__('Error', 'give'), |
|
| 467 | + 'args' => array('response' => 403), |
|
| 468 | 468 | ); |
| 469 | 469 | |
| 470 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
| 470 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
| 471 | 471 | |
| 472 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
| 472 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
| 473 | 473 | wp_die( |
| 474 | 474 | $wp_die_args['message'], |
| 475 | 475 | $wp_die_args['title'], |
@@ -491,23 +491,23 @@ discard block |
||
| 491 | 491 | * |
| 492 | 492 | * @return mixed |
| 493 | 493 | */ |
| 494 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
| 494 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
| 495 | 495 | |
| 496 | - switch ( $conditional ) { |
|
| 496 | + switch ($conditional) { |
|
| 497 | 497 | case 'isset_empty': |
| 498 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
| 498 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
| 499 | 499 | break; |
| 500 | 500 | |
| 501 | 501 | case 'empty': |
| 502 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
| 502 | + $variable = ! empty($variable) ? $variable : $default; |
|
| 503 | 503 | break; |
| 504 | 504 | |
| 505 | 505 | case 'null': |
| 506 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
| 506 | + $variable = ! is_null($variable) ? $variable : $default; |
|
| 507 | 507 | break; |
| 508 | 508 | |
| 509 | 509 | default: |
| 510 | - $variable = isset( $variable ) ? $variable : $default; |
|
| 510 | + $variable = isset($variable) ? $variable : $default; |
|
| 511 | 511 | |
| 512 | 512 | } |
| 513 | 513 | |
@@ -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 | |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * @global $wpdb |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | -function give_install( $network_wide = false ) { |
|
| 29 | +function give_install($network_wide = false) { |
|
| 30 | 30 | |
| 31 | 31 | global $wpdb; |
| 32 | 32 | |
| 33 | - if ( is_multisite() && $network_wide ) { |
|
| 33 | + if (is_multisite() && $network_wide) { |
|
| 34 | 34 | |
| 35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
| 35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
| 36 | 36 | |
| 37 | - switch_to_blog( $blog_id ); |
|
| 37 | + switch_to_blog($blog_id); |
|
| 38 | 38 | give_run_install(); |
| 39 | 39 | restore_current_blog(); |
| 40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 51 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Run the Give Install process. |
@@ -64,24 +64,24 @@ discard block |
||
| 64 | 64 | give_setup_post_types(); |
| 65 | 65 | |
| 66 | 66 | // Clear the permalinks. |
| 67 | - flush_rewrite_rules( false ); |
|
| 67 | + flush_rewrite_rules(false); |
|
| 68 | 68 | |
| 69 | 69 | // Add Upgraded From Option. |
| 70 | - $current_version = get_option( 'give_version' ); |
|
| 71 | - if ( $current_version ) { |
|
| 72 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 70 | + $current_version = get_option('give_version'); |
|
| 71 | + if ($current_version) { |
|
| 72 | + update_option('give_version_upgraded_from', $current_version); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Setup some default options. |
| 76 | 76 | $options = array(); |
| 77 | 77 | |
| 78 | 78 | // Checks if the Success Page option exists AND that the page exists. |
| 79 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 79 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 80 | 80 | |
| 81 | 81 | // Donation Confirmation (Success) Page |
| 82 | 82 | $success = wp_insert_post( |
| 83 | 83 | array( |
| 84 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
| 84 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
| 85 | 85 | 'post_content' => '[give_receipt]', |
| 86 | 86 | 'post_status' => 'publish', |
| 87 | 87 | 'post_author' => 1, |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Checks if the Failure Page option exists AND that the page exists. |
| 98 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 98 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 99 | 99 | |
| 100 | 100 | // Failed Donation Page |
| 101 | 101 | $failed = wp_insert_post( |
| 102 | 102 | array( |
| 103 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
| 104 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
| 103 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
| 104 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
| 105 | 105 | 'post_status' => 'publish', |
| 106 | 106 | 'post_author' => 1, |
| 107 | 107 | 'post_type' => 'page', |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Checks if the History Page option exists AND that the page exists. |
| 116 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 116 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 117 | 117 | // Donation History Page |
| 118 | 118 | $history = wp_insert_post( |
| 119 | 119 | array( |
| 120 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
| 120 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
| 121 | 121 | 'post_content' => '[donation_history]', |
| 122 | 122 | 'post_status' => 'publish', |
| 123 | 123 | 'post_author' => 1, |
@@ -130,23 +130,23 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
| 133 | - if ( empty( $current_version ) ) { |
|
| 134 | - $options = array_merge( $options, give_get_default_settings() ); |
|
| 133 | + if (empty($current_version)) { |
|
| 134 | + $options = array_merge($options, give_get_default_settings()); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Populate the default values. |
| 138 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
| 138 | + update_option('give_settings', array_merge($give_options, $options)); |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Run plugin upgrades. |
| 142 | 142 | * |
| 143 | 143 | * @since 1.8 |
| 144 | 144 | */ |
| 145 | - do_action( 'give_upgrades' ); |
|
| 145 | + do_action('give_upgrades'); |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | - if( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
| 149 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 148 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
| 149 | + update_option('give_version', GIVE_VERSION); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Create Give roles. |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $roles->add_caps(); |
| 156 | 156 | |
| 157 | 157 | $api = new Give_API(); |
| 158 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
| 158 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
| 159 | 159 | |
| 160 | 160 | // Create the customers databases. |
| 161 | 161 | @Give()->customers->create_table(); |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | Give()->session->use_php_sessions(); |
| 166 | 166 | |
| 167 | 167 | // Add a temporary option to note that Give pages have been created. |
| 168 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
| 168 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
| 169 | 169 | |
| 170 | - if ( ! $current_version ) { |
|
| 170 | + if ( ! $current_version) { |
|
| 171 | 171 | |
| 172 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 172 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 173 | 173 | |
| 174 | 174 | // When new upgrade routines are added, mark them as complete on fresh install. |
| 175 | 175 | $upgrade_routines = array( |
@@ -180,22 +180,22 @@ discard block |
||
| 180 | 180 | 'v18_upgrades_form_metadata' |
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 184 | - give_set_upgrade_complete( $upgrade ); |
|
| 183 | + foreach ($upgrade_routines as $upgrade) { |
|
| 184 | + give_set_upgrade_complete($upgrade); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Bail if activating from network, or bulk. |
| 189 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 189 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 190 | 190 | return; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // Add the transient to redirect. |
| 194 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
| 194 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 198 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Network Activated New Site Setup. |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | * @param int $site_id The Site ID. |
| 212 | 212 | * @param array $meta Blog Meta. |
| 213 | 213 | */ |
| 214 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 214 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 215 | 215 | |
| 216 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
| 216 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
| 217 | 217 | |
| 218 | - switch_to_blog( $blog_id ); |
|
| 218 | + switch_to_blog($blog_id); |
|
| 219 | 219 | give_install(); |
| 220 | 220 | restore_current_blog(); |
| 221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
| 226 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -236,13 +236,13 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return array The tables to drop. |
| 238 | 238 | */ |
| 239 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
| 239 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
| 240 | 240 | |
| 241 | - switch_to_blog( $blog_id ); |
|
| 241 | + switch_to_blog($blog_id); |
|
| 242 | 242 | $customers_db = new Give_DB_Customers(); |
| 243 | 243 | $customer_meta_db = new Give_DB_Customer_Meta(); |
| 244 | 244 | |
| 245 | - if ( $customers_db->installed() ) { |
|
| 245 | + if ($customers_db->installed()) { |
|
| 246 | 246 | $tables[] = $customers_db->table_name; |
| 247 | 247 | $tables[] = $customer_meta_db->table_name; |
| 248 | 248 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
| 255 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Post-installation |
@@ -264,16 +264,16 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | function give_after_install() { |
| 266 | 266 | |
| 267 | - if ( ! is_admin() ) { |
|
| 267 | + if ( ! is_admin()) { |
|
| 268 | 268 | return; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
| 272 | - $give_table_check = get_option( '_give_table_check', false ); |
|
| 271 | + $give_options = Give_Cache::get('_give_installed', true); |
|
| 272 | + $give_table_check = get_option('_give_table_check', false); |
|
| 273 | 273 | |
| 274 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
| 274 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
| 275 | 275 | |
| 276 | - if ( ! @Give()->customer_meta->installed() ) { |
|
| 276 | + if ( ! @Give()->customer_meta->installed()) { |
|
| 277 | 277 | |
| 278 | 278 | // Create the customer meta database |
| 279 | 279 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if ( ! @Give()->customers->installed() ) { |
|
| 284 | + if ( ! @Give()->customers->installed()) { |
|
| 285 | 285 | // Create the customers database |
| 286 | 286 | // (this ensures it creates it on multisite instances where it is network activated). |
| 287 | 287 | @Give()->customers->create_table(); |
@@ -293,22 +293,22 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param array $give_options Give plugin options. |
| 295 | 295 | */ |
| 296 | - do_action( 'give_after_install', $give_options ); |
|
| 296 | + do_action('give_after_install', $give_options); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
| 299 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
| 300 | 300 | |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // Delete the transient |
| 304 | - if ( false !== $give_options ) { |
|
| 305 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
| 304 | + if (false !== $give_options) { |
|
| 305 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 311 | +add_action('admin_init', 'give_after_install'); |
|
| 312 | 312 | |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | global $wp_roles; |
| 325 | 325 | |
| 326 | - if ( ! is_object( $wp_roles ) ) { |
|
| 326 | + if ( ! is_object($wp_roles)) { |
|
| 327 | 327 | return; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 330 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 331 | 331 | |
| 332 | 332 | // Create Give plugin roles |
| 333 | 333 | $roles = new Give_Roles(); |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 341 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
| 342 | 342 | |
| 343 | 343 | /** |
| 344 | 344 | * Default core setting values. |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | 'paypal_verification' => 'enabled', |
| 379 | 379 | |
| 380 | 380 | // Default is manual gateway. |
| 381 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
| 381 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
| 382 | 382 | 'default_gateway' => 'manual', |
| 383 | 383 | |
| 384 | 384 | // Offline gateway setup. |
@@ -12,7 +12,7 @@ discard block |
||
| 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 | |
@@ -140,27 +140,27 @@ discard block |
||
| 140 | 140 | 'v1' => 'GIVE_API_V1', |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - foreach ( $this->get_versions() as $version => $class ) { |
|
| 144 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
| 143 | + foreach ($this->get_versions() as $version => $class) { |
|
| 144 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
| 148 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
| 149 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
| 150 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
| 151 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
| 152 | - add_action( 'personal_options_update', array( $this, 'update_key' ) ); |
|
| 153 | - add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); |
|
| 154 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
| 147 | + add_action('init', array($this, 'add_endpoint')); |
|
| 148 | + add_action('wp', array($this, 'process_query'), - 1); |
|
| 149 | + add_filter('query_vars', array($this, 'query_vars')); |
|
| 150 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
| 151 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
| 152 | + add_action('personal_options_update', array($this, 'update_key')); |
|
| 153 | + add_action('edit_user_profile_update', array($this, 'update_key')); |
|
| 154 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
| 155 | 155 | |
| 156 | 156 | // Setup a backwards compatibility check for user API Keys |
| 157 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
| 157 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
| 158 | 158 | |
| 159 | 159 | // Determine if JSON_PRETTY_PRINT is available |
| 160 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
| 160 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
| 161 | 161 | |
| 162 | 162 | // Allow API request logging to be turned off |
| 163 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
| 163 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
| 164 | 164 | |
| 165 | 165 | // Setup Give_Payment_Stats instance |
| 166 | 166 | $this->stats = new Give_Payment_Stats; |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @since 1.1 |
| 178 | 178 | */ |
| 179 | - public function add_endpoint( $rewrite_rules ) { |
|
| 180 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
| 179 | + public function add_endpoint($rewrite_rules) { |
|
| 180 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string[] $vars New query vars |
| 192 | 192 | */ |
| 193 | - public function query_vars( $vars ) { |
|
| 193 | + public function query_vars($vars) { |
|
| 194 | 194 | |
| 195 | 195 | $vars[] = 'token'; |
| 196 | 196 | $vars[] = 'key'; |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function get_default_version() { |
| 243 | 243 | |
| 244 | - $version = get_option( 'give_default_api_version' ); |
|
| 244 | + $version = get_option('give_default_api_version'); |
|
| 245 | 245 | |
| 246 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
| 246 | + if (defined('GIVE_API_VERSION')) { |
|
| 247 | 247 | $version = GIVE_API_VERSION; |
| 248 | - } elseif ( ! $version ) { |
|
| 248 | + } elseif ( ! $version) { |
|
| 249 | 249 | $version = 'v1'; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $version = $wp_query->query_vars['give-api']; |
| 268 | 268 | |
| 269 | - if ( strpos( $version, '/' ) ) { |
|
| 269 | + if (strpos($version, '/')) { |
|
| 270 | 270 | |
| 271 | - $version = explode( '/', $version ); |
|
| 272 | - $version = strtolower( $version[0] ); |
|
| 271 | + $version = explode('/', $version); |
|
| 272 | + $version = strtolower($version[0]); |
|
| 273 | 273 | |
| 274 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
| 274 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
| 275 | 275 | |
| 276 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
| 276 | + if (array_key_exists($version, $this->versions)) { |
|
| 277 | 277 | |
| 278 | 278 | $this->queried_version = $version; |
| 279 | 279 | |
@@ -309,32 +309,32 @@ discard block |
||
| 309 | 309 | $this->override = false; |
| 310 | 310 | |
| 311 | 311 | // Make sure we have both user and api key |
| 312 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
| 312 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
| 313 | 313 | |
| 314 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
| 314 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
| 315 | 315 | $this->missing_auth(); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Retrieve the user by public API key and ensure they exist |
| 319 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
| 319 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
| 320 | 320 | |
| 321 | 321 | $this->invalid_key(); |
| 322 | 322 | |
| 323 | 323 | } else { |
| 324 | 324 | |
| 325 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
| 326 | - $secret = $this->get_user_secret_key( $user ); |
|
| 327 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
| 325 | + $token = urldecode($wp_query->query_vars['token']); |
|
| 326 | + $secret = $this->get_user_secret_key($user); |
|
| 327 | + $public = urldecode($wp_query->query_vars['key']); |
|
| 328 | 328 | |
| 329 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
| 329 | + if (hash_equals(md5($secret.$public), $token)) { |
|
| 330 | 330 | $this->is_valid_request = true; |
| 331 | 331 | } else { |
| 332 | 332 | $this->invalid_auth(); |
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) { |
|
| 335 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') { |
|
| 336 | 336 | $this->is_valid_request = true; |
| 337 | - $wp_query->set( 'key', 'public' ); |
|
| 337 | + $wp_query->set('key', 'public'); |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
@@ -350,25 +350,25 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @return bool if user ID is found, false otherwise |
| 352 | 352 | */ |
| 353 | - public function get_user( $key = '' ) { |
|
| 353 | + public function get_user($key = '') { |
|
| 354 | 354 | global $wpdb, $wp_query; |
| 355 | 355 | |
| 356 | - if ( empty( $key ) ) { |
|
| 357 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
| 356 | + if (empty($key)) { |
|
| 357 | + $key = urldecode($wp_query->query_vars['key']); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if ( empty( $key ) ) { |
|
| 360 | + if (empty($key)) { |
|
| 361 | 361 | return false; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); |
|
| 364 | + $user = Give_Cache::get(md5('give_api_user_'.$key), true); |
|
| 365 | 365 | |
| 366 | - if ( false === $user ) { |
|
| 367 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
| 368 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); |
|
| 366 | + if (false === $user) { |
|
| 367 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
| 368 | + Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if ( $user != null ) { |
|
| 371 | + if ($user != null) { |
|
| 372 | 372 | $this->user_id = $user; |
| 373 | 373 | |
| 374 | 374 | return $user; |
@@ -377,37 +377,37 @@ discard block |
||
| 377 | 377 | return false; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - public function get_user_public_key( $user_id = 0 ) { |
|
| 380 | + public function get_user_public_key($user_id = 0) { |
|
| 381 | 381 | global $wpdb; |
| 382 | 382 | |
| 383 | - if ( empty( $user_id ) ) { |
|
| 383 | + if (empty($user_id)) { |
|
| 384 | 384 | return ''; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
| 388 | - $user_public_key = Give_Cache::get( $cache_key, true ); |
|
| 387 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
| 388 | + $user_public_key = Give_Cache::get($cache_key, true); |
|
| 389 | 389 | |
| 390 | - if ( empty( $user_public_key ) ) { |
|
| 391 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
| 392 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); |
|
| 390 | + if (empty($user_public_key)) { |
|
| 391 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
| 392 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | return $user_public_key; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - public function get_user_secret_key( $user_id = 0 ) { |
|
| 398 | + public function get_user_secret_key($user_id = 0) { |
|
| 399 | 399 | global $wpdb; |
| 400 | 400 | |
| 401 | - if ( empty( $user_id ) ) { |
|
| 401 | + if (empty($user_id)) { |
|
| 402 | 402 | return ''; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
| 406 | - $user_secret_key = Give_Cache::get( $cache_key, true ); |
|
| 405 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
| 406 | + $user_secret_key = Give_Cache::get($cache_key, true); |
|
| 407 | 407 | |
| 408 | - if ( empty( $user_secret_key ) ) { |
|
| 409 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
| 410 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); |
|
| 408 | + if (empty($user_secret_key)) { |
|
| 409 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
| 410 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | return $user_secret_key; |
@@ -423,10 +423,10 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | private function missing_auth() { |
| 425 | 425 | $error = array(); |
| 426 | - $error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' ); |
|
| 426 | + $error['error'] = esc_html__('You must specify both a token and API key.', 'give'); |
|
| 427 | 427 | |
| 428 | 428 | $this->data = $error; |
| 429 | - $this->output( 401 ); |
|
| 429 | + $this->output(401); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | private function invalid_auth() { |
| 442 | 442 | $error = array(); |
| 443 | - $error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' ); |
|
| 443 | + $error['error'] = esc_html__('Your request could not be authenticated.', 'give'); |
|
| 444 | 444 | |
| 445 | 445 | $this->data = $error; |
| 446 | - $this->output( 403 ); |
|
| 446 | + $this->output(403); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -457,10 +457,10 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | private function invalid_key() { |
| 459 | 459 | $error = array(); |
| 460 | - $error['error'] = esc_html__( 'Invalid API key.', 'give' ); |
|
| 460 | + $error['error'] = esc_html__('Invalid API key.', 'give'); |
|
| 461 | 461 | |
| 462 | 462 | $this->data = $error; |
| 463 | - $this->output( 403 ); |
|
| 463 | + $this->output(403); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
@@ -473,10 +473,10 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | private function invalid_version() { |
| 475 | 475 | $error = array(); |
| 476 | - $error['error'] = esc_html__( 'Invalid API version.', 'give' ); |
|
| 476 | + $error['error'] = esc_html__('Invalid API version.', 'give'); |
|
| 477 | 477 | |
| 478 | 478 | $this->data = $error; |
| 479 | - $this->output( 404 ); |
|
| 479 | + $this->output(404); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
@@ -492,10 +492,10 @@ discard block |
||
| 492 | 492 | global $wp_query; |
| 493 | 493 | |
| 494 | 494 | // Start logging how long the request takes for logging |
| 495 | - $before = microtime( true ); |
|
| 495 | + $before = microtime(true); |
|
| 496 | 496 | |
| 497 | 497 | // Check for give-api var. Get out if not present |
| 498 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
| 498 | + if (empty($wp_query->query_vars['give-api'])) { |
|
| 499 | 499 | return; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -509,45 +509,45 @@ discard block |
||
| 509 | 509 | $this->validate_request(); |
| 510 | 510 | |
| 511 | 511 | // Only proceed if no errors have been noted |
| 512 | - if ( ! $this->is_valid_request ) { |
|
| 512 | + if ( ! $this->is_valid_request) { |
|
| 513 | 513 | return; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
| 517 | - define( 'GIVE_DOING_API', true ); |
|
| 516 | + if ( ! defined('GIVE_DOING_API')) { |
|
| 517 | + define('GIVE_DOING_API', true); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | $data = array(); |
| 521 | 521 | $this->routes = new $this->versions[$this->get_queried_version()]; |
| 522 | 522 | $this->routes->validate_request(); |
| 523 | 523 | |
| 524 | - switch ( $this->endpoint ) : |
|
| 524 | + switch ($this->endpoint) : |
|
| 525 | 525 | |
| 526 | 526 | case 'stats' : |
| 527 | 527 | |
| 528 | - $data = $this->routes->get_stats( array( |
|
| 529 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
| 530 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
| 531 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
| 532 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
| 533 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
| 534 | - ) ); |
|
| 528 | + $data = $this->routes->get_stats(array( |
|
| 529 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
| 530 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
| 531 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
| 532 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
| 533 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
| 534 | + )); |
|
| 535 | 535 | |
| 536 | 536 | break; |
| 537 | 537 | |
| 538 | 538 | case 'forms' : |
| 539 | 539 | |
| 540 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
| 540 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
| 541 | 541 | |
| 542 | - $data = $this->routes->get_forms( $form ); |
|
| 542 | + $data = $this->routes->get_forms($form); |
|
| 543 | 543 | |
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | case 'donors' : |
| 547 | 547 | |
| 548 | - $customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
| 548 | + $customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
| 549 | 549 | |
| 550 | - $data = $this->routes->get_customers( $customer ); |
|
| 550 | + $data = $this->routes->get_customers($customer); |
|
| 551 | 551 | |
| 552 | 552 | break; |
| 553 | 553 | |
@@ -560,14 +560,14 @@ discard block |
||
| 560 | 560 | endswitch; |
| 561 | 561 | |
| 562 | 562 | // Allow extensions to setup their own return data |
| 563 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
| 563 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
| 564 | 564 | |
| 565 | - $after = microtime( true ); |
|
| 566 | - $request_time = ( $after - $before ); |
|
| 565 | + $after = microtime(true); |
|
| 566 | + $request_time = ($after - $before); |
|
| 567 | 567 | $this->data['request_speed'] = $request_time; |
| 568 | 568 | |
| 569 | 569 | // Log this API request, if enabled. We log it here because we have access to errors. |
| 570 | - $this->log_request( $this->data ); |
|
| 570 | + $this->log_request($this->data); |
|
| 571 | 571 | |
| 572 | 572 | // Send out data to the output function |
| 573 | 573 | $this->output(); |
@@ -597,25 +597,25 @@ discard block |
||
| 597 | 597 | global $wp_query; |
| 598 | 598 | |
| 599 | 599 | // Whitelist our query options |
| 600 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
| 600 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
| 601 | 601 | 'stats', |
| 602 | 602 | 'forms', |
| 603 | 603 | 'donors', |
| 604 | 604 | 'donations', |
| 605 | - ) ); |
|
| 605 | + )); |
|
| 606 | 606 | |
| 607 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
| 608 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
| 607 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
| 608 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
| 609 | 609 | |
| 610 | 610 | $error = array(); |
| 611 | 611 | |
| 612 | 612 | // Make sure our query is valid |
| 613 | - if ( ! in_array( $query, $accepted ) ) { |
|
| 614 | - $error['error'] = esc_html__( 'Invalid query.', 'give' ); |
|
| 613 | + if ( ! in_array($query, $accepted)) { |
|
| 614 | + $error['error'] = esc_html__('Invalid query.', 'give'); |
|
| 615 | 615 | |
| 616 | 616 | $this->data = $error; |
| 617 | 617 | // 400 is Bad Request |
| 618 | - $this->output( 400 ); |
|
| 618 | + $this->output(400); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | $this->endpoint = $query; |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | public function get_paged() { |
| 633 | 633 | global $wp_query; |
| 634 | 634 | |
| 635 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
| 635 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
@@ -647,13 +647,13 @@ discard block |
||
| 647 | 647 | public function per_page() { |
| 648 | 648 | global $wp_query; |
| 649 | 649 | |
| 650 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
| 650 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
| 651 | 651 | |
| 652 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
| 652 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
| 653 | 653 | $per_page = 99999999; |
| 654 | 654 | } // Customers query doesn't support -1 |
| 655 | 655 | |
| 656 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
| 656 | + return apply_filters('give_api_results_per_page', $per_page); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | * |
| 667 | 667 | * @return array $dates |
| 668 | 668 | */ |
| 669 | - public function get_dates( $args = array() ) { |
|
| 669 | + public function get_dates($args = array()) { |
|
| 670 | 670 | $dates = array(); |
| 671 | 671 | |
| 672 | 672 | $defaults = array( |
@@ -677,60 +677,60 @@ discard block |
||
| 677 | 677 | 'enddate' => null, |
| 678 | 678 | ); |
| 679 | 679 | |
| 680 | - $args = wp_parse_args( $args, $defaults ); |
|
| 680 | + $args = wp_parse_args($args, $defaults); |
|
| 681 | 681 | |
| 682 | - $current_time = current_time( 'timestamp' ); |
|
| 682 | + $current_time = current_time('timestamp'); |
|
| 683 | 683 | |
| 684 | - if ( 'range' === $args['date'] ) { |
|
| 685 | - $startdate = strtotime( $args['startdate'] ); |
|
| 686 | - $enddate = strtotime( $args['enddate'] ); |
|
| 687 | - $dates['day_start'] = date( 'd', $startdate ); |
|
| 688 | - $dates['day_end'] = date( 'd', $enddate ); |
|
| 689 | - $dates['m_start'] = date( 'n', $startdate ); |
|
| 690 | - $dates['m_end'] = date( 'n', $enddate ); |
|
| 691 | - $dates['year'] = date( 'Y', $startdate ); |
|
| 692 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
| 684 | + if ('range' === $args['date']) { |
|
| 685 | + $startdate = strtotime($args['startdate']); |
|
| 686 | + $enddate = strtotime($args['enddate']); |
|
| 687 | + $dates['day_start'] = date('d', $startdate); |
|
| 688 | + $dates['day_end'] = date('d', $enddate); |
|
| 689 | + $dates['m_start'] = date('n', $startdate); |
|
| 690 | + $dates['m_end'] = date('n', $enddate); |
|
| 691 | + $dates['year'] = date('Y', $startdate); |
|
| 692 | + $dates['year_end'] = date('Y', $enddate); |
|
| 693 | 693 | } else { |
| 694 | 694 | // Modify dates based on predefined ranges |
| 695 | - switch ( $args['date'] ) : |
|
| 695 | + switch ($args['date']) : |
|
| 696 | 696 | |
| 697 | 697 | case 'this_month' : |
| 698 | 698 | $dates['day'] = null; |
| 699 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 700 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 701 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 699 | + $dates['m_start'] = date('n', $current_time); |
|
| 700 | + $dates['m_end'] = date('n', $current_time); |
|
| 701 | + $dates['year'] = date('Y', $current_time); |
|
| 702 | 702 | break; |
| 703 | 703 | |
| 704 | 704 | case 'last_month' : |
| 705 | 705 | $dates['day'] = null; |
| 706 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
| 706 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
| 707 | 707 | $dates['m_end'] = $dates['m_start']; |
| 708 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
| 708 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
| 709 | 709 | break; |
| 710 | 710 | |
| 711 | 711 | case 'today' : |
| 712 | - $dates['day'] = date( 'd', $current_time ); |
|
| 713 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 714 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 715 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 712 | + $dates['day'] = date('d', $current_time); |
|
| 713 | + $dates['m_start'] = date('n', $current_time); |
|
| 714 | + $dates['m_end'] = date('n', $current_time); |
|
| 715 | + $dates['year'] = date('Y', $current_time); |
|
| 716 | 716 | break; |
| 717 | 717 | |
| 718 | 718 | case 'yesterday' : |
| 719 | 719 | |
| 720 | - $year = date( 'Y', $current_time ); |
|
| 721 | - $month = date( 'n', $current_time ); |
|
| 722 | - $day = date( 'd', $current_time ); |
|
| 720 | + $year = date('Y', $current_time); |
|
| 721 | + $month = date('n', $current_time); |
|
| 722 | + $day = date('d', $current_time); |
|
| 723 | 723 | |
| 724 | - if ( $month == 1 && $day == 1 ) { |
|
| 724 | + if ($month == 1 && $day == 1) { |
|
| 725 | 725 | |
| 726 | 726 | $year -= 1; |
| 727 | 727 | $month = 12; |
| 728 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 728 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 729 | 729 | |
| 730 | - } elseif ( $month > 1 && $day == 1 ) { |
|
| 730 | + } elseif ($month > 1 && $day == 1) { |
|
| 731 | 731 | |
| 732 | 732 | $month -= 1; |
| 733 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 733 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 734 | 734 | |
| 735 | 735 | } else { |
| 736 | 736 | |
@@ -746,65 +746,65 @@ discard block |
||
| 746 | 746 | break; |
| 747 | 747 | |
| 748 | 748 | case 'this_quarter' : |
| 749 | - $month_now = date( 'n', $current_time ); |
|
| 749 | + $month_now = date('n', $current_time); |
|
| 750 | 750 | |
| 751 | 751 | $dates['day'] = null; |
| 752 | 752 | |
| 753 | - if ( $month_now <= 3 ) { |
|
| 753 | + if ($month_now <= 3) { |
|
| 754 | 754 | |
| 755 | 755 | $dates['m_start'] = 1; |
| 756 | 756 | $dates['m_end'] = 3; |
| 757 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 757 | + $dates['year'] = date('Y', $current_time); |
|
| 758 | 758 | |
| 759 | - } elseif ( $month_now <= 6 ) { |
|
| 759 | + } elseif ($month_now <= 6) { |
|
| 760 | 760 | |
| 761 | 761 | $dates['m_start'] = 4; |
| 762 | 762 | $dates['m_end'] = 6; |
| 763 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 763 | + $dates['year'] = date('Y', $current_time); |
|
| 764 | 764 | |
| 765 | - } elseif ( $month_now <= 9 ) { |
|
| 765 | + } elseif ($month_now <= 9) { |
|
| 766 | 766 | |
| 767 | 767 | $dates['m_start'] = 7; |
| 768 | 768 | $dates['m_end'] = 9; |
| 769 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 769 | + $dates['year'] = date('Y', $current_time); |
|
| 770 | 770 | |
| 771 | 771 | } else { |
| 772 | 772 | |
| 773 | 773 | $dates['m_start'] = 10; |
| 774 | 774 | $dates['m_end'] = 12; |
| 775 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 775 | + $dates['year'] = date('Y', $current_time); |
|
| 776 | 776 | |
| 777 | 777 | } |
| 778 | 778 | break; |
| 779 | 779 | |
| 780 | 780 | case 'last_quarter' : |
| 781 | - $month_now = date( 'n', $current_time ); |
|
| 781 | + $month_now = date('n', $current_time); |
|
| 782 | 782 | |
| 783 | 783 | $dates['day'] = null; |
| 784 | 784 | |
| 785 | - if ( $month_now <= 3 ) { |
|
| 785 | + if ($month_now <= 3) { |
|
| 786 | 786 | |
| 787 | 787 | $dates['m_start'] = 10; |
| 788 | 788 | $dates['m_end'] = 12; |
| 789 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
| 789 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
| 790 | 790 | |
| 791 | - } elseif ( $month_now <= 6 ) { |
|
| 791 | + } elseif ($month_now <= 6) { |
|
| 792 | 792 | |
| 793 | 793 | $dates['m_start'] = 1; |
| 794 | 794 | $dates['m_end'] = 3; |
| 795 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 795 | + $dates['year'] = date('Y', $current_time); |
|
| 796 | 796 | |
| 797 | - } elseif ( $month_now <= 9 ) { |
|
| 797 | + } elseif ($month_now <= 9) { |
|
| 798 | 798 | |
| 799 | 799 | $dates['m_start'] = 4; |
| 800 | 800 | $dates['m_end'] = 6; |
| 801 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 801 | + $dates['year'] = date('Y', $current_time); |
|
| 802 | 802 | |
| 803 | 803 | } else { |
| 804 | 804 | |
| 805 | 805 | $dates['m_start'] = 7; |
| 806 | 806 | $dates['m_end'] = 9; |
| 807 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 807 | + $dates['year'] = date('Y', $current_time); |
|
| 808 | 808 | |
| 809 | 809 | } |
| 810 | 810 | break; |
@@ -813,14 +813,14 @@ discard block |
||
| 813 | 813 | $dates['day'] = null; |
| 814 | 814 | $dates['m_start'] = null; |
| 815 | 815 | $dates['m_end'] = null; |
| 816 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 816 | + $dates['year'] = date('Y', $current_time); |
|
| 817 | 817 | break; |
| 818 | 818 | |
| 819 | 819 | case 'last_year' : |
| 820 | 820 | $dates['day'] = null; |
| 821 | 821 | $dates['m_start'] = null; |
| 822 | 822 | $dates['m_end'] = null; |
| 823 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
| 823 | + $dates['year'] = date('Y', $current_time) - 1; |
|
| 824 | 824 | break; |
| 825 | 825 | |
| 826 | 826 | endswitch; |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | * |
| 834 | 834 | * @param array $dates The dates used for retrieving earnings/donations |
| 835 | 835 | */ |
| 836 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
| 836 | + return apply_filters('give_api_stat_dates', $dates); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -848,11 +848,11 @@ discard block |
||
| 848 | 848 | * |
| 849 | 849 | * @return array $customers Multidimensional array of the customers |
| 850 | 850 | */ |
| 851 | - public function get_customers( $customer = null ) { |
|
| 851 | + public function get_customers($customer = null) { |
|
| 852 | 852 | |
| 853 | 853 | $customers = array(); |
| 854 | 854 | $error = array(); |
| 855 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
| 855 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
| 856 | 856 | return $customers; |
| 857 | 857 | } |
| 858 | 858 | |
@@ -860,63 +860,63 @@ discard block |
||
| 860 | 860 | |
| 861 | 861 | $paged = $this->get_paged(); |
| 862 | 862 | $per_page = $this->per_page(); |
| 863 | - $offset = $per_page * ( $paged - 1 ); |
|
| 863 | + $offset = $per_page * ($paged - 1); |
|
| 864 | 864 | |
| 865 | - if ( is_numeric( $customer ) ) { |
|
| 865 | + if (is_numeric($customer)) { |
|
| 866 | 866 | $field = 'id'; |
| 867 | 867 | } else { |
| 868 | 868 | $field = 'email'; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $customer_query = Give()->customers->get_customers( array( |
|
| 871 | + $customer_query = Give()->customers->get_customers(array( |
|
| 872 | 872 | 'number' => $per_page, |
| 873 | 873 | 'offset' => $offset, |
| 874 | 874 | $field => $customer, |
| 875 | - ) ); |
|
| 875 | + )); |
|
| 876 | 876 | $customer_count = 0; |
| 877 | 877 | |
| 878 | - if ( $customer_query ) { |
|
| 878 | + if ($customer_query) { |
|
| 879 | 879 | |
| 880 | - foreach ( $customer_query as $customer_obj ) { |
|
| 880 | + foreach ($customer_query as $customer_obj) { |
|
| 881 | 881 | |
| 882 | - $names = explode( ' ', $customer_obj->name ); |
|
| 883 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
| 882 | + $names = explode(' ', $customer_obj->name); |
|
| 883 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
| 884 | 884 | $last_name = ''; |
| 885 | - if ( ! empty( $names[1] ) ) { |
|
| 886 | - unset( $names[0] ); |
|
| 887 | - $last_name = implode( ' ', $names ); |
|
| 885 | + if ( ! empty($names[1])) { |
|
| 886 | + unset($names[0]); |
|
| 887 | + $last_name = implode(' ', $names); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - $customers['donors'][ $customer_count ]['info']['user_id'] = ''; |
|
| 891 | - $customers['donors'][ $customer_count ]['info']['username'] = ''; |
|
| 892 | - $customers['donors'][ $customer_count ]['info']['display_name'] = ''; |
|
| 893 | - $customers['donors'][ $customer_count ]['info']['customer_id'] = $customer_obj->id; |
|
| 894 | - $customers['donors'][ $customer_count ]['info']['first_name'] = $first_name; |
|
| 895 | - $customers['donors'][ $customer_count ]['info']['last_name'] = $last_name; |
|
| 896 | - $customers['donors'][ $customer_count ]['info']['email'] = $customer_obj->email; |
|
| 890 | + $customers['donors'][$customer_count]['info']['user_id'] = ''; |
|
| 891 | + $customers['donors'][$customer_count]['info']['username'] = ''; |
|
| 892 | + $customers['donors'][$customer_count]['info']['display_name'] = ''; |
|
| 893 | + $customers['donors'][$customer_count]['info']['customer_id'] = $customer_obj->id; |
|
| 894 | + $customers['donors'][$customer_count]['info']['first_name'] = $first_name; |
|
| 895 | + $customers['donors'][$customer_count]['info']['last_name'] = $last_name; |
|
| 896 | + $customers['donors'][$customer_count]['info']['email'] = $customer_obj->email; |
|
| 897 | 897 | |
| 898 | - if ( ! empty( $customer_obj->user_id ) ) { |
|
| 898 | + if ( ! empty($customer_obj->user_id)) { |
|
| 899 | 899 | |
| 900 | - $user_data = get_userdata( $customer_obj->user_id ); |
|
| 900 | + $user_data = get_userdata($customer_obj->user_id); |
|
| 901 | 901 | |
| 902 | 902 | // Customer with registered account. |
| 903 | - $customers['donors'][ $customer_count ]['info']['user_id'] = $customer_obj->user_id; |
|
| 904 | - $customers['donors'][ $customer_count ]['info']['username'] = $user_data->user_login; |
|
| 905 | - $customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name; |
|
| 903 | + $customers['donors'][$customer_count]['info']['user_id'] = $customer_obj->user_id; |
|
| 904 | + $customers['donors'][$customer_count]['info']['username'] = $user_data->user_login; |
|
| 905 | + $customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name; |
|
| 906 | 906 | |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - $customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
| 910 | - $customers['donors'][ $customer_count ]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
| 909 | + $customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
| 910 | + $customers['donors'][$customer_count]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
| 911 | 911 | |
| 912 | - $customer_count ++; |
|
| 912 | + $customer_count++; |
|
| 913 | 913 | |
| 914 | 914 | } |
| 915 | - } elseif ( $customer ) { |
|
| 915 | + } elseif ($customer) { |
|
| 916 | 916 | |
| 917 | 917 | $error['error'] = sprintf( |
| 918 | 918 | /* translators: %s: customer */ |
| 919 | - esc_html__( 'Donor %s not found.', 'give' ), |
|
| 919 | + esc_html__('Donor %s not found.', 'give'), |
|
| 920 | 920 | $customer |
| 921 | 921 | ); |
| 922 | 922 | |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | |
| 925 | 925 | } else { |
| 926 | 926 | |
| 927 | - $error['error'] = esc_html__( 'No donors found.', 'give' ); |
|
| 927 | + $error['error'] = esc_html__('No donors found.', 'give'); |
|
| 928 | 928 | |
| 929 | 929 | return $error; |
| 930 | 930 | |
@@ -943,38 +943,38 @@ discard block |
||
| 943 | 943 | * |
| 944 | 944 | * @return array $customers Multidimensional array of the forms |
| 945 | 945 | */ |
| 946 | - public function get_forms( $form = null ) { |
|
| 946 | + public function get_forms($form = null) { |
|
| 947 | 947 | |
| 948 | 948 | $forms = array(); |
| 949 | 949 | $error = array(); |
| 950 | 950 | |
| 951 | - if ( $form == null ) { |
|
| 951 | + if ($form == null) { |
|
| 952 | 952 | $forms['forms'] = array(); |
| 953 | 953 | |
| 954 | - $form_list = get_posts( array( |
|
| 954 | + $form_list = get_posts(array( |
|
| 955 | 955 | 'post_type' => 'give_forms', |
| 956 | 956 | 'posts_per_page' => $this->per_page(), |
| 957 | 957 | 'suppress_filters' => true, |
| 958 | 958 | 'paged' => $this->get_paged(), |
| 959 | - ) ); |
|
| 959 | + )); |
|
| 960 | 960 | |
| 961 | - if ( $form_list ) { |
|
| 961 | + if ($form_list) { |
|
| 962 | 962 | $i = 0; |
| 963 | - foreach ( $form_list as $form_info ) { |
|
| 964 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
| 965 | - $i ++; |
|
| 963 | + foreach ($form_list as $form_info) { |
|
| 964 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
| 965 | + $i++; |
|
| 966 | 966 | } |
| 967 | 967 | } |
| 968 | 968 | } else { |
| 969 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
| 970 | - $form_info = get_post( $form ); |
|
| 969 | + if (get_post_type($form) == 'give_forms') { |
|
| 970 | + $form_info = get_post($form); |
|
| 971 | 971 | |
| 972 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
| 972 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
| 973 | 973 | |
| 974 | 974 | } else { |
| 975 | 975 | $error['error'] = sprintf( |
| 976 | 976 | /* translators: %s: form */ |
| 977 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 977 | + esc_html__('Form %s not found.', 'give'), |
|
| 978 | 978 | $form |
| 979 | 979 | ); |
| 980 | 980 | |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | * |
| 995 | 995 | * @return array Array of post data to return back in the API |
| 996 | 996 | */ |
| 997 | - private function get_form_data( $form_info ) { |
|
| 997 | + private function get_form_data($form_info) { |
|
| 998 | 998 | |
| 999 | 999 | $form = array(); |
| 1000 | 1000 | |
@@ -1004,50 +1004,50 @@ discard block |
||
| 1004 | 1004 | $form['info']['create_date'] = $form_info->post_date; |
| 1005 | 1005 | $form['info']['modified_date'] = $form_info->post_modified; |
| 1006 | 1006 | $form['info']['status'] = $form_info->post_status; |
| 1007 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
| 1008 | - $form['info']['content'] = get_post_meta( $form_info->ID, '_give_form_content', true ); |
|
| 1009 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
| 1007 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
| 1008 | + $form['info']['content'] = get_post_meta($form_info->ID, '_give_form_content', true); |
|
| 1009 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
| 1010 | 1010 | |
| 1011 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
| 1012 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
| 1013 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
| 1011 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
| 1012 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
| 1013 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
| 1014 | 1014 | } |
| 1015 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
| 1016 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
| 1015 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
| 1016 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
| 1020 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
| 1021 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
| 1022 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
| 1023 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
| 1019 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
| 1020 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
| 1021 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
| 1022 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
| 1023 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | $counter = 0; |
| 1027 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
| 1028 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
| 1029 | - $counter ++; |
|
| 1027 | + if (give_has_variable_prices($form_info->ID)) { |
|
| 1028 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
| 1029 | + $counter++; |
|
| 1030 | 1030 | // muli-level item |
| 1031 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
| 1032 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
| 1031 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
| 1032 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
| 1033 | 1033 | |
| 1034 | 1034 | } |
| 1035 | 1035 | } else { |
| 1036 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
| 1036 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
| 1039 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
| 1040 | 1040 | |
| 1041 | 1041 | /** |
| 1042 | 1042 | * Fires when generating API sensitive data. |
| 1043 | 1043 | * |
| 1044 | 1044 | * @since 1.1 |
| 1045 | 1045 | */ |
| 1046 | - do_action( 'give_api_sensitive_data' ); |
|
| 1046 | + do_action('give_api_sensitive_data'); |
|
| 1047 | 1047 | |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - return apply_filters( 'give_api_forms_form', $form ); |
|
| 1050 | + return apply_filters('give_api_forms_form', $form); |
|
| 1051 | 1051 | |
| 1052 | 1052 | } |
| 1053 | 1053 | |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | * |
| 1063 | 1063 | * @return array |
| 1064 | 1064 | */ |
| 1065 | - public function get_stats( $args = array() ) { |
|
| 1065 | + public function get_stats($args = array()) { |
|
| 1066 | 1066 | $defaults = array( |
| 1067 | 1067 | 'type' => null, |
| 1068 | 1068 | 'form' => null, |
@@ -1071,9 +1071,9 @@ discard block |
||
| 1071 | 1071 | 'enddate' => null, |
| 1072 | 1072 | ); |
| 1073 | 1073 | |
| 1074 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1074 | + $args = wp_parse_args($args, $defaults); |
|
| 1075 | 1075 | |
| 1076 | - $dates = $this->get_dates( $args ); |
|
| 1076 | + $dates = $this->get_dates($args); |
|
| 1077 | 1077 | |
| 1078 | 1078 | $stats = array(); |
| 1079 | 1079 | $earnings = array( |
@@ -1084,40 +1084,40 @@ discard block |
||
| 1084 | 1084 | ); |
| 1085 | 1085 | $error = array(); |
| 1086 | 1086 | |
| 1087 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
| 1087 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
| 1088 | 1088 | return $stats; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - if ( $args['type'] == 'donations' ) { |
|
| 1091 | + if ($args['type'] == 'donations') { |
|
| 1092 | 1092 | |
| 1093 | - if ( $args['form'] == null ) { |
|
| 1094 | - if ( $args['date'] == null ) { |
|
| 1093 | + if ($args['form'] == null) { |
|
| 1094 | + if ($args['date'] == null) { |
|
| 1095 | 1095 | $sales = $this->get_default_sales_stats(); |
| 1096 | - } elseif ( $args['date'] === 'range' ) { |
|
| 1096 | + } elseif ($args['date'] === 'range') { |
|
| 1097 | 1097 | // Return sales for a date range |
| 1098 | 1098 | // Ensure the end date is later than the start date |
| 1099 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
| 1100 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
| 1099 | + if ($args['enddate'] < $args['startdate']) { |
|
| 1100 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | // Ensure both the start and end date are specified |
| 1104 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
| 1105 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
| 1104 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
| 1105 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | $total = 0; |
| 1109 | 1109 | |
| 1110 | 1110 | // Loop through the years |
| 1111 | 1111 | $y = $dates['year']; |
| 1112 | - while ( $y <= $dates['year_end'] ) : |
|
| 1112 | + while ($y <= $dates['year_end']) : |
|
| 1113 | 1113 | |
| 1114 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1114 | + if ($dates['year'] == $dates['year_end']) { |
|
| 1115 | 1115 | $month_start = $dates['m_start']; |
| 1116 | 1116 | $month_end = $dates['m_end']; |
| 1117 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1117 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
| 1118 | 1118 | $month_start = $dates['m_start']; |
| 1119 | 1119 | $month_end = 12; |
| 1120 | - } elseif ( $y == $dates['year_end'] ) { |
|
| 1120 | + } elseif ($y == $dates['year_end']) { |
|
| 1121 | 1121 | $month_start = 1; |
| 1122 | 1122 | $month_end = $dates['m_end']; |
| 1123 | 1123 | } else { |
@@ -1126,112 +1126,112 @@ discard block |
||
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | $i = $month_start; |
| 1129 | - while ( $i <= $month_end ) : |
|
| 1129 | + while ($i <= $month_end) : |
|
| 1130 | 1130 | |
| 1131 | - if ( $i == $dates['m_start'] ) { |
|
| 1131 | + if ($i == $dates['m_start']) { |
|
| 1132 | 1132 | $d = $dates['day_start']; |
| 1133 | 1133 | } else { |
| 1134 | 1134 | $d = 1; |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - if ( $i == $dates['m_end'] ) { |
|
| 1137 | + if ($i == $dates['m_end']) { |
|
| 1138 | 1138 | $num_of_days = $dates['day_end']; |
| 1139 | 1139 | } else { |
| 1140 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1140 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | - while ( $d <= $num_of_days ) : |
|
| 1144 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
| 1145 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1146 | - if ( ! isset( $sales['sales'][ $date_key ] ) ) { |
|
| 1147 | - $sales['sales'][ $date_key ] = 0; |
|
| 1143 | + while ($d <= $num_of_days) : |
|
| 1144 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
| 1145 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
| 1146 | + if ( ! isset($sales['sales'][$date_key])) { |
|
| 1147 | + $sales['sales'][$date_key] = 0; |
|
| 1148 | 1148 | } |
| 1149 | - $sales['sales'][ $date_key ] += $sale_count; |
|
| 1149 | + $sales['sales'][$date_key] += $sale_count; |
|
| 1150 | 1150 | $total += $sale_count; |
| 1151 | - $d ++; |
|
| 1151 | + $d++; |
|
| 1152 | 1152 | endwhile; |
| 1153 | - $i ++; |
|
| 1153 | + $i++; |
|
| 1154 | 1154 | endwhile; |
| 1155 | 1155 | |
| 1156 | - $y ++; |
|
| 1156 | + $y++; |
|
| 1157 | 1157 | endwhile; |
| 1158 | 1158 | |
| 1159 | 1159 | $sales['totals'] = $total; |
| 1160 | 1160 | } else { |
| 1161 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
| 1161 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
| 1162 | 1162 | $sales_count = 0; |
| 1163 | 1163 | |
| 1164 | 1164 | // Loop through the months |
| 1165 | 1165 | $month = $dates['m_start']; |
| 1166 | 1166 | |
| 1167 | - while ( $month <= $dates['m_end'] ) : |
|
| 1168 | - $sales_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
| 1169 | - $month ++; |
|
| 1167 | + while ($month <= $dates['m_end']) : |
|
| 1168 | + $sales_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
| 1169 | + $month++; |
|
| 1170 | 1170 | endwhile; |
| 1171 | 1171 | |
| 1172 | - $sales['donations'][ $args['date'] ] = $sales_count; |
|
| 1172 | + $sales['donations'][$args['date']] = $sales_count; |
|
| 1173 | 1173 | } else { |
| 1174 | - $sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
| 1174 | + $sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | - } elseif ( $args['form'] == 'all' ) { |
|
| 1178 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
| 1177 | + } elseif ($args['form'] == 'all') { |
|
| 1178 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
| 1179 | 1179 | $i = 0; |
| 1180 | - foreach ( $forms as $form_info ) { |
|
| 1181 | - $sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) ); |
|
| 1182 | - $i ++; |
|
| 1180 | + foreach ($forms as $form_info) { |
|
| 1181 | + $sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID)); |
|
| 1182 | + $i++; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | } else { |
| 1185 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
| 1186 | - $form_info = get_post( $args['form'] ); |
|
| 1187 | - $sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) ); |
|
| 1185 | + if (get_post_type($args['form']) == 'give_forms') { |
|
| 1186 | + $form_info = get_post($args['form']); |
|
| 1187 | + $sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form'])); |
|
| 1188 | 1188 | } else { |
| 1189 | 1189 | $error['error'] = sprintf( |
| 1190 | 1190 | /* translators: %s: form */ |
| 1191 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 1191 | + esc_html__('Form %s not found.', 'give'), |
|
| 1192 | 1192 | $args['form'] |
| 1193 | 1193 | ); |
| 1194 | 1194 | } |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | - if ( ! empty( $error ) ) { |
|
| 1197 | + if ( ! empty($error)) { |
|
| 1198 | 1198 | return $error; |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | return $sales; |
| 1202 | 1202 | |
| 1203 | - } elseif ( $args['type'] == 'earnings' ) { |
|
| 1204 | - if ( $args['form'] == null ) { |
|
| 1205 | - if ( $args['date'] == null ) { |
|
| 1203 | + } elseif ($args['type'] == 'earnings') { |
|
| 1204 | + if ($args['form'] == null) { |
|
| 1205 | + if ($args['date'] == null) { |
|
| 1206 | 1206 | $earnings = $this->get_default_earnings_stats(); |
| 1207 | - } elseif ( $args['date'] === 'range' ) { |
|
| 1207 | + } elseif ($args['date'] === 'range') { |
|
| 1208 | 1208 | // Return sales for a date range |
| 1209 | 1209 | // Ensure the end date is later than the start date |
| 1210 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
| 1211 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
| 1210 | + if ($args['enddate'] < $args['startdate']) { |
|
| 1211 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | // Ensure both the start and end date are specified |
| 1215 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
| 1216 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
| 1215 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
| 1216 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | $total = (float) 0.00; |
| 1220 | 1220 | |
| 1221 | 1221 | // Loop through the years |
| 1222 | 1222 | $y = $dates['year']; |
| 1223 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
| 1223 | + if ( ! isset($earnings['earnings'])) { |
|
| 1224 | 1224 | $earnings['earnings'] = array(); |
| 1225 | 1225 | } |
| 1226 | - while ( $y <= $dates['year_end'] ) : |
|
| 1226 | + while ($y <= $dates['year_end']) : |
|
| 1227 | 1227 | |
| 1228 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1228 | + if ($dates['year'] == $dates['year_end']) { |
|
| 1229 | 1229 | $month_start = $dates['m_start']; |
| 1230 | 1230 | $month_end = $dates['m_end']; |
| 1231 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1231 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
| 1232 | 1232 | $month_start = $dates['m_start']; |
| 1233 | 1233 | $month_end = 12; |
| 1234 | - } elseif ( $y == $dates['year_end'] ) { |
|
| 1234 | + } elseif ($y == $dates['year_end']) { |
|
| 1235 | 1235 | $month_start = 1; |
| 1236 | 1236 | $month_end = $dates['m_end']; |
| 1237 | 1237 | } else { |
@@ -1240,92 +1240,92 @@ discard block |
||
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | $i = $month_start; |
| 1243 | - while ( $i <= $month_end ) : |
|
| 1243 | + while ($i <= $month_end) : |
|
| 1244 | 1244 | |
| 1245 | - if ( $i == $dates['m_start'] ) { |
|
| 1245 | + if ($i == $dates['m_start']) { |
|
| 1246 | 1246 | $d = $dates['day_start']; |
| 1247 | 1247 | } else { |
| 1248 | 1248 | $d = 1; |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - if ( $i == $dates['m_end'] ) { |
|
| 1251 | + if ($i == $dates['m_end']) { |
|
| 1252 | 1252 | $num_of_days = $dates['day_end']; |
| 1253 | 1253 | } else { |
| 1254 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1254 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | - while ( $d <= $num_of_days ) : |
|
| 1258 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
| 1259 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1260 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
| 1261 | - $earnings['earnings'][ $date_key ] = 0; |
|
| 1257 | + while ($d <= $num_of_days) : |
|
| 1258 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
| 1259 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
| 1260 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
| 1261 | + $earnings['earnings'][$date_key] = 0; |
|
| 1262 | 1262 | } |
| 1263 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
| 1263 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
| 1264 | 1264 | $total += $earnings_stat; |
| 1265 | - $d ++; |
|
| 1265 | + $d++; |
|
| 1266 | 1266 | endwhile; |
| 1267 | 1267 | |
| 1268 | - $i ++; |
|
| 1268 | + $i++; |
|
| 1269 | 1269 | endwhile; |
| 1270 | 1270 | |
| 1271 | - $y ++; |
|
| 1271 | + $y++; |
|
| 1272 | 1272 | endwhile; |
| 1273 | 1273 | |
| 1274 | 1274 | $earnings['totals'] = $total; |
| 1275 | 1275 | } else { |
| 1276 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
| 1276 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
| 1277 | 1277 | $earnings_count = (float) 0.00; |
| 1278 | 1278 | |
| 1279 | 1279 | // Loop through the months |
| 1280 | 1280 | $month = $dates['m_start']; |
| 1281 | 1281 | |
| 1282 | - while ( $month <= $dates['m_end'] ) : |
|
| 1283 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
| 1284 | - $month ++; |
|
| 1282 | + while ($month <= $dates['m_end']) : |
|
| 1283 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
| 1284 | + $month++; |
|
| 1285 | 1285 | endwhile; |
| 1286 | 1286 | |
| 1287 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
| 1287 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
| 1288 | 1288 | } else { |
| 1289 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
| 1289 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | } |
| 1292 | - } elseif ( $args['form'] == 'all' ) { |
|
| 1293 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
| 1292 | + } elseif ($args['form'] == 'all') { |
|
| 1293 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
| 1294 | 1294 | |
| 1295 | 1295 | $i = 0; |
| 1296 | - foreach ( $forms as $form_info ) { |
|
| 1297 | - $earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) ); |
|
| 1298 | - $i ++; |
|
| 1296 | + foreach ($forms as $form_info) { |
|
| 1297 | + $earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID)); |
|
| 1298 | + $i++; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | } else { |
| 1301 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
| 1302 | - $form_info = get_post( $args['form'] ); |
|
| 1303 | - $earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) ); |
|
| 1301 | + if (get_post_type($args['form']) == 'give_forms') { |
|
| 1302 | + $form_info = get_post($args['form']); |
|
| 1303 | + $earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form'])); |
|
| 1304 | 1304 | } else { |
| 1305 | 1305 | $error['error'] = sprintf( |
| 1306 | 1306 | /* translators: %s: form */ |
| 1307 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 1307 | + esc_html__('Form %s not found.', 'give'), |
|
| 1308 | 1308 | $args['form'] |
| 1309 | 1309 | ); |
| 1310 | 1310 | } |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | - if ( ! empty( $error ) ) { |
|
| 1313 | + if ( ! empty($error)) { |
|
| 1314 | 1314 | return $error; |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | return $earnings; |
| 1318 | - } elseif ( $args['type'] == 'donors' ) { |
|
| 1318 | + } elseif ($args['type'] == 'donors') { |
|
| 1319 | 1319 | $customers = new Give_DB_Customers(); |
| 1320 | 1320 | $stats['donations']['total_donors'] = $customers->count(); |
| 1321 | 1321 | |
| 1322 | 1322 | return $stats; |
| 1323 | 1323 | |
| 1324 | - } elseif ( empty( $args['type'] ) ) { |
|
| 1325 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
| 1326 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
| 1324 | + } elseif (empty($args['type'])) { |
|
| 1325 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
| 1326 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
| 1327 | 1327 | |
| 1328 | - return array( 'stats' => $stats ); |
|
| 1328 | + return array('stats' => $stats); |
|
| 1329 | 1329 | } |
| 1330 | 1330 | } |
| 1331 | 1331 | |
@@ -1341,18 +1341,18 @@ discard block |
||
| 1341 | 1341 | |
| 1342 | 1342 | $sales = array(); |
| 1343 | 1343 | |
| 1344 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
| 1344 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
| 1345 | 1345 | return $sales; |
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
| 1348 | + if (isset($wp_query->query_vars['id'])) { |
|
| 1349 | 1349 | $query = array(); |
| 1350 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
| 1351 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
| 1350 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
| 1351 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
| 1352 | 1352 | $query = array(); |
| 1353 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
| 1354 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
| 1355 | - $args = array( |
|
| 1353 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
| 1354 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
| 1355 | + $args = array( |
|
| 1356 | 1356 | 'fields' => 'ids', |
| 1357 | 1357 | 'meta_key' => '_give_payment_user_email', |
| 1358 | 1358 | 'meta_value' => $wp_query->query_vars['email'], |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | 'page' => $this->get_paged(), |
| 1361 | 1361 | 'status' => 'publish', |
| 1362 | 1362 | ); |
| 1363 | - $query = give_get_payments( $args ); |
|
| 1363 | + $query = give_get_payments($args); |
|
| 1364 | 1364 | } else { |
| 1365 | 1365 | $args = array( |
| 1366 | 1366 | 'fields' => 'ids', |
@@ -1368,14 +1368,14 @@ discard block |
||
| 1368 | 1368 | 'page' => $this->get_paged(), |
| 1369 | 1369 | 'status' => 'publish', |
| 1370 | 1370 | ); |
| 1371 | - $query = give_get_payments( $args ); |
|
| 1371 | + $query = give_get_payments($args); |
|
| 1372 | 1372 | } |
| 1373 | - if ( $query ) { |
|
| 1373 | + if ($query) { |
|
| 1374 | 1374 | $i = 0; |
| 1375 | - foreach ( $query as $payment ) { |
|
| 1375 | + foreach ($query as $payment) { |
|
| 1376 | 1376 | |
| 1377 | - if ( is_numeric( $payment ) ) { |
|
| 1378 | - $payment = new Give_Payment( $payment ); |
|
| 1377 | + if (is_numeric($payment)) { |
|
| 1378 | + $payment = new Give_Payment($payment); |
|
| 1379 | 1379 | $payment_meta = $payment->get_meta(); |
| 1380 | 1380 | $user_info = $payment->user_info; |
| 1381 | 1381 | } else { |
@@ -1385,40 +1385,40 @@ discard block |
||
| 1385 | 1385 | $payment_meta = $payment->get_meta(); |
| 1386 | 1386 | $user_info = $payment->user_info; |
| 1387 | 1387 | |
| 1388 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
| 1389 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
| 1390 | - |
|
| 1391 | - $sales['donations'][ $i ]['ID'] = $payment->number; |
|
| 1392 | - $sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
| 1393 | - $sales['donations'][ $i ]['key'] = $payment->key; |
|
| 1394 | - $sales['donations'][ $i ]['total'] = $payment->total; |
|
| 1395 | - $sales['donations'][ $i ]['gateway'] = $payment->gateway; |
|
| 1396 | - $sales['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
| 1397 | - $sales['donations'][ $i ]['fname'] = $first_name; |
|
| 1398 | - $sales['donations'][ $i ]['lname'] = $last_name; |
|
| 1399 | - $sales['donations'][ $i ]['email'] = $payment->email; |
|
| 1400 | - $sales['donations'][ $i ]['date'] = $payment->date; |
|
| 1401 | - |
|
| 1402 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
| 1403 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
| 1404 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
| 1405 | - |
|
| 1406 | - $sales['donations'][ $i ]['form']['id'] = $form_id; |
|
| 1407 | - $sales['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
| 1408 | - $sales['donations'][ $i ]['form']['price'] = $price; |
|
| 1409 | - |
|
| 1410 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1411 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
| 1412 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
| 1413 | - $sales['donations'][ $i ]['form']['price_name'] = $price_name; |
|
| 1414 | - $sales['donations'][ $i ]['form']['price_id'] = $price_id; |
|
| 1415 | - $sales['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
| 1388 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
| 1389 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
| 1390 | + |
|
| 1391 | + $sales['donations'][$i]['ID'] = $payment->number; |
|
| 1392 | + $sales['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
| 1393 | + $sales['donations'][$i]['key'] = $payment->key; |
|
| 1394 | + $sales['donations'][$i]['total'] = $payment->total; |
|
| 1395 | + $sales['donations'][$i]['gateway'] = $payment->gateway; |
|
| 1396 | + $sales['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
| 1397 | + $sales['donations'][$i]['fname'] = $first_name; |
|
| 1398 | + $sales['donations'][$i]['lname'] = $last_name; |
|
| 1399 | + $sales['donations'][$i]['email'] = $payment->email; |
|
| 1400 | + $sales['donations'][$i]['date'] = $payment->date; |
|
| 1401 | + |
|
| 1402 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
| 1403 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
| 1404 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
| 1405 | + |
|
| 1406 | + $sales['donations'][$i]['form']['id'] = $form_id; |
|
| 1407 | + $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
| 1408 | + $sales['donations'][$i]['form']['price'] = $price; |
|
| 1409 | + |
|
| 1410 | + if (give_has_variable_prices($form_id)) { |
|
| 1411 | + if (isset($payment_meta['price_id'])) { |
|
| 1412 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
| 1413 | + $sales['donations'][$i]['form']['price_name'] = $price_name; |
|
| 1414 | + $sales['donations'][$i]['form']['price_id'] = $price_id; |
|
| 1415 | + $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
| 1416 | 1416 | |
| 1417 | 1417 | } |
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | 1420 | // Add custom meta to API |
| 1421 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
| 1421 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
| 1422 | 1422 | |
| 1423 | 1423 | $exceptions = array( |
| 1424 | 1424 | 'form_title', |
@@ -1431,19 +1431,19 @@ discard block |
||
| 1431 | 1431 | ); |
| 1432 | 1432 | |
| 1433 | 1433 | // Don't clutter up results with dupes |
| 1434 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
| 1434 | + if (in_array($meta_key, $exceptions)) { |
|
| 1435 | 1435 | continue; |
| 1436 | 1436 | } |
| 1437 | 1437 | |
| 1438 | - $sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
| 1438 | + $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
| 1439 | 1439 | |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | - $i ++; |
|
| 1442 | + $i++; |
|
| 1443 | 1443 | } |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - return apply_filters( 'give_api_donations_endpoint', $sales ); |
|
| 1446 | + return apply_filters('give_api_donations_endpoint', $sales); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1459,9 +1459,9 @@ discard block |
||
| 1459 | 1459 | public function get_output_format() { |
| 1460 | 1460 | global $wp_query; |
| 1461 | 1461 | |
| 1462 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
| 1462 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
| 1463 | 1463 | |
| 1464 | - return apply_filters( 'give_api_output_format', $format ); |
|
| 1464 | + return apply_filters('give_api_output_format', $format); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | |
@@ -1478,8 +1478,8 @@ discard block |
||
| 1478 | 1478 | * |
| 1479 | 1479 | * @return void |
| 1480 | 1480 | */ |
| 1481 | - private function log_request( $data = array() ) { |
|
| 1482 | - if ( ! $this->log_requests ) { |
|
| 1481 | + private function log_request($data = array()) { |
|
| 1482 | + if ( ! $this->log_requests) { |
|
| 1483 | 1483 | return; |
| 1484 | 1484 | } |
| 1485 | 1485 | |
@@ -1495,36 +1495,36 @@ discard block |
||
| 1495 | 1495 | |
| 1496 | 1496 | $query = array( |
| 1497 | 1497 | 'give-api' => $wp_query->query_vars['give-api'], |
| 1498 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
| 1499 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
| 1500 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
| 1501 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
| 1502 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
| 1503 | - 'customer' => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null, |
|
| 1504 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
| 1505 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
| 1506 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
| 1507 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
| 1508 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
| 1509 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
| 1498 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
| 1499 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
| 1500 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
| 1501 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
| 1502 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
| 1503 | + 'customer' => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null, |
|
| 1504 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
| 1505 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
| 1506 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
| 1507 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
| 1508 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
| 1509 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
| 1510 | 1510 | ); |
| 1511 | 1511 | |
| 1512 | 1512 | $log_data = array( |
| 1513 | 1513 | 'log_type' => 'api_request', |
| 1514 | - 'post_excerpt' => http_build_query( $query ), |
|
| 1515 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
| 1514 | + 'post_excerpt' => http_build_query($query), |
|
| 1515 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
| 1516 | 1516 | ); |
| 1517 | 1517 | |
| 1518 | 1518 | $log_meta = array( |
| 1519 | 1519 | 'request_ip' => give_get_ip(), |
| 1520 | 1520 | 'user' => $this->user_id, |
| 1521 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
| 1522 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
| 1521 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
| 1522 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
| 1523 | 1523 | 'time' => $data['request_speed'], |
| 1524 | 1524 | 'version' => $this->get_queried_version(), |
| 1525 | 1525 | ); |
| 1526 | 1526 | |
| 1527 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 1527 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | * |
| 1549 | 1549 | * @param int $status_code |
| 1550 | 1550 | */ |
| 1551 | - public function output( $status_code = 200 ) { |
|
| 1551 | + public function output($status_code = 200) { |
|
| 1552 | 1552 | /** |
| 1553 | 1553 | * @var WP_Query $wp_query |
| 1554 | 1554 | */ |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | |
| 1557 | 1557 | $format = $this->get_output_format(); |
| 1558 | 1558 | |
| 1559 | - status_header( $status_code ); |
|
| 1559 | + status_header($status_code); |
|
| 1560 | 1560 | |
| 1561 | 1561 | /** |
| 1562 | 1562 | * Fires before outputing the API. |
@@ -1567,25 +1567,25 @@ discard block |
||
| 1567 | 1567 | * @param Give_API $this The Give_API object. |
| 1568 | 1568 | * @param string $format Output format, XML or JSON. Default is JSON. |
| 1569 | 1569 | */ |
| 1570 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
| 1570 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
| 1571 | 1571 | |
| 1572 | - switch ( $format ) : |
|
| 1572 | + switch ($format) : |
|
| 1573 | 1573 | |
| 1574 | 1574 | case 'xml' : |
| 1575 | 1575 | |
| 1576 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
| 1577 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
| 1576 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
| 1577 | + $xml = Array2XML::createXML('give', $this->data); |
|
| 1578 | 1578 | echo $xml->saveXML(); |
| 1579 | 1579 | |
| 1580 | 1580 | break; |
| 1581 | 1581 | |
| 1582 | 1582 | case 'json' : |
| 1583 | 1583 | |
| 1584 | - header( 'Content-Type: application/json' ); |
|
| 1585 | - if ( ! empty( $this->pretty_print ) ) { |
|
| 1586 | - echo json_encode( $this->data, $this->pretty_print ); |
|
| 1584 | + header('Content-Type: application/json'); |
|
| 1585 | + if ( ! empty($this->pretty_print)) { |
|
| 1586 | + echo json_encode($this->data, $this->pretty_print); |
|
| 1587 | 1587 | } else { |
| 1588 | - echo json_encode( $this->data ); |
|
| 1588 | + echo json_encode($this->data); |
|
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | break; |
@@ -1600,7 +1600,7 @@ discard block |
||
| 1600 | 1600 | * @param array $data Response data to return. |
| 1601 | 1601 | * @param Give_API $this The Give_API object. |
| 1602 | 1602 | */ |
| 1603 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
| 1603 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
| 1604 | 1604 | |
| 1605 | 1605 | break; |
| 1606 | 1606 | |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | * @param Give_API $this The Give_API object. |
| 1616 | 1616 | * @param string $format Output format, XML or JSON. Default is JSON. |
| 1617 | 1617 | */ |
| 1618 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
| 1618 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
| 1619 | 1619 | |
| 1620 | 1620 | give_die(); |
| 1621 | 1621 | } |
@@ -1632,40 +1632,40 @@ discard block |
||
| 1632 | 1632 | * |
| 1633 | 1633 | * @return void |
| 1634 | 1634 | */ |
| 1635 | - function user_key_field( $user ) { |
|
| 1635 | + function user_key_field($user) { |
|
| 1636 | 1636 | |
| 1637 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
| 1638 | - $user = get_userdata( $user->ID ); |
|
| 1637 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
| 1638 | + $user = get_userdata($user->ID); |
|
| 1639 | 1639 | ?> |
| 1640 | 1640 | <table class="form-table"> |
| 1641 | 1641 | <tbody> |
| 1642 | 1642 | <tr> |
| 1643 | 1643 | <th> |
| 1644 | - <?php esc_html_e( 'Give API Keys', 'give' ); ?> |
|
| 1644 | + <?php esc_html_e('Give API Keys', 'give'); ?> |
|
| 1645 | 1645 | </th> |
| 1646 | 1646 | <td> |
| 1647 | 1647 | <?php |
| 1648 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
| 1649 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
| 1648 | + $public_key = $this->get_user_public_key($user->ID); |
|
| 1649 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
| 1650 | 1650 | ?> |
| 1651 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
| 1651 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
| 1652 | 1652 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
| 1653 | - <span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span> |
|
| 1653 | + <span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span> |
|
| 1654 | 1654 | <?php } else { ?> |
| 1655 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?> |
|
| 1655 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?> |
|
| 1656 | 1656 | </strong> |
| 1657 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/> |
|
| 1657 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/> |
|
| 1658 | 1658 | <br/> |
| 1659 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?> |
|
| 1659 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?> |
|
| 1660 | 1660 | </strong> |
| 1661 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/> |
|
| 1661 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/> |
|
| 1662 | 1662 | <br/> |
| 1663 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?> |
|
| 1663 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?> |
|
| 1664 | 1664 | </strong> |
| 1665 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/> |
|
| 1665 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/> |
|
| 1666 | 1666 | <br/> |
| 1667 | 1667 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
| 1668 | - <span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
| 1668 | + <span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span> |
|
| 1669 | 1669 | <?php } ?> |
| 1670 | 1670 | </td> |
| 1671 | 1671 | </tr> |
@@ -1684,69 +1684,69 @@ discard block |
||
| 1684 | 1684 | * |
| 1685 | 1685 | * @return void |
| 1686 | 1686 | */ |
| 1687 | - public function process_api_key( $args ) { |
|
| 1687 | + public function process_api_key($args) { |
|
| 1688 | 1688 | |
| 1689 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
| 1689 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
| 1690 | 1690 | |
| 1691 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 1691 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 1692 | 1692 | |
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | - if ( empty( $args['user_id'] ) ) { |
|
| 1696 | - wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) ); |
|
| 1695 | + if (empty($args['user_id'])) { |
|
| 1696 | + wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401)); |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | - if ( is_numeric( $args['user_id'] ) ) { |
|
| 1700 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
| 1699 | + if (is_numeric($args['user_id'])) { |
|
| 1700 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
| 1701 | 1701 | } else { |
| 1702 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
| 1702 | + $userdata = get_user_by('login', $args['user_id']); |
|
| 1703 | 1703 | $user_id = $userdata->ID; |
| 1704 | 1704 | } |
| 1705 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
| 1705 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
| 1706 | 1706 | |
| 1707 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1707 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
| 1708 | 1708 | wp_die( |
| 1709 | 1709 | sprintf( |
| 1710 | 1710 | /* translators: %s: process */ |
| 1711 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
| 1711 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
| 1712 | 1712 | $process |
| 1713 | 1713 | ), |
| 1714 | - esc_html__( 'Error', 'give' ), |
|
| 1715 | - array( 'response' => 403 ) |
|
| 1714 | + esc_html__('Error', 'give'), |
|
| 1715 | + array('response' => 403) |
|
| 1716 | 1716 | ); |
| 1717 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1717 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
| 1718 | 1718 | wp_die( |
| 1719 | 1719 | sprintf( |
| 1720 | 1720 | /* translators: %s: process */ |
| 1721 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
| 1721 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
| 1722 | 1722 | $process |
| 1723 | 1723 | ), |
| 1724 | - esc_html__( 'Error', 'give' ), |
|
| 1725 | - array( 'response' => 403 ) |
|
| 1724 | + esc_html__('Error', 'give'), |
|
| 1725 | + array('response' => 403) |
|
| 1726 | 1726 | ); |
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | - switch ( $process ) { |
|
| 1729 | + switch ($process) { |
|
| 1730 | 1730 | case 'generate': |
| 1731 | - if ( $this->generate_api_key( $user_id ) ) { |
|
| 1732 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
| 1733 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
| 1731 | + if ($this->generate_api_key($user_id)) { |
|
| 1732 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
| 1733 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
| 1734 | 1734 | exit(); |
| 1735 | 1735 | } else { |
| 1736 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
| 1736 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
| 1737 | 1737 | exit(); |
| 1738 | 1738 | } |
| 1739 | 1739 | break; |
| 1740 | 1740 | case 'regenerate': |
| 1741 | - $this->generate_api_key( $user_id, true ); |
|
| 1742 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
| 1743 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
| 1741 | + $this->generate_api_key($user_id, true); |
|
| 1742 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
| 1743 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
| 1744 | 1744 | exit(); |
| 1745 | 1745 | break; |
| 1746 | 1746 | case 'revoke': |
| 1747 | - $this->revoke_api_key( $user_id ); |
|
| 1748 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
| 1749 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
| 1747 | + $this->revoke_api_key($user_id); |
|
| 1748 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
| 1749 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
| 1750 | 1750 | exit(); |
| 1751 | 1751 | break; |
| 1752 | 1752 | default; |
@@ -1765,34 +1765,34 @@ discard block |
||
| 1765 | 1765 | * |
| 1766 | 1766 | * @return boolean True if (re)generated succesfully, false otherwise. |
| 1767 | 1767 | */ |
| 1768 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
| 1768 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
| 1769 | 1769 | |
| 1770 | - if ( empty( $user_id ) ) { |
|
| 1770 | + if (empty($user_id)) { |
|
| 1771 | 1771 | return false; |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | - $user = get_userdata( $user_id ); |
|
| 1774 | + $user = get_userdata($user_id); |
|
| 1775 | 1775 | |
| 1776 | - if ( ! $user ) { |
|
| 1776 | + if ( ! $user) { |
|
| 1777 | 1777 | return false; |
| 1778 | 1778 | } |
| 1779 | 1779 | |
| 1780 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1781 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1780 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1781 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1782 | 1782 | |
| 1783 | - if ( empty( $public_key ) || $regenerate == true ) { |
|
| 1784 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
| 1785 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
| 1783 | + if (empty($public_key) || $regenerate == true) { |
|
| 1784 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
| 1785 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
| 1786 | 1786 | } else { |
| 1787 | 1787 | return false; |
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | - if ( $regenerate == true ) { |
|
| 1791 | - $this->revoke_api_key( $user->ID ); |
|
| 1790 | + if ($regenerate == true) { |
|
| 1791 | + $this->revoke_api_key($user->ID); |
|
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
| 1795 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
| 1794 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
| 1795 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
| 1796 | 1796 | |
| 1797 | 1797 | return true; |
| 1798 | 1798 | } |
@@ -1807,26 +1807,26 @@ discard block |
||
| 1807 | 1807 | * |
| 1808 | 1808 | * @return bool |
| 1809 | 1809 | */ |
| 1810 | - public function revoke_api_key( $user_id = 0 ) { |
|
| 1810 | + public function revoke_api_key($user_id = 0) { |
|
| 1811 | 1811 | |
| 1812 | - if ( empty( $user_id ) ) { |
|
| 1812 | + if (empty($user_id)) { |
|
| 1813 | 1813 | return false; |
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | - $user = get_userdata( $user_id ); |
|
| 1816 | + $user = get_userdata($user_id); |
|
| 1817 | 1817 | |
| 1818 | - if ( ! $user ) { |
|
| 1818 | + if ( ! $user) { |
|
| 1819 | 1819 | return false; |
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1823 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1824 | - if ( ! empty( $public_key ) ) { |
|
| 1825 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); |
|
| 1826 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); |
|
| 1827 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); |
|
| 1828 | - delete_user_meta( $user_id, $public_key ); |
|
| 1829 | - delete_user_meta( $user_id, $secret_key ); |
|
| 1822 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1823 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1824 | + if ( ! empty($public_key)) { |
|
| 1825 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); |
|
| 1826 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); |
|
| 1827 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); |
|
| 1828 | + delete_user_meta($user_id, $public_key); |
|
| 1829 | + delete_user_meta($user_id, $secret_key); |
|
| 1830 | 1830 | } else { |
| 1831 | 1831 | return false; |
| 1832 | 1832 | } |
@@ -1851,22 +1851,22 @@ discard block |
||
| 1851 | 1851 | * |
| 1852 | 1852 | * @return void |
| 1853 | 1853 | */ |
| 1854 | - public function update_key( $user_id ) { |
|
| 1855 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) { |
|
| 1854 | + public function update_key($user_id) { |
|
| 1855 | + if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) { |
|
| 1856 | 1856 | |
| 1857 | - $user = get_userdata( $user_id ); |
|
| 1857 | + $user = get_userdata($user_id); |
|
| 1858 | 1858 | |
| 1859 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1860 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1859 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1860 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1861 | 1861 | |
| 1862 | - if ( empty( $public_key ) ) { |
|
| 1863 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
| 1864 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
| 1862 | + if (empty($public_key)) { |
|
| 1863 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
| 1864 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
| 1865 | 1865 | |
| 1866 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
| 1867 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
| 1866 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
| 1867 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
| 1868 | 1868 | } else { |
| 1869 | - $this->revoke_api_key( $user_id ); |
|
| 1869 | + $this->revoke_api_key($user_id); |
|
| 1870 | 1870 | } |
| 1871 | 1871 | } |
| 1872 | 1872 | } |
@@ -1881,9 +1881,9 @@ discard block |
||
| 1881 | 1881 | * |
| 1882 | 1882 | * @return string |
| 1883 | 1883 | */ |
| 1884 | - private function generate_public_key( $user_email = '' ) { |
|
| 1885 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1886 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
| 1884 | + private function generate_public_key($user_email = '') { |
|
| 1885 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1886 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
| 1887 | 1887 | |
| 1888 | 1888 | return $public; |
| 1889 | 1889 | } |
@@ -1898,9 +1898,9 @@ discard block |
||
| 1898 | 1898 | * |
| 1899 | 1899 | * @return string |
| 1900 | 1900 | */ |
| 1901 | - private function generate_private_key( $user_id = 0 ) { |
|
| 1902 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1903 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
| 1901 | + private function generate_private_key($user_id = 0) { |
|
| 1902 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1903 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
| 1904 | 1904 | |
| 1905 | 1905 | return $secret; |
| 1906 | 1906 | } |
@@ -1915,8 +1915,8 @@ discard block |
||
| 1915 | 1915 | * |
| 1916 | 1916 | * @return string |
| 1917 | 1917 | */ |
| 1918 | - public function get_token( $user_id = 0 ) { |
|
| 1919 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
| 1918 | + public function get_token($user_id = 0) { |
|
| 1919 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | 1922 | /** |
@@ -1930,9 +1930,9 @@ discard block |
||
| 1930 | 1930 | |
| 1931 | 1931 | // Default sales return |
| 1932 | 1932 | $sales = array(); |
| 1933 | - $sales['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
| 1934 | - $sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
| 1935 | - $sales['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
| 1933 | + $sales['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
| 1934 | + $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
| 1935 | + $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
| 1936 | 1936 | $sales['donations']['totals'] = give_get_total_sales(); |
| 1937 | 1937 | |
| 1938 | 1938 | return $sales; |
@@ -1949,9 +1949,9 @@ discard block |
||
| 1949 | 1949 | |
| 1950 | 1950 | // Default earnings return |
| 1951 | 1951 | $earnings = array(); |
| 1952 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
| 1953 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
| 1954 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
| 1952 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
| 1953 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
| 1954 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
| 1955 | 1955 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
| 1956 | 1956 | |
| 1957 | 1957 | return $earnings; |
@@ -1971,25 +1971,25 @@ discard block |
||
| 1971 | 1971 | * |
| 1972 | 1972 | * @return string The API key/secret for the user supplied |
| 1973 | 1973 | */ |
| 1974 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
| 1974 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
| 1975 | 1975 | |
| 1976 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
| 1976 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
| 1977 | 1977 | return $check; |
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | $return = $check; |
| 1981 | 1981 | |
| 1982 | - switch ( $meta_key ) { |
|
| 1982 | + switch ($meta_key) { |
|
| 1983 | 1983 | case 'give_user_public_key': |
| 1984 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
| 1984 | + $return = Give()->api->get_user_public_key($object_id); |
|
| 1985 | 1985 | break; |
| 1986 | 1986 | case 'give_user_secret_key': |
| 1987 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
| 1987 | + $return = Give()->api->get_user_secret_key($object_id); |
|
| 1988 | 1988 | break; |
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | - if ( ! $single ) { |
|
| 1992 | - $return = array( $return ); |
|
| 1991 | + if ( ! $single) { |
|
| 1992 | + $return = array($return); |
|
| 1993 | 1993 | } |
| 1994 | 1994 | |
| 1995 | 1995 | return $return; |
@@ -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 | |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function give_is_test_mode() { |
| 25 | 25 | |
| 26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
| 26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
| 27 | 27 | |
| 28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | |
| 40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
| 40 | + $currency = give_get_option('currency', 'USD'); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currency_position() { |
| 53 | 53 | |
| 54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
| 54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
| 56 | + return apply_filters('give_currency_position', $currency_pos); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | function give_get_currencies() { |
| 68 | 68 | $currencies = array( |
| 69 | - 'USD' => __( 'US Dollars ($)', 'give' ), |
|
| 70 | - 'EUR' => __( 'Euros (€)', 'give' ), |
|
| 71 | - 'GBP' => __( 'Pounds Sterling (£)', 'give' ), |
|
| 72 | - 'AUD' => __( 'Australian Dollars ($)', 'give' ), |
|
| 73 | - 'BRL' => __( 'Brazilian Real (R$)', 'give' ), |
|
| 74 | - 'CAD' => __( 'Canadian Dollars ($)', 'give' ), |
|
| 75 | - 'CZK' => __( 'Czech Koruna (Kč)', 'give' ), |
|
| 76 | - 'DKK' => __( 'Danish Krone (kr.)', 'give' ), |
|
| 77 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
| 78 | - 'HUF' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
| 79 | - 'ILS' => __( 'Israeli Shekel (₪)', 'give' ), |
|
| 80 | - 'JPY' => __( 'Japanese Yen (¥)', 'give' ), |
|
| 81 | - 'MYR' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
| 82 | - 'MXN' => __( 'Mexican Peso ($)', 'give' ), |
|
| 83 | - 'MAD' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
| 84 | - 'NZD' => __( 'New Zealand Dollar ($)', 'give' ), |
|
| 85 | - 'NOK' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 86 | - 'PHP' => __( 'Philippine Pesos (₱)', 'give' ), |
|
| 87 | - 'PLN' => __( 'Polish Zloty (zł)', 'give' ), |
|
| 88 | - 'SGD' => __( 'Singapore Dollar ($)', 'give' ), |
|
| 89 | - 'KRW' => __( 'South Korean Won (₩)', 'give' ), |
|
| 90 | - 'ZAR' => __( 'South African Rand (R)', 'give' ), |
|
| 91 | - 'SEK' => __( 'Swedish Krona (kr)', 'give' ), |
|
| 92 | - 'CHF' => __( 'Swiss Franc (CHF)', 'give' ), |
|
| 93 | - 'TWD' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
| 94 | - 'THB' => __( 'Thai Baht (฿)', 'give' ), |
|
| 95 | - 'INR' => __( 'Indian Rupee (₹)', 'give' ), |
|
| 96 | - 'TRY' => __( 'Turkish Lira (₺)', 'give' ), |
|
| 97 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'give' ), |
|
| 98 | - 'RUB' => __( 'Russian Rubles (руб)', 'give' ) |
|
| 69 | + 'USD' => __('US Dollars ($)', 'give'), |
|
| 70 | + 'EUR' => __('Euros (€)', 'give'), |
|
| 71 | + 'GBP' => __('Pounds Sterling (£)', 'give'), |
|
| 72 | + 'AUD' => __('Australian Dollars ($)', 'give'), |
|
| 73 | + 'BRL' => __('Brazilian Real (R$)', 'give'), |
|
| 74 | + 'CAD' => __('Canadian Dollars ($)', 'give'), |
|
| 75 | + 'CZK' => __('Czech Koruna (Kč)', 'give'), |
|
| 76 | + 'DKK' => __('Danish Krone (kr.)', 'give'), |
|
| 77 | + 'HKD' => __('Hong Kong Dollar ($)', 'give'), |
|
| 78 | + 'HUF' => __('Hungarian Forint (Ft)', 'give'), |
|
| 79 | + 'ILS' => __('Israeli Shekel (₪)', 'give'), |
|
| 80 | + 'JPY' => __('Japanese Yen (¥)', 'give'), |
|
| 81 | + 'MYR' => __('Malaysian Ringgits (RM)', 'give'), |
|
| 82 | + 'MXN' => __('Mexican Peso ($)', 'give'), |
|
| 83 | + 'MAD' => __('Moroccan Dirham (.د.م)', 'give'), |
|
| 84 | + 'NZD' => __('New Zealand Dollar ($)', 'give'), |
|
| 85 | + 'NOK' => __('Norwegian Krone (Kr.)', 'give'), |
|
| 86 | + 'PHP' => __('Philippine Pesos (₱)', 'give'), |
|
| 87 | + 'PLN' => __('Polish Zloty (zł)', 'give'), |
|
| 88 | + 'SGD' => __('Singapore Dollar ($)', 'give'), |
|
| 89 | + 'KRW' => __('South Korean Won (₩)', 'give'), |
|
| 90 | + 'ZAR' => __('South African Rand (R)', 'give'), |
|
| 91 | + 'SEK' => __('Swedish Krona (kr)', 'give'), |
|
| 92 | + 'CHF' => __('Swiss Franc (CHF)', 'give'), |
|
| 93 | + 'TWD' => __('Taiwan New Dollars (NT$)', 'give'), |
|
| 94 | + 'THB' => __('Thai Baht (฿)', 'give'), |
|
| 95 | + 'INR' => __('Indian Rupee (₹)', 'give'), |
|
| 96 | + 'TRY' => __('Turkish Lira (₺)', 'give'), |
|
| 97 | + 'RIAL' => __('Iranian Rial (﷼)', 'give'), |
|
| 98 | + 'RUB' => __('Russian Rubles (руб)', 'give') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 101 | + return apply_filters('give_currencies', $currencies); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return string The symbol to use for the currency |
| 116 | 116 | */ |
| 117 | -function give_currency_symbol( $currency = '' ) { |
|
| 117 | +function give_currency_symbol($currency = '') { |
|
| 118 | 118 | |
| 119 | - if ( empty( $currency ) ) { |
|
| 119 | + if (empty($currency)) { |
|
| 120 | 120 | $currency = give_get_currency(); |
| 121 | 121 | } |
| 122 | - switch ( $currency ) : |
|
| 122 | + switch ($currency) : |
|
| 123 | 123 | case 'GBP' : |
| 124 | 124 | $symbol = '£'; |
| 125 | 125 | break; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | endswitch; |
| 199 | 199 | |
| 200 | 200 | |
| 201 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 201 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -212,21 +212,21 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | global $wp; |
| 214 | 214 | |
| 215 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 216 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 215 | + if (get_option('permalink_structure')) { |
|
| 216 | + $base = trailingslashit(home_url($wp->request)); |
|
| 217 | 217 | } else { |
| 218 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 219 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 218 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 219 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | $scheme = is_ssl() ? 'https' : 'http'; |
| 223 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
| 223 | + $current_uri = set_url_scheme($base, $scheme); |
|
| 224 | 224 | |
| 225 | - if ( is_front_page() ) { |
|
| 226 | - $current_uri = home_url( '/' ); |
|
| 225 | + if (is_front_page()) { |
|
| 226 | + $current_uri = home_url('/'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
| 229 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
| 230 | 230 | |
| 231 | 231 | } |
| 232 | 232 | |
@@ -248,15 +248,15 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | $gateways = give_get_enabled_payment_gateways(); |
| 250 | 250 | |
| 251 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 251 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 252 | 252 | $ret = true; |
| 253 | - } else if ( count( $gateways ) == 1 ) { |
|
| 253 | + } else if (count($gateways) == 1) { |
|
| 254 | 254 | $ret = false; |
| 255 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 255 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 256 | 256 | $ret = false; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 259 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -268,26 +268,26 @@ discard block |
||
| 268 | 268 | function give_get_timezone_id() { |
| 269 | 269 | |
| 270 | 270 | // if site timezone string exists, return it |
| 271 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 271 | + if ($timezone = get_option('timezone_string')) { |
|
| 272 | 272 | return $timezone; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // get UTC offset, if it isn't set return UTC |
| 276 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 276 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 277 | 277 | return 'UTC'; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // attempt to guess the timezone string from the UTC offset |
| 281 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 281 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 282 | 282 | |
| 283 | 283 | // last try, guess timezone string manually |
| 284 | - if ( $timezone === false ) { |
|
| 284 | + if ($timezone === false) { |
|
| 285 | 285 | |
| 286 | - $is_dst = date( 'I' ); |
|
| 286 | + $is_dst = date('I'); |
|
| 287 | 287 | |
| 288 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 289 | - foreach ( $abbr as $city ) { |
|
| 290 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 288 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 289 | + foreach ($abbr as $city) { |
|
| 290 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 291 | 291 | return $city['timezone_id']; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -311,17 +311,17 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | $ip = '127.0.0.1'; |
| 313 | 313 | |
| 314 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 314 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 315 | 315 | //check ip from share internet |
| 316 | 316 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 317 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 317 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 318 | 318 | //to check ip is pass from proxy |
| 319 | 319 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 320 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 320 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 321 | 321 | $ip = $_SERVER['REMOTE_ADDR']; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 324 | + return apply_filters('give_get_ip', $ip); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @uses Give()->session->set() |
| 338 | 338 | */ |
| 339 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 340 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 341 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
| 339 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 340 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 341 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | * @return mixed array | false |
| 353 | 353 | */ |
| 354 | 354 | function give_get_purchase_session() { |
| 355 | - return Give()->session->get( 'give_purchase' ); |
|
| 355 | + return Give()->session->get('give_purchase'); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -367,14 +367,14 @@ discard block |
||
| 367 | 367 | * |
| 368 | 368 | * @return string |
| 369 | 369 | */ |
| 370 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 370 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 371 | 371 | $summary = ''; |
| 372 | 372 | |
| 373 | - if ( $email ) { |
|
| 374 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
| 373 | + if ($email) { |
|
| 374 | + $summary .= $purchase_data['user_email'].' - '; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
| 377 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
| 378 | 378 | |
| 379 | 379 | return $summary; |
| 380 | 380 | } |
@@ -391,31 +391,31 @@ discard block |
||
| 391 | 391 | function give_get_host() { |
| 392 | 392 | $host = false; |
| 393 | 393 | |
| 394 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 394 | + if (defined('WPE_APIKEY')) { |
|
| 395 | 395 | $host = 'WP Engine'; |
| 396 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 396 | + } elseif (defined('PAGELYBIN')) { |
|
| 397 | 397 | $host = 'Pagely'; |
| 398 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 398 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 399 | 399 | $host = 'ICDSoft'; |
| 400 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 400 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 401 | 401 | $host = 'NetworkSolutions'; |
| 402 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 402 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 403 | 403 | $host = 'iPage'; |
| 404 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 404 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 405 | 405 | $host = 'IPower'; |
| 406 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 406 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 407 | 407 | $host = 'MediaTemple Grid'; |
| 408 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 408 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 409 | 409 | $host = 'pair Networks'; |
| 410 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 410 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 411 | 411 | $host = 'Rackspace Cloud'; |
| 412 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 412 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 413 | 413 | $host = 'SysFix.eu Power Hosting'; |
| 414 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 414 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 415 | 415 | $host = 'Flywheel'; |
| 416 | 416 | } else { |
| 417 | 417 | // Adding a general fallback for data gathering |
| 418 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 418 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | return $host; |
@@ -431,67 +431,67 @@ discard block |
||
| 431 | 431 | * |
| 432 | 432 | * @return bool true if host matches, false if not |
| 433 | 433 | */ |
| 434 | -function give_is_host( $host = false ) { |
|
| 434 | +function give_is_host($host = false) { |
|
| 435 | 435 | |
| 436 | 436 | $return = false; |
| 437 | 437 | |
| 438 | - if ( $host ) { |
|
| 439 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 438 | + if ($host) { |
|
| 439 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 440 | 440 | |
| 441 | - switch ( $host ) { |
|
| 441 | + switch ($host) { |
|
| 442 | 442 | case 'wpengine': |
| 443 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 443 | + if (defined('WPE_APIKEY')) { |
|
| 444 | 444 | $return = true; |
| 445 | 445 | } |
| 446 | 446 | break; |
| 447 | 447 | case 'pagely': |
| 448 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 448 | + if (defined('PAGELYBIN')) { |
|
| 449 | 449 | $return = true; |
| 450 | 450 | } |
| 451 | 451 | break; |
| 452 | 452 | case 'icdsoft': |
| 453 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 453 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 454 | 454 | $return = true; |
| 455 | 455 | } |
| 456 | 456 | break; |
| 457 | 457 | case 'networksolutions': |
| 458 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 458 | + if (DB_HOST == 'mysqlv5') { |
|
| 459 | 459 | $return = true; |
| 460 | 460 | } |
| 461 | 461 | break; |
| 462 | 462 | case 'ipage': |
| 463 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 463 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 464 | 464 | $return = true; |
| 465 | 465 | } |
| 466 | 466 | break; |
| 467 | 467 | case 'ipower': |
| 468 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 468 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 469 | 469 | $return = true; |
| 470 | 470 | } |
| 471 | 471 | break; |
| 472 | 472 | case 'mediatemplegrid': |
| 473 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 473 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 474 | 474 | $return = true; |
| 475 | 475 | } |
| 476 | 476 | break; |
| 477 | 477 | case 'pairnetworks': |
| 478 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 478 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 479 | 479 | $return = true; |
| 480 | 480 | } |
| 481 | 481 | break; |
| 482 | 482 | case 'rackspacecloud': |
| 483 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 483 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 484 | 484 | $return = true; |
| 485 | 485 | } |
| 486 | 486 | break; |
| 487 | 487 | case 'sysfix.eu': |
| 488 | 488 | case 'sysfix.eupowerhosting': |
| 489 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 489 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 490 | 490 | $return = true; |
| 491 | 491 | } |
| 492 | 492 | break; |
| 493 | 493 | case 'flywheel': |
| 494 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 494 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 495 | 495 | $return = true; |
| 496 | 496 | } |
| 497 | 497 | break; |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | * @param string $replacement Optional. The function that should have been called. |
| 525 | 525 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
| 526 | 526 | */ |
| 527 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
| 527 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
| 528 | 528 | |
| 529 | 529 | /** |
| 530 | 530 | * Fires while give deprecated function call occurs. |
@@ -537,19 +537,19 @@ discard block |
||
| 537 | 537 | * @param string $replacement Optional. The function that should have been called. |
| 538 | 538 | * @param string $version The plugin version that deprecated the function. |
| 539 | 539 | */ |
| 540 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
| 540 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
| 541 | 541 | |
| 542 | - $show_errors = current_user_can( 'manage_options' ); |
|
| 542 | + $show_errors = current_user_can('manage_options'); |
|
| 543 | 543 | |
| 544 | 544 | // Allow plugin to filter the output error trigger |
| 545 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
| 546 | - if ( ! is_null( $replacement ) ) { |
|
| 547 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
| 548 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 545 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
| 546 | + if ( ! is_null($replacement)) { |
|
| 547 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
| 548 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 549 | 549 | // Alternatively we could dump this to a file. |
| 550 | 550 | } else { |
| 551 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
| 552 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 551 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
| 552 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 553 | 553 | // Alternatively we could dump this to a file. |
| 554 | 554 | } |
| 555 | 555 | } |
@@ -563,8 +563,8 @@ discard block |
||
| 563 | 563 | * @return string $post_id |
| 564 | 564 | */ |
| 565 | 565 | function give_get_admin_post_id() { |
| 566 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 567 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 566 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 567 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 568 | 568 | $post_id = $_POST['post_id']; |
| 569 | 569 | } |
| 570 | 570 | |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @return string Arg separator output |
| 579 | 579 | */ |
| 580 | 580 | function give_get_php_arg_separator_output() { |
| 581 | - return ini_get( 'arg_separator.output' ); |
|
| 581 | + return ini_get('arg_separator.output'); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | |
@@ -593,10 +593,10 @@ discard block |
||
| 593 | 593 | * |
| 594 | 594 | * @return string Short month name |
| 595 | 595 | */ |
| 596 | -function give_month_num_to_name( $n ) { |
|
| 597 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 596 | +function give_month_num_to_name($n) { |
|
| 597 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 598 | 598 | |
| 599 | - return date_i18n( "M", $timestamp ); |
|
| 599 | + return date_i18n("M", $timestamp); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
@@ -609,10 +609,10 @@ discard block |
||
| 609 | 609 | * |
| 610 | 610 | * @return bool Whether or not function is disabled. |
| 611 | 611 | */ |
| 612 | -function give_is_func_disabled( $function ) { |
|
| 613 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 612 | +function give_is_func_disabled($function) { |
|
| 613 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 614 | 614 | |
| 615 | - return in_array( $function, $disabled ); |
|
| 615 | + return in_array($function, $disabled); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | function give_get_newsletter() { ?> |
| 625 | 625 | |
| 626 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
| 626 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
| 627 | 627 | |
| 628 | 628 | <div class="give-newsletter-form-wrap"> |
| 629 | 629 | |
@@ -631,33 +631,33 @@ discard block |
||
| 631 | 631 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
| 632 | 632 | target="_blank" novalidate> |
| 633 | 633 | <div class="give-newsletter-confirmation"> |
| 634 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 634 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 635 | 635 | </div> |
| 636 | 636 | |
| 637 | 637 | <table class="form-table give-newsletter-form"> |
| 638 | 638 | <tr valign="middle"> |
| 639 | 639 | <td> |
| 640 | 640 | <label for="mce-EMAIL" |
| 641 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
| 641 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
| 642 | 642 | <input type="email" name="EMAIL" id="mce-EMAIL" |
| 643 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
| 643 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
| 644 | 644 | class="required email" value=""> |
| 645 | 645 | </td> |
| 646 | 646 | <td> |
| 647 | 647 | <label for="mce-FNAME" |
| 648 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
| 648 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
| 649 | 649 | <input type="text" name="FNAME" id="mce-FNAME" |
| 650 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
| 650 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
| 651 | 651 | </td> |
| 652 | 652 | <td> |
| 653 | 653 | <label for="mce-LNAME" |
| 654 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
| 654 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
| 655 | 655 | <input type="text" name="LNAME" id="mce-LNAME" |
| 656 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
| 656 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
| 657 | 657 | </td> |
| 658 | 658 | <td> |
| 659 | 659 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
| 660 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
| 660 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
| 661 | 661 | </td> |
| 662 | 662 | </tr> |
| 663 | 663 | </table> |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
| 721 | 721 | printf( |
| 722 | 722 | /* translators: %s: Give twitter user @givewp */ |
| 723 | - esc_html_e( 'Follow %s', 'give' ), |
|
| 723 | + esc_html_e('Follow %s', 'give'), |
|
| 724 | 724 | '@givewp' |
| 725 | 725 | ); |
| 726 | 726 | ?></a> |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | * |
| 750 | 750 | * @return string |
| 751 | 751 | */ |
| 752 | -function give_svg_icons( $icon ) { |
|
| 752 | +function give_svg_icons($icon) { |
|
| 753 | 753 | |
| 754 | 754 | // Store your SVGs in an associative array |
| 755 | 755 | $svgs = array( |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | ); |
| 762 | 762 | |
| 763 | 763 | // Return the chosen icon's SVG string |
| 764 | - return $svgs[ $icon ]; |
|
| 764 | + return $svgs[$icon]; |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -773,15 +773,15 @@ discard block |
||
| 773 | 773 | * |
| 774 | 774 | * @return mixed |
| 775 | 775 | */ |
| 776 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 777 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 778 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
| 776 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 777 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 778 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | return $post_type; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 784 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 785 | 785 | |
| 786 | 786 | |
| 787 | 787 | /** |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | * @license https://opensource.org/licenses/MIT MIT |
| 796 | 796 | */ |
| 797 | 797 | |
| 798 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 798 | +if ( ! function_exists('array_column')) { |
|
| 799 | 799 | /** |
| 800 | 800 | * Returns the values from a single column of the input array, identified by |
| 801 | 801 | * the $columnKey. |
@@ -814,53 +814,53 @@ discard block |
||
| 814 | 814 | * |
| 815 | 815 | * @return array |
| 816 | 816 | */ |
| 817 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 817 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 818 | 818 | // Using func_get_args() in order to check for proper number of |
| 819 | 819 | // parameters and trigger errors exactly as the built-in array_column() |
| 820 | 820 | // does in PHP 5.5. |
| 821 | 821 | $argc = func_num_args(); |
| 822 | 822 | $params = func_get_args(); |
| 823 | 823 | |
| 824 | - if ( $argc < 2 ) { |
|
| 825 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
| 824 | + if ($argc < 2) { |
|
| 825 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
| 826 | 826 | |
| 827 | 827 | return null; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - if ( ! is_array( $params[0] ) ) { |
|
| 831 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
| 830 | + if ( ! is_array($params[0])) { |
|
| 831 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
| 832 | 832 | |
| 833 | 833 | return null; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - if ( ! is_int( $params[1] ) |
|
| 837 | - && ! is_float( $params[1] ) |
|
| 838 | - && ! is_string( $params[1] ) |
|
| 836 | + if ( ! is_int($params[1]) |
|
| 837 | + && ! is_float($params[1]) |
|
| 838 | + && ! is_string($params[1]) |
|
| 839 | 839 | && $params[1] !== null |
| 840 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 840 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 841 | 841 | ) { |
| 842 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 842 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 843 | 843 | |
| 844 | 844 | return false; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - if ( isset( $params[2] ) |
|
| 848 | - && ! is_int( $params[2] ) |
|
| 849 | - && ! is_float( $params[2] ) |
|
| 850 | - && ! is_string( $params[2] ) |
|
| 851 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 847 | + if (isset($params[2]) |
|
| 848 | + && ! is_int($params[2]) |
|
| 849 | + && ! is_float($params[2]) |
|
| 850 | + && ! is_string($params[2]) |
|
| 851 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 852 | 852 | ) { |
| 853 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 853 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 854 | 854 | |
| 855 | 855 | return false; |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | $paramsInput = $params[0]; |
| 859 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 859 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 860 | 860 | |
| 861 | 861 | $paramsIndexKey = null; |
| 862 | - if ( isset( $params[2] ) ) { |
|
| 863 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 862 | + if (isset($params[2])) { |
|
| 863 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 864 | 864 | $paramsIndexKey = (int) $params[2]; |
| 865 | 865 | } else { |
| 866 | 866 | $paramsIndexKey = (string) $params[2]; |
@@ -869,26 +869,26 @@ discard block |
||
| 869 | 869 | |
| 870 | 870 | $resultArray = array(); |
| 871 | 871 | |
| 872 | - foreach ( $paramsInput as $row ) { |
|
| 872 | + foreach ($paramsInput as $row) { |
|
| 873 | 873 | $key = $value = null; |
| 874 | 874 | $keySet = $valueSet = false; |
| 875 | 875 | |
| 876 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 876 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 877 | 877 | $keySet = true; |
| 878 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 878 | + $key = (string) $row[$paramsIndexKey]; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - if ( $paramsColumnKey === null ) { |
|
| 881 | + if ($paramsColumnKey === null) { |
|
| 882 | 882 | $valueSet = true; |
| 883 | 883 | $value = $row; |
| 884 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 884 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 885 | 885 | $valueSet = true; |
| 886 | - $value = $row[ $paramsColumnKey ]; |
|
| 886 | + $value = $row[$paramsColumnKey]; |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - if ( $valueSet ) { |
|
| 890 | - if ( $keySet ) { |
|
| 891 | - $resultArray[ $key ] = $value; |
|
| 889 | + if ($valueSet) { |
|
| 890 | + if ($keySet) { |
|
| 891 | + $resultArray[$key] = $value; |
|
| 892 | 892 | } else { |
| 893 | 893 | $resultArray[] = $value; |
| 894 | 894 | } |
@@ -910,40 +910,40 @@ discard block |
||
| 910 | 910 | * |
| 911 | 911 | * @return bool Whether the receipt is visible or not. |
| 912 | 912 | */ |
| 913 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 913 | +function give_can_view_receipt($payment_key = '') { |
|
| 914 | 914 | |
| 915 | 915 | $return = false; |
| 916 | 916 | |
| 917 | - if ( empty( $payment_key ) ) { |
|
| 917 | + if (empty($payment_key)) { |
|
| 918 | 918 | return $return; |
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | global $give_receipt_args; |
| 922 | 922 | |
| 923 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 923 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 924 | 924 | |
| 925 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 925 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 926 | 926 | |
| 927 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 927 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 928 | 928 | |
| 929 | - if ( is_user_logged_in() ) { |
|
| 930 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 929 | + if (is_user_logged_in()) { |
|
| 930 | + if ($user_id === (int) get_current_user_id()) { |
|
| 931 | 931 | $return = true; |
| 932 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 932 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 933 | 933 | $return = true; |
| 934 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 934 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 935 | 935 | $return = true; |
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | $session = give_get_purchase_session(); |
| 940 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 941 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 940 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 941 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 942 | 942 | $return = true; |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 946 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 947 | 947 | |
| 948 | 948 | } |
| 949 | 949 | |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | * |
| 953 | 953 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
| 954 | 954 | */ |
| 955 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
| 955 | +if ( ! function_exists('cal_days_in_month')) { |
|
| 956 | 956 | /** |
| 957 | 957 | * cal_days_in_month |
| 958 | 958 | * |
@@ -962,8 +962,8 @@ discard block |
||
| 962 | 962 | * |
| 963 | 963 | * @return bool|string |
| 964 | 964 | */ |
| 965 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
| 966 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 965 | + function cal_days_in_month($calendar, $month, $year) { |
|
| 966 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 967 | 967 | } |
| 968 | 968 | } |
| 969 | 969 | |
@@ -982,42 +982,42 @@ discard block |
||
| 982 | 982 | */ |
| 983 | 983 | function give_get_plugins() { |
| 984 | 984 | $plugins = get_plugins(); |
| 985 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
| 985 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
| 986 | 986 | |
| 987 | - if ( is_multisite() ) { |
|
| 988 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
| 989 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
| 987 | + if (is_multisite()) { |
|
| 988 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
| 989 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
| 992 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
| 993 | 993 | // Is plugin active? |
| 994 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
| 995 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
| 994 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
| 995 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
| 996 | 996 | } else { |
| 997 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
| 997 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
| 1000 | + $dirname = strtolower(dirname($plugin_path)); |
|
| 1001 | 1001 | |
| 1002 | 1002 | // Is plugin a Give add-on by WordImpress? |
| 1003 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
| 1003 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
| 1004 | 1004 | // Plugin is a Give-addon. |
| 1005 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
| 1005 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
| 1006 | 1006 | |
| 1007 | 1007 | // Get license info from database. |
| 1008 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
| 1009 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
| 1010 | - $license_active = get_option( $db_option ); |
|
| 1008 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
| 1009 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
| 1010 | + $license_active = get_option($db_option); |
|
| 1011 | 1011 | |
| 1012 | 1012 | // Does a valid license exist? |
| 1013 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
| 1014 | - $plugins[ $plugin_path ]['License'] = true; |
|
| 1013 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
| 1014 | + $plugins[$plugin_path]['License'] = true; |
|
| 1015 | 1015 | } else { |
| 1016 | - $plugins[ $plugin_path ]['License'] = false; |
|
| 1016 | + $plugins[$plugin_path]['License'] = false; |
|
| 1017 | 1017 | } |
| 1018 | 1018 | } else { |
| 1019 | 1019 | // Plugin is not a Give add-on. |
| 1020 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
| 1020 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | } |
| 1023 | 1023 | |
@@ -1034,16 +1034,16 @@ discard block |
||
| 1034 | 1034 | * |
| 1035 | 1035 | * @return bool |
| 1036 | 1036 | */ |
| 1037 | -function give_is_terms_enabled( $form_id ) { |
|
| 1038 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 1037 | +function give_is_terms_enabled($form_id) { |
|
| 1038 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 1039 | 1039 | |
| 1040 | 1040 | if ( |
| 1041 | - give_is_setting_enabled( $form_option, 'global' ) |
|
| 1042 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
| 1041 | + give_is_setting_enabled($form_option, 'global') |
|
| 1042 | + && give_is_setting_enabled(give_get_option('terms')) |
|
| 1043 | 1043 | ) { |
| 1044 | 1044 | return true; |
| 1045 | 1045 | |
| 1046 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
| 1046 | + } elseif (give_is_setting_enabled($form_option)) { |
|
| 1047 | 1047 | return true; |
| 1048 | 1048 | |
| 1049 | 1049 | } else { |
@@ -1066,9 +1066,9 @@ discard block |
||
| 1066 | 1066 | * |
| 1067 | 1067 | * @return WP_Error|bool |
| 1068 | 1068 | */ |
| 1069 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
| 1069 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
| 1070 | 1070 | // Delete all cache. |
| 1071 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
| 1071 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
| 1072 | 1072 | |
| 1073 | 1073 | /** |
| 1074 | 1074 | * Fire the action when donation stats delete. |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | * @param string|array $date_range |
| 1079 | 1079 | * @param array $args |
| 1080 | 1080 | */ |
| 1081 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
| 1081 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
| 1082 | 1082 | |
| 1083 | 1083 | return $status; |
| 1084 | 1084 | } |
| 1085 | 1085 | \ No newline at end of file |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | 23 | function give_get_templates_dir() { |
| 24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
| 24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function give_get_templates_url() { |
| 34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
| 34 | + return GIVE_PLUGIN_URL.'templates'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
| 44 | 44 | * @param string $template_path Template file path. Default is empty. |
| 45 | 45 | * @param string $default_path Default path. Default is empty. |
| 46 | 46 | */ |
| 47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 49 | - extract( $args ); |
|
| 47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 48 | + if ( ! empty($args) && is_array($args)) { |
|
| 49 | + extract($args); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $template_names = array( $template_name . '.php' ); |
|
| 52 | + $template_names = array($template_name.'.php'); |
|
| 53 | 53 | |
| 54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
| 54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
| 55 | 55 | |
| 56 | - if ( ! file_exists( $located ) ) { |
|
| 56 | + if ( ! file_exists($located)) { |
|
| 57 | 57 | /* translators: %s: the template */ |
| 58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
| 63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
| 75 | 75 | * @param array $args Passed arguments. |
| 76 | 76 | */ |
| 77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
| 78 | 78 | |
| 79 | - include( $located ); |
|
| 79 | + include($located); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
| 91 | 91 | * @param array $args Passed arguments. |
| 92 | 92 | */ |
| 93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
| 109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
| 118 | 118 | * @param string $slug Template part file slug {slug}.php. |
| 119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
| 120 | 120 | */ |
| 121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
| 121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
| 122 | 122 | |
| 123 | 123 | // Setup possible parts |
| 124 | 124 | $templates = array(); |
| 125 | - if ( isset( $name ) ) { |
|
| 126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 125 | + if (isset($name)) { |
|
| 126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
| 127 | 127 | } |
| 128 | - $templates[] = $slug . '.php'; |
|
| 128 | + $templates[] = $slug.'.php'; |
|
| 129 | 129 | |
| 130 | 130 | // Allow template parts to be filtered |
| 131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
| 131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
| 132 | 132 | |
| 133 | 133 | // Return the part that is found |
| 134 | - return give_locate_template( $templates, $load, false ); |
|
| 134 | + return give_locate_template($templates, $load, false); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return string The template filename if one is located. |
| 154 | 154 | */ |
| 155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
| 156 | 156 | // No file found yet |
| 157 | 157 | $located = false; |
| 158 | 158 | |
| 159 | 159 | // Try to find a template file |
| 160 | - foreach ( (array) $template_names as $template_name ) { |
|
| 160 | + foreach ((array) $template_names as $template_name) { |
|
| 161 | 161 | |
| 162 | 162 | // Continue if template is empty |
| 163 | - if ( empty( $template_name ) ) { |
|
| 163 | + if (empty($template_name)) { |
|
| 164 | 164 | continue; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Trim off any slashes from the template name |
| 168 | - $template_name = ltrim( $template_name, '/' ); |
|
| 168 | + $template_name = ltrim($template_name, '/'); |
|
| 169 | 169 | |
| 170 | 170 | // try locating this template file by looping through the template paths |
| 171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
| 171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
| 172 | 172 | |
| 173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 174 | - $located = $template_path . $template_name; |
|
| 173 | + if (file_exists($template_path.$template_name)) { |
|
| 174 | + $located = $template_path.$template_name; |
|
| 175 | 175 | break; |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $located ) { |
|
| 179 | + if ($located) { |
|
| 180 | 180 | break; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 185 | - load_template( $located, $require_once ); |
|
| 184 | + if ((true == $load) && ! empty($located)) { |
|
| 185 | + load_template($located, $require_once); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
| 200 | 200 | |
| 201 | 201 | $file_paths = array( |
| 202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
| 203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
| 204 | 204 | 100 => give_get_templates_dir() |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
| 207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
| 208 | 208 | |
| 209 | 209 | // sort the file paths based on priority |
| 210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 210 | + ksort($file_paths, SORT_NUMERIC); |
|
| 211 | 211 | |
| 212 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 212 | + return array_map('trailingslashit', $file_paths); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | 223 | function give_get_theme_template_dir_name() { |
| 224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
| 224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | 233 | function give_version_in_header() { |
| 234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
| 234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
| 237 | +add_action('wp_head', 'give_version_in_header'); |
|
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | function give_is_donation_history_page() { |
| 246 | 246 | |
| 247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
| 247 | + $ret = is_page(give_get_option('history_page')); |
|
| 248 | 248 | |
| 249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
| 249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return array Modified array of classes |
| 260 | 260 | */ |
| 261 | -function give_add_body_classes( $class ) { |
|
| 261 | +function give_add_body_classes($class) { |
|
| 262 | 262 | $classes = (array) $class; |
| 263 | 263 | |
| 264 | - if ( give_is_success_page() ) { |
|
| 264 | + if (give_is_success_page()) { |
|
| 265 | 265 | $classes[] = 'give-success'; |
| 266 | 266 | $classes[] = 'give-page'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if ( give_is_failed_transaction_page() ) { |
|
| 269 | + if (give_is_failed_transaction_page()) { |
|
| 270 | 270 | $classes[] = 'give-failed-transaction'; |
| 271 | 271 | $classes[] = 'give-page'; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( give_is_donation_history_page() ) { |
|
| 274 | + if (give_is_donation_history_page()) { |
|
| 275 | 275 | $classes[] = 'give-donation-history'; |
| 276 | 276 | $classes[] = 'give-page'; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( give_is_test_mode() ) { |
|
| 279 | + if (give_is_test_mode()) { |
|
| 280 | 280 | $classes[] = 'give-test-mode'; |
| 281 | 281 | $classes[] = 'give-page'; |
| 282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
| 285 | 285 | $current_theme = wp_get_theme(); |
| 286 | 286 | |
| 287 | - switch ( $current_theme->template ) { |
|
| 287 | + switch ($current_theme->template) { |
|
| 288 | 288 | |
| 289 | 289 | case 'Divi': |
| 290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - return array_unique( $classes ); |
|
| 301 | + return array_unique($classes); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
| 304 | +add_filter('body_class', 'give_add_body_classes'); |
|
| 305 | 305 | |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return array |
| 319 | 319 | */ |
| 320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
| 321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
| 320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
| 321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
| 322 | 322 | return $classes; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
| 326 | 326 | |
| 327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
| 328 | - unset( $classes[ $key ] ); |
|
| 327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
| 328 | + unset($classes[$key]); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | return $classes; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
| 335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
| 335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,74 +342,74 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | function give_get_placeholder_img_src() { |
| 344 | 344 | |
| 345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
| 345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
| 346 | 346 | |
| 347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
| 347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Global |
| 353 | 353 | */ |
| 354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
| 354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * Output the start of the page wrapper. |
| 358 | 358 | */ |
| 359 | 359 | function give_output_content_wrapper() { |
| 360 | - give_get_template_part( 'global/wrapper-start' ); |
|
| 360 | + give_get_template_part('global/wrapper-start'); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
| 363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * Output the end of the page wrapper. |
| 367 | 367 | */ |
| 368 | 368 | function give_output_content_wrapper_end() { |
| 369 | - give_get_template_part( 'global/wrapper-end' ); |
|
| 369 | + give_get_template_part('global/wrapper-end'); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Single Give Form |
| 375 | 375 | */ |
| 376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
| 376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
| 377 | 377 | function give_left_sidebar_pre_wrap() { |
| 378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
| 378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
| 382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
| 383 | 383 | function give_left_sidebar_post_wrap() { |
| 384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
| 384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
| 388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
| 389 | 389 | function give_get_forms_sidebar() { |
| 390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
| 390 | + give_get_template_part('single-give-form/sidebar'); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
| 394 | +if ( ! function_exists('give_show_form_images')) { |
|
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | 397 | * Output the donation form featured image. |
| 398 | 398 | */ |
| 399 | 399 | function give_show_form_images() { |
| 400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
| 400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 401 | + give_get_template_part('single-give-form/featured-image'); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
| 406 | +if ( ! function_exists('give_template_single_title')) { |
|
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * Output the form title. |
| 410 | 410 | */ |
| 411 | 411 | function give_template_single_title() { |
| 412 | - give_get_template_part( 'single-give-form/title' ); |
|
| 412 | + give_get_template_part('single-give-form/title'); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * Conditional Functions |
| 418 | 418 | */ |
| 419 | 419 | |
| 420 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
| 420 | +if ( ! function_exists('is_give_form')) { |
|
| 421 | 421 | |
| 422 | 422 | /** |
| 423 | 423 | * is_give_form |
@@ -429,11 +429,11 @@ discard block |
||
| 429 | 429 | * @return bool |
| 430 | 430 | */ |
| 431 | 431 | function is_give_form() { |
| 432 | - return is_singular( array( 'give_form' ) ); |
|
| 432 | + return is_singular(array('give_form')); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
| 436 | +if ( ! function_exists('is_give_category')) { |
|
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | 439 | * is_give_category |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return bool |
| 450 | 450 | */ |
| 451 | - function is_give_category( $term = '' ) { |
|
| 452 | - return is_tax( 'give_forms_category', $term ); |
|
| 451 | + function is_give_category($term = '') { |
|
| 452 | + return is_tax('give_forms_category', $term); |
|
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
| 456 | +if ( ! function_exists('is_give_tag')) { |
|
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | 459 | * is_give_tag |
@@ -468,12 +468,12 @@ discard block |
||
| 468 | 468 | * |
| 469 | 469 | * @return bool |
| 470 | 470 | */ |
| 471 | - function is_give_tag( $term = '' ) { |
|
| 472 | - return is_tax( 'give_forms_tag', $term ); |
|
| 471 | + function is_give_tag($term = '') { |
|
| 472 | + return is_tax('give_forms_tag', $term); |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
| 476 | +if ( ! function_exists('is_give_taxonomy')) { |
|
| 477 | 477 | |
| 478 | 478 | /** |
| 479 | 479 | * is_give_taxonomy |
@@ -485,6 +485,6 @@ discard block |
||
| 485 | 485 | * @return bool |
| 486 | 486 | */ |
| 487 | 487 | function is_give_taxonomy() { |
| 488 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
| 488 | + return is_tax(get_object_taxonomies('give_form')); |
|
| 489 | 489 | } |
| 490 | 490 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param $url |
| 74 | 74 | * |
| 75 | - * @return mixed |
|
| 75 | + * @return string |
|
| 76 | 76 | */ |
| 77 | 77 | public function give_update_cmb_meta_box_url( $url ) { |
| 78 | 78 | // Path to Give's CMB |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | * @since 1.3.5 |
| 936 | 936 | * |
| 937 | 937 | * @param $array |
| 938 | - * @param $position |int|string Expects an array key or 'id' of the settings field to appear after |
|
| 938 | + * @param string $position |int|string Expects an array key or 'id' of the settings field to appear after |
|
| 939 | 939 | * @param $insert |array a valid array of options to insert |
| 940 | 940 | * |
| 941 | 941 | * @return array |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * @since 1.0 |
| 975 | 975 | * |
| 976 | 976 | * @param array $field_arr |
| 977 | - * @param array $saved_values |
|
| 977 | + * @param string|boolean $saved_values |
|
| 978 | 978 | * |
| 979 | 979 | * @return void |
| 980 | 980 | */ |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | * @since 1.0 |
| 1010 | 1010 | * |
| 1011 | 1011 | * @param array $field_arr |
| 1012 | - * @param array $saved_value |
|
| 1012 | + * @param string|boolean $saved_value |
|
| 1013 | 1013 | * |
| 1014 | 1014 | * @return void |
| 1015 | 1015 | */ |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | public function __construct() { |
| 44 | 44 | |
| 45 | 45 | // Custom CMB2 Settings Fields |
| 46 | - add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 ); |
|
| 47 | - add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 ); |
|
| 48 | - add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 ); |
|
| 49 | - add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 ); |
|
| 50 | - add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 ); |
|
| 51 | - add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 ); |
|
| 52 | - add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 ); |
|
| 53 | - add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 ); |
|
| 46 | + add_action('cmb2_render_give_title', 'give_title_callback', 10, 5); |
|
| 47 | + add_action('cmb2_render_give_description', 'give_description_callback', 10, 5); |
|
| 48 | + add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5); |
|
| 49 | + add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5); |
|
| 50 | + add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5); |
|
| 51 | + add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5); |
|
| 52 | + add_action('cmb2_render_api', 'give_api_callback', 10, 5); |
|
| 53 | + add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @since 1.0 |
| 61 | 61 | */ |
| 62 | 62 | public function init() { |
| 63 | - register_setting( $this->key, $this->key ); |
|
| 63 | + register_setting($this->key, $this->key); |
|
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return mixed |
| 76 | 76 | */ |
| 77 | - public function give_update_cmb_meta_box_url( $url ) { |
|
| 77 | + public function give_update_cmb_meta_box_url($url) { |
|
| 78 | 78 | // Path to Give's CMB |
| 79 | - return GIVE_PLUGIN_URL . '/includes/libraries/cmb2'; |
|
| 79 | + return GIVE_PLUGIN_URL.'/includes/libraries/cmb2'; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
@@ -88,27 +88,27 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function give_get_settings_tabs() { |
| 90 | 90 | |
| 91 | - $settings = $this->give_settings( null ); |
|
| 91 | + $settings = $this->give_settings(null); |
|
| 92 | 92 | |
| 93 | 93 | $tabs = array(); |
| 94 | - $tabs['general'] = __( 'General', 'give' ); |
|
| 95 | - $tabs['gateways'] = __( 'Payment Gateways', 'give' ); |
|
| 96 | - $tabs['display'] = __( 'Display Options', 'give' ); |
|
| 97 | - $tabs['emails'] = __( 'Emails', 'give' ); |
|
| 94 | + $tabs['general'] = __('General', 'give'); |
|
| 95 | + $tabs['gateways'] = __('Payment Gateways', 'give'); |
|
| 96 | + $tabs['display'] = __('Display Options', 'give'); |
|
| 97 | + $tabs['emails'] = __('Emails', 'give'); |
|
| 98 | 98 | |
| 99 | - if ( ! empty( $settings['addons']['fields'] ) ) { |
|
| 100 | - $tabs['addons'] = __( 'Add-ons', 'give' ); |
|
| 99 | + if ( ! empty($settings['addons']['fields'])) { |
|
| 100 | + $tabs['addons'] = __('Add-ons', 'give'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( ! empty( $settings['licenses']['fields'] ) ) { |
|
| 104 | - $tabs['licenses'] = __( 'Licenses', 'give' ); |
|
| 103 | + if ( ! empty($settings['licenses']['fields'])) { |
|
| 104 | + $tabs['licenses'] = __('Licenses', 'give'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $tabs['advanced'] = __( 'Advanced', 'give' ); |
|
| 108 | - $tabs['api'] = __( 'API', 'give' ); |
|
| 109 | - $tabs['system_info'] = __( 'System Info', 'give' ); |
|
| 107 | + $tabs['advanced'] = __('Advanced', 'give'); |
|
| 108 | + $tabs['api'] = __('API', 'give'); |
|
| 109 | + $tabs['system_info'] = __('System Info', 'give'); |
|
| 110 | 110 | |
| 111 | - return apply_filters( 'give_settings_tabs', $tabs ); |
|
| 111 | + return apply_filters('give_settings_tabs', $tabs); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function admin_page_display() { |
| 121 | 121 | |
| 122 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general'; |
|
| 122 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general'; |
|
| 123 | 123 | |
| 124 | 124 | ?> |
| 125 | 125 | |
@@ -129,22 +129,22 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | <h2 class="nav-tab-wrapper"> |
| 131 | 131 | <?php |
| 132 | - foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) { |
|
| 132 | + foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) { |
|
| 133 | 133 | |
| 134 | - $tab_url = esc_url( add_query_arg( array( |
|
| 134 | + $tab_url = esc_url(add_query_arg(array( |
|
| 135 | 135 | 'settings-updated' => false, |
| 136 | 136 | 'tab' => $tab_id, |
| 137 | - ) ) ); |
|
| 137 | + ))); |
|
| 138 | 138 | |
| 139 | 139 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
| 140 | 140 | |
| 141 | - echo '<a href="' . esc_url( $tab_url ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>'; |
|
| 141 | + echo '<a href="'.esc_url($tab_url).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>'; |
|
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | ?> |
| 145 | 145 | </h2> |
| 146 | 146 | |
| 147 | - <?php cmb2_metabox_form( $this->give_settings( $active_tab ), $this->key ); ?> |
|
| 147 | + <?php cmb2_metabox_form($this->give_settings($active_tab), $this->key); ?> |
|
| 148 | 148 | |
| 149 | 149 | </div><!-- .wrap --> |
| 150 | 150 | |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | - function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) { |
|
| 169 | + function give_modify_cmb2_form_output($form_format, $object_id, $cmb) { |
|
| 170 | 170 | |
| 171 | 171 | // only modify the give settings form |
| 172 | - if ( 'give_settings' == $object_id ) { |
|
| 172 | + if ('give_settings' == $object_id) { |
|
| 173 | 173 | |
| 174 | - return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . esc_attr__( 'Save Settings', 'give' ) . '" class="button-primary"></div></form>'; |
|
| 174 | + return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.esc_attr__('Save Settings', 'give').'" class="button-primary"></div></form>'; |
|
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return array |
| 190 | 190 | */ |
| 191 | - public function give_settings( $active_tab ) { |
|
| 191 | + public function give_settings($active_tab) { |
|
| 192 | 192 | |
| 193 | 193 | $give_settings = array( |
| 194 | 194 | /** |
@@ -196,99 +196,99 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | 'general' => array( |
| 198 | 198 | 'id' => 'general_settings', |
| 199 | - 'give_title' => __( 'General Settings', 'give' ), |
|
| 200 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 201 | - 'fields' => apply_filters( 'give_settings_general', array( |
|
| 199 | + 'give_title' => __('General Settings', 'give'), |
|
| 200 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 201 | + 'fields' => apply_filters('give_settings_general', array( |
|
| 202 | 202 | array( |
| 203 | - 'name' => __( 'General Settings', 'give' ), |
|
| 203 | + 'name' => __('General Settings', 'give'), |
|
| 204 | 204 | 'desc' => '', |
| 205 | 205 | 'type' => 'give_title', |
| 206 | 206 | 'id' => 'give_title_general_settings_1', |
| 207 | 207 | ), |
| 208 | 208 | array( |
| 209 | - 'name' => __( 'Success Page', 'give' ), |
|
| 209 | + 'name' => __('Success Page', 'give'), |
|
| 210 | 210 | /* translators: %s: [give_receipt] */ |
| 211 | - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
| 211 | + 'desc' => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
| 212 | 212 | 'id' => 'success_page', |
| 213 | 213 | 'type' => 'select', |
| 214 | - 'options' => give_cmb2_get_post_options( array( |
|
| 214 | + 'options' => give_cmb2_get_post_options(array( |
|
| 215 | 215 | 'post_type' => 'page', |
| 216 | - 'numberposts' => - 1, |
|
| 217 | - ) ), |
|
| 216 | + 'numberposts' => -1, |
|
| 217 | + )), |
|
| 218 | 218 | ), |
| 219 | 219 | array( |
| 220 | - 'name' => __( 'Failed Donation Page', 'give' ), |
|
| 221 | - 'desc' => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ), |
|
| 220 | + 'name' => __('Failed Donation Page', 'give'), |
|
| 221 | + 'desc' => __('The page donors are sent to if their donation is cancelled or fails.', 'give'), |
|
| 222 | 222 | 'id' => 'failure_page', |
| 223 | 223 | 'type' => 'select', |
| 224 | - 'options' => give_cmb2_get_post_options( array( |
|
| 224 | + 'options' => give_cmb2_get_post_options(array( |
|
| 225 | 225 | 'post_type' => 'page', |
| 226 | - 'numberposts' => - 1, |
|
| 227 | - ) ), |
|
| 226 | + 'numberposts' => -1, |
|
| 227 | + )), |
|
| 228 | 228 | ), |
| 229 | 229 | array( |
| 230 | - 'name' => __( 'Donation History Page', 'give' ), |
|
| 230 | + 'name' => __('Donation History Page', 'give'), |
|
| 231 | 231 | /* translators: %s: [donation_history] */ |
| 232 | - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
| 232 | + 'desc' => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
| 233 | 233 | 'id' => 'history_page', |
| 234 | 234 | 'type' => 'select', |
| 235 | - 'options' => give_cmb2_get_post_options( array( |
|
| 235 | + 'options' => give_cmb2_get_post_options(array( |
|
| 236 | 236 | 'post_type' => 'page', |
| 237 | - 'numberposts' => - 1, |
|
| 238 | - ) ), |
|
| 237 | + 'numberposts' => -1, |
|
| 238 | + )), |
|
| 239 | 239 | ), |
| 240 | 240 | array( |
| 241 | - 'name' => __( 'Base Country', 'give' ), |
|
| 242 | - 'desc' => __( 'The country your site operates from.', 'give' ), |
|
| 241 | + 'name' => __('Base Country', 'give'), |
|
| 242 | + 'desc' => __('The country your site operates from.', 'give'), |
|
| 243 | 243 | 'id' => 'base_country', |
| 244 | 244 | 'type' => 'select', |
| 245 | 245 | 'options' => give_get_country_list(), |
| 246 | 246 | ), |
| 247 | 247 | array( |
| 248 | - 'name' => __( 'Currency Settings', 'give' ), |
|
| 248 | + 'name' => __('Currency Settings', 'give'), |
|
| 249 | 249 | 'desc' => '', |
| 250 | 250 | 'type' => 'give_title', |
| 251 | 251 | 'id' => 'give_title_general_settings_2', |
| 252 | 252 | ), |
| 253 | 253 | array( |
| 254 | - 'name' => __( 'Currency', 'give' ), |
|
| 255 | - 'desc' => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ), |
|
| 254 | + 'name' => __('Currency', 'give'), |
|
| 255 | + 'desc' => __('The donation currency. Note that some payment gateways have currency restrictions.', 'give'), |
|
| 256 | 256 | 'id' => 'currency', |
| 257 | 257 | 'type' => 'select', |
| 258 | 258 | 'options' => give_get_currencies(), |
| 259 | 259 | 'default' => 'USD', |
| 260 | 260 | ), |
| 261 | 261 | array( |
| 262 | - 'name' => __( 'Currency Position', 'give' ), |
|
| 263 | - 'desc' => __( 'The position of the currency symbol.', 'give' ), |
|
| 262 | + 'name' => __('Currency Position', 'give'), |
|
| 263 | + 'desc' => __('The position of the currency symbol.', 'give'), |
|
| 264 | 264 | 'id' => 'currency_position', |
| 265 | 265 | 'type' => 'select', |
| 266 | 266 | 'options' => array( |
| 267 | 267 | /* translators: %s: currency symbol */ |
| 268 | - 'before' => sprintf( __( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
| 268 | + 'before' => sprintf(__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())), |
|
| 269 | 269 | /* translators: %s: currency symbol */ |
| 270 | - 'after' => sprintf( __( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
| 270 | + 'after' => sprintf(__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())), |
|
| 271 | 271 | ), |
| 272 | 272 | 'default' => 'before', |
| 273 | 273 | ), |
| 274 | 274 | array( |
| 275 | - 'name' => __( 'Thousands Separator', 'give' ), |
|
| 276 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands.', 'give' ), |
|
| 275 | + 'name' => __('Thousands Separator', 'give'), |
|
| 276 | + 'desc' => __('The symbol (usually , or .) to separate thousands.', 'give'), |
|
| 277 | 277 | 'id' => 'thousands_separator', |
| 278 | 278 | 'type' => 'text_small', |
| 279 | 279 | 'sanitization_cb' => 'give_sanitize_thousand_separator', |
| 280 | 280 | 'default' => ',', |
| 281 | 281 | ), |
| 282 | 282 | array( |
| 283 | - 'name' => __( 'Decimal Separator', 'give' ), |
|
| 284 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
| 283 | + 'name' => __('Decimal Separator', 'give'), |
|
| 284 | + 'desc' => __('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
| 285 | 285 | 'id' => 'decimal_separator', |
| 286 | 286 | 'type' => 'text_small', |
| 287 | 287 | 'default' => '.', |
| 288 | 288 | ), |
| 289 | 289 | array( |
| 290 | - 'name' => __( 'Number of Decimals', 'give' ), |
|
| 291 | - 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ), |
|
| 290 | + 'name' => __('Number of Decimals', 'give'), |
|
| 291 | + 'desc' => __('The number of decimal points displayed in amounts.', 'give'), |
|
| 292 | 292 | 'id' => 'number_decimals', |
| 293 | 293 | 'type' => 'text_small', |
| 294 | 294 | 'default' => 2, |
@@ -302,83 +302,83 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | 'gateways' => array( |
| 304 | 304 | 'id' => 'payment_gateways', |
| 305 | - 'give_title' => __( 'Payment Gateways', 'give' ), |
|
| 306 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 307 | - 'fields' => apply_filters( 'give_settings_gateways', array( |
|
| 305 | + 'give_title' => __('Payment Gateways', 'give'), |
|
| 306 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 307 | + 'fields' => apply_filters('give_settings_gateways', array( |
|
| 308 | 308 | array( |
| 309 | - 'name' => __( 'Gateways Settings', 'give' ), |
|
| 309 | + 'name' => __('Gateways Settings', 'give'), |
|
| 310 | 310 | 'desc' => '', |
| 311 | 311 | 'id' => 'give_title_gateway_settings_1', |
| 312 | 312 | 'type' => 'give_title', |
| 313 | 313 | ), |
| 314 | 314 | array( |
| 315 | - 'name' => __( 'Test Mode', 'give' ), |
|
| 316 | - 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
| 315 | + 'name' => __('Test Mode', 'give'), |
|
| 316 | + 'desc' => __('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
| 317 | 317 | 'id' => 'test_mode', |
| 318 | 318 | 'type' => 'checkbox', |
| 319 | 319 | ), |
| 320 | 320 | array( |
| 321 | - 'name' => __( 'Enabled Gateways', 'give' ), |
|
| 322 | - 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
| 321 | + 'name' => __('Enabled Gateways', 'give'), |
|
| 322 | + 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
| 323 | 323 | 'id' => 'gateways', |
| 324 | 324 | 'type' => 'enabled_gateways', |
| 325 | 325 | ), |
| 326 | 326 | array( |
| 327 | - 'name' => __( 'Default Gateway', 'give' ), |
|
| 328 | - 'desc' => __( 'The gateway that will be selected by default.', 'give' ), |
|
| 327 | + 'name' => __('Default Gateway', 'give'), |
|
| 328 | + 'desc' => __('The gateway that will be selected by default.', 'give'), |
|
| 329 | 329 | 'id' => 'default_gateway', |
| 330 | 330 | 'type' => 'default_gateway', |
| 331 | 331 | ), |
| 332 | 332 | array( |
| 333 | - 'name' => __( 'PayPal Standard', 'give' ), |
|
| 333 | + 'name' => __('PayPal Standard', 'give'), |
|
| 334 | 334 | 'desc' => '', |
| 335 | 335 | 'type' => 'give_title', |
| 336 | 336 | 'id' => 'give_title_gateway_settings_2', |
| 337 | 337 | ), |
| 338 | 338 | array( |
| 339 | - 'name' => __( 'PayPal Email', 'give' ), |
|
| 340 | - 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), |
|
| 339 | + 'name' => __('PayPal Email', 'give'), |
|
| 340 | + 'desc' => __('Enter your PayPal account\'s email.', 'give'), |
|
| 341 | 341 | 'id' => 'paypal_email', |
| 342 | 342 | 'type' => 'text_email', |
| 343 | 343 | ), |
| 344 | 344 | array( |
| 345 | - 'name' => __( 'PayPal Page Style', 'give' ), |
|
| 346 | - 'desc' => __( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ), |
|
| 345 | + 'name' => __('PayPal Page Style', 'give'), |
|
| 346 | + 'desc' => __('Enter the name of the page style to use, or leave blank to use the default.', 'give'), |
|
| 347 | 347 | 'id' => 'paypal_page_style', |
| 348 | 348 | 'type' => 'text', |
| 349 | 349 | ), |
| 350 | 350 | array( |
| 351 | - 'name' => __( 'PayPal Transaction Type', 'give' ), |
|
| 352 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
| 351 | + 'name' => __('PayPal Transaction Type', 'give'), |
|
| 352 | + 'desc' => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
| 353 | 353 | 'id' => 'paypal_button_type', |
| 354 | 354 | 'type' => 'radio_inline', |
| 355 | 355 | 'options' => array( |
| 356 | - 'donation' => __( 'Donation', 'give' ), |
|
| 357 | - 'standard' => __( 'Standard Transaction', 'give' ), |
|
| 356 | + 'donation' => __('Donation', 'give'), |
|
| 357 | + 'standard' => __('Standard Transaction', 'give'), |
|
| 358 | 358 | ), |
| 359 | 359 | 'default' => 'donation', |
| 360 | 360 | ), |
| 361 | 361 | array( |
| 362 | - 'name' => __( 'Disable PayPal IPN Verification', 'give' ), |
|
| 363 | - 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
| 362 | + 'name' => __('Disable PayPal IPN Verification', 'give'), |
|
| 363 | + 'desc' => __('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
| 364 | 364 | 'id' => 'disable_paypal_verification', |
| 365 | 365 | 'type' => 'checkbox', |
| 366 | 366 | ), |
| 367 | 367 | array( |
| 368 | - 'name' => __( 'Offline Donations', 'give' ), |
|
| 368 | + 'name' => __('Offline Donations', 'give'), |
|
| 369 | 369 | 'desc' => '', |
| 370 | 370 | 'type' => 'give_title', |
| 371 | 371 | 'id' => 'give_title_gateway_settings_3', |
| 372 | 372 | ), |
| 373 | 373 | array( |
| 374 | - 'name' => __( 'Collect Billing Details', 'give' ), |
|
| 375 | - 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
| 374 | + 'name' => __('Collect Billing Details', 'give'), |
|
| 375 | + 'desc' => __('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
| 376 | 376 | 'id' => 'give_offline_donation_enable_billing_fields', |
| 377 | 377 | 'type' => 'checkbox', |
| 378 | 378 | ), |
| 379 | 379 | array( |
| 380 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
| 381 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
| 380 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
| 381 | + 'desc' => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
| 382 | 382 | 'id' => 'global_offline_donation_content', |
| 383 | 383 | 'default' => give_get_default_offline_donation_content(), |
| 384 | 384 | 'type' => 'wysiwyg', |
@@ -387,15 +387,15 @@ discard block |
||
| 387 | 387 | ), |
| 388 | 388 | ), |
| 389 | 389 | array( |
| 390 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
| 391 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
| 390 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
| 391 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
| 392 | 392 | 'id' => 'offline_donation_subject', |
| 393 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
| 393 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
| 394 | 394 | 'type' => 'text', |
| 395 | 395 | ), |
| 396 | 396 | array( |
| 397 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
| 398 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
| 397 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
| 398 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
| 399 | 399 | 'id' => 'global_offline_donation_email', |
| 400 | 400 | 'default' => give_get_default_offline_donation_email_content(), |
| 401 | 401 | 'type' => 'wysiwyg', |
@@ -409,104 +409,104 @@ discard block |
||
| 409 | 409 | /** Display Settings */ |
| 410 | 410 | 'display' => array( |
| 411 | 411 | 'id' => 'display_settings', |
| 412 | - 'give_title' => __( 'Display Settings', 'give' ), |
|
| 413 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 414 | - 'fields' => apply_filters( 'give_settings_display', array( |
|
| 412 | + 'give_title' => __('Display Settings', 'give'), |
|
| 413 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 414 | + 'fields' => apply_filters('give_settings_display', array( |
|
| 415 | 415 | array( |
| 416 | - 'name' => __( 'Display Settings', 'give' ), |
|
| 416 | + 'name' => __('Display Settings', 'give'), |
|
| 417 | 417 | 'desc' => '', |
| 418 | 418 | 'id' => 'give_title_display_settings_1', |
| 419 | 419 | 'type' => 'give_title', |
| 420 | 420 | ), |
| 421 | 421 | array( |
| 422 | - 'name' => __( 'Disable CSS', 'give' ), |
|
| 423 | - 'desc' => __( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ), |
|
| 422 | + 'name' => __('Disable CSS', 'give'), |
|
| 423 | + 'desc' => __('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'), |
|
| 424 | 424 | 'id' => 'disable_css', |
| 425 | 425 | 'type' => 'checkbox', |
| 426 | 426 | ), |
| 427 | 427 | array( |
| 428 | - 'name' => __( 'Enable Floating Labels', 'give' ), |
|
| 428 | + 'name' => __('Enable Floating Labels', 'give'), |
|
| 429 | 429 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
| 430 | - 'desc' => sprintf( wp_kses( __( 'Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array( |
|
| 430 | + 'desc' => sprintf(wp_kses(__('Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array( |
|
| 431 | 431 | 'a' => array( |
| 432 | 432 | 'href' => array(), |
| 433 | 433 | 'target' => array(), |
| 434 | 434 | ), |
| 435 | - ) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
| 435 | + )), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
| 436 | 436 | 'id' => 'floatlabels', |
| 437 | 437 | 'type' => 'checkbox', |
| 438 | 438 | ), |
| 439 | 439 | array( |
| 440 | - 'name' => __( 'Disable Welcome Screen', 'give' ), |
|
| 440 | + 'name' => __('Disable Welcome Screen', 'give'), |
|
| 441 | 441 | /* translators: %s: about page URL */ |
| 442 | - 'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give' ), array( |
|
| 442 | + 'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give'), array( |
|
| 443 | 443 | 'a' => array( |
| 444 | 444 | 'href' => array(), |
| 445 | 445 | 'target' => array(), |
| 446 | 446 | ), |
| 447 | - ) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ), |
|
| 447 | + )), esc_url(admin_url('index.php?page=give-about'))), |
|
| 448 | 448 | 'id' => 'disable_welcome', |
| 449 | 449 | 'type' => 'checkbox', |
| 450 | 450 | ), |
| 451 | 451 | array( |
| 452 | - 'name' => __( 'Post Types', 'give' ), |
|
| 452 | + 'name' => __('Post Types', 'give'), |
|
| 453 | 453 | 'desc' => '', |
| 454 | 454 | 'id' => 'give_title_display_settings_2', |
| 455 | 455 | 'type' => 'give_title', |
| 456 | 456 | ), |
| 457 | 457 | array( |
| 458 | - 'name' => __( 'Disable Form Single Views', 'give' ), |
|
| 459 | - 'desc' => __( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ), |
|
| 458 | + 'name' => __('Disable Form Single Views', 'give'), |
|
| 459 | + 'desc' => __('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'), |
|
| 460 | 460 | 'id' => 'disable_forms_singular', |
| 461 | 461 | 'type' => 'checkbox', |
| 462 | 462 | ), |
| 463 | 463 | array( |
| 464 | - 'name' => __( 'Disable Form Archives', 'give' ), |
|
| 465 | - 'desc' => __( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ), |
|
| 464 | + 'name' => __('Disable Form Archives', 'give'), |
|
| 465 | + 'desc' => __('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'), |
|
| 466 | 466 | 'id' => 'disable_forms_archives', |
| 467 | 467 | 'type' => 'checkbox', |
| 468 | 468 | ), |
| 469 | 469 | array( |
| 470 | - 'name' => __( 'Disable Form Excerpts', 'give' ), |
|
| 471 | - 'desc' => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ), |
|
| 470 | + 'name' => __('Disable Form Excerpts', 'give'), |
|
| 471 | + 'desc' => __('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'), |
|
| 472 | 472 | 'id' => 'disable_forms_excerpt', |
| 473 | 473 | 'type' => 'checkbox', |
| 474 | 474 | ), |
| 475 | 475 | array( |
| 476 | - 'name' => __( 'Featured Image Size', 'give' ), |
|
| 477 | - 'desc' => __( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ), |
|
| 476 | + 'name' => __('Featured Image Size', 'give'), |
|
| 477 | + 'desc' => __('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give'), |
|
| 478 | 478 | 'id' => 'featured_image_size', |
| 479 | 479 | 'type' => 'select', |
| 480 | 480 | 'default' => 'large', |
| 481 | 481 | 'options' => give_get_featured_image_sizes(), |
| 482 | 482 | ), |
| 483 | 483 | array( |
| 484 | - 'name' => __( 'Disable Form Featured Image', 'give' ), |
|
| 485 | - 'desc' => __( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ), |
|
| 484 | + 'name' => __('Disable Form Featured Image', 'give'), |
|
| 485 | + 'desc' => __('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'), |
|
| 486 | 486 | 'id' => 'disable_form_featured_img', |
| 487 | 487 | 'type' => 'checkbox', |
| 488 | 488 | ), |
| 489 | 489 | array( |
| 490 | - 'name' => __( 'Disable Single Form Sidebar', 'give' ), |
|
| 491 | - 'desc' => __( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ), |
|
| 490 | + 'name' => __('Disable Single Form Sidebar', 'give'), |
|
| 491 | + 'desc' => __('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'), |
|
| 492 | 492 | 'id' => 'disable_form_sidebar', |
| 493 | 493 | 'type' => 'checkbox', |
| 494 | 494 | ), |
| 495 | 495 | array( |
| 496 | - 'name' => __( 'Taxonomies', 'give' ), |
|
| 496 | + 'name' => __('Taxonomies', 'give'), |
|
| 497 | 497 | 'desc' => '', |
| 498 | 498 | 'id' => 'give_title_display_settings_3', |
| 499 | 499 | 'type' => 'give_title', |
| 500 | 500 | ), |
| 501 | 501 | array( |
| 502 | - 'name' => __( 'Enable Form Categories', 'give' ), |
|
| 503 | - 'desc' => __( 'Enables the "Category" taxonomy for all Give forms.', 'give' ), |
|
| 502 | + 'name' => __('Enable Form Categories', 'give'), |
|
| 503 | + 'desc' => __('Enables the "Category" taxonomy for all Give forms.', 'give'), |
|
| 504 | 504 | 'id' => 'categories', |
| 505 | 505 | 'type' => 'checkbox', |
| 506 | 506 | ), |
| 507 | 507 | array( |
| 508 | - 'name' => __( 'Enable Form Tags', 'give' ), |
|
| 509 | - 'desc' => __( 'Enables the "Tag" taxonomy for all Give forms.', 'give' ), |
|
| 508 | + 'name' => __('Enable Form Tags', 'give'), |
|
| 509 | + 'desc' => __('Enables the "Tag" taxonomy for all Give forms.', 'give'), |
|
| 510 | 510 | 'id' => 'tags', |
| 511 | 511 | 'type' => 'checkbox', |
| 512 | 512 | ), |
@@ -519,101 +519,101 @@ discard block |
||
| 519 | 519 | */ |
| 520 | 520 | 'emails' => array( |
| 521 | 521 | 'id' => 'email_settings', |
| 522 | - 'give_title' => __( 'Email Settings', 'give' ), |
|
| 523 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 524 | - 'fields' => apply_filters( 'give_settings_emails', array( |
|
| 522 | + 'give_title' => __('Email Settings', 'give'), |
|
| 523 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 524 | + 'fields' => apply_filters('give_settings_emails', array( |
|
| 525 | 525 | array( |
| 526 | - 'name' => __( 'Email Settings', 'give' ), |
|
| 526 | + 'name' => __('Email Settings', 'give'), |
|
| 527 | 527 | 'desc' => '', |
| 528 | 528 | 'id' => 'give_title_email_settings_1', |
| 529 | 529 | 'type' => 'give_title', |
| 530 | 530 | ), |
| 531 | 531 | array( |
| 532 | 532 | 'id' => 'email_template', |
| 533 | - 'name' => __( 'Email Template', 'give' ), |
|
| 534 | - 'desc' => __( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ), |
|
| 533 | + 'name' => __('Email Template', 'give'), |
|
| 534 | + 'desc' => __('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'), |
|
| 535 | 535 | 'type' => 'select', |
| 536 | 536 | 'options' => give_get_email_templates(), |
| 537 | 537 | ), |
| 538 | 538 | array( |
| 539 | 539 | 'id' => 'email_logo', |
| 540 | - 'name' => __( 'Logo', 'give' ), |
|
| 541 | - 'desc' => __( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
| 540 | + 'name' => __('Logo', 'give'), |
|
| 541 | + 'desc' => __('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
| 542 | 542 | 'type' => 'file', |
| 543 | 543 | ), |
| 544 | 544 | array( |
| 545 | 545 | 'id' => 'from_name', |
| 546 | - 'name' => __( 'From Name', 'give' ), |
|
| 547 | - 'desc' => __( 'The name that appears in the "From" field in donation receipt emails.', 'give' ), |
|
| 548 | - 'default' => get_bloginfo( 'name' ), |
|
| 546 | + 'name' => __('From Name', 'give'), |
|
| 547 | + 'desc' => __('The name that appears in the "From" field in donation receipt emails.', 'give'), |
|
| 548 | + 'default' => get_bloginfo('name'), |
|
| 549 | 549 | 'type' => 'text', |
| 550 | 550 | ), |
| 551 | 551 | array( |
| 552 | 552 | 'id' => 'from_email', |
| 553 | - 'name' => __( 'From Email', 'give' ), |
|
| 554 | - 'desc' => __( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ), |
|
| 555 | - 'default' => get_bloginfo( 'admin_email' ), |
|
| 553 | + 'name' => __('From Email', 'give'), |
|
| 554 | + 'desc' => __('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'), |
|
| 555 | + 'default' => get_bloginfo('admin_email'), |
|
| 556 | 556 | 'type' => 'text', |
| 557 | 557 | ), |
| 558 | 558 | array( |
| 559 | - 'name' => __( 'Donation Receipt', 'give' ), |
|
| 559 | + 'name' => __('Donation Receipt', 'give'), |
|
| 560 | 560 | 'desc' => '', |
| 561 | 561 | 'id' => 'give_title_email_settings_2', |
| 562 | 562 | 'type' => 'give_title', |
| 563 | 563 | ), |
| 564 | 564 | array( |
| 565 | 565 | 'id' => 'donation_subject', |
| 566 | - 'name' => __( 'Donation Email Subject', 'give' ), |
|
| 567 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
| 568 | - 'default' => esc_attr__( 'Donation Receipt', 'give' ), |
|
| 566 | + 'name' => __('Donation Email Subject', 'give'), |
|
| 567 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
| 568 | + 'default' => esc_attr__('Donation Receipt', 'give'), |
|
| 569 | 569 | 'type' => 'text', |
| 570 | 570 | ), |
| 571 | 571 | array( |
| 572 | 572 | 'id' => 'donation_receipt', |
| 573 | - 'name' => __( 'Donation Receipt', 'give' ), |
|
| 573 | + 'name' => __('Donation Receipt', 'give'), |
|
| 574 | 574 | 'desc' => sprintf( |
| 575 | 575 | /* translators: %s: emails tags list */ |
| 576 | - __( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give' ), |
|
| 577 | - '<br/>' . give_get_emails_tags_list() |
|
| 576 | + __('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give'), |
|
| 577 | + '<br/>'.give_get_emails_tags_list() |
|
| 578 | 578 | ), |
| 579 | 579 | 'type' => 'wysiwyg', |
| 580 | 580 | 'default' => give_get_default_donation_receipt_email(), |
| 581 | 581 | ), |
| 582 | 582 | array( |
| 583 | - 'name' => __( 'New Donation Notification', 'give' ), |
|
| 583 | + 'name' => __('New Donation Notification', 'give'), |
|
| 584 | 584 | 'desc' => '', |
| 585 | 585 | 'id' => 'give_title_email_settings_3', |
| 586 | 586 | 'type' => 'give_title', |
| 587 | 587 | ), |
| 588 | 588 | array( |
| 589 | 589 | 'id' => 'donation_notification_subject', |
| 590 | - 'name' => __( 'Donation Notification Subject', 'give' ), |
|
| 591 | - 'desc' => __( 'Enter the subject line for the donation notification email.', 'give' ), |
|
| 590 | + 'name' => __('Donation Notification Subject', 'give'), |
|
| 591 | + 'desc' => __('Enter the subject line for the donation notification email.', 'give'), |
|
| 592 | 592 | 'type' => 'text', |
| 593 | - 'default' => esc_attr__( 'New Donation - #{payment_id}', 'give' ), |
|
| 593 | + 'default' => esc_attr__('New Donation - #{payment_id}', 'give'), |
|
| 594 | 594 | ), |
| 595 | 595 | array( |
| 596 | 596 | 'id' => 'donation_notification', |
| 597 | - 'name' => __( 'Donation Notification', 'give' ), |
|
| 597 | + 'name' => __('Donation Notification', 'give'), |
|
| 598 | 598 | 'desc' => sprintf( |
| 599 | 599 | /* translators: %s: emails tags list */ |
| 600 | - __( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give' ), |
|
| 601 | - '<br/>' . give_get_emails_tags_list() |
|
| 600 | + __('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give'), |
|
| 601 | + '<br/>'.give_get_emails_tags_list() |
|
| 602 | 602 | ), |
| 603 | 603 | 'type' => 'wysiwyg', |
| 604 | 604 | 'default' => give_get_default_donation_notification_email(), |
| 605 | 605 | ), |
| 606 | 606 | array( |
| 607 | 607 | 'id' => 'admin_notice_emails', |
| 608 | - 'name' => __( 'Donation Notification Emails', 'give' ), |
|
| 609 | - 'desc' => __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give' ), |
|
| 608 | + 'name' => __('Donation Notification Emails', 'give'), |
|
| 609 | + 'desc' => __('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give'), |
|
| 610 | 610 | 'type' => 'textarea', |
| 611 | - 'default' => get_bloginfo( 'admin_email' ), |
|
| 611 | + 'default' => get_bloginfo('admin_email'), |
|
| 612 | 612 | ), |
| 613 | 613 | array( |
| 614 | 614 | 'id' => 'disable_admin_notices', |
| 615 | - 'name' => __( 'Disable Admin Notifications', 'give' ), |
|
| 616 | - 'desc' => __( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ), |
|
| 615 | + 'name' => __('Disable Admin Notifications', 'give'), |
|
| 616 | + 'desc' => __('Check this box if you do not want to receive emails when new donations are made.', 'give'), |
|
| 617 | 617 | 'type' => 'checkbox', |
| 618 | 618 | ), |
| 619 | 619 | ) |
@@ -622,99 +622,99 @@ discard block |
||
| 622 | 622 | /** Extension Settings */ |
| 623 | 623 | 'addons' => array( |
| 624 | 624 | 'id' => 'addons', |
| 625 | - 'give_title' => __( 'Give Add-ons Settings', 'give' ), |
|
| 626 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 627 | - 'fields' => apply_filters( 'give_settings_addons', array() |
|
| 625 | + 'give_title' => __('Give Add-ons Settings', 'give'), |
|
| 626 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 627 | + 'fields' => apply_filters('give_settings_addons', array() |
|
| 628 | 628 | ), |
| 629 | 629 | ), |
| 630 | 630 | /** Licenses Settings */ |
| 631 | 631 | 'licenses' => array( |
| 632 | 632 | 'id' => 'licenses', |
| 633 | - 'give_title' => __( 'Give Licenses', 'give' ), |
|
| 634 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 635 | - 'fields' => apply_filters( 'give_settings_licenses', array() |
|
| 633 | + 'give_title' => __('Give Licenses', 'give'), |
|
| 634 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 635 | + 'fields' => apply_filters('give_settings_licenses', array() |
|
| 636 | 636 | ), |
| 637 | 637 | ), |
| 638 | 638 | /** Advanced Options */ |
| 639 | 639 | 'advanced' => array( |
| 640 | 640 | 'id' => 'advanced_options', |
| 641 | - 'give_title' => __( 'Advanced Options', 'give' ), |
|
| 642 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 643 | - 'fields' => apply_filters( 'give_settings_advanced', array( |
|
| 641 | + 'give_title' => __('Advanced Options', 'give'), |
|
| 642 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 643 | + 'fields' => apply_filters('give_settings_advanced', array( |
|
| 644 | 644 | array( |
| 645 | - 'name' => __( 'Access Control', 'give' ), |
|
| 645 | + 'name' => __('Access Control', 'give'), |
|
| 646 | 646 | 'desc' => '', |
| 647 | 647 | 'id' => 'give_title_session_control_1', |
| 648 | 648 | 'type' => 'give_title', |
| 649 | 649 | ), |
| 650 | 650 | array( |
| 651 | 651 | 'id' => 'session_lifetime', |
| 652 | - 'name' => __( 'Session Lifetime', 'give' ), |
|
| 653 | - 'desc' => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ), |
|
| 652 | + 'name' => __('Session Lifetime', 'give'), |
|
| 653 | + 'desc' => __('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'), |
|
| 654 | 654 | 'type' => 'select', |
| 655 | 655 | 'options' => array( |
| 656 | - '86400' => __( '24 Hours', 'give' ), |
|
| 657 | - '172800' => __( '48 Hours', 'give' ), |
|
| 658 | - '259200' => __( '72 Hours', 'give' ), |
|
| 659 | - '604800' => __( '1 Week', 'give' ), |
|
| 656 | + '86400' => __('24 Hours', 'give'), |
|
| 657 | + '172800' => __('48 Hours', 'give'), |
|
| 658 | + '259200' => __('72 Hours', 'give'), |
|
| 659 | + '604800' => __('1 Week', 'give'), |
|
| 660 | 660 | ), |
| 661 | 661 | ), |
| 662 | 662 | array( |
| 663 | - 'name' => __( 'Email Access', 'give' ), |
|
| 664 | - 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
| 663 | + 'name' => __('Email Access', 'give'), |
|
| 664 | + 'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
| 665 | 665 | 'id' => 'email_access', |
| 666 | 666 | 'type' => 'checkbox', |
| 667 | 667 | ), |
| 668 | 668 | array( |
| 669 | 669 | 'id' => 'recaptcha_key', |
| 670 | - 'name' => __( 'reCAPTCHA Site Key', 'give' ), |
|
| 670 | + 'name' => __('reCAPTCHA Site Key', 'give'), |
|
| 671 | 671 | /* translators: %s: https://www.google.com/recaptcha/ */ |
| 672 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'https://www.google.com/recaptcha/' ) ), |
|
| 672 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('https://www.google.com/recaptcha/')), |
|
| 673 | 673 | 'default' => '', |
| 674 | 674 | 'type' => 'text', |
| 675 | 675 | ), |
| 676 | 676 | array( |
| 677 | 677 | 'id' => 'recaptcha_secret', |
| 678 | - 'name' => __( 'reCAPTCHA Secret Key', 'give' ), |
|
| 679 | - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ), |
|
| 678 | + 'name' => __('reCAPTCHA Secret Key', 'give'), |
|
| 679 | + 'desc' => __('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'), |
|
| 680 | 680 | 'default' => '', |
| 681 | 681 | 'type' => 'text', |
| 682 | 682 | ), |
| 683 | 683 | array( |
| 684 | - 'name' => __( 'Data Control', 'give' ), |
|
| 684 | + 'name' => __('Data Control', 'give'), |
|
| 685 | 685 | 'desc' => '', |
| 686 | 686 | 'id' => 'give_title_data_control_2', |
| 687 | 687 | 'type' => 'give_title', |
| 688 | 688 | ), |
| 689 | 689 | array( |
| 690 | - 'name' => __( 'Remove All Data on Uninstall?', 'give' ), |
|
| 691 | - 'desc' => __( 'When the plugin is deleted, completely remove all Give data.', 'give' ), |
|
| 690 | + 'name' => __('Remove All Data on Uninstall?', 'give'), |
|
| 691 | + 'desc' => __('When the plugin is deleted, completely remove all Give data.', 'give'), |
|
| 692 | 692 | 'id' => 'uninstall_on_delete', |
| 693 | 693 | 'type' => 'checkbox', |
| 694 | 694 | ), |
| 695 | 695 | array( |
| 696 | - 'name' => __( 'Filter Control', 'give' ), |
|
| 696 | + 'name' => __('Filter Control', 'give'), |
|
| 697 | 697 | 'desc' => '', |
| 698 | 698 | 'id' => 'give_title_filter_control', |
| 699 | 699 | 'type' => 'give_title', |
| 700 | 700 | ), |
| 701 | 701 | array( |
| 702 | 702 | /* translators: %s: the_content */ |
| 703 | - 'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ), |
|
| 703 | + 'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'), |
|
| 704 | 704 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
| 705 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
| 705 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
| 706 | 706 | 'id' => 'disable_the_content_filter', |
| 707 | 707 | 'type' => 'checkbox', |
| 708 | 708 | ), |
| 709 | 709 | array( |
| 710 | - 'name' => __( 'Script Loading', 'give' ), |
|
| 710 | + 'name' => __('Script Loading', 'give'), |
|
| 711 | 711 | 'desc' => '', |
| 712 | 712 | 'id' => 'give_title_script_control', |
| 713 | 713 | 'type' => 'give_title', |
| 714 | 714 | ), |
| 715 | 715 | array( |
| 716 | - 'name' => __( 'Load Scripts in Footer?', 'give' ), |
|
| 717 | - 'desc' => __( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ), |
|
| 716 | + 'name' => __('Load Scripts in Footer?', 'give'), |
|
| 717 | + 'desc' => __('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'), |
|
| 718 | 718 | 'id' => 'scripts_footer', |
| 719 | 719 | 'type' => 'checkbox', |
| 720 | 720 | ), |
@@ -724,13 +724,13 @@ discard block |
||
| 724 | 724 | /** API Settings */ |
| 725 | 725 | 'api' => array( |
| 726 | 726 | 'id' => 'api', |
| 727 | - 'give_title' => __( 'API', 'give' ), |
|
| 728 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 727 | + 'give_title' => __('API', 'give'), |
|
| 728 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 729 | 729 | 'show_names' => false, // Hide field names on the left |
| 730 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
| 730 | + 'fields' => apply_filters('give_settings_system', array( |
|
| 731 | 731 | array( |
| 732 | 732 | 'id' => 'api', |
| 733 | - 'name' => __( 'API', 'give' ), |
|
| 733 | + 'name' => __('API', 'give'), |
|
| 734 | 734 | 'type' => 'api', |
| 735 | 735 | ), |
| 736 | 736 | ) |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | /** Licenses Settings */ |
| 740 | 740 | 'system_info' => array( |
| 741 | 741 | 'id' => 'system_info', |
| 742 | - 'give_title' => __( 'System Info', 'give' ), |
|
| 743 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key ) ), |
|
| 744 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
| 742 | + 'give_title' => __('System Info', 'give'), |
|
| 743 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key)), |
|
| 744 | + 'fields' => apply_filters('give_settings_system', array( |
|
| 745 | 745 | array( |
| 746 | 746 | 'id' => 'system-info-textarea', |
| 747 | - 'name' => __( 'System Info', 'give' ), |
|
| 748 | - 'desc' => __( 'Please copy and paste this information in your ticket when contacting support.', 'give' ), |
|
| 747 | + 'name' => __('System Info', 'give'), |
|
| 748 | + 'desc' => __('Please copy and paste this information in your ticket when contacting support.', 'give'), |
|
| 749 | 749 | 'type' => 'system_info', |
| 750 | 750 | ), |
| 751 | 751 | ) |
@@ -753,15 +753,15 @@ discard block |
||
| 753 | 753 | ), |
| 754 | 754 | ); |
| 755 | 755 | |
| 756 | - $give_settings = apply_filters( 'give_registered_settings', $give_settings ); |
|
| 756 | + $give_settings = apply_filters('give_registered_settings', $give_settings); |
|
| 757 | 757 | |
| 758 | 758 | // Return all settings array if no active tab |
| 759 | - if ( empty( $active_tab ) || ! isset( $give_settings[ $active_tab ] ) ) { |
|
| 759 | + if (empty($active_tab) || ! isset($give_settings[$active_tab])) { |
|
| 760 | 760 | return $give_settings; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | // Add other tabs and settings fields as needed |
| 764 | - return $give_settings[ $active_tab ]; |
|
| 764 | + return $give_settings[$active_tab]; |
|
| 765 | 765 | |
| 766 | 766 | } |
| 767 | 767 | |
@@ -770,11 +770,11 @@ discard block |
||
| 770 | 770 | */ |
| 771 | 771 | public function settings_notices() { |
| 772 | 772 | |
| 773 | - if ( ! isset( $_POST['give_settings_saved'] ) ) { |
|
| 773 | + if ( ! isset($_POST['give_settings_saved'])) { |
|
| 774 | 774 | return; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - add_settings_error( 'give-notices', 'global-settings-updated', __( 'Settings updated.', 'give' ), 'updated' ); |
|
| 777 | + add_settings_error('give-notices', 'global-settings-updated', __('Settings updated.', 'give'), 'updated'); |
|
| 778 | 778 | |
| 779 | 779 | } |
| 780 | 780 | |
@@ -789,14 +789,14 @@ discard block |
||
| 789 | 789 | * @return mixed Field value or exception is thrown. |
| 790 | 790 | * @throws Exception Throws an exception if the field is invalid. |
| 791 | 791 | */ |
| 792 | - public function __get( $field ) { |
|
| 792 | + public function __get($field) { |
|
| 793 | 793 | |
| 794 | 794 | // Allowed fields to retrieve |
| 795 | - if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) { |
|
| 795 | + if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) { |
|
| 796 | 796 | return $this->{$field}; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - throw new Exception( sprintf( __( 'Invalid property: %s', 'give' ), $field ) ); |
|
| 799 | + throw new Exception(sprintf(__('Invalid property: %s', 'give'), $field)); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | |
@@ -815,12 +815,12 @@ discard block |
||
| 815 | 815 | * |
| 816 | 816 | * @return mixed Option value |
| 817 | 817 | */ |
| 818 | -function give_get_option( $key = '', $default = false ) { |
|
| 818 | +function give_get_option($key = '', $default = false) { |
|
| 819 | 819 | $give_options = give_get_settings(); |
| 820 | - $value = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default; |
|
| 821 | - $value = apply_filters( 'give_get_option', $value, $key, $default ); |
|
| 820 | + $value = ! empty($give_options[$key]) ? $give_options[$key] : $default; |
|
| 821 | + $value = apply_filters('give_get_option', $value, $key, $default); |
|
| 822 | 822 | |
| 823 | - return apply_filters( "give_get_option_{$key}", $value, $key, $default ); |
|
| 823 | + return apply_filters("give_get_option_{$key}", $value, $key, $default); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | |
@@ -838,33 +838,33 @@ discard block |
||
| 838 | 838 | * |
| 839 | 839 | * @return boolean True if updated, false if not. |
| 840 | 840 | */ |
| 841 | -function give_update_option( $key = '', $value = false ) { |
|
| 841 | +function give_update_option($key = '', $value = false) { |
|
| 842 | 842 | |
| 843 | 843 | // If no key, exit |
| 844 | - if ( empty( $key ) ) { |
|
| 844 | + if (empty($key)) { |
|
| 845 | 845 | return false; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - if ( empty( $value ) ) { |
|
| 849 | - $remove_option = give_delete_option( $key ); |
|
| 848 | + if (empty($value)) { |
|
| 849 | + $remove_option = give_delete_option($key); |
|
| 850 | 850 | |
| 851 | 851 | return $remove_option; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | // First let's grab the current settings |
| 855 | - $options = get_option( 'give_settings' ); |
|
| 855 | + $options = get_option('give_settings'); |
|
| 856 | 856 | |
| 857 | 857 | // Let's let devs alter that value coming in |
| 858 | - $value = apply_filters( 'give_update_option', $value, $key ); |
|
| 858 | + $value = apply_filters('give_update_option', $value, $key); |
|
| 859 | 859 | |
| 860 | 860 | // Next let's try to update the value |
| 861 | - $options[ $key ] = $value; |
|
| 862 | - $did_update = update_option( 'give_settings', $options ); |
|
| 861 | + $options[$key] = $value; |
|
| 862 | + $did_update = update_option('give_settings', $options); |
|
| 863 | 863 | |
| 864 | 864 | // If it updated, let's update the global variable |
| 865 | - if ( $did_update ) { |
|
| 865 | + if ($did_update) { |
|
| 866 | 866 | global $give_options; |
| 867 | - $give_options[ $key ] = $value; |
|
| 867 | + $give_options[$key] = $value; |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | return $did_update; |
@@ -883,25 +883,25 @@ discard block |
||
| 883 | 883 | * |
| 884 | 884 | * @return boolean True if updated, false if not. |
| 885 | 885 | */ |
| 886 | -function give_delete_option( $key = '' ) { |
|
| 886 | +function give_delete_option($key = '') { |
|
| 887 | 887 | |
| 888 | 888 | // If no key, exit |
| 889 | - if ( empty( $key ) ) { |
|
| 889 | + if (empty($key)) { |
|
| 890 | 890 | return false; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | // First let's grab the current settings |
| 894 | - $options = get_option( 'give_settings' ); |
|
| 894 | + $options = get_option('give_settings'); |
|
| 895 | 895 | |
| 896 | 896 | // Next let's try to update the value |
| 897 | - if ( isset( $options[ $key ] ) ) { |
|
| 898 | - unset( $options[ $key ] ); |
|
| 897 | + if (isset($options[$key])) { |
|
| 898 | + unset($options[$key]); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - $did_update = update_option( 'give_settings', $options ); |
|
| 901 | + $did_update = update_option('give_settings', $options); |
|
| 902 | 902 | |
| 903 | 903 | // If it updated, let's update the global variable |
| 904 | - if ( $did_update ) { |
|
| 904 | + if ($did_update) { |
|
| 905 | 905 | global $give_options; |
| 906 | 906 | $give_options = $options; |
| 907 | 907 | } |
@@ -920,9 +920,9 @@ discard block |
||
| 920 | 920 | */ |
| 921 | 921 | function give_get_settings() { |
| 922 | 922 | |
| 923 | - $settings = get_option( 'give_settings' ); |
|
| 923 | + $settings = get_option('give_settings'); |
|
| 924 | 924 | |
| 925 | - return (array) apply_filters( 'give_get_settings', $settings ); |
|
| 925 | + return (array) apply_filters('give_get_settings', $settings); |
|
| 926 | 926 | |
| 927 | 927 | } |
| 928 | 928 | |
@@ -940,25 +940,25 @@ discard block |
||
| 940 | 940 | * |
| 941 | 941 | * @return array |
| 942 | 942 | */ |
| 943 | -function give_settings_array_insert( $array, $position, $insert ) { |
|
| 944 | - if ( is_int( $position ) ) { |
|
| 945 | - array_splice( $array, $position, 0, $insert ); |
|
| 943 | +function give_settings_array_insert($array, $position, $insert) { |
|
| 944 | + if (is_int($position)) { |
|
| 945 | + array_splice($array, $position, 0, $insert); |
|
| 946 | 946 | } else { |
| 947 | 947 | |
| 948 | - foreach ( $array as $index => $subarray ) { |
|
| 949 | - if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) { |
|
| 948 | + foreach ($array as $index => $subarray) { |
|
| 949 | + if (isset($subarray['id']) && $subarray['id'] == $position) { |
|
| 950 | 950 | $pos = $index; |
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - if ( ! isset( $pos ) ) { |
|
| 954 | + if ( ! isset($pos)) { |
|
| 955 | 955 | return $array; |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | $array = array_merge( |
| 959 | - array_slice( $array, 0, $pos ), |
|
| 959 | + array_slice($array, 0, $pos), |
|
| 960 | 960 | $insert, |
| 961 | - array_slice( $array, $pos ) |
|
| 961 | + array_slice($array, $pos) |
|
| 962 | 962 | ); |
| 963 | 963 | } |
| 964 | 964 | |
@@ -978,23 +978,23 @@ discard block |
||
| 978 | 978 | * |
| 979 | 979 | * @return void |
| 980 | 980 | */ |
| 981 | -function give_enabled_gateways_callback( $field_arr, $saved_values = array() ) { |
|
| 981 | +function give_enabled_gateways_callback($field_arr, $saved_values = array()) { |
|
| 982 | 982 | |
| 983 | 983 | $id = $field_arr['id']; |
| 984 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
| 984 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
| 985 | 985 | |
| 986 | 986 | echo '<ul class="give-checklist-fields give-payment-gatways-list">'; |
| 987 | 987 | |
| 988 | - foreach ( $gateways as $key => $option ) : |
|
| 988 | + foreach ($gateways as $key => $option) : |
|
| 989 | 989 | |
| 990 | - if ( is_array( $saved_values ) && array_key_exists( $key, $saved_values ) ) { |
|
| 990 | + if (is_array($saved_values) && array_key_exists($key, $saved_values)) { |
|
| 991 | 991 | $enabled = '1'; |
| 992 | 992 | } else { |
| 993 | 993 | $enabled = null; |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | - echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/> '; |
|
| 997 | - echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>'; |
|
| 996 | + echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/> '; |
|
| 997 | + echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>'; |
|
| 998 | 998 | |
| 999 | 999 | endforeach; |
| 1000 | 1000 | |
@@ -1013,16 +1013,16 @@ discard block |
||
| 1013 | 1013 | * |
| 1014 | 1014 | * @return void |
| 1015 | 1015 | */ |
| 1016 | -function give_default_gateway_callback( $field_arr, $saved_value ) { |
|
| 1016 | +function give_default_gateway_callback($field_arr, $saved_value) { |
|
| 1017 | 1017 | $id = $field_arr['id']; |
| 1018 | 1018 | $gateways = give_get_enabled_payment_gateways(); |
| 1019 | - $saved_value = give_get_default_gateway( null ); |
|
| 1019 | + $saved_value = give_get_default_gateway(null); |
|
| 1020 | 1020 | |
| 1021 | - echo '<select class="give-select" name="' . $id . '" id="' . $id . '">'; |
|
| 1021 | + echo '<select class="give-select" name="'.$id.'" id="'.$id.'">'; |
|
| 1022 | 1022 | |
| 1023 | - foreach ( $gateways as $key => $option ) : |
|
| 1024 | - $selected = isset( $saved_value ) ? selected( $key, $saved_value, false ) : ''; |
|
| 1025 | - echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1023 | + foreach ($gateways as $key => $option) : |
|
| 1024 | + $selected = isset($saved_value) ? selected($key, $saved_value, false) : ''; |
|
| 1025 | + echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>'; |
|
| 1026 | 1026 | endforeach; |
| 1027 | 1027 | |
| 1028 | 1028 | echo '</select>'; |
@@ -1040,13 +1040,13 @@ discard block |
||
| 1040 | 1040 | * |
| 1041 | 1041 | * @return void |
| 1042 | 1042 | */ |
| 1043 | -function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
| 1043 | +function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
| 1044 | 1044 | |
| 1045 | 1045 | $id = $field_type_object->field->args['id']; |
| 1046 | 1046 | $title = $field_type_object->field->args['name']; |
| 1047 | 1047 | $field_description = $field_type_object->field->args['desc']; |
| 1048 | 1048 | |
| 1049 | - echo '<hr>' . $field_description; |
|
| 1049 | + echo '<hr>'.$field_description; |
|
| 1050 | 1050 | |
| 1051 | 1051 | } |
| 1052 | 1052 | |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | * |
| 1062 | 1062 | * @return void |
| 1063 | 1063 | */ |
| 1064 | -function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
| 1064 | +function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
| 1065 | 1065 | |
| 1066 | 1066 | $id = $field_type_object->field->args['id']; |
| 1067 | 1067 | $title = $field_type_object->field->args['name']; |
@@ -1080,25 +1080,25 @@ discard block |
||
| 1080 | 1080 | * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types |
| 1081 | 1081 | * @return array An array of options that matches the CMB2 options array |
| 1082 | 1082 | */ |
| 1083 | -function give_cmb2_get_post_options( $query_args, $force = false ) { |
|
| 1083 | +function give_cmb2_get_post_options($query_args, $force = false) { |
|
| 1084 | 1084 | |
| 1085 | - $post_options = array( '' => '' ); // Blank option |
|
| 1085 | + $post_options = array('' => ''); // Blank option |
|
| 1086 | 1086 | |
| 1087 | - if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) { |
|
| 1087 | + if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) { |
|
| 1088 | 1088 | return $post_options; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - $args = wp_parse_args( $query_args, array( |
|
| 1091 | + $args = wp_parse_args($query_args, array( |
|
| 1092 | 1092 | 'post_type' => 'page', |
| 1093 | 1093 | 'numberposts' => 10, |
| 1094 | - ) ); |
|
| 1094 | + )); |
|
| 1095 | 1095 | |
| 1096 | - $posts = get_posts( $args ); |
|
| 1096 | + $posts = get_posts($args); |
|
| 1097 | 1097 | |
| 1098 | - if ( $posts ) { |
|
| 1099 | - foreach ( $posts as $post ) { |
|
| 1098 | + if ($posts) { |
|
| 1099 | + foreach ($posts as $post) { |
|
| 1100 | 1100 | |
| 1101 | - $post_options[ $post->ID ] = $post->post_title; |
|
| 1101 | + $post_options[$post->ID] = $post->post_title; |
|
| 1102 | 1102 | |
| 1103 | 1103 | } |
| 1104 | 1104 | } |
@@ -1124,20 +1124,20 @@ discard block |
||
| 1124 | 1124 | $get_sizes = get_intermediate_image_sizes(); |
| 1125 | 1125 | |
| 1126 | 1126 | // check whether intermediate image sizes exist first |
| 1127 | - if ( empty( $get_sizes ) ) { |
|
| 1128 | - $get_sizes = array( 'thumbnail', 'medium', 'medium_large', 'large' ); |
|
| 1127 | + if (empty($get_sizes)) { |
|
| 1128 | + $get_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - foreach ( $get_sizes as $_size ) { |
|
| 1131 | + foreach ($get_sizes as $_size) { |
|
| 1132 | 1132 | |
| 1133 | - if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) { |
|
| 1134 | - $sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" ); |
|
| 1135 | - } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
|
| 1136 | - $sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height']; |
|
| 1133 | + if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) { |
|
| 1134 | + $sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h"); |
|
| 1135 | + } elseif (isset($_wp_additional_image_sizes[$_size])) { |
|
| 1136 | + $sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height']; |
|
| 1137 | 1137 | } |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - return apply_filters( 'give_get_featured_image_sizes', $sizes ); |
|
| 1140 | + return apply_filters('give_get_featured_image_sizes', $sizes); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | |
@@ -1152,18 +1152,18 @@ discard block |
||
| 1152 | 1152 | * |
| 1153 | 1153 | * @return void |
| 1154 | 1154 | */ |
| 1155 | -function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
| 1155 | +function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
| 1156 | 1156 | /* @var CMB2_Types $field_type_object */ |
| 1157 | 1157 | |
| 1158 | 1158 | $id = $field_type_object->field->args['id']; |
| 1159 | 1159 | $field_description = $field_type_object->field->args['desc']; |
| 1160 | 1160 | $license = $field_type_object->field->args['options']['license']; |
| 1161 | 1161 | $license_key = $escaped_value; |
| 1162 | - $is_license_key = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) ); |
|
| 1163 | - $is_valid_license = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) ); |
|
| 1162 | + $is_license_key = apply_filters('give_is_license_key', (is_object($license) && ! empty($license))); |
|
| 1163 | + $is_valid_license = apply_filters('give_is_valid_license', ($is_license_key && property_exists($license, 'license') && 'valid' === $license->license)); |
|
| 1164 | 1164 | $shortname = $field_type_object->field->args['options']['shortname']; |
| 1165 | 1165 | $field_classes = 'regular-text give-license-field'; |
| 1166 | - $type = empty( $escaped_value ) || ! $is_valid_license ? 'text' : 'password'; |
|
| 1166 | + $type = empty($escaped_value) || ! $is_valid_license ? 'text' : 'password'; |
|
| 1167 | 1167 | $custom_html = ''; |
| 1168 | 1168 | $messages = array(); |
| 1169 | 1169 | $class = ''; |
@@ -1175,135 +1175,135 @@ discard block |
||
| 1175 | 1175 | |
| 1176 | 1176 | // By default query on edd api url will return license object which contain status and message property, this can break below functionality. |
| 1177 | 1177 | // To combat that check if status is set to error or not, if yes then set $is_license_key to false. |
| 1178 | - if ( $is_license_key && property_exists( $license, 'status' ) && 'error' === $license->status ) { |
|
| 1178 | + if ($is_license_key && property_exists($license, 'status') && 'error' === $license->status) { |
|
| 1179 | 1179 | $is_license_key = false; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | // Check if current license is part of subscription or not. |
| 1183 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
| 1183 | + $subscriptions = get_option('give_subscriptions'); |
|
| 1184 | 1184 | |
| 1185 | - if ( $is_license_key && $subscriptions ) { |
|
| 1186 | - foreach ( $subscriptions as $subscription ) { |
|
| 1187 | - if ( in_array( $license_key, $subscription['licenses'] ) ) { |
|
| 1185 | + if ($is_license_key && $subscriptions) { |
|
| 1186 | + foreach ($subscriptions as $subscription) { |
|
| 1187 | + if (in_array($license_key, $subscription['licenses'])) { |
|
| 1188 | 1188 | $is_in_subscription = $subscription['id']; |
| 1189 | 1189 | break; |
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | - if ( $is_license_key ) { |
|
| 1195 | - if ( $is_in_subscription ) { |
|
| 1196 | - $subscription_expires = strtotime( $subscriptions[ $is_in_subscription ]['expires'] ); |
|
| 1197 | - $subscription_status = __( 'renew', 'give' ); |
|
| 1194 | + if ($is_license_key) { |
|
| 1195 | + if ($is_in_subscription) { |
|
| 1196 | + $subscription_expires = strtotime($subscriptions[$is_in_subscription]['expires']); |
|
| 1197 | + $subscription_status = __('renew', 'give'); |
|
| 1198 | 1198 | |
| 1199 | - if ( ( 'active' !== $subscriptions[ $is_in_subscription ]['status'] ) ) { |
|
| 1200 | - $subscription_status = __( 'expire', 'give' ); |
|
| 1199 | + if (('active' !== $subscriptions[$is_in_subscription]['status'])) { |
|
| 1200 | + $subscription_status = __('expire', 'give'); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | - if ( $subscription_expires < current_time( 'timestamp', 1 ) ) { |
|
| 1204 | - $messages[] = sprintf( |
|
| 1205 | - __( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give' ), |
|
| 1206 | - urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ), |
|
| 1207 | - $subscriptions[ $is_in_subscription ]['payment_id'], |
|
| 1208 | - $checkout_page_link . '?edd_license_key=' . $subscriptions[ $is_in_subscription ]['license_key'] . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
| 1203 | + if ($subscription_expires < current_time('timestamp', 1)) { |
|
| 1204 | + $messages[] = sprintf( |
|
| 1205 | + __('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give'), |
|
| 1206 | + urldecode($subscriptions[$is_in_subscription]['invoice_url']), |
|
| 1207 | + $subscriptions[$is_in_subscription]['payment_id'], |
|
| 1208 | + $checkout_page_link.'?edd_license_key='.$subscriptions[$is_in_subscription]['license_key'].'&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
| 1209 | 1209 | ); |
| 1210 | 1210 | $license_status = 'license-expired'; |
| 1211 | - } elseif ( strtotime( '- 7 days', $subscription_expires ) < current_time( 'timestamp', 1 ) ) { |
|
| 1211 | + } elseif (strtotime('- 7 days', $subscription_expires) < current_time('timestamp', 1)) { |
|
| 1212 | 1212 | $messages[] = sprintf( |
| 1213 | - __( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give' ), |
|
| 1214 | - urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ), |
|
| 1215 | - $subscriptions[ $is_in_subscription ]['payment_id'], |
|
| 1213 | + __('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give'), |
|
| 1214 | + urldecode($subscriptions[$is_in_subscription]['invoice_url']), |
|
| 1215 | + $subscriptions[$is_in_subscription]['payment_id'], |
|
| 1216 | 1216 | $subscription_status, |
| 1217 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscriptions[ $is_in_subscription ]['expires'] ) ) |
|
| 1217 | + human_time_diff(current_time('timestamp', 1), strtotime($subscriptions[$is_in_subscription]['expires'])) |
|
| 1218 | 1218 | ); |
| 1219 | 1219 | $license_status = 'license-expires-soon'; |
| 1220 | 1220 | } else { |
| 1221 | 1221 | $messages[] = sprintf( |
| 1222 | - __( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give' ), |
|
| 1223 | - urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ), |
|
| 1224 | - $subscriptions[ $is_in_subscription ]['payment_id'], |
|
| 1222 | + __('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give'), |
|
| 1223 | + urldecode($subscriptions[$is_in_subscription]['invoice_url']), |
|
| 1224 | + $subscriptions[$is_in_subscription]['payment_id'], |
|
| 1225 | 1225 | $subscription_status, |
| 1226 | - date_i18n( get_option( 'date_format' ), strtotime( $subscriptions[ $is_in_subscription ]['expires'], current_time( 'timestamp' ) ) ) |
|
| 1226 | + date_i18n(get_option('date_format'), strtotime($subscriptions[$is_in_subscription]['expires'], current_time('timestamp'))) |
|
| 1227 | 1227 | ); |
| 1228 | 1228 | $license_status = 'license-expiration-date'; |
| 1229 | 1229 | } |
| 1230 | - } elseif ( empty( $license->success ) && property_exists( $license, 'error' ) ) { |
|
| 1230 | + } elseif (empty($license->success) && property_exists($license, 'error')) { |
|
| 1231 | 1231 | |
| 1232 | 1232 | // activate_license 'invalid' on anything other than valid, so if there was an error capture it |
| 1233 | - switch ( $license->error ) { |
|
| 1233 | + switch ($license->error) { |
|
| 1234 | 1234 | case 'expired' : |
| 1235 | 1235 | $class = $license->error; |
| 1236 | 1236 | $messages[] = sprintf( |
| 1237 | - __( 'Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ), |
|
| 1238 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), |
|
| 1239 | - $checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
| 1237 | + __('Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give'), |
|
| 1238 | + date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))), |
|
| 1239 | + $checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
| 1240 | 1240 | ); |
| 1241 | - $license_status = 'license-' . $class; |
|
| 1241 | + $license_status = 'license-'.$class; |
|
| 1242 | 1242 | break; |
| 1243 | 1243 | |
| 1244 | 1244 | case 'missing' : |
| 1245 | 1245 | $class = $license->error; |
| 1246 | 1246 | $messages[] = sprintf( |
| 1247 | - __( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give' ), |
|
| 1248 | - $account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=missing' |
|
| 1247 | + __('Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give'), |
|
| 1248 | + $account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=missing' |
|
| 1249 | 1249 | ); |
| 1250 | - $license_status = 'license-' . $class; |
|
| 1250 | + $license_status = 'license-'.$class; |
|
| 1251 | 1251 | break; |
| 1252 | 1252 | |
| 1253 | 1253 | case 'invalid' : |
| 1254 | 1254 | $class = $license->error; |
| 1255 | 1255 | $messages[] = sprintf( |
| 1256 | - __( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ), |
|
| 1256 | + __('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'), |
|
| 1257 | 1257 | $addon_name, |
| 1258 | - $account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
| 1258 | + $account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
| 1259 | 1259 | ); |
| 1260 | - $license_status = 'license-' . $class; |
|
| 1260 | + $license_status = 'license-'.$class; |
|
| 1261 | 1261 | break; |
| 1262 | 1262 | |
| 1263 | 1263 | case 'site_inactive' : |
| 1264 | 1264 | $class = $license->error; |
| 1265 | 1265 | $messages[] = sprintf( |
| 1266 | - __( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ), |
|
| 1266 | + __('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'), |
|
| 1267 | 1267 | $addon_name, |
| 1268 | - $account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
| 1268 | + $account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
| 1269 | 1269 | ); |
| 1270 | - $license_status = 'license-' . $class; |
|
| 1270 | + $license_status = 'license-'.$class; |
|
| 1271 | 1271 | break; |
| 1272 | 1272 | |
| 1273 | 1273 | case 'item_name_mismatch' : |
| 1274 | 1274 | $class = $license->error; |
| 1275 | - $messages[] = sprintf( __( 'This license %1$s does not belong to %2$s.', 'give' ), $license_key, $addon_name ); |
|
| 1276 | - $license_status = 'license-' . $class; |
|
| 1275 | + $messages[] = sprintf(__('This license %1$s does not belong to %2$s.', 'give'), $license_key, $addon_name); |
|
| 1276 | + $license_status = 'license-'.$class; |
|
| 1277 | 1277 | break; |
| 1278 | 1278 | |
| 1279 | 1279 | case 'no_activations_left': |
| 1280 | 1280 | $class = $license->error; |
| 1281 | - $messages[] = sprintf( __( 'Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give' ), $account_page_link ); |
|
| 1282 | - $license_status = 'license-' . $class; |
|
| 1281 | + $messages[] = sprintf(__('Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give'), $account_page_link); |
|
| 1282 | + $license_status = 'license-'.$class; |
|
| 1283 | 1283 | break; |
| 1284 | 1284 | } |
| 1285 | 1285 | } else { |
| 1286 | - switch ( $license->license ) { |
|
| 1286 | + switch ($license->license) { |
|
| 1287 | 1287 | case 'valid' : |
| 1288 | 1288 | default: |
| 1289 | 1289 | $class = 'valid'; |
| 1290 | - $now = current_time( 'timestamp' ); |
|
| 1291 | - $expiration = strtotime( $license->expires, current_time( 'timestamp' ) ); |
|
| 1290 | + $now = current_time('timestamp'); |
|
| 1291 | + $expiration = strtotime($license->expires, current_time('timestamp')); |
|
| 1292 | 1292 | |
| 1293 | - if ( 'lifetime' === $license->expires ) { |
|
| 1294 | - $messages[] = __( 'License key never expires.', 'give' ); |
|
| 1293 | + if ('lifetime' === $license->expires) { |
|
| 1294 | + $messages[] = __('License key never expires.', 'give'); |
|
| 1295 | 1295 | $license_status = 'license-lifetime-notice'; |
| 1296 | - } elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { |
|
| 1296 | + } elseif ($expiration > $now && $expiration - $now < (DAY_IN_SECONDS * 30)) { |
|
| 1297 | 1297 | $messages[] = sprintf( |
| 1298 | - __( 'Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give' ), |
|
| 1299 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), |
|
| 1300 | - $checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew' |
|
| 1298 | + __('Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give'), |
|
| 1299 | + date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))), |
|
| 1300 | + $checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=renew' |
|
| 1301 | 1301 | ); |
| 1302 | 1302 | $license_status = 'license-expires-soon'; |
| 1303 | 1303 | } else { |
| 1304 | 1304 | $messages[] = sprintf( |
| 1305 | - __( 'Your license key expires on %s.', 'give' ), |
|
| 1306 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ) |
|
| 1305 | + __('Your license key expires on %s.', 'give'), |
|
| 1306 | + date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))) |
|
| 1307 | 1307 | ); |
| 1308 | 1308 | $license_status = 'license-expiration-date'; |
| 1309 | 1309 | } |
@@ -1311,15 +1311,15 @@ discard block |
||
| 1311 | 1311 | } |
| 1312 | 1312 | } |
| 1313 | 1313 | } else { |
| 1314 | - $messages[] = sprintf( |
|
| 1315 | - __( 'To receive updates, please enter your valid %s license key.', 'give' ), |
|
| 1314 | + $messages[] = sprintf( |
|
| 1315 | + __('To receive updates, please enter your valid %s license key.', 'give'), |
|
| 1316 | 1316 | $addon_name |
| 1317 | 1317 | ); |
| 1318 | 1318 | $license_status = 'inactive'; |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | // Add class for input field if license is active. |
| 1322 | - if ( $is_valid_license ) { |
|
| 1322 | + if ($is_valid_license) { |
|
| 1323 | 1323 | $field_classes .= ' give-license-active'; |
| 1324 | 1324 | } |
| 1325 | 1325 | |
@@ -1327,33 +1327,33 @@ discard block |
||
| 1327 | 1327 | $input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\">"; |
| 1328 | 1328 | |
| 1329 | 1329 | // If license is active so show deactivate button. |
| 1330 | - if ( $is_valid_license ) { |
|
| 1330 | + if ($is_valid_license) { |
|
| 1331 | 1331 | // Get input field html. |
| 1332 | 1332 | $input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\" readonly=\"readonly\">"; |
| 1333 | 1333 | |
| 1334 | - $custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="' . $id . '_deactivate" value="' . esc_attr__( 'Deactivate License', 'give' ) . '"/>'; |
|
| 1334 | + $custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="'.$id.'_deactivate" value="'.esc_attr__('Deactivate License', 'give').'"/>'; |
|
| 1335 | 1335 | |
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | // Field description. |
| 1339 | - $custom_html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>'; |
|
| 1339 | + $custom_html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>'; |
|
| 1340 | 1340 | |
| 1341 | 1341 | // If no messages found then inform user that to get updated in future register yourself. |
| 1342 | - if ( empty( $messages ) ) { |
|
| 1343 | - $messages[] = apply_filters( "{$shortname}_default_addon_notice", __( 'To receive updates, please enter your valid license key.', 'give' ) ); |
|
| 1342 | + if (empty($messages)) { |
|
| 1343 | + $messages[] = apply_filters("{$shortname}_default_addon_notice", __('To receive updates, please enter your valid license key.', 'give')); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | - foreach ( $messages as $message ) { |
|
| 1347 | - $custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">'; |
|
| 1348 | - $custom_html .= '<p>' . $message . '</p>'; |
|
| 1346 | + foreach ($messages as $message) { |
|
| 1347 | + $custom_html .= '<div class="give-license-status-notice give-'.$license_status.'">'; |
|
| 1348 | + $custom_html .= '<p>'.$message.'</p>'; |
|
| 1349 | 1349 | $custom_html .= '</div>'; |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | // Field html. |
| 1353 | - $custom_html = apply_filters( 'give_license_key_field_html', $input_field_html . $custom_html, $field_type_object ); |
|
| 1353 | + $custom_html = apply_filters('give_license_key_field_html', $input_field_html.$custom_html, $field_type_object); |
|
| 1354 | 1354 | |
| 1355 | 1355 | // Nonce. |
| 1356 | - wp_nonce_field( $id . '-nonce', $id . '-nonce' ); |
|
| 1356 | + wp_nonce_field($id.'-nonce', $id.'-nonce'); |
|
| 1357 | 1357 | |
| 1358 | 1358 | // Print field html. |
| 1359 | 1359 | echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>"; |
@@ -1368,7 +1368,7 @@ discard block |
||
| 1368 | 1368 | */ |
| 1369 | 1369 | function give_api_callback() { |
| 1370 | 1370 | |
| 1371 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1371 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 1372 | 1372 | return; |
| 1373 | 1373 | } |
| 1374 | 1374 | |
@@ -1377,9 +1377,9 @@ discard block |
||
| 1377 | 1377 | * |
| 1378 | 1378 | * @since 1.0 |
| 1379 | 1379 | */ |
| 1380 | - do_action( 'give_tools_api_keys_before' ); |
|
| 1380 | + do_action('give_tools_api_keys_before'); |
|
| 1381 | 1381 | |
| 1382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
| 1382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
| 1383 | 1383 | |
| 1384 | 1384 | $api_keys_table = new Give_API_Keys_Table(); |
| 1385 | 1385 | $api_keys_table->prepare_items(); |
@@ -1388,9 +1388,9 @@ discard block |
||
| 1388 | 1388 | <span class="cmb2-metabox-description api-description"> |
| 1389 | 1389 | <?php echo sprintf( |
| 1390 | 1390 | /* translators: 1: http://docs.givewp.com/api 2: http://docs.givewp.com/addon-zapier */ |
| 1391 | - __( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ), |
|
| 1392 | - esc_url( 'http://docs.givewp.com/api' ), |
|
| 1393 | - esc_url( 'http://docs.givewp.com/addon-zapier' ) |
|
| 1391 | + __('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'), |
|
| 1392 | + esc_url('http://docs.givewp.com/api'), |
|
| 1393 | + esc_url('http://docs.givewp.com/addon-zapier') |
|
| 1394 | 1394 | ); ?> |
| 1395 | 1395 | </span> |
| 1396 | 1396 | <?php |
@@ -1400,10 +1400,10 @@ discard block |
||
| 1400 | 1400 | * |
| 1401 | 1401 | * @since 1.0 |
| 1402 | 1402 | */ |
| 1403 | - do_action( 'give_tools_api_keys_after' ); |
|
| 1403 | + do_action('give_tools_api_keys_after'); |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | -add_action( 'give_settings_tab_api_keys', 'give_api_callback' ); |
|
| 1406 | +add_action('give_settings_tab_api_keys', 'give_api_callback'); |
|
| 1407 | 1407 | |
| 1408 | 1408 | /** |
| 1409 | 1409 | * Hook Callback |
@@ -1416,7 +1416,7 @@ discard block |
||
| 1416 | 1416 | * |
| 1417 | 1417 | * @return void |
| 1418 | 1418 | */ |
| 1419 | -function give_hook_callback( $args ) { |
|
| 1419 | +function give_hook_callback($args) { |
|
| 1420 | 1420 | |
| 1421 | 1421 | $id = $args['id']; |
| 1422 | 1422 | |
@@ -1425,7 +1425,7 @@ discard block |
||
| 1425 | 1425 | * |
| 1426 | 1426 | * @since 1.0 |
| 1427 | 1427 | */ |
| 1428 | - do_action( "give_{$id}" ); |
|
| 1428 | + do_action("give_{$id}"); |
|
| 1429 | 1429 | |
| 1430 | 1430 | } |
| 1431 | 1431 | |
@@ -1440,19 +1440,19 @@ discard block |
||
| 1440 | 1440 | * |
| 1441 | 1441 | * @return bool |
| 1442 | 1442 | */ |
| 1443 | -function give_is_setting_enabled( $value, $compare_with = null ) { |
|
| 1444 | - if ( ! is_null( $compare_with ) ) { |
|
| 1443 | +function give_is_setting_enabled($value, $compare_with = null) { |
|
| 1444 | + if ( ! is_null($compare_with)) { |
|
| 1445 | 1445 | |
| 1446 | - if ( is_array( $compare_with ) ) { |
|
| 1446 | + if (is_array($compare_with)) { |
|
| 1447 | 1447 | // Output. |
| 1448 | - return in_array( $value, $compare_with ); |
|
| 1448 | + return in_array($value, $compare_with); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | // Output. |
| 1452 | - return ( $value === $compare_with ); |
|
| 1452 | + return ($value === $compare_with); |
|
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | // Backward compatibility: From version 1.8 most of setting is modified to enabled/disabled |
| 1456 | 1456 | // Output. |
| 1457 | - return ( in_array( $value, array( 'enabled', 'on', 'yes' ) ) ? true : false ); |
|
| 1457 | + return (in_array($value, array('enabled', 'on', 'yes')) ? true : false); |
|
| 1458 | 1458 | } |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | * @access public |
| 890 | 890 | * |
| 891 | 891 | * @param string $meta_key Metadata name. Default is empty. |
| 892 | - * @param mixed $meta_value Metadata value. |
|
| 892 | + * @param string $meta_value Metadata value. |
|
| 893 | 893 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
| 894 | 894 | * |
| 895 | 895 | * @return bool False for failure. True for success. |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @access public |
| 922 | 922 | * |
| 923 | 923 | * @param string $meta_key Metadata name. Default is empty. |
| 924 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
| 924 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
| 925 | 925 | * |
| 926 | 926 | * @return bool False for failure. True for success. |
| 927 | 927 | */ |
@@ -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 | |
@@ -144,32 +144,32 @@ discard block |
||
| 144 | 144 | * @param bool $_id_or_email |
| 145 | 145 | * @param bool $by_user_id |
| 146 | 146 | */ |
| 147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 148 | 148 | |
| 149 | 149 | $this->db = new Give_DB_Customers; |
| 150 | 150 | |
| 151 | 151 | if ( |
| 152 | 152 | false === $_id_or_email |
| 153 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
| 153 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
| 154 | 154 | ) { |
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 158 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 159 | 159 | |
| 160 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 160 | + if (is_numeric($_id_or_email)) { |
|
| 161 | 161 | $field = $by_user_id ? 'user_id' : 'id'; |
| 162 | 162 | } else { |
| 163 | 163 | $field = 'email'; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
| 166 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
| 167 | 167 | |
| 168 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
| 168 | + if (empty($customer) || ! is_object($customer)) { |
|
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $this->setup_customer( $customer ); |
|
| 172 | + $this->setup_customer($customer); |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return bool If the setup was successful or not. |
| 187 | 187 | */ |
| 188 | - private function setup_customer( $customer ) { |
|
| 188 | + private function setup_customer($customer) { |
|
| 189 | 189 | |
| 190 | - if ( ! is_object( $customer ) ) { |
|
| 190 | + if ( ! is_object($customer)) { |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - foreach ( $customer as $key => $value ) { |
|
| 194 | + foreach ($customer as $key => $value) { |
|
| 195 | 195 | |
| 196 | - switch ( $key ) { |
|
| 196 | + switch ($key) { |
|
| 197 | 197 | |
| 198 | 198 | case 'notes': |
| 199 | 199 | $this->$key = $this->get_notes(); |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Get donor's all email including primary email. |
| 210 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
| 211 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
| 210 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
| 211 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
| 212 | 212 | |
| 213 | 213 | // Customer ID and email are the only things that are necessary, make sure they exist. |
| 214 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 214 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 215 | 215 | return true; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -225,16 +225,16 @@ discard block |
||
| 225 | 225 | * @since 1.0 |
| 226 | 226 | * @access public |
| 227 | 227 | */ |
| 228 | - public function __get( $key ) { |
|
| 228 | + public function __get($key) { |
|
| 229 | 229 | |
| 230 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 230 | + if (method_exists($this, 'get_'.$key)) { |
|
| 231 | 231 | |
| 232 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 232 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 233 | 233 | |
| 234 | 234 | } else { |
| 235 | 235 | |
| 236 | 236 | /* translators: %s: property key */ |
| 237 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 237 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
| 252 | 252 | */ |
| 253 | - public function create( $data = array() ) { |
|
| 253 | + public function create($data = array()) { |
|
| 254 | 254 | |
| 255 | - if ( $this->id != 0 || empty( $data ) ) { |
|
| 255 | + if ($this->id != 0 || empty($data)) { |
|
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -260,15 +260,15 @@ discard block |
||
| 260 | 260 | 'payment_ids' => '', |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | - $args = wp_parse_args( $data, $defaults ); |
|
| 264 | - $args = $this->sanitize_columns( $args ); |
|
| 263 | + $args = wp_parse_args($data, $defaults); |
|
| 264 | + $args = $this->sanitize_columns($args); |
|
| 265 | 265 | |
| 266 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
| 266 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 271 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 270 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 271 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -278,18 +278,18 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @param array $args Customer attributes. |
| 280 | 280 | */ |
| 281 | - do_action( 'give_customer_pre_create', $args ); |
|
| 281 | + do_action('give_customer_pre_create', $args); |
|
| 282 | 282 | |
| 283 | 283 | $created = false; |
| 284 | 284 | |
| 285 | 285 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
| 286 | - if ( $this->db->add( $data ) ) { |
|
| 286 | + if ($this->db->add($data)) { |
|
| 287 | 287 | |
| 288 | 288 | // We've successfully added/updated the customer, reset the class vars with the new data |
| 289 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
| 289 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
| 290 | 290 | |
| 291 | 291 | // Setup the customer data with the values from DB |
| 292 | - $this->setup_customer( $customer ); |
|
| 292 | + $this->setup_customer($customer); |
|
| 293 | 293 | |
| 294 | 294 | $created = $this->id; |
| 295 | 295 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * customer ID if user is found or valid creation. |
| 304 | 304 | * @param array $args Customer attributes. |
| 305 | 305 | */ |
| 306 | - do_action( 'give_customer_post_create', $created, $args ); |
|
| 306 | + do_action('give_customer_post_create', $created, $args); |
|
| 307 | 307 | |
| 308 | 308 | return $created; |
| 309 | 309 | |
@@ -319,13 +319,13 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | * @return bool If the update was successful or not. |
| 321 | 321 | */ |
| 322 | - public function update( $data = array() ) { |
|
| 322 | + public function update($data = array()) { |
|
| 323 | 323 | |
| 324 | - if ( empty( $data ) ) { |
|
| 324 | + if (empty($data)) { |
|
| 325 | 325 | return false; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - $data = $this->sanitize_columns( $data ); |
|
| 328 | + $data = $this->sanitize_columns($data); |
|
| 329 | 329 | |
| 330 | 330 | /** |
| 331 | 331 | * Fires before updating customers. |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | * @param int $customer_id Customer id. |
| 336 | 336 | * @param array $data Customer attributes. |
| 337 | 337 | */ |
| 338 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
| 338 | + do_action('give_customer_pre_update', $this->id, $data); |
|
| 339 | 339 | |
| 340 | 340 | $updated = false; |
| 341 | 341 | |
| 342 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 342 | + if ($this->db->update($this->id, $data)) { |
|
| 343 | 343 | |
| 344 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
| 345 | - $this->setup_customer( $customer ); |
|
| 344 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
| 345 | + $this->setup_customer($customer); |
|
| 346 | 346 | |
| 347 | 347 | $updated = true; |
| 348 | 348 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @param int $customer_id Customer id. |
| 357 | 357 | * @param array $data Customer attributes. |
| 358 | 358 | */ |
| 359 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
| 359 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
| 360 | 360 | |
| 361 | 361 | return $updated; |
| 362 | 362 | } |
@@ -374,27 +374,27 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * @return bool If the attachment was successfuly. |
| 376 | 376 | */ |
| 377 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 377 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 378 | 378 | |
| 379 | - if ( empty( $payment_id ) ) { |
|
| 379 | + if (empty($payment_id)) { |
|
| 380 | 380 | return false; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( empty( $this->payment_ids ) ) { |
|
| 383 | + if (empty($this->payment_ids)) { |
|
| 384 | 384 | |
| 385 | 385 | $new_payment_ids = $payment_id; |
| 386 | 386 | |
| 387 | 387 | } else { |
| 388 | 388 | |
| 389 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 389 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 390 | 390 | |
| 391 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 391 | + if (in_array($payment_id, $payment_ids)) { |
|
| 392 | 392 | $update_stats = false; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $payment_ids[] = $payment_id; |
| 396 | 396 | |
| 397 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 397 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 398 | 398 | |
| 399 | 399 | } |
| 400 | 400 | |
@@ -406,20 +406,20 @@ discard block |
||
| 406 | 406 | * @param int $payment_id Payment id. |
| 407 | 407 | * @param int $customer_id Customer id. |
| 408 | 408 | */ |
| 409 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
| 409 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
| 410 | 410 | |
| 411 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 411 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 412 | 412 | |
| 413 | - if ( $payment_added ) { |
|
| 413 | + if ($payment_added) { |
|
| 414 | 414 | |
| 415 | 415 | $this->payment_ids = $new_payment_ids; |
| 416 | 416 | |
| 417 | 417 | // We added this payment successfully, increment the stats |
| 418 | - if ( $update_stats ) { |
|
| 419 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 418 | + if ($update_stats) { |
|
| 419 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 420 | 420 | |
| 421 | - if ( ! empty( $payment_amount ) ) { |
|
| 422 | - $this->increase_value( $payment_amount ); |
|
| 421 | + if ( ! empty($payment_amount)) { |
|
| 422 | + $this->increase_value($payment_amount); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | $this->increase_purchase_count(); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @param int $payment_id Payment id. |
| 436 | 436 | * @param int $customer_id Customer id. |
| 437 | 437 | */ |
| 438 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 438 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 439 | 439 | |
| 440 | 440 | return $payment_added; |
| 441 | 441 | } |
@@ -453,33 +453,33 @@ discard block |
||
| 453 | 453 | * |
| 454 | 454 | * @return boolean If the removal was successful. |
| 455 | 455 | */ |
| 456 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 456 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 457 | 457 | |
| 458 | - if ( empty( $payment_id ) ) { |
|
| 458 | + if (empty($payment_id)) { |
|
| 459 | 459 | return false; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - $payment = new Give_Payment( $payment_id ); |
|
| 462 | + $payment = new Give_Payment($payment_id); |
|
| 463 | 463 | |
| 464 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 464 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 465 | 465 | $update_stats = false; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | $new_payment_ids = ''; |
| 469 | 469 | |
| 470 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 470 | + if ( ! empty($this->payment_ids)) { |
|
| 471 | 471 | |
| 472 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 472 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 473 | 473 | |
| 474 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 475 | - if ( false === $pos ) { |
|
| 474 | + $pos = array_search($payment_id, $payment_ids); |
|
| 475 | + if (false === $pos) { |
|
| 476 | 476 | return false; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - unset( $payment_ids[ $pos ] ); |
|
| 480 | - $payment_ids = array_filter( $payment_ids ); |
|
| 479 | + unset($payment_ids[$pos]); |
|
| 480 | + $payment_ids = array_filter($payment_ids); |
|
| 481 | 481 | |
| 482 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 482 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 483 | 483 | |
| 484 | 484 | } |
| 485 | 485 | |
@@ -491,20 +491,20 @@ discard block |
||
| 491 | 491 | * @param int $payment_id Payment id. |
| 492 | 492 | * @param int $customer_id Customer id. |
| 493 | 493 | */ |
| 494 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
| 494 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
| 495 | 495 | |
| 496 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 496 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 497 | 497 | |
| 498 | - if ( $payment_removed ) { |
|
| 498 | + if ($payment_removed) { |
|
| 499 | 499 | |
| 500 | 500 | $this->payment_ids = $new_payment_ids; |
| 501 | 501 | |
| 502 | - if ( $update_stats ) { |
|
| 502 | + if ($update_stats) { |
|
| 503 | 503 | // We removed this payment successfully, decrement the stats |
| 504 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 504 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 505 | 505 | |
| 506 | - if ( ! empty( $payment_amount ) ) { |
|
| 507 | - $this->decrease_value( $payment_amount ); |
|
| 506 | + if ( ! empty($payment_amount)) { |
|
| 507 | + $this->decrease_value($payment_amount); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @param int $payment_id Payment id. |
| 521 | 521 | * @param int $customer_id Customer id. |
| 522 | 522 | */ |
| 523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 524 | 524 | |
| 525 | 525 | return $payment_removed; |
| 526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @return int The donation count. |
| 538 | 538 | */ |
| 539 | - public function increase_purchase_count( $count = 1 ) { |
|
| 539 | + public function increase_purchase_count($count = 1) { |
|
| 540 | 540 | |
| 541 | 541 | // Make sure it's numeric and not negative. |
| 542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 543 | 543 | return false; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | * @param int $count The number to increase by. |
| 554 | 554 | * @param int $customer_id Customer id. |
| 555 | 555 | */ |
| 556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
| 556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
| 557 | 557 | |
| 558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 559 | 559 | $this->purchase_count = $new_total; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @param int $count The number increased by. |
| 569 | 569 | * @param int $customer_id Customer id. |
| 570 | 570 | */ |
| 571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 572 | 572 | |
| 573 | 573 | return $this->purchase_count; |
| 574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return mixed If successful, the new count, otherwise false. |
| 585 | 585 | */ |
| 586 | - public function decrease_purchase_count( $count = 1 ) { |
|
| 586 | + public function decrease_purchase_count($count = 1) { |
|
| 587 | 587 | |
| 588 | 588 | // Make sure it's numeric and not negative |
| 589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 590 | 590 | return false; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
| 594 | 594 | |
| 595 | - if ( $new_total < 0 ) { |
|
| 595 | + if ($new_total < 0) { |
|
| 596 | 596 | $new_total = 0; |
| 597 | 597 | } |
| 598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
| 604 | 604 | * @param int $count The number to decrease by. |
| 605 | 605 | * @param int $customer_id Customer id. |
| 606 | 606 | */ |
| 607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
| 607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
| 608 | 608 | |
| 609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 610 | 610 | $this->purchase_count = $new_total; |
| 611 | 611 | } |
| 612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @param int $count The number decreased by. |
| 620 | 620 | * @param int $customer_id Customer id. |
| 621 | 621 | */ |
| 622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 623 | 623 | |
| 624 | 624 | return $this->purchase_count; |
| 625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
| 634 | 634 | * |
| 635 | 635 | * @return mixed If successful, the new value, otherwise false. |
| 636 | 636 | */ |
| 637 | - public function increase_value( $value = 0.00 ) { |
|
| 637 | + public function increase_value($value = 0.00) { |
|
| 638 | 638 | |
| 639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 639 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
| 646 | 646 | * @param float $value The value to increase by. |
| 647 | 647 | * @param int $customer_id Customer id. |
| 648 | 648 | */ |
| 649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
| 649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
| 650 | 650 | |
| 651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 652 | 652 | $this->purchase_value = $new_value; |
| 653 | 653 | } |
| 654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @param float $value The value increased by. |
| 662 | 662 | * @param int $customer_id Customer id. |
| 663 | 663 | */ |
| 664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 665 | 665 | |
| 666 | 666 | return $this->purchase_value; |
| 667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return mixed If successful, the new value, otherwise false. |
| 678 | 678 | */ |
| 679 | - public function decrease_value( $value = 0.00 ) { |
|
| 679 | + public function decrease_value($value = 0.00) { |
|
| 680 | 680 | |
| 681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 681 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 682 | 682 | |
| 683 | - if ( $new_value < 0 ) { |
|
| 683 | + if ($new_value < 0) { |
|
| 684 | 684 | $new_value = 0.00; |
| 685 | 685 | } |
| 686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | * @param float $value The value to decrease by. |
| 693 | 693 | * @param int $customer_id Customer id. |
| 694 | 694 | */ |
| 695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
| 695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
| 696 | 696 | |
| 697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 698 | 698 | $this->purchase_value = $new_value; |
| 699 | 699 | } |
| 700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @param float $value The value decreased by. |
| 708 | 708 | * @param int $customer_id Customer id. |
| 709 | 709 | */ |
| 710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 711 | 711 | |
| 712 | 712 | return $this->purchase_value; |
| 713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | * |
| 727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 728 | 728 | */ |
| 729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 730 | 730 | /** |
| 731 | 731 | * Payment total difference value can be: |
| 732 | 732 | * zero (in case amount not change) |
@@ -736,15 +736,15 @@ discard block |
||
| 736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
| 737 | 737 | |
| 738 | 738 | // We do not need to update donation stat if donation did not change. |
| 739 | - if ( ! $payment_total_diff ) { |
|
| 739 | + if ( ! $payment_total_diff) { |
|
| 740 | 740 | return false; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if ( $payment_total_diff > 0 ) { |
|
| 744 | - $this->increase_value( $payment_total_diff ); |
|
| 743 | + if ($payment_total_diff > 0) { |
|
| 744 | + $this->increase_value($payment_total_diff); |
|
| 745 | 745 | } else { |
| 746 | 746 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 747 | - $this->decrease_value( - $payment_total_diff ); |
|
| 747 | + $this->decrease_value( -$payment_total_diff ); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | return $this->purchase_value; |
@@ -761,15 +761,15 @@ discard block |
||
| 761 | 761 | * |
| 762 | 762 | * @return array The notes requested. |
| 763 | 763 | */ |
| 764 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 764 | + public function get_notes($length = 20, $paged = 1) { |
|
| 765 | 765 | |
| 766 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 767 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 766 | + $length = is_numeric($length) ? $length : 20; |
|
| 767 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 768 | 768 | |
| 769 | 769 | $all_notes = $this->get_raw_notes(); |
| 770 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 770 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 771 | 771 | |
| 772 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 772 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 773 | 773 | |
| 774 | 774 | return $desired_notes; |
| 775 | 775 | |
@@ -786,9 +786,9 @@ discard block |
||
| 786 | 786 | public function get_notes_count() { |
| 787 | 787 | |
| 788 | 788 | $all_notes = $this->get_raw_notes(); |
| 789 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 789 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 790 | 790 | |
| 791 | - return count( $notes_array ); |
|
| 791 | + return count($notes_array); |
|
| 792 | 792 | |
| 793 | 793 | } |
| 794 | 794 | |
@@ -802,22 +802,22 @@ discard block |
||
| 802 | 802 | * |
| 803 | 803 | * @return string|boolean The new note if added successfully, false otherwise. |
| 804 | 804 | */ |
| 805 | - public function add_note( $note = '' ) { |
|
| 805 | + public function add_note($note = '') { |
|
| 806 | 806 | |
| 807 | - $note = trim( $note ); |
|
| 808 | - if ( empty( $note ) ) { |
|
| 807 | + $note = trim($note); |
|
| 808 | + if (empty($note)) { |
|
| 809 | 809 | return false; |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | $notes = $this->get_raw_notes(); |
| 813 | 813 | |
| 814 | - if ( empty( $notes ) ) { |
|
| 814 | + if (empty($notes)) { |
|
| 815 | 815 | $notes = ''; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 819 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 820 | - $notes .= "\n\n" . $new_note; |
|
| 818 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 819 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 820 | + $notes .= "\n\n".$new_note; |
|
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | 823 | * Fires before customer note added. |
@@ -827,11 +827,11 @@ discard block |
||
| 827 | 827 | * @param string $new_note New note to add. |
| 828 | 828 | * @param int $customer_id Customer id. |
| 829 | 829 | */ |
| 830 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
| 830 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
| 831 | 831 | |
| 832 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 832 | + $updated = $this->update(array('notes' => $notes)); |
|
| 833 | 833 | |
| 834 | - if ( $updated ) { |
|
| 834 | + if ($updated) { |
|
| 835 | 835 | $this->notes = $this->get_notes(); |
| 836 | 836 | } |
| 837 | 837 | |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | * @param string $new_note New note added. |
| 845 | 845 | * @param int $customer_id Customer id. |
| 846 | 846 | */ |
| 847 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 847 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
| 848 | 848 | |
| 849 | 849 | // Return the formatted note, so we can test, as well as update any displays |
| 850 | 850 | return $new_note; |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | */ |
| 862 | 862 | private function get_raw_notes() { |
| 863 | 863 | |
| 864 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 864 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 865 | 865 | |
| 866 | 866 | return $all_notes; |
| 867 | 867 | |
@@ -878,8 +878,8 @@ discard block |
||
| 878 | 878 | * |
| 879 | 879 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 880 | 880 | */ |
| 881 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 882 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 881 | + public function get_meta($meta_key = '', $single = true) { |
|
| 882 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | /** |
@@ -894,8 +894,8 @@ discard block |
||
| 894 | 894 | * |
| 895 | 895 | * @return bool False for failure. True for success. |
| 896 | 896 | */ |
| 897 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 898 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 897 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 898 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | /** |
@@ -910,8 +910,8 @@ discard block |
||
| 910 | 910 | * |
| 911 | 911 | * @return bool False on failure, true if success. |
| 912 | 912 | */ |
| 913 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 914 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 913 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 914 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | /** |
@@ -925,8 +925,8 @@ discard block |
||
| 925 | 925 | * |
| 926 | 926 | * @return bool False for failure. True for success. |
| 927 | 927 | */ |
| 928 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 929 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 928 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 929 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | /** |
@@ -939,51 +939,51 @@ discard block |
||
| 939 | 939 | * |
| 940 | 940 | * @return array The sanitized data, based off column defaults. |
| 941 | 941 | */ |
| 942 | - private function sanitize_columns( $data ) { |
|
| 942 | + private function sanitize_columns($data) { |
|
| 943 | 943 | |
| 944 | 944 | $columns = $this->db->get_columns(); |
| 945 | 945 | $default_values = $this->db->get_column_defaults(); |
| 946 | 946 | |
| 947 | - foreach ( $columns as $key => $type ) { |
|
| 947 | + foreach ($columns as $key => $type) { |
|
| 948 | 948 | |
| 949 | 949 | // Only sanitize data that we were provided |
| 950 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 950 | + if ( ! array_key_exists($key, $data)) { |
|
| 951 | 951 | continue; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - switch ( $type ) { |
|
| 954 | + switch ($type) { |
|
| 955 | 955 | |
| 956 | 956 | case '%s': |
| 957 | - if ( 'email' == $key ) { |
|
| 958 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 959 | - } elseif ( 'notes' == $key ) { |
|
| 960 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 957 | + if ('email' == $key) { |
|
| 958 | + $data[$key] = sanitize_email($data[$key]); |
|
| 959 | + } elseif ('notes' == $key) { |
|
| 960 | + $data[$key] = strip_tags($data[$key]); |
|
| 961 | 961 | } else { |
| 962 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 962 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 963 | 963 | } |
| 964 | 964 | break; |
| 965 | 965 | |
| 966 | 966 | case '%d': |
| 967 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 968 | - $data[ $key ] = $default_values[ $key ]; |
|
| 967 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 968 | + $data[$key] = $default_values[$key]; |
|
| 969 | 969 | } else { |
| 970 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 970 | + $data[$key] = absint($data[$key]); |
|
| 971 | 971 | } |
| 972 | 972 | break; |
| 973 | 973 | |
| 974 | 974 | case '%f': |
| 975 | 975 | // Convert what was given to a float |
| 976 | - $value = floatval( $data[ $key ] ); |
|
| 976 | + $value = floatval($data[$key]); |
|
| 977 | 977 | |
| 978 | - if ( ! is_float( $value ) ) { |
|
| 979 | - $data[ $key ] = $default_values[ $key ]; |
|
| 978 | + if ( ! is_float($value)) { |
|
| 979 | + $data[$key] = $default_values[$key]; |
|
| 980 | 980 | } else { |
| 981 | - $data[ $key ] = $value; |
|
| 981 | + $data[$key] = $value; |
|
| 982 | 982 | } |
| 983 | 983 | break; |
| 984 | 984 | |
| 985 | 985 | default: |
| 986 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 986 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 987 | 987 | break; |
| 988 | 988 | |
| 989 | 989 | } |
@@ -1003,33 +1003,33 @@ discard block |
||
| 1003 | 1003 | * |
| 1004 | 1004 | * @return bool If the email was added successfully |
| 1005 | 1005 | */ |
| 1006 | - public function add_email( $email = '', $primary = false ) { |
|
| 1007 | - if ( ! is_email( $email ) ) { |
|
| 1006 | + public function add_email($email = '', $primary = false) { |
|
| 1007 | + if ( ! is_email($email)) { |
|
| 1008 | 1008 | return false; |
| 1009 | 1009 | } |
| 1010 | - $existing = new Give_Customer( $email ); |
|
| 1010 | + $existing = new Give_Customer($email); |
|
| 1011 | 1011 | |
| 1012 | - if ( $existing->id > 0 ) { |
|
| 1012 | + if ($existing->id > 0) { |
|
| 1013 | 1013 | // Email address already belongs to another customer |
| 1014 | 1014 | return false; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - if ( email_exists( $email ) ) { |
|
| 1018 | - $user = get_user_by( 'email', $email ); |
|
| 1019 | - if ( $user->ID != $this->user_id ) { |
|
| 1017 | + if (email_exists($email)) { |
|
| 1018 | + $user = get_user_by('email', $email); |
|
| 1019 | + if ($user->ID != $this->user_id) { |
|
| 1020 | 1020 | return false; |
| 1021 | 1021 | } |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
| 1024 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
| 1025 | 1025 | |
| 1026 | 1026 | // Add is used to ensure duplicate emails are not added |
| 1027 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
| 1027 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
| 1028 | 1028 | |
| 1029 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
| 1029 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
| 1030 | 1030 | |
| 1031 | - if ( $ret && true === $primary ) { |
|
| 1032 | - $this->set_primary_email( $email ); |
|
| 1031 | + if ($ret && true === $primary) { |
|
| 1032 | + $this->set_primary_email($email); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | return $ret; |
@@ -1045,16 +1045,16 @@ discard block |
||
| 1045 | 1045 | * |
| 1046 | 1046 | * @return bool If the email was removed successfully |
| 1047 | 1047 | */ |
| 1048 | - public function remove_email( $email = '' ) { |
|
| 1049 | - if ( ! is_email( $email ) ) { |
|
| 1048 | + public function remove_email($email = '') { |
|
| 1049 | + if ( ! is_email($email)) { |
|
| 1050 | 1050 | return false; |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
| 1053 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
| 1054 | 1054 | |
| 1055 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
| 1055 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
| 1056 | 1056 | |
| 1057 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
| 1057 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
| 1058 | 1058 | |
| 1059 | 1059 | return $ret; |
| 1060 | 1060 | } |
@@ -1071,16 +1071,16 @@ discard block |
||
| 1071 | 1071 | * |
| 1072 | 1072 | * @return bool If the email was set as primary successfully |
| 1073 | 1073 | */ |
| 1074 | - public function set_primary_email( $new_primary_email = '' ) { |
|
| 1075 | - if ( ! is_email( $new_primary_email ) ) { |
|
| 1074 | + public function set_primary_email($new_primary_email = '') { |
|
| 1075 | + if ( ! is_email($new_primary_email)) { |
|
| 1076 | 1076 | return false; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1079 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1080 | 1080 | |
| 1081 | - $existing = new Give_Customer( $new_primary_email ); |
|
| 1081 | + $existing = new Give_Customer($new_primary_email); |
|
| 1082 | 1082 | |
| 1083 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
| 1083 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
| 1084 | 1084 | // This email belongs to another customer |
| 1085 | 1085 | return false; |
| 1086 | 1086 | } |
@@ -1088,21 +1088,21 @@ discard block |
||
| 1088 | 1088 | $old_email = $this->email; |
| 1089 | 1089 | |
| 1090 | 1090 | // Update customer record with new email |
| 1091 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
| 1091 | + $update = $this->update(array('email' => $new_primary_email)); |
|
| 1092 | 1092 | |
| 1093 | 1093 | // Remove new primary from list of additional emails |
| 1094 | - $remove = $this->remove_email( $new_primary_email ); |
|
| 1094 | + $remove = $this->remove_email($new_primary_email); |
|
| 1095 | 1095 | |
| 1096 | 1096 | // Add old email to additional emails list |
| 1097 | - $add = $this->add_email( $old_email ); |
|
| 1097 | + $add = $this->add_email($old_email); |
|
| 1098 | 1098 | |
| 1099 | 1099 | $ret = $update && $remove && $add; |
| 1100 | 1100 | |
| 1101 | - if ( $ret ) { |
|
| 1101 | + if ($ret) { |
|
| 1102 | 1102 | $this->email = $new_primary_email; |
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1105 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1106 | 1106 | |
| 1107 | 1107 | return $ret; |
| 1108 | 1108 | } |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | * @access public |
| 488 | 488 | * @since 1.7 |
| 489 | 489 | * |
| 490 | - * @return bool|void |
|
| 490 | + * @return false|null |
|
| 491 | 491 | */ |
| 492 | 492 | public function weekly_license_check() { |
| 493 | 493 | |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @access public |
| 541 | 541 | * @since 1.7 |
| 542 | 542 | * |
| 543 | - * @return bool|void |
|
| 543 | + * @return false|null |
|
| 544 | 544 | */ |
| 545 | 545 | public function weekly_subscription_check() { |
| 546 | 546 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @access private |
| 622 | 622 | * @since 1.7 |
| 623 | 623 | * |
| 624 | - * @return bool|void |
|
| 624 | + * @return false|null |
|
| 625 | 625 | */ |
| 626 | 626 | private function __single_subscription_check() { |
| 627 | 627 | // Do not fire if license key is not set. |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | * @access private |
| 834 | 834 | * @since 1.7 |
| 835 | 835 | * |
| 836 | - * @return void|bool |
|
| 836 | + * @return false|null |
|
| 837 | 837 | */ |
| 838 | 838 | private function __remove_license_key_from_subscriptions() { |
| 839 | 839 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | * @param $plugin_data |
| 933 | 933 | * @param $status |
| 934 | 934 | * |
| 935 | - * @return bool |
|
| 935 | + * @return false|null |
|
| 936 | 936 | */ |
| 937 | 937 | public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
| 938 | 938 | // Bailout. |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | * |
| 955 | 955 | * @since 1.8.7 |
| 956 | 956 | * @access public |
| 957 | - * @return array |
|
| 957 | + * @return string |
|
| 958 | 958 | */ |
| 959 | 959 | public function license_state_message() { |
| 960 | 960 | $message_data = array(); |
@@ -10,11 +10,11 @@ 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 | |
| 17 | -if ( ! class_exists( 'Give_License' ) ) : |
|
| 17 | +if ( ! class_exists('Give_License')) : |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Give_License Class |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | * @param string $_checkout_url |
| 143 | 143 | * @param string $_account_url |
| 144 | 144 | */ |
| 145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
| 145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
| 146 | 146 | |
| 147 | 147 | $give_options = give_get_settings(); |
| 148 | 148 | |
| 149 | 149 | $this->file = $_file; |
| 150 | 150 | $this->item_name = $_item_name; |
| 151 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
| 151 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
| 152 | 152 | $this->version = $_version; |
| 153 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
| 154 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
| 153 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
| 154 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
| 155 | 155 | $this->author = $_author; |
| 156 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
| 157 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
| 158 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
| 156 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
| 157 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
| 158 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
| 159 | 159 | $this->auto_updater_obj = null; |
| 160 | 160 | |
| 161 | 161 | // Setup hooks |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | private function includes() { |
| 178 | 178 | |
| 179 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 179 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
| 180 | 180 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -194,29 +194,29 @@ discard block |
||
| 194 | 194 | private function hooks() { |
| 195 | 195 | |
| 196 | 196 | // Register settings |
| 197 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
| 197 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
| 198 | 198 | |
| 199 | 199 | // Activate license key on settings save |
| 200 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
| 200 | + add_action('admin_init', array($this, 'activate_license')); |
|
| 201 | 201 | |
| 202 | 202 | // Deactivate license key |
| 203 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
| 203 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
| 204 | 204 | |
| 205 | 205 | // Updater |
| 206 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
| 207 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
| 206 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
| 207 | + add_action('admin_notices', array($this, 'notices')); |
|
| 208 | 208 | |
| 209 | 209 | // Check license weekly. |
| 210 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
| 211 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
| 210 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
| 211 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
| 212 | 212 | |
| 213 | 213 | // Check subscription weekly. |
| 214 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
| 215 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
| 214 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
| 215 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
| 216 | 216 | |
| 217 | 217 | // Show addon notice on plugin page. |
| 218 | - $plugin_name = end( explode( 'plugins/', $this->file ) ); |
|
| 219 | - add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 ); |
|
| 218 | + $plugin_name = end(explode('plugins/', $this->file)); |
|
| 219 | + add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3); |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
@@ -256,16 +256,16 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return array License settings. |
| 258 | 258 | */ |
| 259 | - public function settings( $settings ) { |
|
| 259 | + public function settings($settings) { |
|
| 260 | 260 | |
| 261 | 261 | $give_license_settings = array( |
| 262 | 262 | array( |
| 263 | 263 | 'name' => $this->item_name, |
| 264 | - 'id' => $this->item_shortname . '_license_key', |
|
| 264 | + 'id' => $this->item_shortname.'_license_key', |
|
| 265 | 265 | 'desc' => '', |
| 266 | 266 | 'type' => 'license_key', |
| 267 | 267 | 'options' => array( |
| 268 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
| 268 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
| 269 | 269 | 'shortname' => $this->item_shortname, |
| 270 | 270 | 'item_name' => $this->item_name, |
| 271 | 271 | 'api_url' => $this->api_url, |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | ), |
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | - return array_merge( $settings, $give_license_settings ); |
|
| 279 | + return array_merge($settings, $give_license_settings); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -291,18 +291,18 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @return array License settings content. |
| 293 | 293 | */ |
| 294 | - public function license_settings_content( $settings ) { |
|
| 294 | + public function license_settings_content($settings) { |
|
| 295 | 295 | |
| 296 | 296 | $give_license_settings = array( |
| 297 | 297 | array( |
| 298 | - 'name' => __( 'Add-on Licenses', 'give' ), |
|
| 298 | + 'name' => __('Add-on Licenses', 'give'), |
|
| 299 | 299 | 'desc' => '<hr>', |
| 300 | 300 | 'type' => 'give_title', |
| 301 | 301 | 'id' => 'give_title', |
| 302 | 302 | ), |
| 303 | 303 | ); |
| 304 | 304 | |
| 305 | - return array_merge( $settings, $give_license_settings ); |
|
| 305 | + return array_merge($settings, $give_license_settings); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -317,52 +317,52 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | public function activate_license() { |
| 319 | 319 | // Bailout: Check if license key set of not. |
| 320 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 320 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 321 | 321 | return; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Security check. |
| 325 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
| 326 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 325 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
| 326 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Check if user have correct permissions. |
| 330 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 330 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 331 | 331 | return; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Allow third party addon developers to handle license activation. |
| 335 | - if ( $this->__is_third_party_addon() ) { |
|
| 336 | - do_action( 'give_activate_license', $this ); |
|
| 335 | + if ($this->__is_third_party_addon()) { |
|
| 336 | + do_action('give_activate_license', $this); |
|
| 337 | 337 | |
| 338 | 338 | return; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Delete previous license setting if a empty license key submitted. |
| 342 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 343 | - delete_option( $this->item_shortname . '_license_active' ); |
|
| 342 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
| 343 | + delete_option($this->item_shortname.'_license_active'); |
|
| 344 | 344 | |
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Do not simultaneously activate add-ons if the user want to deactivate a specific add-on. |
| 349 | - foreach ( $_POST as $key => $value ) { |
|
| 350 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
| 349 | + foreach ($_POST as $key => $value) { |
|
| 350 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
| 351 | 351 | // Don't activate a key when deactivating a different key |
| 352 | 352 | return; |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Check if plugin previously installed. |
| 357 | - if ( $this->is_valid_license() ) { |
|
| 357 | + if ($this->is_valid_license()) { |
|
| 358 | 358 | return; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | // Get license key. |
| 362 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
| 362 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
| 363 | 363 | |
| 364 | 364 | // Bailout. |
| 365 | - if ( empty( $license ) ) { |
|
| 365 | + if (empty($license)) { |
|
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $api_params = array( |
| 374 | 374 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
| 375 | 375 | 'license' => $license, |
| 376 | - 'item_name' => urlencode( $this->item_name ), |
|
| 376 | + 'item_name' => urlencode($this->item_name), |
|
| 377 | 377 | 'url' => home_url(), |
| 378 | 378 | ); |
| 379 | 379 | |
@@ -388,19 +388,19 @@ discard block |
||
| 388 | 388 | ); |
| 389 | 389 | |
| 390 | 390 | // Make sure there are no errors |
| 391 | - if ( is_wp_error( $response ) ) { |
|
| 391 | + if (is_wp_error($response)) { |
|
| 392 | 392 | return; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | // Tell WordPress to look for updates |
| 396 | - set_site_transient( 'update_plugins', null ); |
|
| 396 | + set_site_transient('update_plugins', null); |
|
| 397 | 397 | |
| 398 | 398 | // Decode license data |
| 399 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 400 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
| 399 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 400 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
| 401 | 401 | |
| 402 | 402 | // Add license key. |
| 403 | - give_update_option( "{$this->item_shortname}_license_key", $license ); |
|
| 403 | + give_update_option("{$this->item_shortname}_license_key", $license); |
|
| 404 | 404 | |
| 405 | 405 | // Check subscription for license key and store this to db (if any). |
| 406 | 406 | $this->__single_subscription_check(); |
@@ -418,33 +418,33 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function deactivate_license() { |
| 420 | 420 | |
| 421 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 421 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 422 | 422 | return; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
| 426 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 425 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
| 426 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 429 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 430 | 430 | return; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Allow third party add-on developers to handle license deactivation. |
| 434 | - if ( $this->__is_third_party_addon() ) { |
|
| 435 | - do_action( 'give_deactivate_license', $this ); |
|
| 434 | + if ($this->__is_third_party_addon()) { |
|
| 435 | + do_action('give_deactivate_license', $this); |
|
| 436 | 436 | |
| 437 | 437 | return; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | // Run on deactivate button press |
| 441 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
| 441 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
| 442 | 442 | |
| 443 | 443 | // Data to send to the API |
| 444 | 444 | $api_params = array( |
| 445 | 445 | 'edd_action' => 'deactivate_license', // never change from "edd_" to "give_"! |
| 446 | 446 | 'license' => $this->license, |
| 447 | - 'item_name' => urlencode( $this->item_name ), |
|
| 447 | + 'item_name' => urlencode($this->item_name), |
|
| 448 | 448 | 'url' => home_url(), |
| 449 | 449 | ); |
| 450 | 450 | |
@@ -459,20 +459,20 @@ discard block |
||
| 459 | 459 | ); |
| 460 | 460 | |
| 461 | 461 | // Make sure there are no errors |
| 462 | - if ( is_wp_error( $response ) ) { |
|
| 462 | + if (is_wp_error($response)) { |
|
| 463 | 463 | return; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // Decode the license data |
| 467 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 467 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 468 | 468 | |
| 469 | 469 | // Ensure deactivated successfully. |
| 470 | - if ( isset( $license_data->success ) ) { |
|
| 470 | + if (isset($license_data->success)) { |
|
| 471 | 471 | |
| 472 | 472 | // Remove license data. |
| 473 | - delete_option( $this->item_shortname . '_license_active' ); |
|
| 473 | + delete_option($this->item_shortname.'_license_active'); |
|
| 474 | 474 | |
| 475 | - give_delete_option( $this->item_shortname . '_license_key' ); |
|
| 475 | + give_delete_option($this->item_shortname.'_license_key'); |
|
| 476 | 476 | |
| 477 | 477 | // Remove license key from subscriptions if exist. |
| 478 | 478 | $this->__remove_license_key_from_subscriptions(); |
@@ -491,18 +491,18 @@ discard block |
||
| 491 | 491 | */ |
| 492 | 492 | public function weekly_license_check() { |
| 493 | 493 | |
| 494 | - if ( ! empty( $_POST['give_settings'] ) ) { |
|
| 494 | + if ( ! empty($_POST['give_settings'])) { |
|
| 495 | 495 | // Don't fire when saving settings |
| 496 | 496 | return false; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - if ( empty( $this->license ) ) { |
|
| 499 | + if (empty($this->license)) { |
|
| 500 | 500 | return false; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | // Allow third party add-on developers to handle their license check. |
| 504 | - if ( $this->__is_third_party_addon() ) { |
|
| 505 | - do_action( 'give_weekly_license_check', $this ); |
|
| 504 | + if ($this->__is_third_party_addon()) { |
|
| 505 | + do_action('give_weekly_license_check', $this); |
|
| 506 | 506 | |
| 507 | 507 | return false; |
| 508 | 508 | } |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | $api_params = array( |
| 512 | 512 | 'edd_action' => 'check_license', |
| 513 | 513 | 'license' => $this->license, |
| 514 | - 'item_name' => urlencode( $this->item_name ), |
|
| 514 | + 'item_name' => urlencode($this->item_name), |
|
| 515 | 515 | 'url' => home_url(), |
| 516 | 516 | ); |
| 517 | 517 | |
@@ -526,12 +526,12 @@ discard block |
||
| 526 | 526 | ); |
| 527 | 527 | |
| 528 | 528 | // Make sure the response came back okay. |
| 529 | - if ( is_wp_error( $response ) ) { |
|
| 529 | + if (is_wp_error($response)) { |
|
| 530 | 530 | return false; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 534 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
| 533 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 534 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -544,24 +544,24 @@ discard block |
||
| 544 | 544 | */ |
| 545 | 545 | public function weekly_subscription_check() { |
| 546 | 546 | |
| 547 | - if ( ! empty( $_POST['give_settings'] ) ) { |
|
| 547 | + if ( ! empty($_POST['give_settings'])) { |
|
| 548 | 548 | // Don't fire when saving settings |
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | // Remove old subscription data. |
| 553 | - if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) { |
|
| 554 | - delete_option( 'give_subscriptions' ); |
|
| 555 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) ); |
|
| 553 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
| 554 | + delete_option('give_subscriptions'); |
|
| 555 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - if ( empty( $this->license ) ) { |
|
| 558 | + if (empty($this->license)) { |
|
| 559 | 559 | return false; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // Allow third party add-on developers to handle their subscription check. |
| 563 | - if ( $this->__is_third_party_addon() ) { |
|
| 564 | - do_action( 'give_weekly_subscription_check', $this ); |
|
| 563 | + if ($this->__is_third_party_addon()) { |
|
| 564 | + do_action('give_weekly_subscription_check', $this); |
|
| 565 | 565 | |
| 566 | 566 | return false; |
| 567 | 567 | } |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | // This is a custom feature to check subscriptions. |
| 577 | 577 | 'edd_action' => 'check_subscription', |
| 578 | 578 | 'license' => $this->license, |
| 579 | - 'item_name' => urlencode( $this->item_name ), |
|
| 579 | + 'item_name' => urlencode($this->item_name), |
|
| 580 | 580 | 'url' => home_url(), |
| 581 | 581 | ); |
| 582 | 582 | |
@@ -591,27 +591,27 @@ discard block |
||
| 591 | 591 | ); |
| 592 | 592 | |
| 593 | 593 | // Make sure the response came back okay. |
| 594 | - if ( is_wp_error( $response ) ) { |
|
| 594 | + if (is_wp_error($response)) { |
|
| 595 | 595 | return false; |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 598 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
| 599 | 599 | |
| 600 | - if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
| 601 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
| 600 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
| 601 | + $subscriptions = get_option('give_subscriptions', array()); |
|
| 602 | 602 | |
| 603 | 603 | // Update subscription data only if subscription does not exist already. |
| 604 | - if ( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
| 605 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
| 606 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
| 604 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
| 605 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
| 606 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // Store licenses for subscription. |
| 610 | - if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
| 611 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
| 610 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
| 611 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - update_option( 'give_subscriptions', $subscriptions ); |
|
| 614 | + update_option('give_subscriptions', $subscriptions); |
|
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | |
@@ -625,11 +625,11 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | private function __single_subscription_check() { |
| 627 | 627 | // Do not fire if license key is not set. |
| 628 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 628 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 629 | 629 | return false; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - if ( empty( $this->license ) ) { |
|
| 632 | + if (empty($this->license)) { |
|
| 633 | 633 | return false; |
| 634 | 634 | } |
| 635 | 635 | |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | // This is a custom feature to check subscriptions. |
| 641 | 641 | 'edd_action' => 'check_subscription', |
| 642 | 642 | 'license' => $this->license, |
| 643 | - 'item_name' => urlencode( $this->item_name ), |
|
| 643 | + 'item_name' => urlencode($this->item_name), |
|
| 644 | 644 | 'url' => home_url(), |
| 645 | 645 | ); |
| 646 | 646 | |
@@ -655,27 +655,27 @@ discard block |
||
| 655 | 655 | ); |
| 656 | 656 | |
| 657 | 657 | // Make sure the response came back okay. |
| 658 | - if ( is_wp_error( $response ) ) { |
|
| 658 | + if (is_wp_error($response)) { |
|
| 659 | 659 | return false; |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 662 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
| 663 | 663 | |
| 664 | - if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
| 665 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
| 664 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
| 665 | + $subscriptions = get_option('give_subscriptions', array()); |
|
| 666 | 666 | |
| 667 | 667 | // Update subscription data only if subscription does not exist already. |
| 668 | - if ( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
| 669 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
| 670 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
| 668 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
| 669 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
| 670 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | // Store licenses for subscription. |
| 674 | - if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
| 675 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
| 674 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
| 675 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - update_option( 'give_subscriptions', $subscriptions ); |
|
| 678 | + update_option('give_subscriptions', $subscriptions); |
|
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | |
@@ -689,12 +689,12 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | public function notices() { |
| 691 | 691 | |
| 692 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 692 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 693 | 693 | return; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | // Do not show licenses notices on license tab. |
| 697 | - if ( 'licenses' === give_get_current_setting_tab() ) { |
|
| 697 | + if ('licenses' === give_get_current_setting_tab()) { |
|
| 698 | 698 | return; |
| 699 | 699 | } |
| 700 | 700 | |
@@ -703,93 +703,93 @@ discard block |
||
| 703 | 703 | static $addon_license_key_in_subscriptions; |
| 704 | 704 | |
| 705 | 705 | // Set default value. |
| 706 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
| 706 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
| 707 | 707 | $messages = array(); |
| 708 | 708 | |
| 709 | 709 | if ( |
| 710 | - empty( $this->license ) |
|
| 711 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
| 712 | - && empty( $showed_invalid_message ) |
|
| 710 | + empty($this->license) |
|
| 711 | + && ! $this->__is_notice_dismissed('general') |
|
| 712 | + && empty($showed_invalid_message) |
|
| 713 | 713 | ) { |
| 714 | - $messages['general'] = sprintf( |
|
| 715 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
| 716 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
| 714 | + $messages['general'] = sprintf( |
|
| 715 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
| 716 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
| 717 | 717 | ); |
| 718 | 718 | $showed_invalid_message = true; |
| 719 | 719 | |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | // Get subscriptions. |
| 723 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
| 723 | + $subscriptions = get_option('give_subscriptions'); |
|
| 724 | 724 | |
| 725 | 725 | // Show subscription messages. |
| 726 | - if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
| 726 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
| 727 | 727 | |
| 728 | - foreach ( $subscriptions as $subscription ) { |
|
| 728 | + foreach ($subscriptions as $subscription) { |
|
| 729 | 729 | // Subscription expires timestamp. |
| 730 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
| 730 | + $subscription_expires = strtotime($subscription['expires']); |
|
| 731 | 731 | |
| 732 | 732 | // Start showing subscriptions message before one week of renewal date. |
| 733 | - if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
| 733 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
| 734 | 734 | continue; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | // Check if subscription message already exist in messages. |
| 738 | - if ( array_key_exists( $subscription['id'], $messages ) ) { |
|
| 738 | + if (array_key_exists($subscription['id'], $messages)) { |
|
| 739 | 739 | continue; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if ( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
| 742 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
| 743 | 743 | |
| 744 | - if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
| 745 | - $messages[ $subscription['id'] ] = sprintf( |
|
| 746 | - __( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or <a href="%4$s">Click here if already renewed</a>.', 'give' ), |
|
| 747 | - urldecode( $subscription['invoice_url'] ), |
|
| 744 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
| 745 | + $messages[$subscription['id']] = sprintf( |
|
| 746 | + __('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or <a href="%4$s">Click here if already renewed</a>.', 'give'), |
|
| 747 | + urldecode($subscription['invoice_url']), |
|
| 748 | 748 | $subscription['payment_id'], |
| 749 | 749 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
| 750 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
| 750 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
| 751 | 751 | ); |
| 752 | 752 | } else { |
| 753 | - $messages[ $subscription['id'] ] = sprintf( |
|
| 754 | - __( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or <a href="%5$s">Click here if already renewed</a>.', 'give' ), |
|
| 755 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
| 756 | - urldecode( $subscription['invoice_url'] ), |
|
| 753 | + $messages[$subscription['id']] = sprintf( |
|
| 754 | + __('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or <a href="%5$s">Click here if already renewed</a>.', 'give'), |
|
| 755 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
| 756 | + urldecode($subscription['invoice_url']), |
|
| 757 | 757 | $subscription['payment_id'], |
| 758 | 758 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
| 759 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
| 759 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
| 760 | 760 | ); |
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | // Stop validation for these license keys. |
| 765 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
| 765 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
| 766 | 766 | }// End foreach(). |
| 767 | 767 | $showed_subscriptions_message = true; |
| 768 | 768 | }// End if(). |
| 769 | 769 | |
| 770 | 770 | // Show non subscription addon messages. |
| 771 | 771 | if ( |
| 772 | - ! in_array( $this->license, $addon_license_key_in_subscriptions ) |
|
| 773 | - && ! $this->__is_notice_dismissed( 'general' ) |
|
| 772 | + ! in_array($this->license, $addon_license_key_in_subscriptions) |
|
| 773 | + && ! $this->__is_notice_dismissed('general') |
|
| 774 | 774 | && ! $this->is_valid_license() |
| 775 | - && empty( $showed_invalid_message ) |
|
| 775 | + && empty($showed_invalid_message) |
|
| 776 | 776 | ) { |
| 777 | 777 | |
| 778 | - $messages['general'] = sprintf( |
|
| 779 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
| 780 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
| 778 | + $messages['general'] = sprintf( |
|
| 779 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
| 780 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
| 781 | 781 | ); |
| 782 | 782 | $showed_invalid_message = true; |
| 783 | 783 | |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | // Print messages. |
| 787 | - if ( ! empty( $messages ) ) { |
|
| 788 | - foreach ( $messages as $notice_id => $message ) { |
|
| 787 | + if ( ! empty($messages)) { |
|
| 788 | + foreach ($messages as $notice_id => $message) { |
|
| 789 | 789 | |
| 790 | 790 | echo sprintf( |
| 791 | 791 | '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="%1$s"><p>%2$s</p></div>', |
| 792 | - esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ), |
|
| 792 | + esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])), |
|
| 793 | 793 | $message |
| 794 | 794 | ); |
| 795 | 795 | } |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * @return bool |
| 806 | 806 | */ |
| 807 | 807 | public function is_valid_license() { |
| 808 | - if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) { |
|
| 808 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
| 809 | 809 | return true; |
| 810 | 810 | } |
| 811 | 811 | |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | * @return bool |
| 822 | 822 | */ |
| 823 | 823 | private function __is_third_party_addon() { |
| 824 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
| 824 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -836,25 +836,25 @@ discard block |
||
| 836 | 836 | * @return void|bool |
| 837 | 837 | */ |
| 838 | 838 | private function __remove_license_key_from_subscriptions() { |
| 839 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
| 839 | + $subscriptions = get_option('give_subscriptions', array()); |
|
| 840 | 840 | |
| 841 | 841 | // Bailout. |
| 842 | - if ( empty( $this->license ) ) { |
|
| 842 | + if (empty($this->license)) { |
|
| 843 | 843 | return false; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | - if ( ! empty( $subscriptions ) ) { |
|
| 847 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
| 848 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
| 849 | - if ( false !== $license_index ) { |
|
| 846 | + if ( ! empty($subscriptions)) { |
|
| 847 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
| 848 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
| 849 | + if (false !== $license_index) { |
|
| 850 | 850 | // Remove license key. |
| 851 | - unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] ); |
|
| 851 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
| 852 | 852 | |
| 853 | 853 | // Rearrange license keys. |
| 854 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
| 854 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
| 855 | 855 | |
| 856 | 856 | // Update subscription information. |
| 857 | - update_option( 'give_subscriptions', $subscriptions ); |
|
| 857 | + update_option('give_subscriptions', $subscriptions); |
|
| 858 | 858 | break; |
| 859 | 859 | } |
| 860 | 860 | } |
@@ -907,18 +907,18 @@ discard block |
||
| 907 | 907 | * |
| 908 | 908 | * @return bool |
| 909 | 909 | */ |
| 910 | - private function __is_notice_dismissed( $notice_id ) { |
|
| 910 | + private function __is_notice_dismissed($notice_id) { |
|
| 911 | 911 | $current_user = wp_get_current_user(); |
| 912 | 912 | $is_notice_dismissed = false; |
| 913 | 913 | |
| 914 | 914 | // Ge is notice dismissed permanently. |
| 915 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
| 915 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
| 916 | 916 | ? $already_dismiss_notices |
| 917 | 917 | : array(); |
| 918 | 918 | |
| 919 | 919 | if ( |
| 920 | - in_array( $notice_id, $already_dismiss_notices ) |
|
| 921 | - || Give_Cache::get( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true ) |
|
| 920 | + in_array($notice_id, $already_dismiss_notices) |
|
| 921 | + || Give_Cache::get("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true) |
|
| 922 | 922 | ) { |
| 923 | 923 | $is_notice_dismissed = true; |
| 924 | 924 | } |
@@ -934,17 +934,17 @@ discard block |
||
| 934 | 934 | * |
| 935 | 935 | * @return bool |
| 936 | 936 | */ |
| 937 | - public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
|
| 937 | + public function plugin_page_notices($plugin_file, $plugin_data, $status) { |
|
| 938 | 938 | // Bailout. |
| 939 | - if ( $this->is_valid_license() ) { |
|
| 939 | + if ($this->is_valid_license()) { |
|
| 940 | 940 | return false; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | $update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>'; |
| 944 | 944 | $message = $this->license_state_message(); |
| 945 | 945 | |
| 946 | - if ( ! empty( $message['message'] ) ) { |
|
| 947 | - echo sprintf( $update_notice_wrap, $message['message'] ); |
|
| 946 | + if ( ! empty($message['message'])) { |
|
| 947 | + echo sprintf($update_notice_wrap, $message['message']); |
|
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | |
@@ -959,11 +959,11 @@ discard block |
||
| 959 | 959 | public function license_state_message() { |
| 960 | 960 | $message_data = array(); |
| 961 | 961 | |
| 962 | - if ( ! $this->is_valid_license() ) { |
|
| 962 | + if ( ! $this->is_valid_license()) { |
|
| 963 | 963 | |
| 964 | 964 | $message_data['message'] = sprintf( |
| 965 | 965 | 'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.', |
| 966 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ), |
|
| 966 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')), |
|
| 967 | 967 | $this->item_name |
| 968 | 968 | ); |
| 969 | 969 | } |