@@ -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,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|bool Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array Variable prices |
67 | 67 | */ |
68 | -function give_get_variable_price_ids( $form_id = 0 ) { |
|
69 | - if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) { |
|
68 | +function give_get_variable_price_ids($form_id = 0) { |
|
69 | + if ( ! ($prices = give_get_variable_prices($form_id))) { |
|
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $price_ids = array(); |
74 | - foreach ( $prices as $price ){ |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | $price_ids[] = $price['_give_id']['level_id']; |
76 | 76 | } |
77 | 77 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string $default_price |
91 | 91 | */ |
92 | -function give_get_default_multilevel_amount( $form_id ) { |
|
92 | +function give_get_default_multilevel_amount($form_id) { |
|
93 | 93 | $default_price = '1.00'; |
94 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
94 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
95 | 95 | |
96 | - foreach ( $prices as $price ) { |
|
96 | + foreach ($prices as $price) { |
|
97 | 97 | |
98 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
98 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
99 | 99 | $default_price = $price['_give_amount']; |
100 | 100 | } |
101 | 101 | |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | * @return string $default_price |
117 | 117 | * @since 1.0 |
118 | 118 | */ |
119 | -function give_get_default_form_amount( $form_id ) { |
|
119 | +function give_get_default_form_amount($form_id) { |
|
120 | 120 | |
121 | - if ( give_has_variable_prices( $form_id ) ) { |
|
121 | + if (give_has_variable_prices($form_id)) { |
|
122 | 122 | |
123 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
123 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
124 | 124 | |
125 | 125 | } else { |
126 | 126 | |
127 | - $default_amount = give_get_meta( $form_id, '_give_set_price', true ); |
|
127 | + $default_amount = give_get_meta($form_id, '_give_set_price', true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_default_form_amount', $default_amount, $form_id ); |
|
131 | + return apply_filters('give_default_form_amount', $default_amount, $form_id); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
149 | +function give_is_custom_price_mode($form_id = 0) { |
|
150 | 150 | |
151 | - if ( empty( $form_id ) ) { |
|
151 | + if (empty($form_id)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $form = new Give_Donate_Form( $form_id ); |
|
155 | + $form = new Give_Donate_Form($form_id); |
|
156 | 156 | |
157 | 157 | return $form->is_custom_price_mode(); |
158 | 158 | } |
159 | 159 | \ 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 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /* @var WPDB $wpdb */ |
44 | 44 | global $wpdb; |
45 | 45 | |
46 | - $wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
46 | + $wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
47 | 47 | $this->primary_key = 'meta_id'; |
48 | 48 | $this->version = '1.0'; |
49 | 49 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
83 | 83 | */ |
84 | - public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) { |
|
85 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
86 | - if ( false === $donor_id ) { |
|
84 | + public function get_meta($donor_id = 0, $meta_key = '', $single = false) { |
|
85 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
86 | + if (false === $donor_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
90 | - return get_metadata( 'customer', $donor_id, $meta_key, $single ); |
|
90 | + return get_metadata('customer', $donor_id, $meta_key, $single); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return bool False for failure. True for success. |
107 | 107 | */ |
108 | - public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
109 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
110 | - if ( false === $donor_id ) { |
|
108 | + public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
109 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
110 | + if (false === $donor_id) { |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | |
114 | - return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
114 | + return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return bool False on failure, true if success. |
136 | 136 | */ |
137 | - public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
138 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
139 | - if ( false === $donor_id ) { |
|
137 | + public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
138 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
139 | + if (false === $donor_id) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
143 | + return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return bool False for failure. True for success. |
163 | 163 | */ |
164 | - public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) { |
|
165 | - return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value ); |
|
164 | + public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') { |
|
165 | + return delete_metadata('customer', $donor_id, $meta_key, $meta_value); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool False for failure. True for success. |
177 | 177 | */ |
178 | - public function delete_all_meta( $donor_id = 0 ) { |
|
178 | + public function delete_all_meta($donor_id = 0) { |
|
179 | 179 | global $wpdb; |
180 | - $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) ); |
|
180 | + $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d')); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function create_table() { |
192 | 192 | |
193 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
193 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
194 | 194 | |
195 | 195 | $sql = "CREATE TABLE {$this->table_name} ( |
196 | 196 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | KEY meta_key (meta_key) |
203 | 203 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
204 | 204 | |
205 | - dbDelta( $sql ); |
|
205 | + dbDelta($sql); |
|
206 | 206 | |
207 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
207 | + update_option($this->table_name.'_db_version', $this->version); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -217,23 +217,23 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return int|bool The normalized donor ID or false if it's found to not be valid. |
219 | 219 | */ |
220 | - private function sanitize_donor_id( $donor_id ) { |
|
221 | - if ( ! is_numeric( $donor_id ) ) { |
|
220 | + private function sanitize_donor_id($donor_id) { |
|
221 | + if ( ! is_numeric($donor_id)) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $donor_id = (int) $donor_id; |
226 | 226 | |
227 | 227 | // We were given a non positive number. |
228 | - if ( absint( $donor_id ) !== $donor_id ) { |
|
228 | + if (absint($donor_id) !== $donor_id) { |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | |
232 | - if ( empty( $donor_id ) ) { |
|
232 | + if (empty($donor_id)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - return absint( $donor_id ); |
|
236 | + return absint($donor_id); |
|
237 | 237 | |
238 | 238 | } |
239 | 239 |
@@ -288,8 +288,8 @@ |
||
288 | 288 | |
289 | 289 | // Check spam detect. |
290 | 290 | if ( isset( $_POST['action'] ) |
291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
292 | - && give_is_spam_donation() |
|
291 | + && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
292 | + && give_is_spam_donation() |
|
293 | 293 | ) { |
294 | 294 | give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
295 | 295 | } |
@@ -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 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data. |
36 | 36 | $valid_data = give_donation_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form. |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user. |
58 | - $user = give_get_donation_form_user( $valid_data ); |
|
58 | + $user = give_get_donation_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission. |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions. |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible. |
83 | 83 | // we're using a slightly modified class-wp-sessions.php. |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,21 +97,20 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? |
|
103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
104 | - '0.00'; |
|
105 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? |
|
103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
106 | 105 | |
107 | 106 | // Setup donation information. |
108 | 107 | $donation_data = array( |
109 | 108 | 'price' => $price, |
110 | 109 | 'purchase_key' => $purchase_key, |
111 | 110 | 'user_email' => $user['user_email'], |
112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
114 | - 'post_data' => give_clean( $_POST ), |
|
111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
112 | + 'user_info' => stripslashes_deep($user_info), |
|
113 | + 'post_data' => give_clean($_POST), |
|
115 | 114 | 'gateway' => $valid_data['gateway'], |
116 | 115 | 'card_info' => $valid_data['cc_info'], |
117 | 116 | ); |
@@ -130,10 +129,10 @@ discard block |
||
130 | 129 | * @param array $user_info Array containing basic user information. |
131 | 130 | * @param bool|array $valid_data Validate fields. |
132 | 131 | */ |
133 | - do_action( 'give_checkout_before_gateway', give_clean( $_POST ), $user_info, $valid_data ); |
|
132 | + do_action('give_checkout_before_gateway', give_clean($_POST), $user_info, $valid_data); |
|
134 | 133 | |
135 | 134 | // Sanity check for price. |
136 | - if ( ! $donation_data['price'] ) { |
|
135 | + if ( ! $donation_data['price']) { |
|
137 | 136 | // Revert to manual. |
138 | 137 | $donation_data['gateway'] = 'manual'; |
139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
144 | 143 | * |
145 | 144 | * @since 1.7 |
146 | 145 | */ |
147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
148 | 147 | |
149 | 148 | // Setup the data we're storing in the donation session. |
150 | 149 | $session_data = $donation_data; |
151 | 150 | |
152 | 151 | // Make sure credit card numbers are never stored in sessions. |
153 | - unset( $session_data['card_info']['card_number'] ); |
|
154 | - unset( $session_data['post_data']['card_number'] ); |
|
152 | + unset($session_data['card_info']['card_number']); |
|
153 | + unset($session_data['post_data']['card_number']); |
|
155 | 154 | |
156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
157 | - give_set_purchase_session( $session_data ); |
|
156 | + give_set_purchase_session($session_data); |
|
158 | 157 | |
159 | 158 | // Send info to the gateway for payment processing. |
160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
161 | 160 | give_die(); |
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
168 | 167 | |
169 | 168 | |
170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return void |
179 | 178 | */ |
180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
181 | 180 | |
182 | 181 | // Verify that the email address belongs to this customer. |
183 | - if ( is_user_logged_in() ) { |
|
182 | + if (is_user_logged_in()) { |
|
184 | 183 | |
185 | 184 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
187 | 186 | |
188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
189 | 188 | if ( |
190 | 189 | $submitted_email !== $donor->email |
191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
192 | 191 | ) { |
193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
192 | + $found_donor = new Give_Donor($submitted_email); |
|
194 | 193 | |
195 | - if ( $found_donor->id > 0 ) { |
|
196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
194 | + if ($found_donor->id > 0) { |
|
195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
197 | 196 | } |
198 | 197 | } |
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
203 | 202 | |
204 | 203 | /** |
205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
209 | 208 | * @return void |
210 | 209 | */ |
211 | 210 | function give_process_form_login() { |
212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
211 | + $is_ajax = isset($_POST['give_ajax']); |
|
213 | 212 | |
214 | 213 | $user_data = give_donation_form_validate_user_login(); |
215 | 214 | |
216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
217 | - if ( $is_ajax ) { |
|
215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
216 | + if ($is_ajax) { |
|
218 | 217 | /** |
219 | 218 | * Fires when AJAX sends back errors from the donation form. |
220 | 219 | * |
221 | 220 | * @since 1.0 |
222 | 221 | */ |
223 | 222 | ob_start(); |
224 | - do_action( 'give_ajax_donation_errors' ); |
|
223 | + do_action('give_ajax_donation_errors'); |
|
225 | 224 | $message = ob_get_contents(); |
226 | 225 | ob_end_clean(); |
227 | - wp_send_json_error( $message ); |
|
226 | + wp_send_json_error($message); |
|
228 | 227 | } else { |
229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
230 | 229 | exit; |
231 | 230 | } |
232 | 231 | } |
233 | 232 | |
234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
235 | 234 | |
236 | - if ( $is_ajax ) { |
|
235 | + if ($is_ajax) { |
|
237 | 236 | $message = Give()->notices->print_frontend_notice( |
238 | 237 | sprintf( |
239 | 238 | /* translators: %s: user first name */ |
240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
242 | 241 | ), |
243 | 242 | false, |
244 | 243 | 'success' |
245 | 244 | ); |
246 | 245 | |
247 | - wp_send_json_success( $message ); |
|
246 | + wp_send_json_success($message); |
|
248 | 247 | } else { |
249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
250 | 249 | } |
251 | 250 | } |
252 | 251 | |
253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
255 | 254 | |
256 | 255 | /** |
257 | 256 | * Donation Form Validate Fields. |
@@ -263,63 +262,63 @@ discard block |
||
263 | 262 | function give_donation_form_validate_fields() { |
264 | 263 | |
265 | 264 | // Check if there is $_POST. |
266 | - if ( empty( $_POST ) ) { |
|
265 | + if (empty($_POST)) { |
|
267 | 266 | return false; |
268 | 267 | } |
269 | 268 | |
270 | - $form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
269 | + $form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
271 | 270 | |
272 | 271 | // Start an array to collect valid data. |
273 | 272 | $valid_data = array( |
274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
275 | - 'need_new_user' => false, // New user flag. |
|
276 | - 'need_user_login' => false, // Login user flag. |
|
277 | - 'logged_user_data' => array(), // Logged user collected data. |
|
278 | - 'new_user_data' => array(), // New user collected data. |
|
279 | - 'login_user_data' => array(), // Login user collected data. |
|
280 | - 'guest_user_data' => array(), // Guest user collected data. |
|
281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info. |
|
274 | + 'need_new_user' => false, // New user flag. |
|
275 | + 'need_user_login' => false, // Login user flag. |
|
276 | + 'logged_user_data' => array(), // Logged user collected data. |
|
277 | + 'new_user_data' => array(), // New user collected data. |
|
278 | + 'login_user_data' => array(), // Login user collected data. |
|
279 | + 'guest_user_data' => array(), // Guest user collected data. |
|
280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
|
282 | 281 | ); |
283 | 282 | |
284 | 283 | // Validate Honeypot First. |
285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
287 | 286 | } |
288 | 287 | |
289 | 288 | // Check spam detect. |
290 | - if ( isset( $_POST['action'] ) |
|
291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
289 | + if (isset($_POST['action']) |
|
290 | + && give_is_setting_enabled(give_get_option('akismet_spam_protection')) |
|
292 | 291 | && give_is_spam_donation() |
293 | 292 | ) { |
294 | - give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
293 | + give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
295 | 294 | } |
296 | 295 | |
297 | 296 | // Validate agree to terms. |
298 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
297 | + if (give_is_terms_enabled($form_id)) { |
|
299 | 298 | give_donation_form_validate_agree_to_terms(); |
300 | 299 | } |
301 | 300 | |
302 | 301 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
303 | 302 | // If registration form username field is empty that means donor does want to registration instead wants guest checkout. |
304 | 303 | if ( |
305 | - ! give_logged_in_only( $form_id ) |
|
306 | - && isset( $_POST['give-purchase-var'] ) |
|
304 | + ! give_logged_in_only($form_id) |
|
305 | + && isset($_POST['give-purchase-var']) |
|
307 | 306 | && $_POST['give-purchase-var'] == 'needs-to-register' |
308 | - && empty( $_POST['give_user_login'] ) |
|
307 | + && empty($_POST['give_user_login']) |
|
309 | 308 | ) { |
310 | - unset( $_POST['give-purchase-var'] ); |
|
309 | + unset($_POST['give-purchase-var']); |
|
311 | 310 | } |
312 | 311 | |
313 | - if ( is_user_logged_in() ) { |
|
312 | + if (is_user_logged_in()) { |
|
314 | 313 | // Collect logged in user data. |
315 | 314 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
316 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
315 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
317 | 316 | // Set new user registration as required. |
318 | 317 | $valid_data['need_new_user'] = true; |
319 | 318 | // Validate new user data. |
320 | 319 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
321 | 320 | // Check if login validation is needed. |
322 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
321 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
323 | 322 | // Set user login as required. |
324 | 323 | $valid_data['need_user_login'] = true; |
325 | 324 | // Validate users login info. |
@@ -343,14 +342,14 @@ discard block |
||
343 | 342 | function give_is_spam_donation() { |
344 | 343 | $spam = false; |
345 | 344 | |
346 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
345 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
347 | 346 | |
348 | - if ( strlen( $user_agent ) < 2 ) { |
|
347 | + if (strlen($user_agent) < 2) { |
|
349 | 348 | $spam = true; |
350 | 349 | } |
351 | 350 | |
352 | 351 | // Allow developer to customized Akismet spam detect API call and it's response. |
353 | - return apply_filters( 'give_spam', $spam ); |
|
352 | + return apply_filters('give_spam', $spam); |
|
354 | 353 | } |
355 | 354 | |
356 | 355 | /** |
@@ -364,41 +363,41 @@ discard block |
||
364 | 363 | */ |
365 | 364 | function give_donation_form_validate_gateway() { |
366 | 365 | |
367 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
368 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
369 | - $gateway = give_get_default_gateway( $form_id ); |
|
366 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
367 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
368 | + $gateway = give_get_default_gateway($form_id); |
|
370 | 369 | |
371 | 370 | // Check if a gateway value is present. |
372 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
371 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
373 | 372 | |
374 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
373 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
375 | 374 | |
376 | 375 | // Is amount being donated in LIVE mode 0.00? If so, error: |
377 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
376 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
378 | 377 | |
379 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
378 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
380 | 379 | |
381 | 380 | } // End if(). |
382 | - elseif ( ! give_verify_minimum_price() ) { |
|
381 | + elseif ( ! give_verify_minimum_price()) { |
|
383 | 382 | // translators: %s: minimum donation amount. |
384 | 383 | give_set_error( |
385 | 384 | 'invalid_donation_minimum', |
386 | 385 | sprintf( |
387 | 386 | /* translators: %s: minimum donation amount */ |
388 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
389 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
387 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
388 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
390 | 389 | ) |
391 | 390 | ); |
392 | 391 | |
393 | 392 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
394 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
393 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
395 | 394 | |
396 | 395 | $gateway = 'manual'; |
397 | 396 | |
398 | 397 | } //Check if this gateway is active. |
399 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
398 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
400 | 399 | |
401 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
400 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
402 | 401 | |
403 | 402 | } |
404 | 403 | } |
@@ -416,21 +415,21 @@ discard block |
||
416 | 415 | */ |
417 | 416 | function give_verify_minimum_price() { |
418 | 417 | |
419 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
420 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
421 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
422 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
418 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
419 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
420 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
421 | + $variable_prices = give_has_variable_prices($form_id); |
|
423 | 422 | |
424 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
423 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
425 | 424 | |
426 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
425 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
427 | 426 | |
428 | - if ( $price_level_amount == $amount ) { |
|
427 | + if ($price_level_amount == $amount) { |
|
429 | 428 | return true; |
430 | 429 | } |
431 | 430 | } |
432 | 431 | |
433 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
432 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
434 | 433 | return false; |
435 | 434 | } |
436 | 435 | |
@@ -446,9 +445,9 @@ discard block |
||
446 | 445 | */ |
447 | 446 | function give_donation_form_validate_agree_to_terms() { |
448 | 447 | // Validate agree to terms. |
449 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
448 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
450 | 449 | // User did not agree. |
451 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
450 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
452 | 451 | } |
453 | 452 | } |
454 | 453 | |
@@ -462,59 +461,59 @@ discard block |
||
462 | 461 | * |
463 | 462 | * @return array |
464 | 463 | */ |
465 | -function give_get_required_fields( $form_id ) { |
|
464 | +function give_get_required_fields($form_id) { |
|
466 | 465 | |
467 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
466 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
468 | 467 | |
469 | 468 | $required_fields = array( |
470 | 469 | 'give_email' => array( |
471 | 470 | 'error_id' => 'invalid_email', |
472 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
471 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
473 | 472 | ), |
474 | 473 | 'give_first' => array( |
475 | 474 | 'error_id' => 'invalid_first_name', |
476 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
475 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
477 | 476 | ), |
478 | 477 | ); |
479 | 478 | |
480 | - $require_address = give_require_billing_address( $payment_mode ); |
|
479 | + $require_address = give_require_billing_address($payment_mode); |
|
481 | 480 | |
482 | - if ( $require_address ) { |
|
483 | - $required_fields['card_address'] = array( |
|
481 | + if ($require_address) { |
|
482 | + $required_fields['card_address'] = array( |
|
484 | 483 | 'error_id' => 'invalid_card_address', |
485 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
484 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
486 | 485 | ); |
487 | - $required_fields['card_zip'] = array( |
|
486 | + $required_fields['card_zip'] = array( |
|
488 | 487 | 'error_id' => 'invalid_zip_code', |
489 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
488 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
490 | 489 | ); |
491 | - $required_fields['card_city'] = array( |
|
490 | + $required_fields['card_city'] = array( |
|
492 | 491 | 'error_id' => 'invalid_city', |
493 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
492 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
494 | 493 | ); |
495 | 494 | $required_fields['billing_country'] = array( |
496 | 495 | 'error_id' => 'invalid_country', |
497 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
496 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
498 | 497 | ); |
499 | 498 | |
500 | 499 | |
501 | 500 | $required_fields['card_state'] = array( |
502 | 501 | 'error_id' => 'invalid_state', |
503 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
502 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
504 | 503 | ); |
505 | 504 | |
506 | 505 | // Check if billing country already exists. |
507 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
506 | + if ( ! empty($_POST['billing_country'])) { |
|
508 | 507 | // Get the value from $_POST. |
509 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
508 | + $country = sanitize_text_field($_POST['billing_country']); |
|
510 | 509 | |
511 | 510 | // Get the country list that does not required any states init. |
512 | 511 | $states_country = give_states_not_required_country_list(); |
513 | 512 | |
514 | 513 | // Check if states is empty or not. |
515 | - if ( array_key_exists( $country, $states_country ) ) { |
|
514 | + if (array_key_exists($country, $states_country)) { |
|
516 | 515 | // If states is empty remove the required feilds of state in billing cart. |
517 | - unset( $required_fields['card_state'] ); |
|
516 | + unset($required_fields['card_state']); |
|
518 | 517 | } |
519 | 518 | } |
520 | 519 | } |
@@ -524,7 +523,7 @@ discard block |
||
524 | 523 | * |
525 | 524 | * @since 1.7 |
526 | 525 | */ |
527 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
526 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
528 | 527 | |
529 | 528 | return $required_fields; |
530 | 529 | |
@@ -539,16 +538,16 @@ discard block |
||
539 | 538 | * |
540 | 539 | * @return bool |
541 | 540 | */ |
542 | -function give_require_billing_address( $payment_mode ) { |
|
541 | +function give_require_billing_address($payment_mode) { |
|
543 | 542 | |
544 | 543 | $return = false; |
545 | 544 | |
546 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
545 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
547 | 546 | $return = true; |
548 | 547 | } |
549 | 548 | |
550 | 549 | // Let payment gateways and other extensions determine if address fields should be required. |
551 | - return apply_filters( 'give_require_billing_address', $return ); |
|
550 | + return apply_filters('give_require_billing_address', $return); |
|
552 | 551 | |
553 | 552 | } |
554 | 553 | |
@@ -562,42 +561,42 @@ discard block |
||
562 | 561 | function give_donation_form_validate_logged_in_user() { |
563 | 562 | global $user_ID; |
564 | 563 | |
565 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
564 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
566 | 565 | |
567 | 566 | // Start empty array to collect valid user data. |
568 | 567 | $valid_user_data = array( |
569 | 568 | // Assume there will be errors. |
570 | - 'user_id' => - 1, |
|
569 | + 'user_id' => -1, |
|
571 | 570 | ); |
572 | 571 | |
573 | 572 | // Verify there is a user_ID. |
574 | - if ( $user_ID > 0 ) { |
|
573 | + if ($user_ID > 0) { |
|
575 | 574 | // Get the logged in user data. |
576 | - $user_data = get_userdata( $user_ID ); |
|
575 | + $user_data = get_userdata($user_ID); |
|
577 | 576 | |
578 | 577 | // Loop through required fields and show error messages. |
579 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
580 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
581 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
578 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
579 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
580 | + give_set_error($value['error_id'], $value['error_message']); |
|
582 | 581 | } |
583 | 582 | } |
584 | 583 | |
585 | 584 | // Verify data. |
586 | - if ( $user_data ) { |
|
585 | + if ($user_data) { |
|
587 | 586 | // Collected logged in user data. |
588 | 587 | $valid_user_data = array( |
589 | 588 | 'user_id' => $user_ID, |
590 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
591 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
592 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
589 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
590 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
591 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
593 | 592 | ); |
594 | 593 | |
595 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
596 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
594 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
595 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
597 | 596 | } |
598 | 597 | } else { |
599 | 598 | // Set invalid user error. |
600 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
599 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
601 | 600 | } |
602 | 601 | } |
603 | 602 | |
@@ -616,7 +615,7 @@ discard block |
||
616 | 615 | // Default user data. |
617 | 616 | $default_user_data = array( |
618 | 617 | 'give-form-id' => '', |
619 | - 'user_id' => - 1, // Assume there will be errors. |
|
618 | + 'user_id' => -1, // Assume there will be errors. |
|
620 | 619 | 'user_first' => '', |
621 | 620 | 'user_last' => '', |
622 | 621 | 'give_user_login' => false, |
@@ -626,14 +625,14 @@ discard block |
||
626 | 625 | ); |
627 | 626 | |
628 | 627 | // Get user data. |
629 | - $user_data = wp_parse_args( give_clean( $_POST ), $default_user_data ); |
|
628 | + $user_data = wp_parse_args(give_clean($_POST), $default_user_data); |
|
630 | 629 | $registering_new_user = false; |
631 | - $form_id = absint( $user_data['give-form-id'] ); |
|
630 | + $form_id = absint($user_data['give-form-id']); |
|
632 | 631 | |
633 | 632 | // Start an empty array to collect valid user data. |
634 | 633 | $valid_user_data = array( |
635 | 634 | // Assume there will be errors. |
636 | - 'user_id' => - 1, |
|
635 | + 'user_id' => -1, |
|
637 | 636 | |
638 | 637 | // Get first name. |
639 | 638 | 'user_first' => $user_data['give_first'], |
@@ -643,25 +642,25 @@ discard block |
||
643 | 642 | ); |
644 | 643 | |
645 | 644 | // Loop through required fields and show error messages. |
646 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
647 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
648 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
645 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
646 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
647 | + give_set_error($value['error_id'], $value['error_message']); |
|
649 | 648 | } |
650 | 649 | } |
651 | 650 | |
652 | 651 | // Check if we have an username to register. |
653 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
652 | + if (give_validate_username($user_data['give_user_login'])) { |
|
654 | 653 | $registering_new_user = true; |
655 | 654 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
656 | 655 | } |
657 | 656 | |
658 | 657 | // Check if we have an email to verify. |
659 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
658 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
660 | 659 | $valid_user_data['user_email'] = $user_data['give_email']; |
661 | 660 | } |
662 | 661 | |
663 | 662 | // Check password. |
664 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
663 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
665 | 664 | // All is good to go. |
666 | 665 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
667 | 666 | } |
@@ -681,36 +680,36 @@ discard block |
||
681 | 680 | // Start an array to collect valid user data. |
682 | 681 | $valid_user_data = array( |
683 | 682 | // Assume there will be errors. |
684 | - 'user_id' => - 1, |
|
683 | + 'user_id' => -1, |
|
685 | 684 | ); |
686 | 685 | |
687 | 686 | // Username. |
688 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
689 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
687 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
688 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
690 | 689 | |
691 | 690 | return $valid_user_data; |
692 | 691 | } |
693 | 692 | |
694 | 693 | // Get the user by login. |
695 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
694 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
696 | 695 | |
697 | 696 | // Check if user exists. |
698 | - if ( $user_data ) { |
|
697 | + if ($user_data) { |
|
699 | 698 | // Get password. |
700 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
699 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
701 | 700 | |
702 | 701 | // Check user_pass. |
703 | - if ( $user_pass ) { |
|
702 | + if ($user_pass) { |
|
704 | 703 | // Check if password is valid. |
705 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
704 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
706 | 705 | // Incorrect password. |
707 | 706 | give_set_error( |
708 | 707 | 'password_incorrect', |
709 | 708 | sprintf( |
710 | 709 | '%1$s <a href="%2$s">%3$s</a>', |
711 | - __( 'The password you entered is incorrect.', 'give' ), |
|
712 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
713 | - __( 'Reset Password', 'give' ) |
|
710 | + __('The password you entered is incorrect.', 'give'), |
|
711 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
712 | + __('Reset Password', 'give') |
|
714 | 713 | ) |
715 | 714 | ); |
716 | 715 | // All is correct. |
@@ -728,11 +727,11 @@ discard block |
||
728 | 727 | } |
729 | 728 | } else { |
730 | 729 | // Empty password. |
731 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
730 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
732 | 731 | } |
733 | 732 | } else { |
734 | 733 | // No username. |
735 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
734 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
736 | 735 | }// End if(). |
737 | 736 | |
738 | 737 | return $valid_user_data; |
@@ -747,7 +746,7 @@ discard block |
||
747 | 746 | */ |
748 | 747 | function give_donation_form_validate_guest_user() { |
749 | 748 | |
750 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
749 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
751 | 750 | |
752 | 751 | // Start an array to collect valid user data. |
753 | 752 | $valid_user_data = array( |
@@ -756,38 +755,38 @@ discard block |
||
756 | 755 | ); |
757 | 756 | |
758 | 757 | // Show error message if user must be logged in. |
759 | - if ( give_logged_in_only( $form_id ) ) { |
|
760 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
758 | + if (give_logged_in_only($form_id)) { |
|
759 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
761 | 760 | } |
762 | 761 | |
763 | 762 | // Get the guest email. |
764 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
763 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
765 | 764 | |
766 | 765 | // Check email. |
767 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
766 | + if ($guest_email && strlen($guest_email) > 0) { |
|
768 | 767 | // Validate email. |
769 | - if ( ! is_email( $guest_email ) ) { |
|
768 | + if ( ! is_email($guest_email)) { |
|
770 | 769 | // Invalid email. |
771 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
770 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
772 | 771 | } else { |
773 | 772 | // All is good to go. |
774 | 773 | $valid_user_data['user_email'] = $guest_email; |
775 | 774 | |
776 | 775 | // Get user_id from donor if exist. |
777 | - $donor = new Give_Donor( $guest_email ); |
|
778 | - if ( $donor->id && $donor->user_id ) { |
|
776 | + $donor = new Give_Donor($guest_email); |
|
777 | + if ($donor->id && $donor->user_id) { |
|
779 | 778 | $valid_user_data['user_id'] = $donor->user_id; |
780 | 779 | } |
781 | 780 | } |
782 | 781 | } else { |
783 | 782 | // No email. |
784 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
783 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
785 | 784 | } |
786 | 785 | |
787 | 786 | // Loop through required fields and show error messages. |
788 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
789 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
790 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
787 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
788 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
789 | + give_set_error($value['error_id'], $value['error_message']); |
|
791 | 790 | } |
792 | 791 | } |
793 | 792 | |
@@ -803,36 +802,36 @@ discard block |
||
803 | 802 | * @since 1.0 |
804 | 803 | * @return integer |
805 | 804 | */ |
806 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
805 | +function give_register_and_login_new_user($user_data = array()) { |
|
807 | 806 | // Verify the array. |
808 | - if ( empty( $user_data ) ) { |
|
809 | - return - 1; |
|
807 | + if (empty($user_data)) { |
|
808 | + return -1; |
|
810 | 809 | } |
811 | 810 | |
812 | - if ( give_get_errors() ) { |
|
813 | - return - 1; |
|
811 | + if (give_get_errors()) { |
|
812 | + return -1; |
|
814 | 813 | } |
815 | 814 | |
816 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
817 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
818 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
819 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
820 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
821 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
822 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
823 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
824 | - ), $user_data ); |
|
815 | + $user_args = apply_filters('give_insert_user_args', array( |
|
816 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
817 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
818 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
819 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
820 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
821 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
822 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
823 | + ), $user_data); |
|
825 | 824 | |
826 | 825 | // Insert new user. |
827 | - $user_id = wp_insert_user( $user_args ); |
|
826 | + $user_id = wp_insert_user($user_args); |
|
828 | 827 | |
829 | 828 | // Validate inserted user. |
830 | - if ( is_wp_error( $user_id ) ) { |
|
831 | - return - 1; |
|
829 | + if (is_wp_error($user_id)) { |
|
830 | + return -1; |
|
832 | 831 | } |
833 | 832 | |
834 | 833 | // Allow themes and plugins to filter the user data. |
835 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
834 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
836 | 835 | |
837 | 836 | /** |
838 | 837 | * Fires after inserting user. |
@@ -842,7 +841,7 @@ discard block |
||
842 | 841 | * @param int $user_id User id. |
843 | 842 | * @param array $user_data Array containing user data. |
844 | 843 | */ |
845 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
844 | + do_action('give_insert_user', $user_id, $user_data); |
|
846 | 845 | |
847 | 846 | /** |
848 | 847 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -851,9 +850,9 @@ discard block |
||
851 | 850 | * |
852 | 851 | * return bool True if login with registration and False if only want to register. |
853 | 852 | */ |
854 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
853 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
855 | 854 | // Login new user. |
856 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
855 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
857 | 856 | } |
858 | 857 | |
859 | 858 | // Return user id. |
@@ -869,27 +868,27 @@ discard block |
||
869 | 868 | * @since 1.0 |
870 | 869 | * @return array|bool |
871 | 870 | */ |
872 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
871 | +function give_get_donation_form_user($valid_data = array()) { |
|
873 | 872 | |
874 | 873 | // Initialize user. |
875 | 874 | $user = false; |
876 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
875 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
877 | 876 | |
878 | - if ( $is_ajax ) { |
|
877 | + if ($is_ajax) { |
|
879 | 878 | // Do not create or login the user during the ajax submission (check for errors only). |
880 | 879 | return true; |
881 | - } elseif ( is_user_logged_in() ) { |
|
880 | + } elseif (is_user_logged_in()) { |
|
882 | 881 | // Set the valid user as the logged in collected data. |
883 | 882 | $user = $valid_data['logged_in_user']; |
884 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
883 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
885 | 884 | // New user registration. |
886 | - if ( $valid_data['need_new_user'] === true ) { |
|
885 | + if ($valid_data['need_new_user'] === true) { |
|
887 | 886 | // Set user. |
888 | 887 | $user = $valid_data['new_user_data']; |
889 | 888 | // Register and login new user. |
890 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
889 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
891 | 890 | // User login |
892 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
891 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
893 | 892 | |
894 | 893 | /** |
895 | 894 | * The login form is now processed in the give_process_donation_login() function. |
@@ -901,48 +900,48 @@ discard block |
||
901 | 900 | // Set user. |
902 | 901 | $user = $valid_data['login_user_data']; |
903 | 902 | // Login user. |
904 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
903 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
905 | 904 | } |
906 | 905 | } |
907 | 906 | |
908 | 907 | // Check guest checkout. |
909 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
908 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
910 | 909 | // Set user |
911 | 910 | $user = $valid_data['guest_user_data']; |
912 | 911 | } |
913 | 912 | |
914 | 913 | // Verify we have an user. |
915 | - if ( false === $user || empty( $user ) ) { |
|
914 | + if (false === $user || empty($user)) { |
|
916 | 915 | // Return false. |
917 | 916 | return false; |
918 | 917 | } |
919 | 918 | |
920 | 919 | // Get user first name. |
921 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
922 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
920 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
921 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
923 | 922 | } |
924 | 923 | |
925 | 924 | // Get user last name. |
926 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
927 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
925 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
926 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
928 | 927 | } |
929 | 928 | |
930 | 929 | // Get the user's billing address details. |
931 | 930 | $user['address'] = array(); |
932 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
933 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
934 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
935 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
936 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
937 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
938 | - |
|
939 | - if ( empty( $user['address']['country'] ) ) { |
|
931 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
932 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
933 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
934 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
935 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
936 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
937 | + |
|
938 | + if (empty($user['address']['country'])) { |
|
940 | 939 | $user['address'] = false; |
941 | 940 | } // End if(). |
942 | 941 | |
943 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
942 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
944 | 943 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
945 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
944 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
946 | 945 | } |
947 | 946 | |
948 | 947 | // Return valid user. |
@@ -961,16 +960,16 @@ discard block |
||
961 | 960 | $card_data = give_get_donation_cc_info(); |
962 | 961 | |
963 | 962 | // Validate the card zip. |
964 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
965 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
966 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
963 | + if ( ! empty($card_data['card_zip'])) { |
|
964 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
965 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
967 | 966 | } |
968 | 967 | } |
969 | 968 | |
970 | 969 | // Ensure no spaces. |
971 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
972 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
973 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
970 | + if ( ! empty($card_data['card_number'])) { |
|
971 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
972 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
974 | 973 | } |
975 | 974 | |
976 | 975 | // This should validate card numbers at some point too. |
@@ -987,17 +986,17 @@ discard block |
||
987 | 986 | function give_get_donation_cc_info() { |
988 | 987 | |
989 | 988 | $cc_info = array(); |
990 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
991 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
992 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
993 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
994 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
995 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
996 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
997 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
998 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
999 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
1000 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
989 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
990 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
991 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
992 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
993 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
994 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
995 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
996 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
997 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
998 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
999 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
1001 | 1000 | |
1002 | 1001 | // Return cc info. |
1003 | 1002 | return $cc_info; |
@@ -1013,14 +1012,14 @@ discard block |
||
1013 | 1012 | * |
1014 | 1013 | * @return bool|mixed |
1015 | 1014 | */ |
1016 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
1015 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
1017 | 1016 | $ret = false; |
1018 | 1017 | |
1019 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
1018 | + if (empty($zip) || empty($country_code)) { |
|
1020 | 1019 | return $ret; |
1021 | 1020 | } |
1022 | 1021 | |
1023 | - $country_code = strtoupper( $country_code ); |
|
1022 | + $country_code = strtoupper($country_code); |
|
1024 | 1023 | |
1025 | 1024 | $zip_regex = array( |
1026 | 1025 | 'AD' => 'AD\d{3}', |
@@ -1180,11 +1179,11 @@ discard block |
||
1180 | 1179 | 'ZM' => '\d{5}', |
1181 | 1180 | ); |
1182 | 1181 | |
1183 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1182 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1184 | 1183 | $ret = true; |
1185 | 1184 | } |
1186 | 1185 | |
1187 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1186 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1188 | 1187 | } |
1189 | 1188 | |
1190 | 1189 | |
@@ -1198,47 +1197,47 @@ discard block |
||
1198 | 1197 | * |
1199 | 1198 | * @return bool |
1200 | 1199 | */ |
1201 | -function give_validate_donation_amount( $valid_data, $data ) { |
|
1200 | +function give_validate_donation_amount($valid_data, $data) { |
|
1202 | 1201 | /* @var Give_Donate_Form $form */ |
1203 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1202 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1204 | 1203 | |
1205 | 1204 | $donation_level_matched = false; |
1206 | 1205 | |
1207 | - if ( $form->is_set_type_donation_form() ) { |
|
1206 | + if ($form->is_set_type_donation_form()) { |
|
1208 | 1207 | // Sanitize donation amount. |
1209 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1208 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1210 | 1209 | |
1211 | 1210 | // Backward compatibility. |
1212 | - if ( $form->is_custom_price( $data['give-amount'] ) ) { |
|
1211 | + if ($form->is_custom_price($data['give-amount'])) { |
|
1213 | 1212 | $_POST['give-price-id'] = 'custom'; |
1214 | 1213 | } |
1215 | 1214 | |
1216 | 1215 | $donation_level_matched = true; |
1217 | 1216 | |
1218 | - } elseif ( $form->is_multi_type_donation_form() ) { |
|
1217 | + } elseif ($form->is_multi_type_donation_form()) { |
|
1219 | 1218 | |
1220 | 1219 | // Bailout. |
1221 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1220 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1222 | 1221 | return false; |
1223 | 1222 | } |
1224 | 1223 | |
1225 | 1224 | // Sanitize donation amount. |
1226 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1225 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1227 | 1226 | |
1228 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1227 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1229 | 1228 | return true; |
1230 | 1229 | } |
1231 | 1230 | |
1232 | - if ( $form->is_custom_price( $data['give-amount'] ) ) { |
|
1231 | + if ($form->is_custom_price($data['give-amount'])) { |
|
1233 | 1232 | $_POST['give-price-id'] = 'custom'; |
1234 | 1233 | } else { |
1235 | 1234 | // Find correct donation level from all donation levels. |
1236 | - foreach ( $variable_prices as $variable_price ) { |
|
1235 | + foreach ($variable_prices as $variable_price) { |
|
1237 | 1236 | // Sanitize level amount. |
1238 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1237 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1239 | 1238 | |
1240 | 1239 | // Set first match donation level ID. |
1241 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1240 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1242 | 1241 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1243 | 1242 | break; |
1244 | 1243 | } |
@@ -1247,12 +1246,12 @@ discard block |
||
1247 | 1246 | |
1248 | 1247 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
1249 | 1248 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1250 | - if ( ! empty( $_POST['give-price-id'] ) ) { |
|
1249 | + if ( ! empty($_POST['give-price-id'])) { |
|
1251 | 1250 | $donation_level_matched = true; |
1252 | 1251 | } |
1253 | 1252 | }// End if(). |
1254 | 1253 | |
1255 | - return ( $donation_level_matched ? true : false ); |
|
1254 | + return ($donation_level_matched ? true : false); |
|
1256 | 1255 | } |
1257 | 1256 | |
1258 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 2 ); |
|
1257 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 2); |
@@ -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,11 +26,11 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | |
31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
31 | + $payment_data = give_get_payment_meta($payment_id); |
|
32 | 32 | |
33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Filters the from name. |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.0 |
42 | 42 | */ |
43 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
43 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
44 | 44 | |
45 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
45 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Filters the from email. |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @since 1.0 |
54 | 54 | */ |
55 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
55 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
56 | 56 | |
57 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
57 | + $to_email = give_get_payment_user_email($payment_id); |
|
58 | 58 | |
59 | - $subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) ); |
|
59 | + $subject = give_get_option('donation_subject', __('Donation Receipt', 'give')); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Filters the donation email receipt subject. |
63 | 63 | * |
64 | 64 | * @since 1.0 |
65 | 65 | */ |
66 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
67 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
66 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
67 | + $subject = give_do_email_tags($subject, $payment_id); |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt. |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @since 1.0 |
76 | 76 | */ |
77 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
78 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
77 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
78 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
79 | 79 | |
80 | 80 | $emails = Give()->emails; |
81 | 81 | |
82 | - $emails->__set( 'from_name', $from_name ); |
|
83 | - $emails->__set( 'from_email', $from_email ); |
|
84 | - $emails->__set( 'heading', __( 'Donation Receipt', 'give' ) ); |
|
82 | + $emails->__set('from_name', $from_name); |
|
83 | + $emails->__set('from_email', $from_email); |
|
84 | + $emails->__set('heading', __('Donation Receipt', 'give')); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Filters the donation receipt's email headers. |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @since 1.0 |
93 | 93 | */ |
94 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
95 | - $emails->__set( 'headers', $headers ); |
|
94 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
95 | + $emails->__set('headers', $headers); |
|
96 | 96 | |
97 | 97 | //Send the donation receipt. |
98 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
98 | + $emails->send($to_email, $subject, $message, $attachments); |
|
99 | 99 | |
100 | 100 | //If admin notifications are on, send the admin notice. |
101 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
101 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
102 | 102 | /** |
103 | 103 | * Fires in the donation email receipt. |
104 | 104 | * |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param int $payment_id Payment id. |
110 | 110 | * @param mixed $payment_data Payment meta data. |
111 | 111 | */ |
112 | - do_action( 'give_admin_donation_email', $payment_id, $payment_data ); |
|
112 | + do_action('give_admin_donation_email', $payment_id, $payment_data); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -122,41 +122,41 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function give_email_test_donation_receipt() { |
124 | 124 | |
125 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
125 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Filters the from name. |
129 | 129 | * |
130 | 130 | * @since 1.7 |
131 | 131 | */ |
132 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() ); |
|
132 | + $from_name = apply_filters('give_donation_from_name', $from_name, 0, array()); |
|
133 | 133 | |
134 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
134 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Filters the from email. |
138 | 138 | * |
139 | 139 | * @since 1.7 |
140 | 140 | */ |
141 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() ); |
|
141 | + $from_email = apply_filters('give_donation_from_address', $from_email, 0, array()); |
|
142 | 142 | |
143 | - $subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) ); |
|
144 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
145 | - $subject = give_do_email_tags( $subject, 0 ); |
|
143 | + $subject = give_get_option('donation_subject', __('Donation Receipt', 'give')); |
|
144 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
145 | + $subject = give_do_email_tags($subject, 0); |
|
146 | 146 | |
147 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
147 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
148 | 148 | |
149 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
149 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
150 | 150 | |
151 | 151 | $emails = Give()->emails; |
152 | - $emails->__set( 'from_name', $from_name ); |
|
153 | - $emails->__set( 'from_email', $from_email ); |
|
154 | - $emails->__set( 'heading', __( 'Donation Receipt', 'give' ) ); |
|
152 | + $emails->__set('from_name', $from_name); |
|
153 | + $emails->__set('from_email', $from_email); |
|
154 | + $emails->__set('heading', __('Donation Receipt', 'give')); |
|
155 | 155 | |
156 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
157 | - $emails->__set( 'headers', $headers ); |
|
156 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
157 | + $emails->__set('headers', $headers); |
|
158 | 158 | |
159 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
159 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
@@ -170,49 +170,49 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return void |
172 | 172 | */ |
173 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
173 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
174 | 174 | |
175 | - $payment_id = absint( $payment_id ); |
|
175 | + $payment_id = absint($payment_id); |
|
176 | 176 | |
177 | - if ( empty( $payment_id ) ) { |
|
177 | + if (empty($payment_id)) { |
|
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
181 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
181 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
185 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Filters the from name. |
189 | 189 | * |
190 | 190 | * @since 1.0 |
191 | 191 | */ |
192 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
192 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
193 | 193 | |
194 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
194 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Filters the from email. |
198 | 198 | * |
199 | 199 | * @since 1.0 |
200 | 200 | */ |
201 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
201 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
202 | 202 | |
203 | 203 | /* translators: %s: payment id */ |
204 | - $subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) ); |
|
204 | + $subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id)); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Filters the donation notification subject. |
208 | 208 | * |
209 | 209 | * @since 1.0 |
210 | 210 | */ |
211 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
212 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
211 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
212 | + $subject = give_do_email_tags($subject, $payment_id); |
|
213 | 213 | |
214 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
215 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
214 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
215 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
216 | 216 | //$headers .= "MIME-Version: 1.0\r\n"; |
217 | 217 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
218 | 218 | |
@@ -221,28 +221,28 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @since 1.0 |
223 | 223 | */ |
224 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
224 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple. |
228 | 228 | * |
229 | 229 | * @since 1.0 |
230 | 230 | */ |
231 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
231 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
232 | 232 | |
233 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
233 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
234 | 234 | |
235 | 235 | $emails = Give()->emails; |
236 | - $emails->__set( 'from_name', $from_name ); |
|
237 | - $emails->__set( 'from_email', $from_email ); |
|
238 | - $emails->__set( 'headers', $headers ); |
|
239 | - $emails->__set( 'heading', __( 'New Donation!', 'give' ) ); |
|
236 | + $emails->__set('from_name', $from_name); |
|
237 | + $emails->__set('from_email', $from_email); |
|
238 | + $emails->__set('headers', $headers); |
|
239 | + $emails->__set('heading', __('New Donation!', 'give')); |
|
240 | 240 | |
241 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
241 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
245 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 ); |
|
245 | +add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2); |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings). |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | */ |
253 | 253 | function give_get_admin_notice_emails() { |
254 | 254 | |
255 | - $email_option = give_get_option( 'admin_notice_emails' ); |
|
255 | + $email_option = give_get_option('admin_notice_emails'); |
|
256 | 256 | |
257 | - $emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' ); |
|
258 | - $emails = give_clean( explode( "\n", $emails ) ); |
|
257 | + $emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email'); |
|
258 | + $emails = give_clean(explode("\n", $emails)); |
|
259 | 259 | |
260 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
260 | + return apply_filters('give_admin_notice_emails', $emails); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
272 | +function give_admin_notices_disabled($payment_id = 0) { |
|
273 | 273 | |
274 | 274 | return apply_filters( |
275 | 275 | 'give_admin_notices_disabled', |
276 | - ! give_is_setting_enabled( give_get_option( 'admin_notices' ) ), |
|
276 | + ! give_is_setting_enabled(give_get_option('admin_notices')), |
|
277 | 277 | $payment_id |
278 | 278 | ); |
279 | 279 | } |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | */ |
289 | 289 | function give_get_default_donation_notification_email() { |
290 | 290 | |
291 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
292 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
293 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
294 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
295 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
296 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
297 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
298 | - $default_email_body .= '{sitename}' . "\n"; |
|
291 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
292 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
293 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
294 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
295 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
296 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
297 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
298 | + $default_email_body .= '{sitename}'."\n"; |
|
299 | 299 | |
300 | - $custom_message = give_get_option( 'donation_notification' ); |
|
301 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
300 | + $custom_message = give_get_option('donation_notification'); |
|
301 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
302 | 302 | |
303 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
303 | + return apply_filters('give_default_donation_notification_email', $message); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -314,25 +314,25 @@ discard block |
||
314 | 314 | */ |
315 | 315 | function give_get_default_donation_receipt_email() { |
316 | 316 | |
317 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
318 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
319 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
320 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
321 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
322 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
323 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
324 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
325 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
326 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
317 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
318 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
319 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
320 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
321 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
322 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
323 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
324 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
325 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
326 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
327 | 327 | $default_email_body .= "\n\n"; |
328 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
329 | - $default_email_body .= '{sitename}' . "\n"; |
|
328 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
329 | + $default_email_body .= '{sitename}'."\n"; |
|
330 | 330 | |
331 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
331 | + $custom_message = give_get_option('donation_receipt'); |
|
332 | 332 | |
333 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
333 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
334 | 334 | |
335 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
335 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -345,22 +345,22 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return array $email_names |
347 | 347 | */ |
348 | -function give_get_email_names( $user_info, $payment = false ) { |
|
348 | +function give_get_email_names($user_info, $payment = false) { |
|
349 | 349 | $email_names = array(); |
350 | 350 | |
351 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
351 | + if (is_a($payment, 'Give_Payment')) { |
|
352 | 352 | |
353 | - if ( $payment->user_id > 0 ) { |
|
353 | + if ($payment->user_id > 0) { |
|
354 | 354 | |
355 | - $user_data = get_userdata( $payment->user_id ); |
|
355 | + $user_data = get_userdata($payment->user_id); |
|
356 | 356 | $email_names['name'] = $payment->first_name; |
357 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
357 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
358 | 358 | $email_names['username'] = $user_data->user_login; |
359 | 359 | |
360 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
360 | + } elseif ( ! empty($payment->first_name)) { |
|
361 | 361 | |
362 | 362 | $email_names['name'] = $payment->first_name; |
363 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
363 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
364 | 364 | $email_names['username'] = $payment->first_name; |
365 | 365 | |
366 | 366 | } else { |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | } else { |
374 | 374 | |
375 | 375 | // Support for old serialized data. |
376 | - if ( is_serialized( $user_info ) ) { |
|
376 | + if (is_serialized($user_info)) { |
|
377 | 377 | |
378 | 378 | // Security check. |
379 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
380 | - if ( ! empty( $matches ) ) { |
|
379 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
380 | + if ( ! empty($matches)) { |
|
381 | 381 | return array( |
382 | 382 | 'name' => '', |
383 | 383 | 'fullname' => '', |
384 | 384 | 'username' => '', |
385 | 385 | ); |
386 | 386 | } else { |
387 | - $user_info = maybe_unserialize( $user_info ); |
|
387 | + $user_info = maybe_unserialize($user_info); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
393 | - $user_data = get_userdata( $user_info['id'] ); |
|
392 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
393 | + $user_data = get_userdata($user_info['id']); |
|
394 | 394 | $email_names['name'] = $user_info['first_name']; |
395 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
395 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
396 | 396 | $email_names['username'] = $user_data->user_login; |
397 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
397 | + } elseif (isset($user_info['first_name'])) { |
|
398 | 398 | $email_names['name'] = $user_info['first_name']; |
399 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
399 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
400 | 400 | $email_names['username'] = $user_info['first_name']; |
401 | 401 | } else { |
402 | 402 | $email_names['name'] = $user_info['email']; |
@@ -416,37 +416,37 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @since 1.8.14 |
418 | 418 | */ |
419 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
419 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
420 | 420 | |
421 | - $user_id = absint( $user_id ); |
|
422 | - $donor_id = absint( $donor_id ); |
|
421 | + $user_id = absint($user_id); |
|
422 | + $donor_id = absint($donor_id); |
|
423 | 423 | |
424 | 424 | // Bail Out, if user id doesn't exists. |
425 | - if ( empty( $user_id ) ) { |
|
425 | + if (empty($user_id)) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Bail Out, if donor id doesn't exists. |
430 | - if ( empty( $donor_id ) ) { |
|
430 | + if (empty($donor_id)) { |
|
431 | 431 | return; |
432 | 432 | } |
433 | 433 | |
434 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
434 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
435 | 435 | |
436 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
436 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
437 | 437 | |
438 | 438 | /* translators: %s: payment id */ |
439 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
439 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
440 | 440 | |
441 | 441 | /** |
442 | 442 | * Filters the Donor-User Disconnection notification subject. |
443 | 443 | * |
444 | 444 | * @since 1.8.14 |
445 | 445 | */ |
446 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
446 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
447 | 447 | |
448 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
449 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
448 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
449 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
450 | 450 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
451 | 451 | |
452 | 452 | /** |
@@ -454,25 +454,25 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.8.14 |
456 | 456 | */ |
457 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
457 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
458 | 458 | |
459 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
460 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
461 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
459 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
460 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
461 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
462 | 462 | $message .= sprintf( |
463 | 463 | '<a href="%1$s">%2$s</a>', |
464 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ), |
|
465 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
464 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'), |
|
465 | + __('Reconnect User', 'give')."\n\n" |
|
466 | 466 | ); |
467 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
468 | - $message .= '{sitename}' . "\n"; |
|
467 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
468 | + $message .= '{sitename}'."\n"; |
|
469 | 469 | |
470 | 470 | $emails = Give()->emails; |
471 | - $emails->__set( 'from_name', $from_name ); |
|
472 | - $emails->__set( 'from_email', $from_email ); |
|
473 | - $emails->__set( 'headers', $headers ); |
|
474 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
471 | + $emails->__set('from_name', $from_name); |
|
472 | + $emails->__set('from_email', $from_email); |
|
473 | + $emails->__set('headers', $headers); |
|
474 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
475 | 475 | |
476 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
476 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
477 | 477 | |
478 | 478 | } |
@@ -666,6 +666,7 @@ |
||
666 | 666 | * Check if Import donation is duplicate |
667 | 667 | * |
668 | 668 | * @since 1.8.13 |
669 | + * @param Give_Donate_Form $form |
|
669 | 670 | */ |
670 | 671 | function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
671 | 672 | $return = false; |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.8.13 |
21 | 21 | */ |
22 | 22 | function give_import_donation_report() { |
23 | - return get_option( 'give_import_donation_report', array() ); |
|
23 | + return get_option('give_import_donation_report', array()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8.13 |
31 | 31 | */ |
32 | -function give_import_donation_report_update( $value = array() ) { |
|
33 | - update_option( 'give_import_donation_report', $value ); |
|
32 | +function give_import_donation_report_update($value = array()) { |
|
33 | + update_option('give_import_donation_report', $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @since 1.8.13 |
41 | 41 | */ |
42 | 42 | function give_import_donation_report_reset() { |
43 | - update_option( 'give_import_donation_report', array() ); |
|
43 | + update_option('give_import_donation_report', array()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
54 | 54 | */ |
55 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
55 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
56 | 56 | $new_form = false; |
57 | 57 | |
58 | 58 | // Get the import report |
@@ -61,58 +61,58 @@ discard block |
||
61 | 61 | $form = false; |
62 | 62 | $meta = array(); |
63 | 63 | |
64 | - if ( ! empty( $data['form_id'] ) ) { |
|
65 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
64 | + if ( ! empty($data['form_id'])) { |
|
65 | + $form = new Give_Donate_Form($data['form_id']); |
|
66 | 66 | // Add support to older php version. |
67 | 67 | $form_id = $form->get_ID(); |
68 | - if ( empty( $form_id ) ) { |
|
69 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
68 | + if (empty($form_id)) { |
|
69 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
70 | 70 | $form = false; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
75 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
74 | + if (false === $form && ! empty($data['form_title'])) { |
|
75 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
76 | 76 | |
77 | - if ( ! empty( $form->ID ) ) { |
|
77 | + if ( ! empty($form->ID)) { |
|
78 | 78 | |
79 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
79 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
80 | 80 | |
81 | - $form = new Give_Donate_Form( $form->ID ); |
|
81 | + $form = new Give_Donate_Form($form->ID); |
|
82 | 82 | } else { |
83 | 83 | $form = new Give_Donate_Form(); |
84 | 84 | $args = array( |
85 | 85 | 'post_title' => $data['form_title'], |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | ); |
88 | - $form = $form->create( $args ); |
|
89 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
88 | + $form = $form->create($args); |
|
89 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
90 | 90 | $new_form = true; |
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
95 | - $form = new Give_Donate_Form( $form->ID ); |
|
94 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
95 | + $form = new Give_Donate_Form($form->ID); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $form ) && $form->get_ID() ) { |
|
99 | - if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) { |
|
98 | + if ( ! empty($form) && $form->get_ID()) { |
|
99 | + if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) { |
|
100 | 100 | $prices = (array) $form->get_prices(); |
101 | 101 | $price_text = array(); |
102 | - foreach ( $prices as $key => $price ) { |
|
103 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
104 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' ); |
|
102 | + foreach ($prices as $key => $price) { |
|
103 | + if (isset($price['_give_id']['level_id'])) { |
|
104 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : ''); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! in_array( $data['form_level'], $price_text ) ) { |
|
108 | + if ( ! in_array($data['form_level'], $price_text)) { |
|
109 | 109 | |
110 | 110 | // For generating unquiet level id. |
111 | 111 | $count = 1; |
112 | - $new_level = count( $prices ) + $count; |
|
113 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
114 | - $count ++; |
|
115 | - $new_level = count( $prices ) + $count; |
|
112 | + $new_level = count($prices) + $count; |
|
113 | + while (array_key_exists($new_level, $price_text)) { |
|
114 | + $count++; |
|
115 | + $new_level = count($prices) + $count; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $multi_level_donations = array( |
@@ -120,57 +120,57 @@ discard block |
||
120 | 120 | '_give_id' => array( |
121 | 121 | 'level_id' => $new_level, |
122 | 122 | ), |
123 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
123 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
124 | 124 | '_give_text' => $data['form_level'], |
125 | 125 | ), |
126 | 126 | ); |
127 | 127 | |
128 | - $price_text[ $new_level ] = $data['form_level']; |
|
128 | + $price_text[$new_level] = $data['form_level']; |
|
129 | 129 | |
130 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
131 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
130 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
131 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
132 | 132 | |
133 | 133 | // Sort $prices by amount in ascending order. |
134 | - $prices = wp_list_sort( $prices, '_give_amount', 'ASC' ); |
|
134 | + $prices = wp_list_sort($prices, '_give_amount', 'ASC'); |
|
135 | 135 | } else { |
136 | 136 | $prices = $multi_level_donations; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Unset _give_default key from $prices. |
140 | - foreach ( $prices as $key => $price ) { |
|
141 | - if ( isset( $prices[ $key ]['_give_default'] ) ) { |
|
142 | - unset( $prices[ $key ]['_give_default'] ); |
|
140 | + foreach ($prices as $key => $price) { |
|
141 | + if (isset($prices[$key]['_give_default'])) { |
|
142 | + unset($prices[$key]['_give_default']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Set the first $price of the $prices as defalut. |
147 | 147 | $prices[0]['_give_default'] = 'default'; |
148 | 148 | } |
149 | - $form->price_id = array_search( $data['form_level'], $price_text ); |
|
149 | + $form->price_id = array_search($data['form_level'], $price_text); |
|
150 | 150 | |
151 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
152 | - $min_amount = min( $donation_levels_amounts ); |
|
153 | - $max_amount = max( $donation_levels_amounts ); |
|
151 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
152 | + $min_amount = min($donation_levels_amounts); |
|
153 | + $max_amount = max($donation_levels_amounts); |
|
154 | 154 | |
155 | 155 | $meta = array( |
156 | 156 | '_give_levels_minimum_amount' => $min_amount, |
157 | 157 | '_give_levels_maximum_amount' => $max_amount, |
158 | 158 | '_give_price_option' => 'multi', |
159 | - '_give_donation_levels' => array_values( $prices ), |
|
159 | + '_give_donation_levels' => array_values($prices), |
|
160 | 160 | ); |
161 | 161 | } else { |
162 | 162 | $form->price_id = 'custom'; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $defaults = array( |
166 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
166 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
167 | 167 | '_give_price_option' => 'set', |
168 | 168 | ); |
169 | 169 | |
170 | 170 | // If new form is created. |
171 | - if ( ! empty( $new_form ) ) { |
|
171 | + if ( ! empty($new_form)) { |
|
172 | 172 | $new_form = array( |
173 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
173 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
174 | 174 | '_give_logged_in_only' => 'enabled', |
175 | 175 | '_give_custom_amount' => 'enabled', |
176 | 176 | '_give_payment_import' => true, |
@@ -181,18 +181,18 @@ discard block |
||
181 | 181 | '_give_default_gateway' => 'global', |
182 | 182 | '_give_show_register_form' => 'both', |
183 | 183 | ); |
184 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
184 | + $defaults = wp_parse_args($defaults, $new_form); |
|
185 | 185 | } |
186 | 186 | |
187 | - $meta = wp_parse_args( $meta, $defaults ); |
|
187 | + $meta = wp_parse_args($meta, $defaults); |
|
188 | 188 | |
189 | - foreach ( $meta as $key => $value ) { |
|
190 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
189 | + foreach ($meta as $key => $value) { |
|
190 | + give_update_meta($form->get_ID(), $key, $value); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | // update the report |
195 | - give_import_donation_report_update( $report ); |
|
195 | + give_import_donation_report_update($report); |
|
196 | 196 | |
197 | 197 | return $form; |
198 | 198 | } |
@@ -206,30 +206,30 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return bool|false|WP_User |
208 | 208 | */ |
209 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
209 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
210 | 210 | $report = give_import_donation_report(); |
211 | 211 | $donor_data = false; |
212 | 212 | $customer_id = false; |
213 | 213 | |
214 | 214 | // check if donor id is not empty |
215 | - if ( ! empty( $data['donor_id'] ) ) { |
|
216 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
217 | - if ( ! empty( $donor_data->id ) ) { |
|
218 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
215 | + if ( ! empty($data['donor_id'])) { |
|
216 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
217 | + if ( ! empty($donor_data->id)) { |
|
218 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
222 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
223 | 223 | $user_id = (int) $data['user_id']; |
224 | - $donor_data = new Give_Donor( $user_id, true ); |
|
224 | + $donor_data = new Give_Donor($user_id, true); |
|
225 | 225 | |
226 | 226 | |
227 | - if ( empty( $donor_data->id ) ) { |
|
228 | - $donor_data = get_user_by( 'id', $user_id ); |
|
229 | - if ( ! empty( $donor_data->ID ) ) { |
|
230 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
231 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
232 | - $name = $first_name . ' ' . $last_name; |
|
227 | + if (empty($donor_data->id)) { |
|
228 | + $donor_data = get_user_by('id', $user_id); |
|
229 | + if ( ! empty($donor_data->ID)) { |
|
230 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
231 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
232 | + $name = $first_name.' '.$last_name; |
|
233 | 233 | $user_email = $donor_data->user_email; |
234 | 234 | $donor_args = array( |
235 | 235 | 'name' => $name, |
@@ -238,45 +238,45 @@ discard block |
||
238 | 238 | ); |
239 | 239 | |
240 | 240 | $donor_data = new Give_Donor(); |
241 | - $donor_data->create( $donor_args ); |
|
241 | + $donor_data->create($donor_args); |
|
242 | 242 | |
243 | 243 | // Adding notes that donor is being imported from CSV. |
244 | 244 | $current_user = wp_get_current_user(); |
245 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
245 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
246 | 246 | |
247 | 247 | // Add is used to ensure duplicate emails are not added |
248 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
249 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
248 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
249 | + $donor_data->add_meta('additional_email', $data['email']); |
|
250 | 250 | } |
251 | 251 | |
252 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
252 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
253 | 253 | } |
254 | 254 | } else { |
255 | 255 | // Add is used to ensure duplicate emails are not added |
256 | - if ( $donor_data->email != $data['email'] ) { |
|
257 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
256 | + if ($donor_data->email != $data['email']) { |
|
257 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
258 | 258 | } |
259 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
259 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
263 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
264 | 264 | |
265 | - $donor_data = new Give_Donor( $data['email'] ); |
|
266 | - if ( empty( $donor_data->id ) ) { |
|
267 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
265 | + $donor_data = new Give_Donor($data['email']); |
|
266 | + if (empty($donor_data->id)) { |
|
267 | + $donor_data = get_user_by('email', $data['email']); |
|
268 | 268 | |
269 | - if ( empty( $donor_data->ID ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
270 | - $data['first_name'] = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $data['email'] ); |
|
271 | - $data['last_name'] = ( ! empty( $data['last_name'] ) ? $data['last_name'] : '' ); |
|
272 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
269 | + if (empty($donor_data->ID) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
270 | + $data['first_name'] = ( ! empty($data['first_name']) ? $data['first_name'] : $data['email']); |
|
271 | + $data['last_name'] = ( ! empty($data['last_name']) ? $data['last_name'] : ''); |
|
272 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
273 | 273 | $donor_args = array( |
274 | 274 | 'user_login' => $data['email'], |
275 | 275 | 'user_email' => $data['email'], |
276 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
276 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
277 | 277 | 'user_first' => $data['first_name'], |
278 | 278 | 'user_last' => $data['last_name'], |
279 | - 'user_pass' => wp_generate_password( 8, true ), |
|
279 | + 'user_pass' => wp_generate_password(8, true), |
|
280 | 280 | 'role' => $give_role, |
281 | 281 | ); |
282 | 282 | |
@@ -285,55 +285,55 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @since 1.8.13 |
287 | 287 | */ |
288 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
288 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
289 | 289 | |
290 | 290 | // This action was added to remove the login when using the give register function. |
291 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
292 | - $customer_id = give_register_and_login_new_user( $donor_args ); |
|
293 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
291 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
292 | + $customer_id = give_register_and_login_new_user($donor_args); |
|
293 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
294 | 294 | |
295 | - update_user_meta( $customer_id, '_give_payment_import', true ); |
|
296 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
295 | + update_user_meta($customer_id, '_give_payment_import', true); |
|
296 | + $donor_data = new Give_Donor($customer_id, true); |
|
297 | 297 | } else { |
298 | - $customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
298 | + $customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
302 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
301 | + if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
302 | + $donor_data = new Give_Donor($customer_id, true); |
|
303 | 303 | |
304 | - if ( empty( $donor_data->id ) ) { |
|
304 | + if (empty($donor_data->id)) { |
|
305 | 305 | |
306 | - if ( ! empty( $data['form_id'] ) ) { |
|
307 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
306 | + if ( ! empty($data['form_id'])) { |
|
307 | + $form = new Give_Donate_Form($data['form_id']); |
|
308 | 308 | } |
309 | 309 | |
310 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
310 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
311 | 311 | $donor_args = array( |
312 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
312 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
313 | 313 | 'email' => $data['email'], |
314 | 314 | ); |
315 | 315 | |
316 | - if ( ! empty( $customer_id ) ) { |
|
316 | + if ( ! empty($customer_id)) { |
|
317 | 317 | $donor_args['user_id'] = $customer_id; |
318 | 318 | } |
319 | 319 | |
320 | - $donor_data->create( $donor_args ); |
|
320 | + $donor_data->create($donor_args); |
|
321 | 321 | |
322 | 322 | // Adding notes that donor is being imported from CSV. |
323 | 323 | $current_user = wp_get_current_user(); |
324 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
324 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
325 | 325 | |
326 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
326 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
327 | 327 | } else { |
328 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
328 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } else { |
332 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
332 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | // update the report |
336 | - give_import_donation_report_update( $report ); |
|
336 | + give_import_donation_report_update($report); |
|
337 | 337 | |
338 | 338 | return $donor_data; |
339 | 339 | } |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return array |
353 | 353 | */ |
354 | - return (array) apply_filters( 'give_import_default_options', array( |
|
355 | - '' => __( 'Do not import', 'give' ), |
|
356 | - ) ); |
|
354 | + return (array) apply_filters('give_import_default_options', array( |
|
355 | + '' => __('Do not import', 'give'), |
|
356 | + )); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -369,62 +369,62 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @return array |
371 | 371 | */ |
372 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
373 | - 'id' => __( 'Donation ID', 'give' ), |
|
372 | + return (array) apply_filters('give_import_donations_options', array( |
|
373 | + 'id' => __('Donation ID', 'give'), |
|
374 | 374 | 'amount' => array( |
375 | - __( 'Donation Amount', 'give' ), |
|
376 | - __( 'Amount', 'give' ) |
|
375 | + __('Donation Amount', 'give'), |
|
376 | + __('Amount', 'give') |
|
377 | 377 | ), |
378 | 378 | 'post_date' => array( |
379 | - __( 'Donation Date', 'give' ), |
|
380 | - __( 'Date', 'give' ), |
|
379 | + __('Donation Date', 'give'), |
|
380 | + __('Date', 'give'), |
|
381 | 381 | ), |
382 | 382 | 'first_name' => array( |
383 | - __( 'Donor First Name', 'give' ), |
|
384 | - __( 'First Name', 'give' ), |
|
385 | - __( 'Name', 'give' ), |
|
383 | + __('Donor First Name', 'give'), |
|
384 | + __('First Name', 'give'), |
|
385 | + __('Name', 'give'), |
|
386 | 386 | ), |
387 | 387 | 'last_name' => array( |
388 | - __( 'Donor Last Name', 'give' ), |
|
389 | - __( 'Last Name', 'give' ), |
|
388 | + __('Donor Last Name', 'give'), |
|
389 | + __('Last Name', 'give'), |
|
390 | 390 | ), |
391 | 391 | 'line1' => array( |
392 | - __( 'Address 1', 'give' ), |
|
393 | - __( 'Address', 'give' ), |
|
392 | + __('Address 1', 'give'), |
|
393 | + __('Address', 'give'), |
|
394 | 394 | ), |
395 | - 'line2' => __( 'Address 2', 'give' ), |
|
396 | - 'city' => __( 'City', 'give' ), |
|
395 | + 'line2' => __('Address 2', 'give'), |
|
396 | + 'city' => __('City', 'give'), |
|
397 | 397 | 'state' => array( |
398 | - __( 'State', 'give' ), |
|
399 | - __( 'Province', 'give' ), |
|
400 | - __( 'County', 'give' ), |
|
401 | - __( 'Region', 'give' ), |
|
398 | + __('State', 'give'), |
|
399 | + __('Province', 'give'), |
|
400 | + __('County', 'give'), |
|
401 | + __('Region', 'give'), |
|
402 | 402 | ), |
403 | - 'country' => __( 'Country', 'give' ), |
|
403 | + 'country' => __('Country', 'give'), |
|
404 | 404 | 'zip' => array( |
405 | - __( 'Zip', 'give' ), |
|
406 | - __( 'Zip Code', 'give' ), |
|
407 | - __( 'Postal Code', 'give' ), |
|
405 | + __('Zip', 'give'), |
|
406 | + __('Zip Code', 'give'), |
|
407 | + __('Postal Code', 'give'), |
|
408 | 408 | ), |
409 | 409 | 'email' => array( |
410 | - __( 'Donor Email', 'give' ), |
|
411 | - __( 'Email', 'give' ) |
|
410 | + __('Donor Email', 'give'), |
|
411 | + __('Email', 'give') |
|
412 | 412 | ), |
413 | 413 | 'post_status' => array( |
414 | - __( 'Donation Status', 'give' ), |
|
415 | - __( 'Status', 'give' ), |
|
414 | + __('Donation Status', 'give'), |
|
415 | + __('Status', 'give'), |
|
416 | 416 | ), |
417 | 417 | 'gateway' => array( |
418 | - __( 'Payment Method', 'give' ), |
|
419 | - __( 'Method', 'give' ), |
|
418 | + __('Payment Method', 'give'), |
|
419 | + __('Method', 'give'), |
|
420 | 420 | ), |
421 | - 'notes' => __( 'Notes', 'give' ), |
|
421 | + 'notes' => __('Notes', 'give'), |
|
422 | 422 | 'mode' => array( |
423 | - __( 'Test Mode', 'give' ), |
|
424 | - __( 'Mode', 'give' ), |
|
423 | + __('Test Mode', 'give'), |
|
424 | + __('Mode', 'give'), |
|
425 | 425 | ), |
426 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
427 | - ) ); |
|
426 | + 'post_meta' => __('Import as Meta', 'give'), |
|
427 | + )); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @return array |
442 | 442 | */ |
443 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
444 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
445 | - 'user_id' => __( 'User ID', 'give' ), |
|
446 | - ) ); |
|
443 | + return (array) apply_filters('give_import_donor_options', array( |
|
444 | + 'donor_id' => __('Donor ID', 'give'), |
|
445 | + 'user_id' => __('User ID', 'give'), |
|
446 | + )); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -459,23 +459,23 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return array |
461 | 461 | */ |
462 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
462 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
463 | 463 | 'form_title' => array( |
464 | - __( 'Donation Form Title', 'give' ), |
|
465 | - __( 'Donation Form', 'give' ), |
|
466 | - __( 'Form Name', 'give' ), |
|
467 | - __( 'Title', 'give' ), |
|
464 | + __('Donation Form Title', 'give'), |
|
465 | + __('Donation Form', 'give'), |
|
466 | + __('Form Name', 'give'), |
|
467 | + __('Title', 'give'), |
|
468 | 468 | ), |
469 | 469 | 'form_id' => array( |
470 | - __( 'Donation Form ID', 'give' ), |
|
471 | - __( 'Form ID', 'give' ) |
|
470 | + __('Donation Form ID', 'give'), |
|
471 | + __('Form ID', 'give') |
|
472 | 472 | ), |
473 | 473 | 'form_level' => array( |
474 | - __( 'Donation Level', 'give' ), |
|
475 | - __( 'Level', 'give' ), |
|
474 | + __('Donation Level', 'give'), |
|
475 | + __('Level', 'give'), |
|
476 | 476 | ), |
477 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
478 | - ) ); |
|
477 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
478 | + )); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return array |
490 | 490 | */ |
491 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
491 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
492 | 492 | /** |
493 | 493 | * Filter to modify delimiter of Import. |
494 | 494 | * |
@@ -497,19 +497,19 @@ discard block |
||
497 | 497 | * |
498 | 498 | * Return string $delimiter. |
499 | 499 | */ |
500 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
500 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
501 | 501 | |
502 | 502 | $raw_data = array(); |
503 | - $file_dir = get_attached_file( $file_id ); |
|
503 | + $file_dir = get_attached_file($file_id); |
|
504 | 504 | $count = 0; |
505 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
506 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
507 | - if ( $count >= $start && $count <= $end ) { |
|
505 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
506 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
507 | + if ($count >= $start && $count <= $end) { |
|
508 | 508 | $raw_data[] = $row; |
509 | 509 | } |
510 | - $count ++; |
|
510 | + $count++; |
|
511 | 511 | } |
512 | - fclose( $handle ); |
|
512 | + fclose($handle); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $raw_data; |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return bool |
527 | 527 | */ |
528 | -function give_log_user_in_on_register_callback( $value ) { |
|
528 | +function give_log_user_in_on_register_callback($value) { |
|
529 | 529 | return false; |
530 | 530 | } |
531 | 531 | |
@@ -541,22 +541,22 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @return bool |
543 | 543 | */ |
544 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
545 | - $data = array_combine( $raw_key, $row_data ); |
|
544 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
545 | + $data = array_combine($raw_key, $row_data); |
|
546 | 546 | $price_id = false; |
547 | 547 | $customer_id = 0; |
548 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
548 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
549 | 549 | |
550 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
550 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
551 | 551 | |
552 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
552 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
553 | 553 | |
554 | 554 | // Here come the login function. |
555 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
556 | - if ( ! empty( $donor_data->id ) ) { |
|
557 | - if ( ! empty( $donor_data->user_id ) ) { |
|
555 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
556 | + if ( ! empty($donor_data->id)) { |
|
557 | + if ( ! empty($donor_data->user_id)) { |
|
558 | 558 | $customer_id = $donor_data->user_id; |
559 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
559 | + } elseif ( ! empty($data['user_id'])) { |
|
560 | 560 | $customer_id = $data['user_id']; |
561 | 561 | } |
562 | 562 | } else { |
@@ -564,97 +564,97 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | // get form data or register a form data. |
567 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
568 | - if ( false == $form ) { |
|
567 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
568 | + if (false == $form) { |
|
569 | 569 | return false; |
570 | 570 | } else { |
571 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
571 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
575 | 575 | $address = array( |
576 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
577 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
578 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
579 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
580 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
581 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
576 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
577 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
578 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
579 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
580 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
581 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
582 | 582 | ); |
583 | 583 | |
584 | 584 | //Create payment_data array |
585 | 585 | $payment_data = array( |
586 | 586 | 'donor_id' => $donor_data->id, |
587 | 587 | 'price' => $data['amount'], |
588 | - 'status' => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ), |
|
588 | + 'status' => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'), |
|
589 | 589 | 'currency' => give_get_currency(), |
590 | 590 | 'user_info' => array( |
591 | 591 | 'id' => $customer_id, |
592 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
593 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
594 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
592 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
593 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
594 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
595 | 595 | 'address' => $address, |
596 | 596 | ), |
597 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
598 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
597 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
598 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
599 | 599 | 'give_form_id' => (string) $form->get_ID(), |
600 | 600 | 'give_price_id' => $price_id, |
601 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
601 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
602 | 602 | 'user_email' => $data['email'], |
603 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
604 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
603 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
604 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
605 | 605 | ); |
606 | 606 | |
607 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
607 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
608 | 608 | |
609 | 609 | // Get the report |
610 | 610 | $report = give_import_donation_report(); |
611 | 611 | |
612 | 612 | // Check for duplicate code. |
613 | - $donation_duplicate = give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ); |
|
614 | - if ( false !== $donation_duplicate ) { |
|
615 | - $report['donation_details'][ $import_setting['donation_key'] ]['duplicate'] = $donation_duplicate; |
|
616 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
613 | + $donation_duplicate = give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data); |
|
614 | + if (false !== $donation_duplicate) { |
|
615 | + $report['donation_details'][$import_setting['donation_key']]['duplicate'] = $donation_duplicate; |
|
616 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
617 | 617 | } else { |
618 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
619 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
620 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
621 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
622 | - $payment = give_insert_payment( $payment_data ); |
|
623 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
624 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
625 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
626 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
618 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
619 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
620 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
621 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
622 | + $payment = give_insert_payment($payment_data); |
|
623 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
624 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
625 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
626 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
627 | 627 | |
628 | - if ( $payment ) { |
|
628 | + if ($payment) { |
|
629 | 629 | |
630 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
630 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
631 | 631 | |
632 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
632 | + update_post_meta($payment, '_give_payment_import', true); |
|
633 | 633 | |
634 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
635 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
634 | + if ( ! empty($import_setting['csv'])) { |
|
635 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | // Insert Notes. |
639 | - if ( ! empty( $data['notes'] ) ) { |
|
640 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
639 | + if ( ! empty($data['notes'])) { |
|
640 | + give_insert_payment_note($payment, $data['notes']); |
|
641 | 641 | } |
642 | 642 | |
643 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
644 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
645 | - foreach ( $meta_exists as $meta_exist ) { |
|
646 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
647 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
643 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
644 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
645 | + foreach ($meta_exists as $meta_exist) { |
|
646 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
647 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
651 | 651 | } else { |
652 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
652 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
656 | 656 | // update the report |
657 | - give_import_donation_report_update( $report ); |
|
657 | + give_import_donation_report_update($report); |
|
658 | 658 | |
659 | 659 | return true; |
660 | 660 | } |
@@ -670,12 +670,12 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return Give_Donor |
672 | 672 | */ |
673 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
673 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
674 | 674 | $old_donor = $donor; |
675 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
676 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
677 | - $donor = new Give_Donor( $donor_id ); |
|
678 | - if ( ! empty( $donor->id ) ) { |
|
675 | + if ( ! empty($payment_data['donor_id'])) { |
|
676 | + $donor_id = absint($payment_data['donor_id']); |
|
677 | + $donor = new Give_Donor($donor_id); |
|
678 | + if ( ! empty($donor->id)) { |
|
679 | 679 | return $donor; |
680 | 680 | } |
681 | 681 | } |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | * |
689 | 689 | * @since 1.8.13 |
690 | 690 | */ |
691 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
691 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
692 | 692 | // Update Give Customers purchase_count |
693 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
694 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
695 | - if ( ! empty( $donor_id ) ) { |
|
696 | - $donor = new Give_Donor( $donor_id ); |
|
693 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
694 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
695 | + if ( ! empty($donor_id)) { |
|
696 | + $donor = new Give_Donor($donor_id); |
|
697 | 697 | $donor->increase_purchase_count(); |
698 | 698 | } |
699 | 699 | } |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | * |
705 | 705 | * @since 1.8.13 |
706 | 706 | */ |
707 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
708 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
707 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
708 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
709 | 709 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
710 | 710 | } |
711 | 711 | |
@@ -717,11 +717,11 @@ discard block |
||
717 | 717 | * |
718 | 718 | * @since 1.8.13 |
719 | 719 | */ |
720 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
720 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
721 | 721 | $return = false; |
722 | - if ( ! empty( $data['post_date'] ) ) { |
|
723 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
724 | - $post_date = explode( '-', $post_date ); |
|
722 | + if ( ! empty($data['post_date'])) { |
|
723 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
724 | + $post_date = explode('-', $post_date); |
|
725 | 725 | $args = array( |
726 | 726 | 'output' => 'post', |
727 | 727 | 'cache_results' => false, |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'meta_query' => array( |
743 | 743 | array( |
744 | 744 | 'key' => '_give_payment_total', |
745 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
745 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
746 | 746 | 'compare' => 'LIKE', |
747 | 747 | ), |
748 | 748 | array( |
@@ -764,9 +764,9 @@ discard block |
||
764 | 764 | ), |
765 | 765 | ); |
766 | 766 | |
767 | - $payments = new Give_Payments_Query( $args ); |
|
767 | + $payments = new Give_Payments_Query($args); |
|
768 | 768 | $donations = $payments->get_payments(); |
769 | - if ( ! empty( $donations ) ) { |
|
769 | + if ( ! empty($donations)) { |
|
770 | 770 | $return = $donations; |
771 | 771 | } |
772 | 772 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | * |
777 | 777 | * @since 1.8.18 |
778 | 778 | */ |
779 | - return apply_filters( 'give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data ); |
|
779 | + return apply_filters('give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
@@ -788,9 +788,9 @@ discard block |
||
788 | 788 | * |
789 | 789 | * @return void |
790 | 790 | */ |
791 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
791 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
792 | 792 | $current_user = wp_get_current_user(); |
793 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
793 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -802,14 +802,14 @@ discard block |
||
802 | 802 | * |
803 | 803 | * @return string URL |
804 | 804 | */ |
805 | -function give_import_page_url( $parameter = array() ) { |
|
805 | +function give_import_page_url($parameter = array()) { |
|
806 | 806 | $defalut_query_arg = array( |
807 | 807 | 'post_type' => 'give_forms', |
808 | 808 | 'page' => 'give-tools', |
809 | 809 | 'tab' => 'import', |
810 | 810 | 'importer-type' => 'import_donations', |
811 | 811 | ); |
812 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
812 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
813 | 813 | |
814 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
814 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
815 | 815 | } |
816 | 816 | \ 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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the donation data and uses the Manual Payment gateway to record |
@@ -32,44 +32,44 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
49 | 49 | 'purchase_key' => $purchase_data['purchase_key'], |
50 | - 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ), |
|
50 | + 'currency' => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data), |
|
51 | 51 | 'user_info' => $purchase_data['user_info'], |
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the donation page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function donations_dropdown( $args = array() ) { |
|
38 | + public function donations_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
48 | + 'placeholder' => __('Select a donation', 'give'), |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'], |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | // Provide nice human readable options. |
62 | - if ( $payments ) { |
|
62 | + if ($payments) { |
|
63 | 63 | $options[0] = $args['placeholder']; |
64 | - foreach ( $payments as $payment ) { |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
70 | + $options[0] = __('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output = $this->select( array( |
|
73 | + $output = $this->select(array( |
|
74 | 74 | 'name' => $args['name'], |
75 | 75 | 'selected' => $args['selected'], |
76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'select_atts' => $args['select_atts'], |
83 | 83 | 'show_option_all' => false, |
84 | 84 | 'show_option_none' => false, |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | 87 | return $output; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string Give forms dropdown. |
101 | 101 | */ |
102 | - public function forms_dropdown( $args = array() ) { |
|
102 | + public function forms_dropdown($args = array()) { |
|
103 | 103 | |
104 | 104 | $defaults = array( |
105 | 105 | 'name' => 'forms', |
@@ -109,39 +109,39 @@ discard block |
||
109 | 109 | 'selected' => 0, |
110 | 110 | 'chosen' => false, |
111 | 111 | 'number' => 30, |
112 | - 'placeholder' => esc_attr__( 'All Forms', 'give' ), |
|
112 | + 'placeholder' => esc_attr__('All Forms', 'give'), |
|
113 | 113 | 'data' => array( |
114 | 114 | 'search-type' => 'form', |
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | |
118 | - $args = wp_parse_args( $args, $defaults ); |
|
118 | + $args = wp_parse_args($args, $defaults); |
|
119 | 119 | |
120 | - $forms = get_posts( array( |
|
120 | + $forms = get_posts(array( |
|
121 | 121 | 'post_type' => 'give_forms', |
122 | 122 | 'orderby' => 'title', |
123 | 123 | 'order' => 'ASC', |
124 | 124 | 'posts_per_page' => $args['number'], |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | |
127 | 127 | $options = array(); |
128 | 128 | |
129 | 129 | // Ensure the selected. |
130 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
131 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
130 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
131 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
132 | 132 | } |
133 | 133 | |
134 | - if ( $forms ) { |
|
134 | + if ($forms) { |
|
135 | 135 | $options[0] = $args['placeholder']; |
136 | - foreach ( $forms as $form ) { |
|
137 | - $form_title = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; |
|
138 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
136 | + foreach ($forms as $form) { |
|
137 | + $form_title = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title; |
|
138 | + $options[absint($form->ID)] = esc_html($form_title); |
|
139 | 139 | } |
140 | 140 | } else { |
141 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
141 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
142 | 142 | } |
143 | 143 | |
144 | - $output = $this->select( array( |
|
144 | + $output = $this->select(array( |
|
145 | 145 | 'name' => $args['name'], |
146 | 146 | 'selected' => $args['selected'], |
147 | 147 | 'id' => $args['id'], |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'show_option_all' => false, |
154 | 154 | 'show_option_none' => false, |
155 | 155 | 'data' => $args['data'], |
156 | - ) ); |
|
156 | + )); |
|
157 | 157 | |
158 | 158 | return $output; |
159 | 159 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string Donors dropdown. |
172 | 172 | */ |
173 | - public function donor_dropdown( $args = array() ) { |
|
173 | + public function donor_dropdown($args = array()) { |
|
174 | 174 | |
175 | 175 | $defaults = array( |
176 | 176 | 'name' => 'donors', |
@@ -179,57 +179,57 @@ discard block |
||
179 | 179 | 'multiple' => false, |
180 | 180 | 'selected' => 0, |
181 | 181 | 'chosen' => true, |
182 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
182 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
183 | 183 | 'number' => 30, |
184 | 184 | 'data' => array( |
185 | 185 | 'search-type' => 'donor', |
186 | 186 | ), |
187 | 187 | ); |
188 | 188 | |
189 | - $args = wp_parse_args( $args, $defaults ); |
|
189 | + $args = wp_parse_args($args, $defaults); |
|
190 | 190 | |
191 | - $donors = Give()->donors->get_donors( array( |
|
191 | + $donors = Give()->donors->get_donors(array( |
|
192 | 192 | 'number' => $args['number'] |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | |
195 | 195 | $options = array(); |
196 | 196 | |
197 | - if ( $donors ) { |
|
198 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
199 | - foreach ( $donors as $donor ) { |
|
200 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
197 | + if ($donors) { |
|
198 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
199 | + foreach ($donors as $donor) { |
|
200 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
201 | 201 | } |
202 | 202 | } else { |
203 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
203 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
204 | 204 | } |
205 | 205 | |
206 | - if ( ! empty( $args['selected'] ) ) { |
|
206 | + if ( ! empty($args['selected'])) { |
|
207 | 207 | |
208 | 208 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
209 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
209 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
210 | 210 | |
211 | - $donor = new Give_Donor( $args['selected'] ); |
|
211 | + $donor = new Give_Donor($args['selected']); |
|
212 | 212 | |
213 | - if ( $donor ) { |
|
213 | + if ($donor) { |
|
214 | 214 | |
215 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
215 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - $output = $this->select( array( |
|
221 | + $output = $this->select(array( |
|
222 | 222 | 'name' => $args['name'], |
223 | 223 | 'selected' => $args['selected'], |
224 | 224 | 'id' => $args['id'], |
225 | - 'class' => $args['class'] . ' give-customer-select', |
|
225 | + 'class' => $args['class'].' give-customer-select', |
|
226 | 226 | 'options' => $options, |
227 | 227 | 'multiple' => $args['multiple'], |
228 | 228 | 'chosen' => $args['chosen'], |
229 | 229 | 'show_option_all' => false, |
230 | 230 | 'show_option_none' => false, |
231 | 231 | 'data' => $args['data'], |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | |
234 | 234 | return $output; |
235 | 235 | } |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return string Categories dropdown. |
250 | 250 | */ |
251 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
252 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
251 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
252 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
253 | 253 | $options = array(); |
254 | 254 | |
255 | - foreach ( $categories as $category ) { |
|
256 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
255 | + foreach ($categories as $category) { |
|
256 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
257 | 257 | } |
258 | 258 | |
259 | - $output = $this->select( wp_parse_args( $args, array( |
|
259 | + $output = $this->select(wp_parse_args($args, array( |
|
260 | 260 | 'name' => $name, |
261 | 261 | 'selected' => $selected, |
262 | 262 | 'options' => $options, |
263 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
263 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
264 | 264 | 'show_option_none' => false, |
265 | - ) ) ); |
|
265 | + ))); |
|
266 | 266 | |
267 | 267 | return $output; |
268 | 268 | } |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string Tags dropdown. |
283 | 283 | */ |
284 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
285 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
284 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
285 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
286 | 286 | $options = array(); |
287 | 287 | |
288 | - foreach ( $tags as $tag ) { |
|
289 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
288 | + foreach ($tags as $tag) { |
|
289 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
290 | 290 | } |
291 | 291 | |
292 | - $output = $this->select( wp_parse_args( $args, array( |
|
292 | + $output = $this->select(wp_parse_args($args, array( |
|
293 | 293 | 'name' => $name, |
294 | 294 | 'selected' => $selected, |
295 | 295 | 'options' => $options, |
296 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
296 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
297 | 297 | 'show_option_none' => false, |
298 | - ) ) ); |
|
298 | + ))); |
|
299 | 299 | |
300 | 300 | return $output; |
301 | 301 | } |
@@ -315,25 +315,25 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return string Years dropdown. |
317 | 317 | */ |
318 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
319 | - $current = date( 'Y' ); |
|
320 | - $start_year = $current - absint( $years_before ); |
|
321 | - $end_year = $current + absint( $years_after ); |
|
322 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
318 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
319 | + $current = date('Y'); |
|
320 | + $start_year = $current - absint($years_before); |
|
321 | + $end_year = $current + absint($years_after); |
|
322 | + $selected = empty($selected) ? date('Y') : $selected; |
|
323 | 323 | $options = array(); |
324 | 324 | |
325 | - while ( $start_year <= $end_year ) { |
|
326 | - $options[ absint( $start_year ) ] = $start_year; |
|
327 | - $start_year ++; |
|
325 | + while ($start_year <= $end_year) { |
|
326 | + $options[absint($start_year)] = $start_year; |
|
327 | + $start_year++; |
|
328 | 328 | } |
329 | 329 | |
330 | - $output = $this->select( array( |
|
330 | + $output = $this->select(array( |
|
331 | 331 | 'name' => $name, |
332 | 332 | 'selected' => $selected, |
333 | 333 | 'options' => $options, |
334 | 334 | 'show_option_all' => false, |
335 | 335 | 'show_option_none' => false, |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | |
338 | 338 | return $output; |
339 | 339 | } |
@@ -351,23 +351,23 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return string Months dropdown. |
353 | 353 | */ |
354 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
354 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
355 | 355 | $month = 1; |
356 | 356 | $options = array(); |
357 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
357 | + $selected = empty($selected) ? date('n') : $selected; |
|
358 | 358 | |
359 | - while ( $month <= 12 ) { |
|
360 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
361 | - $month ++; |
|
359 | + while ($month <= 12) { |
|
360 | + $options[absint($month)] = give_month_num_to_name($month); |
|
361 | + $month++; |
|
362 | 362 | } |
363 | 363 | |
364 | - $output = $this->select( array( |
|
364 | + $output = $this->select(array( |
|
365 | 365 | 'name' => $name, |
366 | 366 | 'selected' => $selected, |
367 | 367 | 'options' => $options, |
368 | 368 | 'show_option_all' => false, |
369 | 369 | 'show_option_none' => false, |
370 | - ) ); |
|
370 | + )); |
|
371 | 371 | |
372 | 372 | return $output; |
373 | 373 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return string The dropdown. |
386 | 386 | */ |
387 | - public function select( $args = array() ) { |
|
387 | + public function select($args = array()) { |
|
388 | 388 | $defaults = array( |
389 | 389 | 'options' => array(), |
390 | 390 | 'name' => null, |
@@ -395,67 +395,67 @@ discard block |
||
395 | 395 | 'placeholder' => null, |
396 | 396 | 'multiple' => false, |
397 | 397 | 'select_atts' => false, |
398 | - 'show_option_all' => __( 'All', 'give' ), |
|
399 | - 'show_option_none' => __( 'None', 'give' ), |
|
398 | + 'show_option_all' => __('All', 'give'), |
|
399 | + 'show_option_none' => __('None', 'give'), |
|
400 | 400 | 'data' => array(), |
401 | 401 | 'readonly' => false, |
402 | 402 | 'disabled' => false, |
403 | 403 | ); |
404 | 404 | |
405 | - $args = wp_parse_args( $args, $defaults ); |
|
405 | + $args = wp_parse_args($args, $defaults); |
|
406 | 406 | |
407 | 407 | $data_elements = ''; |
408 | - foreach ( $args['data'] as $key => $value ) { |
|
409 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
408 | + foreach ($args['data'] as $key => $value) { |
|
409 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
410 | 410 | } |
411 | 411 | |
412 | - if ( $args['multiple'] ) { |
|
412 | + if ($args['multiple']) { |
|
413 | 413 | $multiple = ' MULTIPLE'; |
414 | 414 | } else { |
415 | 415 | $multiple = ''; |
416 | 416 | } |
417 | 417 | |
418 | - if ( $args['chosen'] ) { |
|
418 | + if ($args['chosen']) { |
|
419 | 419 | $args['class'] .= ' give-select-chosen'; |
420 | 420 | } |
421 | 421 | |
422 | - if ( $args['placeholder'] ) { |
|
422 | + if ($args['placeholder']) { |
|
423 | 423 | $placeholder = $args['placeholder']; |
424 | 424 | } else { |
425 | 425 | $placeholder = ''; |
426 | 426 | } |
427 | 427 | |
428 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; |
|
428 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'"'.$data_elements.'>'; |
|
429 | 429 | |
430 | - if ( $args['show_option_all'] ) { |
|
431 | - if ( $args['multiple'] ) { |
|
432 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
430 | + if ($args['show_option_all']) { |
|
431 | + if ($args['multiple']) { |
|
432 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
433 | 433 | } else { |
434 | - $selected = selected( $args['selected'], 0, false ); |
|
434 | + $selected = selected($args['selected'], 0, false); |
|
435 | 435 | } |
436 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
436 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
437 | 437 | } |
438 | 438 | |
439 | - if ( ! empty( $args['options'] ) ) { |
|
439 | + if ( ! empty($args['options'])) { |
|
440 | 440 | |
441 | - if ( $args['show_option_none'] ) { |
|
442 | - if ( $args['multiple'] ) { |
|
443 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
441 | + if ($args['show_option_none']) { |
|
442 | + if ($args['multiple']) { |
|
443 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
444 | 444 | } else { |
445 | - $selected = selected( $args['selected'], - 1, false ); |
|
445 | + $selected = selected($args['selected'], - 1, false); |
|
446 | 446 | } |
447 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
447 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
448 | 448 | } |
449 | 449 | |
450 | - foreach ( $args['options'] as $key => $option ) { |
|
450 | + foreach ($args['options'] as $key => $option) { |
|
451 | 451 | |
452 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
453 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
452 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
453 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
454 | 454 | } else { |
455 | - $selected = selected( $args['selected'], $key, false ); |
|
455 | + $selected = selected($args['selected'], $key, false); |
|
456 | 456 | } |
457 | 457 | |
458 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
458 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return string The checkbox. |
478 | 478 | */ |
479 | - public function checkbox( $args = array() ) { |
|
479 | + public function checkbox($args = array()) { |
|
480 | 480 | $defaults = array( |
481 | 481 | 'name' => null, |
482 | 482 | 'current' => null, |
@@ -487,16 +487,16 @@ discard block |
||
487 | 487 | ), |
488 | 488 | ); |
489 | 489 | |
490 | - $args = wp_parse_args( $args, $defaults ); |
|
490 | + $args = wp_parse_args($args, $defaults); |
|
491 | 491 | |
492 | 492 | $options = ''; |
493 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
493 | + if ( ! empty($args['options']['disabled'])) { |
|
494 | 494 | $options .= ' disabled="disabled"'; |
495 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
495 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
496 | 496 | $options .= ' readonly'; |
497 | 497 | } |
498 | 498 | |
499 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
499 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
500 | 500 | |
501 | 501 | return $output; |
502 | 502 | } |
@@ -513,22 +513,22 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @return string The text field. |
515 | 515 | */ |
516 | - public function text( $args = array() ) { |
|
516 | + public function text($args = array()) { |
|
517 | 517 | // Backwards compatibility. |
518 | - if ( func_num_args() > 1 ) { |
|
518 | + if (func_num_args() > 1) { |
|
519 | 519 | $args = func_get_args(); |
520 | 520 | |
521 | 521 | $name = $args[0]; |
522 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
523 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
524 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
522 | + $value = isset($args[1]) ? $args[1] : ''; |
|
523 | + $label = isset($args[2]) ? $args[2] : ''; |
|
524 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $defaults = array( |
528 | - 'name' => isset( $name ) ? $name : 'text', |
|
529 | - 'value' => isset( $value ) ? $value : null, |
|
530 | - 'label' => isset( $label ) ? $label : null, |
|
531 | - 'desc' => isset( $desc ) ? $desc : null, |
|
528 | + 'name' => isset($name) ? $name : 'text', |
|
529 | + 'value' => isset($value) ? $value : null, |
|
530 | + 'label' => isset($label) ? $label : null, |
|
531 | + 'desc' => isset($desc) ? $desc : null, |
|
532 | 532 | 'placeholder' => '', |
533 | 533 | 'class' => 'regular-text', |
534 | 534 | 'disabled' => false, |
@@ -536,29 +536,29 @@ discard block |
||
536 | 536 | 'data' => false, |
537 | 537 | ); |
538 | 538 | |
539 | - $args = wp_parse_args( $args, $defaults ); |
|
539 | + $args = wp_parse_args($args, $defaults); |
|
540 | 540 | |
541 | 541 | $disabled = ''; |
542 | - if ( $args['disabled'] ) { |
|
542 | + if ($args['disabled']) { |
|
543 | 543 | $disabled = ' disabled="disabled"'; |
544 | 544 | } |
545 | 545 | |
546 | 546 | $data = ''; |
547 | - if ( ! empty( $args['data'] ) ) { |
|
548 | - foreach ( $args['data'] as $key => $value ) { |
|
549 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
547 | + if ( ! empty($args['data'])) { |
|
548 | + foreach ($args['data'] as $key => $value) { |
|
549 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
553 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
554 | 554 | |
555 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
555 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
556 | 556 | |
557 | - if ( ! empty( $args['desc'] ) ) { |
|
558 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
557 | + if ( ! empty($args['desc'])) { |
|
558 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
559 | 559 | } |
560 | 560 | |
561 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
561 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
562 | 562 | |
563 | 563 | $output .= '</span>'; |
564 | 564 | |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | * |
578 | 578 | * @return string The date picker. |
579 | 579 | */ |
580 | - public function date_field( $args = array() ) { |
|
580 | + public function date_field($args = array()) { |
|
581 | 581 | |
582 | - if ( empty( $args['class'] ) ) { |
|
582 | + if (empty($args['class'])) { |
|
583 | 583 | $args['class'] = 'give_datepicker'; |
584 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
584 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
585 | 585 | $args['class'] .= ' give_datepicker'; |
586 | 586 | } |
587 | 587 | |
588 | - return $this->text( $args ); |
|
588 | + return $this->text($args); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * |
601 | 601 | * @return string The textarea. |
602 | 602 | */ |
603 | - public function textarea( $args = array() ) { |
|
603 | + public function textarea($args = array()) { |
|
604 | 604 | $defaults = array( |
605 | 605 | 'name' => 'textarea', |
606 | 606 | 'value' => null, |
@@ -610,21 +610,21 @@ discard block |
||
610 | 610 | 'disabled' => false, |
611 | 611 | ); |
612 | 612 | |
613 | - $args = wp_parse_args( $args, $defaults ); |
|
613 | + $args = wp_parse_args($args, $defaults); |
|
614 | 614 | |
615 | 615 | $disabled = ''; |
616 | - if ( $args['disabled'] ) { |
|
616 | + if ($args['disabled']) { |
|
617 | 617 | $disabled = ' disabled="disabled"'; |
618 | 618 | } |
619 | 619 | |
620 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
620 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
621 | 621 | |
622 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
622 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
623 | 623 | |
624 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
624 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
625 | 625 | |
626 | - if ( ! empty( $args['desc'] ) ) { |
|
627 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
626 | + if ( ! empty($args['desc'])) { |
|
627 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | $output .= '</span>'; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @return string The text field with ajax search. |
646 | 646 | */ |
647 | - public function ajax_user_search( $args = array() ) { |
|
647 | + public function ajax_user_search($args = array()) { |
|
648 | 648 | |
649 | 649 | $defaults = array( |
650 | 650 | 'name' => 'users', |
@@ -655,13 +655,13 @@ discard block |
||
655 | 655 | 'chosen' => true, |
656 | 656 | 'number' => 30, |
657 | 657 | 'select_atts' => '', |
658 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
658 | + 'placeholder' => __('Select a user', 'give'), |
|
659 | 659 | 'data' => array( |
660 | 660 | 'search-type' => 'user', |
661 | 661 | ), |
662 | 662 | ); |
663 | 663 | |
664 | - $args = wp_parse_args( $args, $defaults ); |
|
664 | + $args = wp_parse_args($args, $defaults); |
|
665 | 665 | |
666 | 666 | // Set initial args. |
667 | 667 | $get_users_args = array( |
@@ -670,31 +670,31 @@ discard block |
||
670 | 670 | |
671 | 671 | // Ensure selected user is not included in initial query. |
672 | 672 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
673 | - if ( ! empty( $args['selected'] ) ) { |
|
673 | + if ( ! empty($args['selected'])) { |
|
674 | 674 | $get_users_args['exclude'] = $args['selected']; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Initial users array. |
678 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
678 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
679 | 679 | |
680 | 680 | // Now add the selected user to the $users array if the arg is present. |
681 | - if ( ! empty( $args['selected'] ) ) { |
|
682 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
683 | - $users = array_merge( $users, $selected_user ); |
|
681 | + if ( ! empty($args['selected'])) { |
|
682 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
683 | + $users = array_merge($users, $selected_user); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | $options = array(); |
687 | 687 | |
688 | - if ( $users ) { |
|
688 | + if ($users) { |
|
689 | 689 | $options[0] = $args['placeholder']; |
690 | - foreach ( $users as $user ) { |
|
691 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
690 | + foreach ($users as $user) { |
|
691 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
692 | 692 | } |
693 | 693 | } else { |
694 | - $options[0] = __( 'No users found.', 'give' ); |
|
694 | + $options[0] = __('No users found.', 'give'); |
|
695 | 695 | } |
696 | 696 | |
697 | - $output = $this->select( array( |
|
697 | + $output = $this->select(array( |
|
698 | 698 | 'name' => $args['name'], |
699 | 699 | 'selected' => $args['selected'], |
700 | 700 | 'id' => $args['id'], |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | 'show_option_all' => false, |
708 | 708 | 'show_option_none' => false, |
709 | 709 | 'data' => $args['data'], |
710 | - ) ); |
|
710 | + )); |
|
711 | 711 | |
712 | 712 | return $output; |
713 | 713 |
@@ -258,7 +258,7 @@ |
||
258 | 258 | * @access public |
259 | 259 | * @since 1.0 |
260 | 260 | * |
261 | - * @return mixed string If search is present, false otherwise. |
|
261 | + * @return string|false string If search is present, false otherwise. |
|
262 | 262 | */ |
263 | 263 | public function get_search() { |
264 | 264 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -12,13 +12,13 @@ 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 | |
19 | 19 | // Load WP_List_Table if not loaded. |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults. |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | 67 | 'ajax' => false, // Does this table support ajax?. |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo sprintf( '<input type="hidden" name="orderby" value="%1$s" />', esc_attr( $_REQUEST['orderby'] ) ); |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo sprintf('<input type="hidden" name="orderby" value="%1$s" />', esc_attr($_REQUEST['orderby'])); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
91 | - echo sprintf( '<input type="hidden" name="order" value="%1$s" />', esc_attr( $_REQUEST['order'] ) ); |
|
90 | + if ( ! empty($_REQUEST['order'])) { |
|
91 | + echo sprintf('<input type="hidden" name="order" value="%1$s" />', esc_attr($_REQUEST['order'])); |
|
92 | 92 | } |
93 | 93 | ?> |
94 | 94 | <p class="search-box" role="search"> |
95 | 95 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
96 | 96 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
97 | - <?php submit_button( $text, 'button', false, false, array( |
|
97 | + <?php submit_button($text, 'button', false, false, array( |
|
98 | 98 | 'ID' => 'search-submit', |
99 | - ) ); ?> |
|
99 | + )); ?> |
|
100 | 100 | </p> |
101 | 101 | <?php |
102 | 102 | } |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return string Column Name. |
114 | 114 | */ |
115 | - public function column_default( $donor, $column_name ) { |
|
115 | + public function column_default($donor, $column_name) { |
|
116 | 116 | |
117 | - switch ( $column_name ) { |
|
117 | + switch ($column_name) { |
|
118 | 118 | |
119 | 119 | case 'num_donations' : |
120 | 120 | $value = sprintf( |
121 | 121 | '<a href="%s">%s</a>', |
122 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
123 | - esc_html( $donor['num_donations'] ) |
|
122 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
123 | + esc_html($donor['num_donations']) |
|
124 | 124 | ); |
125 | 125 | break; |
126 | 126 | |
127 | 127 | case 'amount_spent' : |
128 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
128 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case 'date_created' : |
132 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
132 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | default: |
136 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
136 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
137 | 137 | break; |
138 | 138 | } |
139 | 139 | |
140 | - return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] ); |
|
140 | + return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function column_cb( $donor ){ |
|
154 | + public function column_cb($donor) { |
|
155 | 155 | return sprintf( |
156 | 156 | '<input class="donor-selector" type="checkbox" name="%1$s[]" value="%2$d" data-name="%3$s" />', |
157 | 157 | $this->_args['singular'], |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string |
172 | 172 | */ |
173 | - public function column_name( $donor ) { |
|
174 | - $name = '#' . $donor['id'] . ' '; |
|
175 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>'; |
|
176 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
177 | - $actions = $this->get_row_actions( $donor ); |
|
173 | + public function column_name($donor) { |
|
174 | + $name = '#'.$donor['id'].' '; |
|
175 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>'; |
|
176 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
177 | + $actions = $this->get_row_actions($donor); |
|
178 | 178 | |
179 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
179 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | 192 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
193 | - 'name' => __( 'Name', 'give' ), |
|
194 | - 'email' => __( 'Email', 'give' ), |
|
195 | - 'num_donations' => __( 'Donations', 'give' ), |
|
196 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
197 | - 'date_created' => __( 'Date Created', 'give' ), |
|
193 | + 'name' => __('Name', 'give'), |
|
194 | + 'email' => __('Email', 'give'), |
|
195 | + 'num_donations' => __('Donations', 'give'), |
|
196 | + 'amount_spent' => __('Total Donated', 'give'), |
|
197 | + 'date_created' => __('Date Created', 'give'), |
|
198 | 198 | ); |
199 | 199 | |
200 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
200 | + return apply_filters('give_list_donors_columns', $columns); |
|
201 | 201 | |
202 | 202 | } |
203 | 203 | |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | public function get_sortable_columns() { |
212 | 212 | |
213 | 213 | $columns = array( |
214 | - 'date_created' => array( 'date_created', true ), |
|
215 | - 'name' => array( 'name', true ), |
|
216 | - 'num_donations' => array( 'purchase_count', false ), |
|
217 | - 'amount_spent' => array( 'purchase_value', false ), |
|
214 | + 'date_created' => array('date_created', true), |
|
215 | + 'name' => array('name', true), |
|
216 | + 'num_donations' => array('purchase_count', false), |
|
217 | + 'amount_spent' => array('purchase_value', false), |
|
218 | 218 | ); |
219 | 219 | |
220 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
220 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return array An array of action links. |
232 | 232 | */ |
233 | - public function get_row_actions( $donor ) { |
|
233 | + public function get_row_actions($donor) { |
|
234 | 234 | |
235 | 235 | $actions = array( |
236 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
237 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
238 | - 'delete' => sprintf( '<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'],sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
236 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
237 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
238 | + 'delete' => sprintf('<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'], sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
239 | 239 | ); |
240 | 240 | |
241 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
241 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return int Current page number. |
252 | 252 | */ |
253 | 253 | public function get_paged() { |
254 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
254 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @return mixed string If search is present, false otherwise. |
264 | 264 | */ |
265 | 265 | public function get_search() { |
266 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
266 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function get_bulk_actions() { |
278 | 278 | $actions = array( |
279 | - 'delete' => __( 'Delete', 'give' ), |
|
279 | + 'delete' => __('Delete', 'give'), |
|
280 | 280 | ); |
281 | 281 | return $actions; |
282 | 282 | } |
@@ -289,19 +289,19 @@ discard block |
||
289 | 289 | * @access protected |
290 | 290 | * @since 1.8.16 |
291 | 291 | */ |
292 | - protected function display_tablenav( $which ) { |
|
293 | - if ( 'top' === $which ) { |
|
294 | - wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false ); |
|
292 | + protected function display_tablenav($which) { |
|
293 | + if ('top' === $which) { |
|
294 | + wp_nonce_field('bulk-'.$this->_args['plural'], '_wpnonce', false); |
|
295 | 295 | } |
296 | 296 | ?> |
297 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
298 | - <?php if ( $this->has_items() ): ?> |
|
297 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
298 | + <?php if ($this->has_items()): ?> |
|
299 | 299 | <div class="alignleft actions bulkactions"> |
300 | - <?php $this->bulk_actions( $which ); ?> |
|
300 | + <?php $this->bulk_actions($which); ?> |
|
301 | 301 | </div> |
302 | 302 | <?php endif; |
303 | - $this->extra_tablenav( $which ); |
|
304 | - $this->pagination( $which ); |
|
303 | + $this->extra_tablenav($which); |
|
304 | + $this->pagination($which); |
|
305 | 305 | ?> |
306 | 306 | <br class="clear" /> |
307 | 307 | </div> |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | |
323 | 323 | // Get donor query. |
324 | 324 | $args = $this->get_donor_query(); |
325 | - $donors = Give()->donors->get_donors( $args ); |
|
325 | + $donors = Give()->donors->get_donors($args); |
|
326 | 326 | |
327 | - if ( $donors ) { |
|
327 | + if ($donors) { |
|
328 | 328 | |
329 | - foreach ( $donors as $donor ) { |
|
329 | + foreach ($donors as $donor) { |
|
330 | 330 | |
331 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
331 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
332 | 332 | |
333 | 333 | $data[] = array( |
334 | 334 | 'id' => $donor->id, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
345 | + return apply_filters('give_donors_column_query_data', $data); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $_donor_query['number'] = - 1; |
359 | 359 | $_donor_query['offset'] = 0; |
360 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
360 | + $donors = Give()->donors->get_donors($_donor_query); |
|
361 | 361 | |
362 | - return count( $donors ); |
|
362 | + return count($donors); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function get_donor_query() { |
374 | 374 | $paged = $this->get_paged(); |
375 | - $offset = $this->per_page * ( $paged - 1 ); |
|
375 | + $offset = $this->per_page * ($paged - 1); |
|
376 | 376 | $search = $this->get_search(); |
377 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
378 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
377 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
378 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
379 | 379 | |
380 | 380 | $args = array( |
381 | 381 | 'number' => $this->per_page, |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | 'orderby' => $orderby, |
385 | 385 | ); |
386 | 386 | |
387 | - if ( $search ) { |
|
388 | - if ( is_email( $search ) ) { |
|
387 | + if ($search) { |
|
388 | + if (is_email($search)) { |
|
389 | 389 | $args['email'] = $search; |
390 | - } elseif ( is_numeric( $search ) ) { |
|
390 | + } elseif (is_numeric($search)) { |
|
391 | 391 | $args['id'] = $search; |
392 | 392 | } else { |
393 | 393 | $args['name'] = $search; |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | * @since 1.8.17 |
406 | 406 | * @access public |
407 | 407 | */ |
408 | - public function single_row( $item ) { |
|
409 | - echo sprintf( '<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name'] ); |
|
410 | - $this->single_row_columns( $item ); |
|
408 | + public function single_row($item) { |
|
409 | + echo sprintf('<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name']); |
|
410 | + $this->single_row_columns($item); |
|
411 | 411 | echo '</tr>'; |
412 | 412 | } |
413 | 413 | |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | public function display() { |
421 | 421 | $singular = $this->_args['singular']; |
422 | 422 | |
423 | - $this->display_tablenav( 'top' ); |
|
423 | + $this->display_tablenav('top'); |
|
424 | 424 | |
425 | - $this->screen->render_screen_reader_content( 'heading_list' ); |
|
425 | + $this->screen->render_screen_reader_content('heading_list'); |
|
426 | 426 | ?> |
427 | - <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
427 | + <table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
428 | 428 | <thead> |
429 | 429 | <tr> |
430 | 430 | <?php $this->print_column_headers(); ?> |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | </thead> |
433 | 433 | |
434 | 434 | <tbody id="the-list"<?php |
435 | - if ( $singular ) { |
|
435 | + if ($singular) { |
|
436 | 436 | echo " data-wp-lists='list:$singular'"; |
437 | 437 | } ?>> |
438 | 438 | <tr class="hidden"></tr> |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | <td colspan="6" class="colspanchange"> |
441 | 441 | |
442 | 442 | <fieldset class="inline-edit-col-left"> |
443 | - <legend class="inline-edit-legend"><?php _e( 'BULK DELETE', 'give' ); ?></legend> |
|
443 | + <legend class="inline-edit-legend"><?php _e('BULK DELETE', 'give'); ?></legend> |
|
444 | 444 | <div class="inline-edit-col"> |
445 | 445 | <div id="bulk-titles"> |
446 | 446 | <div id="give-bulk-donors" class="give-bulk-donors"> |
@@ -453,22 +453,22 @@ discard block |
||
453 | 453 | <div class="inline-edit-col"> |
454 | 454 | <label> |
455 | 455 | <input id="give-delete-donor-confirm" type="checkbox" name="give-delete-donor-confirm"/> |
456 | - <?php _e( 'Are you sure you want to delete the selected donor(s)?', 'give' ); ?> |
|
456 | + <?php _e('Are you sure you want to delete the selected donor(s)?', 'give'); ?> |
|
457 | 457 | </label> |
458 | 458 | <label> |
459 | 459 | <input id="give-delete-donor-records" type="checkbox" name="give-delete-donor-records"/> |
460 | - <?php _e( 'Delete all associated donations and records?', 'give' ); ?> |
|
460 | + <?php _e('Delete all associated donations and records?', 'give'); ?> |
|
461 | 461 | </label> |
462 | 462 | </div> |
463 | 463 | </fieldset> |
464 | 464 | |
465 | 465 | <p class="submit inline-edit-save"> |
466 | 466 | <input type="hidden" name="give_action" value="delete_donor"/> |
467 | - <input type="hidden" name="s" value="<?php echo ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; ?>"/> |
|
468 | - <input type="hidden" name="orderby" value="<?php echo ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id'; ?>"/> |
|
469 | - <input type="hidden" name="order" value="<?php echo ( ! empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc'; ?>"/> |
|
470 | - <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e( 'Cancel', 'give' ); ?></button> |
|
471 | - <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e( 'Delete', 'give' ); ?>"> |
|
467 | + <input type="hidden" name="s" value="<?php echo ( ! empty($_GET['s'])) ? $_GET['s'] : ''; ?>"/> |
|
468 | + <input type="hidden" name="orderby" value="<?php echo ( ! empty($_GET['orderby'])) ? $_GET['orderby'] : 'id'; ?>"/> |
|
469 | + <input type="hidden" name="order" value="<?php echo ( ! empty($_GET['order'])) ? $_GET['order'] : 'desc'; ?>"/> |
|
470 | + <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e('Cancel', 'give'); ?></button> |
|
471 | + <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e('Delete', 'give'); ?>"> |
|
472 | 472 | <br class="clear"> |
473 | 473 | </p> |
474 | 474 | </td> |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | |
479 | 479 | <tfoot> |
480 | 480 | <tr> |
481 | - <?php $this->print_column_headers( false ); ?> |
|
481 | + <?php $this->print_column_headers(false); ?> |
|
482 | 482 | </tr> |
483 | 483 | </tfoot> |
484 | 484 | |
485 | 485 | </table> |
486 | 486 | <?php |
487 | - $this->display_tablenav( 'bottom' ); |
|
487 | + $this->display_tablenav('bottom'); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -501,16 +501,16 @@ discard block |
||
501 | 501 | $hidden = array(); // No hidden columns. |
502 | 502 | $sortable = $this->get_sortable_columns(); |
503 | 503 | |
504 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
504 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
505 | 505 | |
506 | 506 | $this->items = $this->donor_data(); |
507 | 507 | |
508 | 508 | $this->total = $this->get_donor_count(); |
509 | 509 | |
510 | - $this->set_pagination_args( array( |
|
510 | + $this->set_pagination_args(array( |
|
511 | 511 | 'total_items' => $this->total, |
512 | 512 | 'per_page' => $this->per_page, |
513 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
514 | - ) ); |
|
513 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
514 | + )); |
|
515 | 515 | } |
516 | 516 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @since 1.0 |
23 | 23 | * |
24 | - * @return array|bool $output Response messages |
|
24 | + * @return false|null $output Response messages |
|
25 | 25 | */ |
26 | 26 | function give_edit_donor( $args ) { |
27 | 27 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | * |
230 | - * @return int Whether it was a successful deletion. |
|
230 | + * @return false|null Whether it was a successful deletion. |
|
231 | 231 | */ |
232 | 232 | function give_donor_delete( $args ) { |
233 | 233 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @since 1.7 |
523 | 523 | * |
524 | - * @return bool|null |
|
524 | + * @return false|null |
|
525 | 525 | */ |
526 | 526 | function give_remove_donor_email() { |
527 | 527 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @since 1.7 |
567 | 567 | * |
568 | - * @return bool|null |
|
568 | + * @return false|null |
|
569 | 569 | */ |
570 | 570 | function give_set_donor_primary_email() { |
571 | 571 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -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,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array|bool $output Response messages |
25 | 25 | */ |
26 | -function give_edit_donor( $args ) { |
|
26 | +function give_edit_donor($args) { |
|
27 | 27 | |
28 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
28 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
30 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
32 | 32 | 'response' => 403, |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $args ) ) { |
|
36 | + if (empty($args)) { |
|
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | $donor_id = (int) $args['customerinfo']['id']; |
42 | 42 | $nonce = $args['_wpnonce']; |
43 | 43 | |
44 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
45 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
44 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
45 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
46 | 46 | 'response' => 400, |
47 | - ) ); |
|
47 | + )); |
|
48 | 48 | } |
49 | 49 | |
50 | - $donor = new Give_Donor( $donor_id ); |
|
50 | + $donor = new Give_Donor($donor_id); |
|
51 | 51 | |
52 | - if ( empty( $donor->id ) ) { |
|
52 | + if (empty($donor->id)) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -64,79 +64,79 @@ discard block |
||
64 | 64 | 'country' => '', |
65 | 65 | ); |
66 | 66 | |
67 | - $donor_info = wp_parse_args( $donor_info, $defaults ); |
|
67 | + $donor_info = wp_parse_args($donor_info, $defaults); |
|
68 | 68 | |
69 | - if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) { |
|
69 | + if ((int) $donor_info['user_id'] !== (int) $donor->user_id) { |
|
70 | 70 | |
71 | 71 | // Make sure we don't already have this user attached to a donor. |
72 | - if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) { |
|
73 | - give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) ); |
|
72 | + if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) { |
|
73 | + give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Make sure it's actually a user. |
77 | - $user = get_user_by( 'id', $donor_info['user_id'] ); |
|
78 | - if ( ! empty( $donor_info['user_id'] ) && false === $user ) { |
|
79 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) ); |
|
77 | + $user = get_user_by('id', $donor_info['user_id']); |
|
78 | + if ( ! empty($donor_info['user_id']) && false === $user) { |
|
79 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id'])); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - if ( give_get_errors() ) { |
|
83 | + if (give_get_errors()) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Setup the donor address, if present. |
88 | 88 | $address = array(); |
89 | - if ( intval( $donor_info['user_id'] ) > 0 ) { |
|
90 | - |
|
91 | - $current_address = (array) get_user_meta( $donor_info['user_id'], '_give_user_address', true ); |
|
92 | - |
|
93 | - if ( is_array( $current_address ) && 0 < count( $current_address ) ) { |
|
94 | - $current_address = wp_parse_args( $current_address, $defaults ); |
|
95 | - $address['line1'] = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1']; |
|
96 | - $address['line2'] = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2']; |
|
97 | - $address['city'] = ! empty( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city']; |
|
98 | - $address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country']; |
|
99 | - $address['zip'] = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip']; |
|
100 | - $address['state'] = ! empty( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state']; |
|
89 | + if (intval($donor_info['user_id']) > 0) { |
|
90 | + |
|
91 | + $current_address = (array) get_user_meta($donor_info['user_id'], '_give_user_address', true); |
|
92 | + |
|
93 | + if (is_array($current_address) && 0 < count($current_address)) { |
|
94 | + $current_address = wp_parse_args($current_address, $defaults); |
|
95 | + $address['line1'] = ! empty($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1']; |
|
96 | + $address['line2'] = ! empty($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2']; |
|
97 | + $address['city'] = ! empty($donor_info['city']) ? $donor_info['city'] : $current_address['city']; |
|
98 | + $address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : $current_address['country']; |
|
99 | + $address['zip'] = ! empty($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip']; |
|
100 | + $address['state'] = ! empty($donor_info['state']) ? $donor_info['state'] : $current_address['state']; |
|
101 | 101 | } else { |
102 | - $address['line1'] = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : ''; |
|
103 | - $address['line2'] = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : ''; |
|
104 | - $address['city'] = ! empty( $donor_info['city'] ) ? $donor_info['city'] : ''; |
|
105 | - $address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : ''; |
|
106 | - $address['zip'] = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : ''; |
|
107 | - $address['state'] = ! empty( $donor_info['state'] ) ? $donor_info['state'] : ''; |
|
102 | + $address['line1'] = ! empty($donor_info['line1']) ? $donor_info['line1'] : ''; |
|
103 | + $address['line2'] = ! empty($donor_info['line2']) ? $donor_info['line2'] : ''; |
|
104 | + $address['city'] = ! empty($donor_info['city']) ? $donor_info['city'] : ''; |
|
105 | + $address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : ''; |
|
106 | + $address['zip'] = ! empty($donor_info['zip']) ? $donor_info['zip'] : ''; |
|
107 | + $address['state'] = ! empty($donor_info['state']) ? $donor_info['state'] : ''; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Sanitize the inputs. |
113 | 113 | $donor_data = array(); |
114 | - $donor_data['name'] = strip_tags( stripslashes( $donor_info['name'] ) ); |
|
114 | + $donor_data['name'] = strip_tags(stripslashes($donor_info['name'])); |
|
115 | 115 | $donor_data['user_id'] = $donor_info['user_id']; |
116 | 116 | |
117 | - $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id ); |
|
118 | - $address = apply_filters( 'give_edit_donor_address', $address, $donor_id ); |
|
117 | + $donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id); |
|
118 | + $address = apply_filters('give_edit_donor_address', $address, $donor_id); |
|
119 | 119 | |
120 | - $donor_data = array_map( 'sanitize_text_field', $donor_data ); |
|
121 | - $address = array_map( 'sanitize_text_field', $address ); |
|
120 | + $donor_data = array_map('sanitize_text_field', $donor_data); |
|
121 | + $address = array_map('sanitize_text_field', $address); |
|
122 | 122 | |
123 | - $output = give_connect_user_donor_profile( $donor, $donor_data, $address ); |
|
123 | + $output = give_connect_user_donor_profile($donor, $donor_data, $address); |
|
124 | 124 | |
125 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
126 | - header( 'Content-Type: application/json' ); |
|
127 | - echo json_encode( $output ); |
|
125 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
126 | + header('Content-Type: application/json'); |
|
127 | + echo json_encode($output); |
|
128 | 128 | wp_die(); |
129 | 129 | } |
130 | 130 | |
131 | - if ( $output['success'] ) { |
|
132 | - wp_redirect( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated" ) ); |
|
131 | + if ($output['success']) { |
|
132 | + wp_redirect(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated")); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | exit; |
136 | 136 | |
137 | 137 | } |
138 | 138 | |
139 | -add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 ); |
|
139 | +add_action('give_edit-donor', 'give_edit_donor', 10, 1); |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Save a donor note. |
@@ -147,40 +147,40 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return int The Note ID that was saved, or 0 if nothing was saved. |
149 | 149 | */ |
150 | -function give_donor_save_note( $args ) { |
|
150 | +function give_donor_save_note($args) { |
|
151 | 151 | |
152 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
152 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
153 | 153 | |
154 | - if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) { |
|
155 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
154 | + if ( ! is_admin() || ! current_user_can($donor_view_role)) { |
|
155 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
156 | 156 | 'response' => 403, |
157 | - ) ); |
|
157 | + )); |
|
158 | 158 | } |
159 | 159 | |
160 | - if ( empty( $args ) ) { |
|
160 | + if (empty($args)) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
164 | - $donor_note = trim( sanitize_text_field( $args['donor_note'] ) ); |
|
164 | + $donor_note = trim(sanitize_text_field($args['donor_note'])); |
|
165 | 165 | $donor_id = (int) $args['customer_id']; |
166 | 166 | $nonce = $args['add_donor_note_nonce']; |
167 | 167 | |
168 | - if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) { |
|
169 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
168 | + if ( ! wp_verify_nonce($nonce, 'add-donor-note')) { |
|
169 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
170 | 170 | 'response' => 400, |
171 | - ) ); |
|
171 | + )); |
|
172 | 172 | } |
173 | 173 | |
174 | - if ( empty( $donor_note ) ) { |
|
175 | - give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) ); |
|
174 | + if (empty($donor_note)) { |
|
175 | + give_set_error('empty-donor-note', __('A note is required.', 'give')); |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( give_get_errors() ) { |
|
178 | + if (give_get_errors()) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - $donor = new Give_Donor( $donor_id ); |
|
183 | - $new_note = $donor->add_note( $donor_note ); |
|
182 | + $donor = new Give_Donor($donor_id); |
|
183 | + $new_note = $donor->add_note($donor_note); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Fires before inserting donor note. |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @since 1.0 |
192 | 192 | */ |
193 | - do_action( 'give_pre_insert_donor_note', $donor_id, $new_note ); |
|
193 | + do_action('give_pre_insert_donor_note', $donor_id, $new_note); |
|
194 | 194 | |
195 | - if ( ! empty( $new_note ) && ! empty( $donor->id ) ) { |
|
195 | + if ( ! empty($new_note) && ! empty($donor->id)) { |
|
196 | 196 | |
197 | 197 | ob_start(); |
198 | 198 | ?> |
199 | 199 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
200 | 200 | <span class="note-content-wrap"> |
201 | - <?php echo stripslashes( $new_note ); ?> |
|
201 | + <?php echo stripslashes($new_note); ?> |
|
202 | 202 | </span> |
203 | 203 | </div> |
204 | 204 | <?php |
205 | 205 | $output = ob_get_contents(); |
206 | 206 | ob_end_clean(); |
207 | 207 | |
208 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
208 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
209 | 209 | echo $output; |
210 | 210 | exit; |
211 | 211 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | } |
220 | 220 | |
221 | -add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 ); |
|
221 | +add_action('give_add-donor-note', 'give_donor_save_note', 10, 1); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Delete a donor. |
@@ -229,41 +229,41 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return int Whether it was a successful deletion. |
231 | 231 | */ |
232 | -function give_donor_delete( $args ) { |
|
232 | +function give_donor_delete($args) { |
|
233 | 233 | |
234 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
234 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
235 | 235 | |
236 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
237 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
236 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
237 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
238 | 238 | 'response' => 403, |
239 | - ) ); |
|
239 | + )); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( empty( $args ) ) { |
|
242 | + if (empty($args)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | 246 | $donor_id = (int) $args['customer_id']; |
247 | - $confirm = ! empty( $args['give-donor-delete-confirm'] ) ? true : false; |
|
248 | - $remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false; |
|
247 | + $confirm = ! empty($args['give-donor-delete-confirm']) ? true : false; |
|
248 | + $remove_data = ! empty($args['give-donor-delete-records']) ? true : false; |
|
249 | 249 | $nonce = $args['_wpnonce']; |
250 | 250 | |
251 | - if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) { |
|
252 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
251 | + if ( ! wp_verify_nonce($nonce, 'delete-donor')) { |
|
252 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
253 | 253 | 'response' => 400, |
254 | - ) ); |
|
254 | + )); |
|
255 | 255 | } |
256 | 256 | |
257 | - if ( ! $confirm ) { |
|
258 | - give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
257 | + if ( ! $confirm) { |
|
258 | + give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give')); |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( give_get_errors() ) { |
|
262 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) ); |
|
261 | + if (give_get_errors()) { |
|
262 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id)); |
|
263 | 263 | exit; |
264 | 264 | } |
265 | 265 | |
266 | - $donor = new Give_Donor( $donor_id ); |
|
266 | + $donor = new Give_Donor($donor_id); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Fires before deleting donor. |
@@ -274,50 +274,50 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @since 1.0 |
276 | 276 | */ |
277 | - do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data ); |
|
277 | + do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data); |
|
278 | 278 | |
279 | - if ( $donor->id > 0 ) { |
|
279 | + if ($donor->id > 0) { |
|
280 | 280 | |
281 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
282 | - $success = Give()->donors->delete( $donor->id ); |
|
281 | + $payments_array = explode(',', $donor->payment_ids); |
|
282 | + $success = Give()->donors->delete($donor->id); |
|
283 | 283 | |
284 | - if ( $success ) { |
|
284 | + if ($success) { |
|
285 | 285 | |
286 | - if ( $remove_data ) { |
|
286 | + if ($remove_data) { |
|
287 | 287 | |
288 | 288 | // Remove all donations, logs, etc. |
289 | - foreach ( $payments_array as $payment_id ) { |
|
290 | - give_delete_donation( $payment_id ); |
|
289 | + foreach ($payments_array as $payment_id) { |
|
290 | + give_delete_donation($payment_id); |
|
291 | 291 | } |
292 | 292 | } else { |
293 | 293 | |
294 | 294 | // Just set the donations to customer_id of 0. |
295 | - foreach ( $payments_array as $payment_id ) { |
|
296 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
295 | + foreach ($payments_array as $payment_id) { |
|
296 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' ); |
|
300 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted'); |
|
301 | 301 | |
302 | 302 | } else { |
303 | 303 | |
304 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) ); |
|
305 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id ); |
|
304 | + give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give')); |
|
305 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | } else { |
309 | 309 | |
310 | - give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) ); |
|
311 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
310 | + give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give')); |
|
311 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
315 | - wp_redirect( $redirect ); |
|
315 | + wp_redirect($redirect); |
|
316 | 316 | exit; |
317 | 317 | |
318 | 318 | } |
319 | 319 | |
320 | -add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 ); |
|
320 | +add_action('give_delete-donor', 'give_donor_delete', 10, 1); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Disconnect a user ID from a donor |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return bool|array If the disconnect was successful. |
330 | 330 | */ |
331 | -function give_disconnect_donor_user_id( $args ) { |
|
331 | +function give_disconnect_donor_user_id($args) { |
|
332 | 332 | |
333 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
333 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
334 | 334 | |
335 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
336 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
335 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
336 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
337 | 337 | 'response' => 403, |
338 | - ) ); |
|
338 | + )); |
|
339 | 339 | } |
340 | 340 | |
341 | - if ( empty( $args ) ) { |
|
341 | + if (empty($args)) { |
|
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | |
347 | 347 | $nonce = $args['_wpnonce']; |
348 | 348 | |
349 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
350 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
349 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
350 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
351 | 351 | 'response' => 400, |
352 | - ) ); |
|
352 | + )); |
|
353 | 353 | } |
354 | 354 | |
355 | - $donor = new Give_Donor( $donor_id ); |
|
356 | - if ( empty( $donor->id ) ) { |
|
355 | + $donor = new Give_Donor($donor_id); |
|
356 | + if (empty($donor->id)) { |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
@@ -367,34 +367,34 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @since 1.0 |
369 | 369 | */ |
370 | - do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id ); |
|
370 | + do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id); |
|
371 | 371 | |
372 | 372 | $output = array(); |
373 | 373 | $donor_args = array( |
374 | 374 | 'user_id' => 0, |
375 | 375 | ); |
376 | 376 | |
377 | - if ( $donor->update( $donor_args ) ) { |
|
377 | + if ($donor->update($donor_args)) { |
|
378 | 378 | global $wpdb; |
379 | 379 | |
380 | - if ( ! empty( $donor->payment_ids ) ) { |
|
381 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" ); |
|
380 | + if ( ! empty($donor->payment_ids)) { |
|
381 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )"); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | // Set Donor Disconnection status true, if user and donor are disconnected with each other. |
385 | - update_user_meta( $user_id, '_give_is_donor_disconnected', true ); |
|
386 | - update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id ); |
|
387 | - $donor->update_meta( '_give_disconnected_user_id', $user_id ); |
|
385 | + update_user_meta($user_id, '_give_is_donor_disconnected', true); |
|
386 | + update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id); |
|
387 | + $donor->update_meta('_give_disconnected_user_id', $user_id); |
|
388 | 388 | |
389 | 389 | $output['success'] = true; |
390 | 390 | |
391 | 391 | } else { |
392 | 392 | |
393 | 393 | $output['success'] = false; |
394 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
394 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
395 | 395 | } |
396 | 396 | |
397 | - $output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id; |
|
397 | + $output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id; |
|
398 | 398 | |
399 | 399 | /** |
400 | 400 | * Fires after disconnecting user ID from a donor. |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @since 1.0 |
405 | 405 | */ |
406 | - do_action( 'give_post_donor_disconnect_user_id', $donor_id ); |
|
406 | + do_action('give_post_donor_disconnect_user_id', $donor_id); |
|
407 | 407 | |
408 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
409 | - header( 'Content-Type: application/json' ); |
|
410 | - echo json_encode( $output ); |
|
408 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
409 | + header('Content-Type: application/json'); |
|
410 | + echo json_encode($output); |
|
411 | 411 | wp_die(); |
412 | 412 | } |
413 | 413 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | -add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 ); |
|
418 | +add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1); |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Add an email address to the donor from within the admin and log a donor note. |
@@ -426,86 +426,86 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string). |
428 | 428 | */ |
429 | -function give_add_donor_email( $args ) { |
|
429 | +function give_add_donor_email($args) { |
|
430 | 430 | |
431 | 431 | $donor_id = ''; |
432 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
432 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
433 | 433 | |
434 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
435 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
434 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
435 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
436 | 436 | 'response' => 403, |
437 | - ) ); |
|
437 | + )); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $output = array(); |
441 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
441 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
442 | 442 | $output['success'] = false; |
443 | - if ( empty( $args['email'] ) ) { |
|
444 | - $output['message'] = __( 'Email address is required.', 'give' ); |
|
445 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
446 | - $output['message'] = __( 'Donor ID is required.', 'give' ); |
|
443 | + if (empty($args['email'])) { |
|
444 | + $output['message'] = __('Email address is required.', 'give'); |
|
445 | + } elseif (empty($args['customer_id'])) { |
|
446 | + $output['message'] = __('Donor ID is required.', 'give'); |
|
447 | 447 | } else { |
448 | - $output['message'] = __( 'An error has occurred. Please try again.', 'give' ); |
|
448 | + $output['message'] = __('An error has occurred. Please try again.', 'give'); |
|
449 | 449 | } |
450 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
450 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
451 | 451 | $output = array( |
452 | 452 | 'success' => false, |
453 | - 'message' => __( 'Nonce verification failed.', 'give' ), |
|
453 | + 'message' => __('Nonce verification failed.', 'give'), |
|
454 | 454 | ); |
455 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
455 | + } elseif ( ! is_email($args['email'])) { |
|
456 | 456 | $output = array( |
457 | 457 | 'success' => false, |
458 | - 'message' => __( 'Invalid email.', 'give' ), |
|
458 | + 'message' => __('Invalid email.', 'give'), |
|
459 | 459 | ); |
460 | 460 | } else { |
461 | - $email = sanitize_email( $args['email'] ); |
|
461 | + $email = sanitize_email($args['email']); |
|
462 | 462 | $donor_id = (int) $args['customer_id']; |
463 | 463 | $primary = 'true' === $args['primary'] ? true : false; |
464 | - $donor = new Give_Donor( $donor_id ); |
|
465 | - if ( false === $donor->add_email( $email, $primary ) ) { |
|
466 | - if ( in_array( $email, $donor->emails ) ) { |
|
464 | + $donor = new Give_Donor($donor_id); |
|
465 | + if (false === $donor->add_email($email, $primary)) { |
|
466 | + if (in_array($email, $donor->emails)) { |
|
467 | 467 | $output = array( |
468 | 468 | 'success' => false, |
469 | - 'message' => __( 'Email already associated with this donor.', 'give' ), |
|
469 | + 'message' => __('Email already associated with this donor.', 'give'), |
|
470 | 470 | ); |
471 | 471 | } else { |
472 | 472 | $output = array( |
473 | 473 | 'success' => false, |
474 | - 'message' => __( 'Email address is already associated with another donor.', 'give' ), |
|
474 | + 'message' => __('Email address is already associated with another donor.', 'give'), |
|
475 | 475 | ); |
476 | 476 | } |
477 | 477 | } else { |
478 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' ); |
|
478 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added'); |
|
479 | 479 | $output = array( |
480 | 480 | 'success' => true, |
481 | - 'message' => __( 'Email successfully added to donor.', 'give' ), |
|
481 | + 'message' => __('Email successfully added to donor.', 'give'), |
|
482 | 482 | 'redirect' => $redirect, |
483 | 483 | ); |
484 | 484 | |
485 | 485 | $user = wp_get_current_user(); |
486 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
487 | - $donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
488 | - $donor->add_note( $donor_note ); |
|
486 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
487 | + $donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
488 | + $donor->add_note($donor_note); |
|
489 | 489 | |
490 | - if ( $primary ) { |
|
491 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
492 | - $donor->add_note( $donor_note ); |
|
490 | + if ($primary) { |
|
491 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
492 | + $donor->add_note($donor_note); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } // End if(). |
496 | 496 | |
497 | - do_action( 'give_post_add_donor_email', $donor_id, $args ); |
|
497 | + do_action('give_post_add_donor_email', $donor_id, $args); |
|
498 | 498 | |
499 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
500 | - header( 'Content-Type: application/json' ); |
|
501 | - echo json_encode( $output ); |
|
499 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
500 | + header('Content-Type: application/json'); |
|
501 | + echo json_encode($output); |
|
502 | 502 | wp_die(); |
503 | 503 | } |
504 | 504 | |
505 | 505 | return $output; |
506 | 506 | } |
507 | 507 | |
508 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
508 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
509 | 509 | |
510 | 510 | |
511 | 511 | /** |
@@ -516,39 +516,39 @@ discard block |
||
516 | 516 | * @return bool|null |
517 | 517 | */ |
518 | 518 | function give_remove_donor_email() { |
519 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
519 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
520 | 520 | return false; |
521 | 521 | } |
522 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
522 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
523 | 523 | return false; |
524 | 524 | } |
525 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
525 | + if (empty($_GET['_wpnonce'])) { |
|
526 | 526 | return false; |
527 | 527 | } |
528 | 528 | |
529 | 529 | $nonce = $_GET['_wpnonce']; |
530 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
531 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
530 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
531 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
532 | 532 | 'response' => 403, |
533 | - ) ); |
|
533 | + )); |
|
534 | 534 | } |
535 | 535 | |
536 | - $donor = new Give_Donor( $_GET['id'] ); |
|
537 | - if ( $donor->remove_email( $_GET['email'] ) ) { |
|
538 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
536 | + $donor = new Give_Donor($_GET['id']); |
|
537 | + if ($donor->remove_email($_GET['email'])) { |
|
538 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
539 | 539 | $user = wp_get_current_user(); |
540 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
541 | - $donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
542 | - $donor->add_note( $donor_note ); |
|
540 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
541 | + $donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
542 | + $donor->add_note($donor_note); |
|
543 | 543 | } else { |
544 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
544 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
545 | 545 | } |
546 | 546 | |
547 | - wp_safe_redirect( $url ); |
|
547 | + wp_safe_redirect($url); |
|
548 | 548 | exit; |
549 | 549 | } |
550 | 550 | |
551 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
551 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
552 | 552 | |
553 | 553 | |
554 | 554 | /** |
@@ -560,44 +560,44 @@ discard block |
||
560 | 560 | * @return bool|null |
561 | 561 | */ |
562 | 562 | function give_set_donor_primary_email() { |
563 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
563 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
564 | 564 | return false; |
565 | 565 | } |
566 | 566 | |
567 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
567 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
568 | 568 | return false; |
569 | 569 | } |
570 | 570 | |
571 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
571 | + if (empty($_GET['_wpnonce'])) { |
|
572 | 572 | return false; |
573 | 573 | } |
574 | 574 | |
575 | 575 | $nonce = $_GET['_wpnonce']; |
576 | 576 | |
577 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
578 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
577 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
578 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
579 | 579 | 'response' => 403, |
580 | - ) ); |
|
580 | + )); |
|
581 | 581 | } |
582 | 582 | |
583 | - $donor = new Give_Donor( $_GET['id'] ); |
|
583 | + $donor = new Give_Donor($_GET['id']); |
|
584 | 584 | |
585 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
586 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
585 | + if ($donor->set_primary_email($_GET['email'])) { |
|
586 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
587 | 587 | $user = wp_get_current_user(); |
588 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
589 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
588 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
589 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login); |
|
590 | 590 | |
591 | - $donor->add_note( $donor_note ); |
|
591 | + $donor->add_note($donor_note); |
|
592 | 592 | } else { |
593 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
593 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
594 | 594 | } |
595 | 595 | |
596 | - wp_safe_redirect( $url ); |
|
596 | + wp_safe_redirect($url); |
|
597 | 597 | exit; |
598 | 598 | } |
599 | 599 | |
600 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
600 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
|
601 | 601 | |
602 | 602 | /** |
603 | 603 | * Delete Donor using Bulk Actions. |
@@ -608,57 +608,57 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return void |
610 | 610 | */ |
611 | -function give_delete_donor( $args ) { |
|
611 | +function give_delete_donor($args) { |
|
612 | 612 | |
613 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
613 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
614 | 614 | |
615 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
616 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
615 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
616 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
617 | 617 | 'response' => 403, |
618 | - ) ); |
|
618 | + )); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $give_args = array(); |
622 | - $donor_ids = ( ! empty( $_GET['donor'] ) && is_array( $_GET['donor'] ) && count( $_GET['donor'] ) > 0 ) ? $_GET['donor'] : array(); |
|
623 | - $delete_donor = ! empty( $_GET['give-delete-donor-confirm'] ) ? $_GET['give-delete-donor-confirm'] : ''; |
|
624 | - $delete_donations = ! empty( $_GET['give-delete-donor-records'] ) ? $_GET['give-delete-donor-records'] : ''; |
|
625 | - $search_keyword = ! empty( $_GET['s'] ) ? $_GET['s'] : ''; |
|
626 | - $give_args['orderby'] = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'id'; |
|
627 | - $give_args['order'] = ! empty( $_GET['order'] ) ? $_GET['order'] : 'desc'; |
|
622 | + $donor_ids = ( ! empty($_GET['donor']) && is_array($_GET['donor']) && count($_GET['donor']) > 0) ? $_GET['donor'] : array(); |
|
623 | + $delete_donor = ! empty($_GET['give-delete-donor-confirm']) ? $_GET['give-delete-donor-confirm'] : ''; |
|
624 | + $delete_donations = ! empty($_GET['give-delete-donor-records']) ? $_GET['give-delete-donor-records'] : ''; |
|
625 | + $search_keyword = ! empty($_GET['s']) ? $_GET['s'] : ''; |
|
626 | + $give_args['orderby'] = ! empty($_GET['orderby']) ? $_GET['orderby'] : 'id'; |
|
627 | + $give_args['order'] = ! empty($_GET['order']) ? $_GET['order'] : 'desc'; |
|
628 | 628 | $nonce = $args['_wpnonce']; |
629 | 629 | |
630 | 630 | // Verify Nonce for deleting bulk donors. |
631 | - if ( ! wp_verify_nonce( $nonce, 'bulk-donors' ) ) { |
|
632 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
631 | + if ( ! wp_verify_nonce($nonce, 'bulk-donors')) { |
|
632 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
633 | 633 | 'response' => 400, |
634 | - ) ); |
|
634 | + )); |
|
635 | 635 | } |
636 | 636 | |
637 | - if( count( $donor_ids ) > 0 ) { |
|
638 | - foreach ( $donor_ids as $donor_id ) { |
|
639 | - $donor = new Give_Donor( $donor_id ); |
|
637 | + if (count($donor_ids) > 0) { |
|
638 | + foreach ($donor_ids as $donor_id) { |
|
639 | + $donor = new Give_Donor($donor_id); |
|
640 | 640 | |
641 | - if ( $donor->id > 0 ) { |
|
641 | + if ($donor->id > 0) { |
|
642 | 642 | |
643 | - if( $delete_donor ) { |
|
644 | - $donor_deleted = Give()->donors->delete( $donor->id ); |
|
643 | + if ($delete_donor) { |
|
644 | + $donor_deleted = Give()->donors->delete($donor->id); |
|
645 | 645 | |
646 | - if ( $donor_deleted ) { |
|
647 | - $donation_ids = explode( ',', $donor->payment_ids ); |
|
646 | + if ($donor_deleted) { |
|
647 | + $donation_ids = explode(',', $donor->payment_ids); |
|
648 | 648 | |
649 | - if( $delete_donations ) { |
|
649 | + if ($delete_donations) { |
|
650 | 650 | |
651 | 651 | // Remove all donations, logs, etc. |
652 | - foreach ( $donation_ids as $donation_id ) { |
|
653 | - give_delete_donation( $donation_id ); |
|
652 | + foreach ($donation_ids as $donation_id) { |
|
653 | + give_delete_donation($donation_id); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | $give_args['give-message'] = 'donor-donations-deleted'; |
657 | 657 | } else { |
658 | 658 | |
659 | 659 | // Just set the donations to customer_id of 0. |
660 | - foreach ( $donation_ids as $donation_id ) { |
|
661 | - give_update_payment_meta( $donation_id, '_give_payment_customer_id', 0 ); |
|
660 | + foreach ($donation_ids as $donation_id) { |
|
661 | + give_update_payment_meta($donation_id, '_give_payment_customer_id', 0); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | $give_args['give-message'] = 'donor-deleted'; |
@@ -675,13 +675,13 @@ discard block |
||
675 | 675 | } |
676 | 676 | |
677 | 677 | // Add Search Keyword on redirection, if it exists. |
678 | - if ( ! empty( $search_keyword ) ) { |
|
678 | + if ( ! empty($search_keyword)) { |
|
679 | 679 | $give_args['s'] = $search_keyword; |
680 | 680 | } |
681 | 681 | |
682 | - wp_redirect( add_query_arg( $give_args, admin_url( 'edit.php?post_type=give_forms&page=give-donors' ) ) ); |
|
682 | + wp_redirect(add_query_arg($give_args, admin_url('edit.php?post_type=give_forms&page=give-donors'))); |
|
683 | 683 | give_die(); |
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
687 | -add_action( 'give_delete_donor', 'give_delete_donor' ); |
|
688 | 687 | \ No newline at end of file |
688 | +add_action('give_delete_donor', 'give_delete_donor'); |
|
689 | 689 | \ No newline at end of file |