@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Login extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Login', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Login', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Login', 'give'); |
|
22 | + $this->shortcode['label'] = __('Login', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_login' ); |
|
24 | + parent::__construct('give_login'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Redirect URL (optional):', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="no-margin">%s</p>', __('Redirect URL (optional):', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'textbox', |
41 | 41 | 'name' => 'redirect', |
42 | 42 | 'minWidth' => 320, |
43 | - 'tooltip' => __( 'Enter an URL here to redirect to after login.', 'give' ), |
|
43 | + 'tooltip' => __('Enter an URL here to redirect to after login.', 'give'), |
|
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Profile_Editor extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['label'] = __( 'Profile Editor', 'give' ); |
|
21 | + $this->shortcode['label'] = __('Profile Editor', 'give'); |
|
22 | 22 | |
23 | - parent::__construct( 'give_profile_editor' ); |
|
23 | + parent::__construct('give_profile_editor'); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Donation_Receipt extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Donation Receipt', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Donation Receipt', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Donation Receipt', 'give'); |
|
22 | + $this->shortcode['label'] = __('Donation Receipt', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_receipt' ); |
|
24 | + parent::__construct('give_receipt'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,51 +34,51 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="strong">%s</p>', __( 'Optional settings', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="strong">%s</p>', __('Optional settings', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'listbox', |
41 | 41 | 'name' => 'price', |
42 | - 'label' => __( 'Show Price:', 'give' ), |
|
42 | + 'label' => __('Show Price:', 'give'), |
|
43 | 43 | 'options' => array( |
44 | - 'true' => __( 'Show', 'give' ), |
|
45 | - 'false' => __( 'Hide', 'give' ), |
|
44 | + 'true' => __('Show', 'give'), |
|
45 | + 'false' => __('Hide', 'give'), |
|
46 | 46 | ), |
47 | 47 | ), |
48 | 48 | array( |
49 | 49 | 'type' => 'listbox', |
50 | 50 | 'name' => 'date', |
51 | - 'label' => __( 'Show Date:', 'give' ), |
|
51 | + 'label' => __('Show Date:', 'give'), |
|
52 | 52 | 'options' => array( |
53 | - 'true' => __( 'Show', 'give' ), |
|
54 | - 'false' => __( 'Hide', 'give' ), |
|
53 | + 'true' => __('Show', 'give'), |
|
54 | + 'false' => __('Hide', 'give'), |
|
55 | 55 | ), |
56 | 56 | ), |
57 | 57 | array( |
58 | 58 | 'type' => 'listbox', |
59 | 59 | 'name' => 'payment_key', |
60 | - 'label' => __( 'Show Payment Key:', 'give' ), |
|
60 | + 'label' => __('Show Payment Key:', 'give'), |
|
61 | 61 | 'options' => array( |
62 | - 'true' => __( 'Show', 'give' ), |
|
63 | - 'false' => __( 'Hide', 'give' ), |
|
62 | + 'true' => __('Show', 'give'), |
|
63 | + 'false' => __('Hide', 'give'), |
|
64 | 64 | ), |
65 | 65 | ), |
66 | 66 | array( |
67 | 67 | 'type' => 'listbox', |
68 | 68 | 'name' => 'payment_method', |
69 | - 'label' => __( 'Show Payment Method:', 'give' ), |
|
69 | + 'label' => __('Show Payment Method:', 'give'), |
|
70 | 70 | 'options' => array( |
71 | - 'true' => __( 'Show', 'give' ), |
|
72 | - 'false' => __( 'Hide', 'give' ), |
|
71 | + 'true' => __('Show', 'give'), |
|
72 | + 'false' => __('Hide', 'give'), |
|
73 | 73 | ), |
74 | 74 | ), |
75 | 75 | array( |
76 | 76 | 'type' => 'listbox', |
77 | 77 | 'name' => 'payment_id', |
78 | - 'label' => __( 'Show Payment ID:', 'give' ), |
|
78 | + 'label' => __('Show Payment ID:', 'give'), |
|
79 | 79 | 'options' => array( |
80 | - 'true' => __( 'Show', 'give' ), |
|
81 | - 'false' => __( 'Hide', 'give' ), |
|
80 | + 'true' => __('Show', 'give'), |
|
81 | + 'false' => __('Hide', 'give'), |
|
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Register extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Register', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Register', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Register', 'give'); |
|
22 | + $this->shortcode['label'] = __('Register', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_register' ); |
|
24 | + parent::__construct('give_register'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Redirect URL (optional):', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="no-margin">%s</p>', __('Redirect URL (optional):', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'textbox', |
41 | 41 | 'name' => 'redirect', |
42 | 42 | 'minWidth' => 320, |
43 | - 'tooltip' => __( 'Enter an URL here to redirect to after registering.', 'give' ), |
|
43 | + 'tooltip' => __('Enter an URL here to redirect to after registering.', 'give'), |
|
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | } |
@@ -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,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_upgrades_screen() { |
24 | - $action = isset( $_GET['give-upgrade'] ) ? sanitize_text_field( $_GET['give-upgrade'] ) : ''; |
|
25 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
26 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
27 | - $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; |
|
28 | - $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; |
|
29 | - $steps = round( ( $total / $number ), 0 ); |
|
24 | + $action = isset($_GET['give-upgrade']) ? sanitize_text_field($_GET['give-upgrade']) : ''; |
|
25 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
26 | + $total = isset($_GET['total']) ? absint($_GET['total']) : false; |
|
27 | + $custom = isset($_GET['custom']) ? absint($_GET['custom']) : 0; |
|
28 | + $number = isset($_GET['number']) ? absint($_GET['number']) : 100; |
|
29 | + $steps = round(($total / $number), 0); |
|
30 | 30 | |
31 | 31 | $doing_upgrade_args = array( |
32 | 32 | 'page' => 'give-upgrades', |
@@ -36,25 +36,25 @@ discard block |
||
36 | 36 | 'custom' => $custom, |
37 | 37 | 'steps' => $steps |
38 | 38 | ); |
39 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
40 | - if ( $step > $steps ) { |
|
39 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
40 | + if ($step > $steps) { |
|
41 | 41 | // Prevent a weird case where the estimate was off. Usually only a couple. |
42 | 42 | $steps = $step; |
43 | 43 | } |
44 | 44 | ?> |
45 | 45 | <div class="wrap"> |
46 | - <h2><?php _e( 'Give - Upgrades', 'give' ); ?></h2> |
|
46 | + <h2><?php _e('Give - Upgrades', 'give'); ?></h2> |
|
47 | 47 | |
48 | - <?php if ( ! empty( $action ) ) : ?> |
|
48 | + <?php if ( ! empty($action)) : ?> |
|
49 | 49 | |
50 | 50 | <div id="give-upgrade-status"> |
51 | - <p style="font-size: 20px;max-width: 900px;"><?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
52 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
51 | + <p style="font-size: 20px;max-width: 900px;"><?php _e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?> |
|
52 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
53 | 53 | </p> |
54 | 54 | |
55 | - <?php if ( ! empty( $total ) ) : ?> |
|
55 | + <?php if ( ! empty($total)) : ?> |
|
56 | 56 | <p> |
57 | - <strong><?php printf( __( 'Step %d of approximately %d running', 'give' ), $step, $steps ); ?></strong> |
|
57 | + <strong><?php printf(__('Step %d of approximately %d running', 'give'), $step, $steps); ?></strong> |
|
58 | 58 | </p> |
59 | 59 | <?php endif; ?> |
60 | 60 | </div> |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | <div id="give-upgrade-status"> |
70 | 70 | <p style="font-size: 20px;max-width: 900px;"> |
71 | - <?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
72 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
71 | + <?php _e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?> |
|
72 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
73 | 73 | </p> |
74 | 74 | </div> |
75 | 75 | <script type="text/javascript"> |
@@ -64,11 +64,14 @@ |
||
64 | 64 | }, 250 ); |
65 | 65 | </script> |
66 | 66 | |
67 | - <?php else : ?> |
|
67 | + <?php else { |
|
68 | + : ?> |
|
68 | 69 | |
69 | 70 | <div id="give-upgrade-status"> |
70 | 71 | <p style="font-size: 20px;max-width: 900px;"> |
71 | - <?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
72 | + <?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); |
|
73 | +} |
|
74 | +?> |
|
72 | 75 | <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
73 | 76 | </p> |
74 | 77 | </div> |
@@ -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 | |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | function give_test_ajax_works() { |
26 | 26 | |
27 | 27 | // Check if the Airplane Mode plugin is installed |
28 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
28 | + if (class_exists('Airplane_Mode_Core')) { |
|
29 | 29 | |
30 | 30 | $airplane = Airplane_Mode_Core::getInstance(); |
31 | 31 | |
32 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
32 | + if (method_exists($airplane, 'enabled')) { |
|
33 | 33 | |
34 | - if ( $airplane->enabled() ) { |
|
34 | + if ($airplane->enabled()) { |
|
35 | 35 | return true; |
36 | 36 | } |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - if ( $airplane->check_status() == 'on' ) { |
|
40 | + if ($airplane->check_status() == 'on') { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
46 | + add_filter('block_local_requests', '__return_false'); |
|
47 | 47 | |
48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
48 | + if (get_transient('_give_ajax_works')) { |
|
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
61 | 61 | $works = true; |
62 | 62 | |
63 | - if ( is_wp_error( $ajax ) ) { |
|
63 | + if (is_wp_error($ajax)) { |
|
64 | 64 | |
65 | 65 | $works = false; |
66 | 66 | |
67 | 67 | } else { |
68 | 68 | |
69 | - if( empty( $ajax['response'] ) ) { |
|
69 | + if (empty($ajax['response'])) { |
|
70 | 70 | $works = false; |
71 | 71 | } |
72 | 72 | |
73 | - if( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
73 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
74 | 74 | $works = false; |
75 | 75 | } |
76 | 76 | |
77 | - if( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
77 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
78 | 78 | $works = false; |
79 | 79 | } |
80 | 80 | |
81 | - if( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
81 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
82 | 82 | $works = false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - if ( $works ) { |
|
88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
87 | + if ($works) { |
|
88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $works; |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | * @return string |
100 | 100 | */ |
101 | 101 | function give_get_ajax_url() { |
102 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
102 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
103 | 103 | |
104 | 104 | $current_url = give_get_current_page_url(); |
105 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
105 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
106 | 106 | |
107 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
108 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
107 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
108 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
111 | + return apply_filters('give_ajax_url', $ajax_url); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * @return void |
119 | 119 | */ |
120 | 120 | function give_load_checkout_login_fields() { |
121 | - do_action( 'give_purchase_form_login_fields' ); |
|
121 | + do_action('give_purchase_form_login_fields'); |
|
122 | 122 | give_die(); |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
125 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Load Checkout Register Fields via AJAX |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @return void |
132 | 132 | */ |
133 | 133 | function give_load_checkout_register_fields() { |
134 | - do_action( 'give_purchase_form_register_fields' ); |
|
134 | + do_action('give_purchase_form_register_fields'); |
|
135 | 135 | give_die(); |
136 | 136 | } |
137 | 137 | |
138 | -add_action( 'wp_ajax_nopriv_checkout_register', 'give_load_checkout_register_fields' ); |
|
138 | +add_action('wp_ajax_nopriv_checkout_register', 'give_load_checkout_register_fields'); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | * @return void |
145 | 145 | */ |
146 | 146 | function give_ajax_get_form_title() { |
147 | - if ( isset( $_POST['form_id'] ) ) { |
|
148 | - $title = get_the_title( $_POST['form_id'] ); |
|
149 | - if ( $title ) { |
|
147 | + if (isset($_POST['form_id'])) { |
|
148 | + $title = get_the_title($_POST['form_id']); |
|
149 | + if ($title) { |
|
150 | 150 | echo $title; |
151 | 151 | } else { |
152 | 152 | echo 'fail'; |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | give_die(); |
156 | 156 | } |
157 | 157 | |
158 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
159 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
158 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
159 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Retrieve a states drop down |
@@ -166,23 +166,23 @@ discard block |
||
166 | 166 | */ |
167 | 167 | function give_ajax_get_states_field() { |
168 | 168 | |
169 | - if ( empty( $_POST['country'] ) ) { |
|
169 | + if (empty($_POST['country'])) { |
|
170 | 170 | $_POST['country'] = give_get_country(); |
171 | 171 | } |
172 | - $states = give_get_states( $_POST['country'] ); |
|
172 | + $states = give_get_states($_POST['country']); |
|
173 | 173 | |
174 | - if ( ! empty( $states ) ) { |
|
174 | + if ( ! empty($states)) { |
|
175 | 175 | |
176 | 176 | $args = array( |
177 | 177 | 'name' => $_POST['field_name'], |
178 | 178 | 'id' => $_POST['field_name'], |
179 | - 'class' => $_POST['field_name'] . ' give-select', |
|
180 | - 'options' => give_get_states( $_POST['country'] ), |
|
179 | + 'class' => $_POST['field_name'].' give-select', |
|
180 | + 'options' => give_get_states($_POST['country']), |
|
181 | 181 | 'show_option_all' => false, |
182 | 182 | 'show_option_none' => false |
183 | 183 | ); |
184 | 184 | |
185 | - $response = Give()->html->select( $args ); |
|
185 | + $response = Give()->html->select($args); |
|
186 | 186 | |
187 | 187 | } else { |
188 | 188 | |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | give_die(); |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
198 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
197 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
198 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Retrieve a states drop down |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | function give_ajax_form_search() { |
207 | 207 | global $wpdb; |
208 | 208 | |
209 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
209 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
210 | 210 | $results = array(); |
211 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
212 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
211 | + if (current_user_can('edit_give_forms')) { |
|
212 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
213 | 213 | } else { |
214 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
214 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
215 | 215 | } |
216 | 216 | |
217 | - if ( $items ) { |
|
217 | + if ($items) { |
|
218 | 218 | |
219 | - foreach ( $items as $item ) { |
|
219 | + foreach ($items as $item) { |
|
220 | 220 | |
221 | 221 | $results[] = array( |
222 | 222 | 'id' => $item->ID, |
@@ -228,18 +228,18 @@ discard block |
||
228 | 228 | |
229 | 229 | $items[] = array( |
230 | 230 | 'id' => 0, |
231 | - 'name' => __( 'No results found', 'give' ) |
|
231 | + 'name' => __('No results found', 'give') |
|
232 | 232 | ); |
233 | 233 | |
234 | 234 | } |
235 | 235 | |
236 | - echo json_encode( $results ); |
|
236 | + echo json_encode($results); |
|
237 | 237 | |
238 | 238 | give_die(); |
239 | 239 | } |
240 | 240 | |
241 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
242 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
241 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
242 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * Search the donors database via Ajax |
@@ -250,21 +250,21 @@ discard block |
||
250 | 250 | function give_ajax_donor_search() { |
251 | 251 | global $wpdb; |
252 | 252 | |
253 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
253 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
254 | 254 | $results = array(); |
255 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
255 | + if ( ! current_user_can('view_give_reports')) { |
|
256 | 256 | $donors = array(); |
257 | 257 | } else { |
258 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
258 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( $donors ) { |
|
261 | + if ($donors) { |
|
262 | 262 | |
263 | - foreach ( $donors as $donor ) { |
|
263 | + foreach ($donors as $donor) { |
|
264 | 264 | |
265 | 265 | $results[] = array( |
266 | 266 | 'id' => $donor->id, |
267 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
267 | + 'name' => $donor->name.'('.$donor->email.')' |
|
268 | 268 | ); |
269 | 269 | } |
270 | 270 | |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | |
273 | 273 | $donors[] = array( |
274 | 274 | 'id' => 0, |
275 | - 'name' => __( 'No results found', 'give' ) |
|
275 | + 'name' => __('No results found', 'give') |
|
276 | 276 | ); |
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | - echo json_encode( $results ); |
|
280 | + echo json_encode($results); |
|
281 | 281 | |
282 | 282 | give_die(); |
283 | 283 | } |
284 | 284 | |
285 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
285 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
286 | 286 | |
287 | 287 | |
288 | 288 | /** |
@@ -293,30 +293,30 @@ discard block |
||
293 | 293 | */ |
294 | 294 | function give_ajax_search_users() { |
295 | 295 | |
296 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
296 | + if (current_user_can('manage_give_settings')) { |
|
297 | 297 | |
298 | - $search_query = trim( $_POST['user_name'] ); |
|
298 | + $search_query = trim($_POST['user_name']); |
|
299 | 299 | |
300 | - $found_users = get_users( array( |
|
300 | + $found_users = get_users(array( |
|
301 | 301 | 'number' => 9999, |
302 | - 'search' => $search_query . '*' |
|
302 | + 'search' => $search_query.'*' |
|
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
306 | 306 | $user_list = '<ul>'; |
307 | - if ( $found_users ) { |
|
308 | - foreach ( $found_users as $user ) { |
|
309 | - $user_list .= '<li><a href="#" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
307 | + if ($found_users) { |
|
308 | + foreach ($found_users as $user) { |
|
309 | + $user_list .= '<li><a href="#" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
310 | 310 | } |
311 | 311 | } else { |
312 | - $user_list .= '<li>' . __( 'No users found', 'give' ) . '</li>'; |
|
312 | + $user_list .= '<li>'.__('No users found', 'give').'</li>'; |
|
313 | 313 | } |
314 | 314 | $user_list .= '</ul>'; |
315 | 315 | |
316 | - echo json_encode( array( 'results' => $user_list ) ); |
|
316 | + echo json_encode(array('results' => $user_list)); |
|
317 | 317 | |
318 | 318 | } |
319 | 319 | die(); |
320 | 320 | } |
321 | 321 | |
322 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
323 | 322 | \ No newline at end of file |
323 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
324 | 324 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined('ABSPATH')) exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give_API_V1 Class |
@@ -10,7 +10,9 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
14 | + exit; |
|
15 | +} |
|
14 | 16 | |
15 | 17 | /** |
16 | 18 | * Give_API_V1 Class |
@@ -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 | |
@@ -96,29 +96,29 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @since 1.0 |
98 | 98 | */ |
99 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
99 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
100 | 100 | |
101 | 101 | $this->db = new Give_DB_Customers; |
102 | 102 | |
103 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
103 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
107 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
108 | 108 | |
109 | - if ( is_numeric( $_id_or_email ) ) { |
|
109 | + if (is_numeric($_id_or_email)) { |
|
110 | 110 | $field = $by_user_id ? 'user_id' : 'id'; |
111 | 111 | } else { |
112 | 112 | $field = 'email'; |
113 | 113 | } |
114 | 114 | |
115 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
115 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
116 | 116 | |
117 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
117 | + if (empty($customer) || ! is_object($customer)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - $this->setup_customer( $customer ); |
|
121 | + $this->setup_customer($customer); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool If the setup was successful or not |
133 | 133 | */ |
134 | - private function setup_customer( $customer ) { |
|
134 | + private function setup_customer($customer) { |
|
135 | 135 | |
136 | - if ( ! is_object( $customer ) ) { |
|
136 | + if ( ! is_object($customer)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - foreach ( $customer as $key => $value ) { |
|
140 | + foreach ($customer as $key => $value) { |
|
141 | 141 | |
142 | - switch ( $key ) { |
|
142 | + switch ($key) { |
|
143 | 143 | |
144 | 144 | case 'notes': |
145 | 145 | $this->$key = $this->get_notes(); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Customer ID and email are the only things that are necessary, make sure they exist |
157 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
157 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - public function __get( $key ) { |
|
170 | + public function __get($key) { |
|
171 | 171 | |
172 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
172 | + if (method_exists($this, 'get_'.$key)) { |
|
173 | 173 | |
174 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
174 | + return call_user_func(array($this, 'get_'.$key)); |
|
175 | 175 | |
176 | 176 | } else { |
177 | 177 | |
178 | - return new WP_Error( 'give-customer-invalid-property', sprintf( __( 'Can\'t get property %s', 'give' ), $key ) ); |
|
178 | + return new WP_Error('give-customer-invalid-property', sprintf(__('Can\'t get property %s', 'give'), $key)); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return mixed False if not a valid creation, Customer ID if user is found or valid creation |
192 | 192 | */ |
193 | - public function create( $data = array() ) { |
|
193 | + public function create($data = array()) { |
|
194 | 194 | |
195 | - if ( $this->id != 0 || empty( $data ) ) { |
|
195 | + if ($this->id != 0 || empty($data)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | 'payment_ids' => '' |
201 | 201 | ); |
202 | 202 | |
203 | - $args = wp_parse_args( $data, $defaults ); |
|
204 | - $args = $this->sanitize_columns( $args ); |
|
203 | + $args = wp_parse_args($data, $defaults); |
|
204 | + $args = $this->sanitize_columns($args); |
|
205 | 205 | |
206 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
206 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
211 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
210 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
211 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
212 | 212 | } |
213 | 213 | |
214 | - do_action( 'give_customer_pre_create', $args ); |
|
214 | + do_action('give_customer_pre_create', $args); |
|
215 | 215 | |
216 | 216 | $created = false; |
217 | 217 | |
218 | 218 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
219 | - if ( $this->db->add( $data ) ) { |
|
219 | + if ($this->db->add($data)) { |
|
220 | 220 | |
221 | 221 | // We've successfully added/updated the customer, reset the class vars with the new data |
222 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
222 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
223 | 223 | |
224 | 224 | // Setup the customer data with the values from DB |
225 | - $this->setup_customer( $customer ); |
|
225 | + $this->setup_customer($customer); |
|
226 | 226 | |
227 | 227 | $created = $this->id; |
228 | 228 | } |
229 | 229 | |
230 | - do_action( 'give_customer_post_create', $created, $args ); |
|
230 | + do_action('give_customer_post_create', $created, $args); |
|
231 | 231 | |
232 | 232 | return $created; |
233 | 233 | |
@@ -242,27 +242,27 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return bool If the update was successful or not |
244 | 244 | */ |
245 | - public function update( $data = array() ) { |
|
245 | + public function update($data = array()) { |
|
246 | 246 | |
247 | - if ( empty( $data ) ) { |
|
247 | + if (empty($data)) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | - $data = $this->sanitize_columns( $data ); |
|
251 | + $data = $this->sanitize_columns($data); |
|
252 | 252 | |
253 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
253 | + do_action('give_customer_pre_update', $this->id, $data); |
|
254 | 254 | |
255 | 255 | $updated = false; |
256 | 256 | |
257 | - if ( $this->db->update( $this->id, $data ) ) { |
|
257 | + if ($this->db->update($this->id, $data)) { |
|
258 | 258 | |
259 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
260 | - $this->setup_customer( $customer ); |
|
259 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
260 | + $this->setup_customer($customer); |
|
261 | 261 | |
262 | 262 | $updated = true; |
263 | 263 | } |
264 | 264 | |
265 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
265 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
266 | 266 | |
267 | 267 | return $updated; |
268 | 268 | } |
@@ -278,44 +278,44 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return bool If the attachment was successfuly |
280 | 280 | */ |
281 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
281 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
282 | 282 | |
283 | - if ( empty( $payment_id ) ) { |
|
283 | + if (empty($payment_id)) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
287 | - if ( empty( $this->payment_ids ) ) { |
|
287 | + if (empty($this->payment_ids)) { |
|
288 | 288 | |
289 | 289 | $new_payment_ids = $payment_id; |
290 | 290 | |
291 | 291 | } else { |
292 | 292 | |
293 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
293 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
294 | 294 | |
295 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
295 | + if (in_array($payment_id, $payment_ids)) { |
|
296 | 296 | $update_stats = false; |
297 | 297 | } |
298 | 298 | |
299 | 299 | $payment_ids[] = $payment_id; |
300 | 300 | |
301 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
301 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | |
305 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
305 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
306 | 306 | |
307 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
307 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
308 | 308 | |
309 | - if ( $payment_added ) { |
|
309 | + if ($payment_added) { |
|
310 | 310 | |
311 | 311 | $this->payment_ids = $new_payment_ids; |
312 | 312 | |
313 | 313 | // We added this payment successfully, increment the stats |
314 | - if ( $update_stats ) { |
|
315 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
314 | + if ($update_stats) { |
|
315 | + $payment_amount = give_get_payment_amount($payment_id); |
|
316 | 316 | |
317 | - if ( ! empty( $payment_amount ) ) { |
|
318 | - $this->increase_value( $payment_amount ); |
|
317 | + if ( ! empty($payment_amount)) { |
|
318 | + $this->increase_value($payment_amount); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $this->increase_purchase_count(); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
326 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
327 | 327 | |
328 | 328 | return $payment_added; |
329 | 329 | } |
@@ -339,44 +339,44 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return boolean If the removal was successful |
341 | 341 | */ |
342 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
342 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
344 | + if (empty($payment_id)) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | 348 | $new_payment_ids = ''; |
349 | 349 | |
350 | - if ( ! empty( $this->payment_ids ) ) { |
|
350 | + if ( ! empty($this->payment_ids)) { |
|
351 | 351 | |
352 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
352 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
353 | 353 | |
354 | - $pos = array_search( $payment_id, $payment_ids ); |
|
355 | - if ( false === $pos ) { |
|
354 | + $pos = array_search($payment_id, $payment_ids); |
|
355 | + if (false === $pos) { |
|
356 | 356 | return false; |
357 | 357 | } |
358 | 358 | |
359 | - unset( $payment_ids[ $pos ] ); |
|
360 | - $payment_ids = array_filter( $payment_ids ); |
|
359 | + unset($payment_ids[$pos]); |
|
360 | + $payment_ids = array_filter($payment_ids); |
|
361 | 361 | |
362 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
362 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
363 | 363 | |
364 | 364 | } |
365 | 365 | |
366 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
366 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
367 | 367 | |
368 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
368 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
369 | 369 | |
370 | - if ( $payment_removed ) { |
|
370 | + if ($payment_removed) { |
|
371 | 371 | |
372 | 372 | $this->payment_ids = $new_payment_ids; |
373 | 373 | |
374 | - if ( $update_stats ) { |
|
374 | + if ($update_stats) { |
|
375 | 375 | // We removed this payment successfully, decrement the stats |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | |
378 | - if ( ! empty( $payment_amount ) ) { |
|
379 | - $this->decrease_value( $payment_amount ); |
|
378 | + if ( ! empty($payment_amount)) { |
|
379 | + $this->decrease_value($payment_amount); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | $this->decrease_purchase_count(); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | } |
386 | 386 | |
387 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
387 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
388 | 388 | |
389 | 389 | return $payment_removed; |
390 | 390 | |
@@ -399,22 +399,22 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return int The purchase count |
401 | 401 | */ |
402 | - public function increase_purchase_count( $count = 1 ) { |
|
402 | + public function increase_purchase_count($count = 1) { |
|
403 | 403 | |
404 | 404 | // Make sure it's numeric and not negative |
405 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
405 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
406 | 406 | return false; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $new_total = (int) $this->purchase_count + (int) $count; |
410 | 410 | |
411 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
411 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
412 | 412 | |
413 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
413 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
414 | 414 | $this->purchase_count = $new_total; |
415 | 415 | } |
416 | 416 | |
417 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
417 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
418 | 418 | |
419 | 419 | return $this->purchase_count; |
420 | 420 | } |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return mixed If successful, the new count, otherwise false |
430 | 430 | */ |
431 | - public function decrease_purchase_count( $count = 1 ) { |
|
431 | + public function decrease_purchase_count($count = 1) { |
|
432 | 432 | |
433 | 433 | // Make sure it's numeric and not negative |
434 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
434 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
435 | 435 | return false; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $new_total = (int) $this->purchase_count - (int) $count; |
439 | 439 | |
440 | - if ( $new_total < 0 ) { |
|
440 | + if ($new_total < 0) { |
|
441 | 441 | $new_total = 0; |
442 | 442 | } |
443 | 443 | |
444 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
444 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
445 | 445 | |
446 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
446 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
447 | 447 | $this->purchase_count = $new_total; |
448 | 448 | } |
449 | 449 | |
450 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
450 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
451 | 451 | |
452 | 452 | return $this->purchase_count; |
453 | 453 | } |
@@ -461,17 +461,17 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @return mixed If successful, the new value, otherwise false |
463 | 463 | */ |
464 | - public function increase_value( $value = 0.00 ) { |
|
464 | + public function increase_value($value = 0.00) { |
|
465 | 465 | |
466 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
466 | + $new_value = floatval($this->purchase_value) + $value; |
|
467 | 467 | |
468 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
468 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
469 | 469 | |
470 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
470 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
471 | 471 | $this->purchase_value = $new_value; |
472 | 472 | } |
473 | 473 | |
474 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
474 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
475 | 475 | |
476 | 476 | return $this->purchase_value; |
477 | 477 | } |
@@ -485,21 +485,21 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return mixed If successful, the new value, otherwise false |
487 | 487 | */ |
488 | - public function decrease_value( $value = 0.00 ) { |
|
488 | + public function decrease_value($value = 0.00) { |
|
489 | 489 | |
490 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
490 | + $new_value = floatval($this->purchase_value) - $value; |
|
491 | 491 | |
492 | - if ( $new_value < 0 ) { |
|
492 | + if ($new_value < 0) { |
|
493 | 493 | $new_value = 0.00; |
494 | 494 | } |
495 | 495 | |
496 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
496 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
497 | 497 | |
498 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
498 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
499 | 499 | $this->purchase_value = $new_value; |
500 | 500 | } |
501 | 501 | |
502 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
502 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
503 | 503 | |
504 | 504 | return $this->purchase_value; |
505 | 505 | } |
@@ -514,15 +514,15 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @return array The notes requsted |
516 | 516 | */ |
517 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
517 | + public function get_notes($length = 20, $paged = 1) { |
|
518 | 518 | |
519 | - $length = is_numeric( $length ) ? $length : 20; |
|
520 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
519 | + $length = is_numeric($length) ? $length : 20; |
|
520 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
521 | 521 | |
522 | 522 | $all_notes = $this->get_raw_notes(); |
523 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
523 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
524 | 524 | |
525 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
525 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
526 | 526 | |
527 | 527 | return $desired_notes; |
528 | 528 | |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | public function get_notes_count() { |
538 | 538 | |
539 | 539 | $all_notes = $this->get_raw_notes(); |
540 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
540 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
541 | 541 | |
542 | - return count( $notes_array ); |
|
542 | + return count($notes_array); |
|
543 | 543 | |
544 | 544 | } |
545 | 545 | |
@@ -552,32 +552,32 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return string|boolean The new note if added succesfully, false otherwise |
554 | 554 | */ |
555 | - public function add_note( $note = '' ) { |
|
555 | + public function add_note($note = '') { |
|
556 | 556 | |
557 | - $note = trim( $note ); |
|
558 | - if ( empty( $note ) ) { |
|
557 | + $note = trim($note); |
|
558 | + if (empty($note)) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
562 | 562 | $notes = $this->get_raw_notes(); |
563 | 563 | |
564 | - if ( empty( $notes ) ) { |
|
564 | + if (empty($notes)) { |
|
565 | 565 | $notes = ''; |
566 | 566 | } |
567 | 567 | |
568 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
569 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
570 | - $notes .= "\n\n" . $new_note; |
|
568 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
569 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
570 | + $notes .= "\n\n".$new_note; |
|
571 | 571 | |
572 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
572 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
573 | 573 | |
574 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
574 | + $updated = $this->update(array('notes' => $notes)); |
|
575 | 575 | |
576 | - if ( $updated ) { |
|
576 | + if ($updated) { |
|
577 | 577 | $this->notes = $this->get_notes(); |
578 | 578 | } |
579 | 579 | |
580 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
580 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
581 | 581 | |
582 | 582 | // Return the formatted note, so we can test, as well as update any displays |
583 | 583 | return $new_note; |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | private function get_raw_notes() { |
594 | 594 | |
595 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
595 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
596 | 596 | |
597 | 597 | return $all_notes; |
598 | 598 | |
@@ -607,51 +607,51 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return array The sanitized data, based off column defaults |
609 | 609 | */ |
610 | - private function sanitize_columns( $data ) { |
|
610 | + private function sanitize_columns($data) { |
|
611 | 611 | |
612 | 612 | $columns = $this->db->get_columns(); |
613 | 613 | $default_values = $this->db->get_column_defaults(); |
614 | 614 | |
615 | - foreach ( $columns as $key => $type ) { |
|
615 | + foreach ($columns as $key => $type) { |
|
616 | 616 | |
617 | 617 | // Only sanitize data that we were provided |
618 | - if ( ! array_key_exists( $key, $data ) ) { |
|
618 | + if ( ! array_key_exists($key, $data)) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | 621 | |
622 | - switch ( $type ) { |
|
622 | + switch ($type) { |
|
623 | 623 | |
624 | 624 | case '%s': |
625 | - if ( 'email' == $key ) { |
|
626 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
627 | - } elseif ( 'notes' == $key ) { |
|
628 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
625 | + if ('email' == $key) { |
|
626 | + $data[$key] = sanitize_email($data[$key]); |
|
627 | + } elseif ('notes' == $key) { |
|
628 | + $data[$key] = strip_tags($data[$key]); |
|
629 | 629 | } else { |
630 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
630 | + $data[$key] = sanitize_text_field($data[$key]); |
|
631 | 631 | } |
632 | 632 | break; |
633 | 633 | |
634 | 634 | case '%d': |
635 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
636 | - $data[ $key ] = $default_values[ $key ]; |
|
635 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
636 | + $data[$key] = $default_values[$key]; |
|
637 | 637 | } else { |
638 | - $data[ $key ] = absint( $data[ $key ] ); |
|
638 | + $data[$key] = absint($data[$key]); |
|
639 | 639 | } |
640 | 640 | break; |
641 | 641 | |
642 | 642 | case '%f': |
643 | 643 | // Convert what was given to a float |
644 | - $value = floatval( $data[ $key ] ); |
|
644 | + $value = floatval($data[$key]); |
|
645 | 645 | |
646 | - if ( ! is_float( $value ) ) { |
|
647 | - $data[ $key ] = $default_values[ $key ]; |
|
646 | + if ( ! is_float($value)) { |
|
647 | + $data[$key] = $default_values[$key]; |
|
648 | 648 | } else { |
649 | - $data[ $key ] = $value; |
|
649 | + $data[$key] = $value; |
|
650 | 650 | } |
651 | 651 | break; |
652 | 652 | |
653 | 653 | default: |
654 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
654 | + $data[$key] = sanitize_text_field($data[$key]); |
|
655 | 655 | break; |
656 | 656 | |
657 | 657 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Customer (Donor) Object |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Classes/Customer |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Customer (Donor) Object |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Classes/Customer |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
36 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
37 | 37 | $this->primary_key = 'id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'purchase_value' => 0.00, |
75 | 75 | 'purchase_count' => 0, |
76 | 76 | 'notes' => '', |
77 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
77 | + 'date_created' => date('Y-m-d H:i:s'), |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
@@ -84,40 +84,40 @@ discard block |
||
84 | 84 | * @access public |
85 | 85 | * @since 1.0 |
86 | 86 | */ |
87 | - public function add( $data = array() ) { |
|
87 | + public function add($data = array()) { |
|
88 | 88 | |
89 | 89 | $defaults = array( |
90 | 90 | 'payment_ids' => '' |
91 | 91 | ); |
92 | 92 | |
93 | - $args = wp_parse_args( $data, $defaults ); |
|
93 | + $args = wp_parse_args($data, $defaults); |
|
94 | 94 | |
95 | - if ( empty( $args['email'] ) ) { |
|
95 | + if (empty($args['email'])) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
100 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
99 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
100 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
101 | 101 | } |
102 | 102 | |
103 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
103 | + $customer = $this->get_customer_by('email', $args['email']); |
|
104 | 104 | |
105 | - if ( $customer ) { |
|
105 | + if ($customer) { |
|
106 | 106 | // update an existing customer |
107 | 107 | |
108 | 108 | // Update the payment IDs attached to the customer |
109 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
109 | + if ( ! empty($args['payment_ids'])) { |
|
110 | 110 | |
111 | - if ( empty( $customer->payment_ids ) ) { |
|
111 | + if (empty($customer->payment_ids)) { |
|
112 | 112 | |
113 | 113 | $customer->payment_ids = $args['payment_ids']; |
114 | 114 | |
115 | 115 | } else { |
116 | 116 | |
117 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
118 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
119 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
120 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
117 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
118 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
119 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
120 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - $this->update( $customer->id, $args ); |
|
128 | + $this->update($customer->id, $args); |
|
129 | 129 | |
130 | 130 | return $customer->id; |
131 | 131 | |
132 | 132 | } else { |
133 | 133 | |
134 | - return $this->insert( $args, 'customer' ); |
|
134 | + return $this->insert($args, 'customer'); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - public function delete( $_id_or_email = false ) { |
|
149 | + public function delete($_id_or_email = false) { |
|
150 | 150 | |
151 | - if ( empty( $_id_or_email ) ) { |
|
151 | + if (empty($_id_or_email)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
156 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
155 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
156 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
157 | 157 | |
158 | - if ( $customer->id > 0 ) { |
|
158 | + if ($customer->id > 0) { |
|
159 | 159 | |
160 | 160 | global $wpdb; |
161 | 161 | |
162 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
162 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
163 | 163 | |
164 | 164 | } else { |
165 | 165 | return false; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @access public |
174 | 174 | * @since 1.0 |
175 | 175 | */ |
176 | - public function exists( $email = '' ) { |
|
176 | + public function exists($email = '') { |
|
177 | 177 | |
178 | - return (bool) $this->get_column_by( 'id', 'email', $email ); |
|
178 | + return (bool) $this->get_column_by('id', 'email', $email); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | * @access public |
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
188 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
189 | 189 | |
190 | - $customer = new Give_Customer( $customer_id ); |
|
190 | + $customer = new Give_Customer($customer_id); |
|
191 | 191 | |
192 | - if ( empty( $customer->id ) ) { |
|
192 | + if (empty($customer->id)) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Attach the payment, but don't increment stats, as this function previously did not |
197 | - return $customer->attach_payment( $payment_id, false ); |
|
197 | + return $customer->attach_payment($payment_id, false); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | * @access public |
205 | 205 | * @since 1.0 |
206 | 206 | */ |
207 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
207 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
208 | 208 | |
209 | - $customer = new Give_Customer( $customer_id ); |
|
209 | + $customer = new Give_Customer($customer_id); |
|
210 | 210 | |
211 | - if ( ! $customer ) { |
|
211 | + if ( ! $customer) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | 215 | // Remove the payment, but don't decrease stats, as this function previously did not |
216 | - return $customer->remove_payment( $payment_id, false ); |
|
216 | + return $customer->remove_payment($payment_id, false); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -225,18 +225,18 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return bool |
227 | 227 | */ |
228 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
228 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
229 | 229 | |
230 | - $customer = new Give_Customer( $customer_id ); |
|
230 | + $customer = new Give_Customer($customer_id); |
|
231 | 231 | |
232 | - if ( empty( $customer->id ) ) { |
|
232 | + if (empty($customer->id)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | 236 | $increased_count = $customer->increase_purchase_count(); |
237 | - $increased_value = $customer->increase_value( $amount ); |
|
237 | + $increased_value = $customer->increase_value($amount); |
|
238 | 238 | |
239 | - return ( $increased_count && $increased_value ) ? true : false; |
|
239 | + return ($increased_count && $increased_value) ? true : false; |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | * @access public |
247 | 247 | * @since 1.0 |
248 | 248 | */ |
249 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
249 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
250 | 250 | |
251 | - $customer = new Give_Customer( $customer_id ); |
|
251 | + $customer = new Give_Customer($customer_id); |
|
252 | 252 | |
253 | - if ( ! $customer ) { |
|
253 | + if ( ! $customer) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
257 | 257 | $decreased_count = $customer->decrease_purchase_count(); |
258 | - $decreased_value = $customer->decrease_value( $amount ); |
|
258 | + $decreased_value = $customer->decrease_value($amount); |
|
259 | 259 | |
260 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
260 | + return ($decreased_count && $decreased_value) ? true : false; |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | |
@@ -272,45 +272,45 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
274 | 274 | */ |
275 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
275 | + public function get_customer_by($field = 'id', $value = 0) { |
|
276 | 276 | global $wpdb; |
277 | 277 | |
278 | - if ( empty( $field ) || empty( $value ) ) { |
|
278 | + if (empty($field) || empty($value)) { |
|
279 | 279 | return null; |
280 | 280 | } |
281 | 281 | |
282 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
282 | + if ('id' == $field || 'user_id' == $field) { |
|
283 | 283 | // Make sure the value is numeric to avoid casting objects, for example, |
284 | 284 | // to int 1. |
285 | - if ( ! is_numeric( $value ) ) { |
|
285 | + if ( ! is_numeric($value)) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | - $value = intval( $value ); |
|
289 | + $value = intval($value); |
|
290 | 290 | |
291 | - if ( $value < 1 ) { |
|
291 | + if ($value < 1) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - } elseif ( 'email' === $field ) { |
|
295 | + } elseif ('email' === $field) { |
|
296 | 296 | |
297 | - if ( ! is_email( $value ) ) { |
|
297 | + if ( ! is_email($value)) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | |
301 | - $value = trim( $value ); |
|
301 | + $value = trim($value); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( ! $value ) { |
|
304 | + if ( ! $value) { |
|
305 | 305 | return false; |
306 | 306 | } |
307 | 307 | |
308 | - switch ( $field ) { |
|
308 | + switch ($field) { |
|
309 | 309 | case 'id': |
310 | 310 | $db_field = 'id'; |
311 | 311 | break; |
312 | 312 | case 'email': |
313 | - $value = sanitize_text_field( $value ); |
|
313 | + $value = sanitize_text_field($value); |
|
314 | 314 | $db_field = 'email'; |
315 | 315 | break; |
316 | 316 | case 'user_id': |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
323 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @access public |
334 | 334 | * @since 1.0 |
335 | 335 | */ |
336 | - public function get_customers( $args = array() ) { |
|
336 | + public function get_customers($args = array()) { |
|
337 | 337 | |
338 | 338 | global $wpdb; |
339 | 339 | |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | 'order' => 'DESC' |
346 | 346 | ); |
347 | 347 | |
348 | - $args = wp_parse_args( $args, $defaults ); |
|
348 | + $args = wp_parse_args($args, $defaults); |
|
349 | 349 | |
350 | - if ( $args['number'] < 1 ) { |
|
350 | + if ($args['number'] < 1) { |
|
351 | 351 | $args['number'] = 999999999999; |
352 | 352 | } |
353 | 353 | |
354 | 354 | $where = ' WHERE 1=1 '; |
355 | 355 | |
356 | 356 | // specific customers |
357 | - if ( ! empty( $args['id'] ) ) { |
|
357 | + if ( ! empty($args['id'])) { |
|
358 | 358 | |
359 | - if ( is_array( $args['id'] ) ) { |
|
360 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
359 | + if (is_array($args['id'])) { |
|
360 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
361 | 361 | } else { |
362 | - $ids = intval( $args['id'] ); |
|
362 | + $ids = intval($args['id']); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | // customers for specific user accounts |
370 | - if ( ! empty( $args['user_id'] ) ) { |
|
370 | + if ( ! empty($args['user_id'])) { |
|
371 | 371 | |
372 | - if ( is_array( $args['user_id'] ) ) { |
|
373 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
372 | + if (is_array($args['user_id'])) { |
|
373 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
374 | 374 | } else { |
375 | - $user_ids = intval( $args['user_id'] ); |
|
375 | + $user_ids = intval($args['user_id']); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -380,15 +380,15 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | //specific customers by email |
383 | - if ( ! empty( $args['email'] ) ) { |
|
383 | + if ( ! empty($args['email'])) { |
|
384 | 384 | |
385 | - if ( is_array( $args['email'] ) ) { |
|
386 | - $emails = "'" . implode( "', '", $args['email'] ) . "'"; |
|
385 | + if (is_array($args['email'])) { |
|
386 | + $emails = "'".implode("', '", $args['email'])."'"; |
|
387 | 387 | } else { |
388 | - $emails = "'" . $args['email'] . "'"; |
|
388 | + $emails = "'".$args['email']."'"; |
|
389 | 389 | } |
390 | 390 | |
391 | - if ( ! empty( $where ) ) { |
|
391 | + if ( ! empty($where)) { |
|
392 | 392 | $where .= " AND `email` IN( {$emails} ) "; |
393 | 393 | } else { |
394 | 394 | $where .= "WHERE `email` IN( {$emails} ) "; |
@@ -397,31 +397,31 @@ discard block |
||
397 | 397 | } |
398 | 398 | |
399 | 399 | // specific customers by name |
400 | - if ( ! empty( $args['name'] ) ) { |
|
400 | + if ( ! empty($args['name'])) { |
|
401 | 401 | |
402 | - if ( ! empty( $where ) ) { |
|
403 | - $where .= " AND `name` LIKE '%%" . $args['name'] . "%%' "; |
|
402 | + if ( ! empty($where)) { |
|
403 | + $where .= " AND `name` LIKE '%%".$args['name']."%%' "; |
|
404 | 404 | } else { |
405 | - $where .= "WHERE `name` LIKE '%%" . $args['name'] . "%%' "; |
|
405 | + $where .= "WHERE `name` LIKE '%%".$args['name']."%%' "; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | 409 | // Customers created for a specific date or in a date range |
410 | - if ( ! empty( $args['date'] ) ) { |
|
410 | + if ( ! empty($args['date'])) { |
|
411 | 411 | |
412 | - if ( is_array( $args['date'] ) ) { |
|
412 | + if (is_array($args['date'])) { |
|
413 | 413 | |
414 | - if ( ! empty( $args['date']['start'] ) ) { |
|
414 | + if ( ! empty($args['date']['start'])) { |
|
415 | 415 | |
416 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
416 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
417 | 417 | |
418 | 418 | $where .= " AND `date_created` >= '{$start}'"; |
419 | 419 | |
420 | 420 | } |
421 | 421 | |
422 | - if ( ! empty( $args['date']['end'] ) ) { |
|
422 | + if ( ! empty($args['date']['end'])) { |
|
423 | 423 | |
424 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
424 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
425 | 425 | |
426 | 426 | $where .= " AND `date_created` <= '{$end}'"; |
427 | 427 | |
@@ -429,31 +429,31 @@ discard block |
||
429 | 429 | |
430 | 430 | } else { |
431 | 431 | |
432 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
433 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
434 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
432 | + $year = date('Y', strtotime($args['date'])); |
|
433 | + $month = date('m', strtotime($args['date'])); |
|
434 | + $day = date('d', strtotime($args['date'])); |
|
435 | 435 | |
436 | 436 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
437 | 437 | } |
438 | 438 | |
439 | 439 | } |
440 | 440 | |
441 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
441 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
442 | 442 | |
443 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
443 | + if ('purchase_value' == $args['orderby']) { |
|
444 | 444 | $args['orderby'] = 'purchase_value+0'; |
445 | 445 | } |
446 | 446 | |
447 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
447 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
448 | 448 | |
449 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
449 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
450 | 450 | |
451 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
452 | - $args['order'] = esc_sql( $args['order'] ); |
|
451 | + $args['orderby'] = esc_sql($args['orderby']); |
|
452 | + $args['order'] = esc_sql($args['order']); |
|
453 | 453 | |
454 | - if ( $customers === false ) { |
|
455 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
456 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
454 | + if ($customers === false) { |
|
455 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
456 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | return $customers; |
@@ -467,26 +467,26 @@ discard block |
||
467 | 467 | * @access public |
468 | 468 | * @since 1.0 |
469 | 469 | */ |
470 | - public function count( $args = array() ) { |
|
470 | + public function count($args = array()) { |
|
471 | 471 | |
472 | 472 | global $wpdb; |
473 | 473 | |
474 | 474 | $where = ' WHERE 1=1 '; |
475 | 475 | |
476 | - if ( ! empty( $args['date'] ) ) { |
|
476 | + if ( ! empty($args['date'])) { |
|
477 | 477 | |
478 | - if ( is_array( $args['date'] ) ) { |
|
478 | + if (is_array($args['date'])) { |
|
479 | 479 | |
480 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
481 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
480 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
481 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
482 | 482 | |
483 | 483 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
484 | 484 | |
485 | 485 | } else { |
486 | 486 | |
487 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
488 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
489 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
487 | + $year = date('Y', strtotime($args['date'])); |
|
488 | + $month = date('m', strtotime($args['date'])); |
|
489 | + $day = date('d', strtotime($args['date'])); |
|
490 | 490 | |
491 | 491 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
492 | 492 | } |
@@ -494,16 +494,16 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | |
497 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
497 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
498 | 498 | |
499 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
499 | + $count = wp_cache_get($cache_key, 'customers'); |
|
500 | 500 | |
501 | - if ( $count === false ) { |
|
502 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
503 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
501 | + if ($count === false) { |
|
502 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
503 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
504 | 504 | } |
505 | 505 | |
506 | - return absint( $count ); |
|
506 | + return absint($count); |
|
507 | 507 | |
508 | 508 | } |
509 | 509 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | |
518 | 518 | global $wpdb; |
519 | 519 | |
520 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
520 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
521 | 521 | |
522 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
522 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
523 | 523 | id bigint(20) NOT NULL AUTO_INCREMENT, |
524 | 524 | user_id bigint(20) NOT NULL, |
525 | 525 | email varchar(50) NOT NULL, |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | KEY user (user_id) |
535 | 535 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
536 | 536 | |
537 | - dbDelta( $sql ); |
|
537 | + dbDelta($sql); |
|
538 | 538 | |
539 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
539 | + update_option($this->table_name.'_db_version', $this->version); |
|
540 | 540 | } |
541 | 541 | } |
@@ -272,7 +272,7 @@ |
||
272 | 272 | * @since 1.0 |
273 | 273 | * |
274 | 274 | * @param string $field id or email |
275 | - * @param mixed $value The Customer ID or email to search |
|
275 | + * @param integer $value The Customer ID or email to search |
|
276 | 276 | * |
277 | 277 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
278 | 278 | */ |