@@ -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 do not want to registration instead want 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 alredy 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,33 +1197,33 @@ discard block |
||
1198 | 1197 | * |
1199 | 1198 | * @return bool |
1200 | 1199 | */ |
1201 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1200 | +function give_validate_multi_donation_form_level($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_multi_type_donation_form() ) { |
|
1206 | + if ($form->is_multi_type_donation_form()) { |
|
1208 | 1207 | |
1209 | 1208 | // Bailout. |
1210 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1209 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1211 | 1210 | return false; |
1212 | 1211 | } |
1213 | 1212 | |
1214 | 1213 | // Sanitize donation amount. |
1215 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1214 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1216 | 1215 | |
1217 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1216 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1218 | 1217 | return true; |
1219 | 1218 | } |
1220 | 1219 | |
1221 | 1220 | // Find correct donation level from all donation levels. |
1222 | - foreach ( $variable_prices as $variable_price ) { |
|
1221 | + foreach ($variable_prices as $variable_price) { |
|
1223 | 1222 | // Sanitize level amount. |
1224 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1223 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1225 | 1224 | |
1226 | 1225 | // Set first match donation level ID. |
1227 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1226 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1228 | 1227 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1229 | 1228 | $donation_level_matched = true; |
1230 | 1229 | break; |
@@ -1235,19 +1234,19 @@ discard block |
||
1235 | 1234 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1236 | 1235 | if ( |
1237 | 1236 | ! $donation_level_matched |
1238 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1237 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1239 | 1238 | ) { |
1240 | 1239 | // Sanitize custom minimum amount. |
1241 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
1240 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
1242 | 1241 | |
1243 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1242 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1244 | 1243 | $_POST['give-price-id'] = 'custom'; |
1245 | 1244 | $donation_level_matched = true; |
1246 | 1245 | } |
1247 | 1246 | } |
1248 | 1247 | }// End if(). |
1249 | 1248 | |
1250 | - return ( $donation_level_matched ? true : false ); |
|
1249 | + return ($donation_level_matched ? true : false); |
|
1251 | 1250 | } |
1252 | 1251 | |
1253 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1252 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 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,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | give_setup_post_types(); |
62 | 62 | |
63 | 63 | // Add Upgraded From Option. |
64 | - $current_version = get_option( 'give_version' ); |
|
65 | - if ( $current_version ) { |
|
66 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
64 | + $current_version = get_option('give_version'); |
|
65 | + if ($current_version) { |
|
66 | + update_option('give_version_upgraded_from', $current_version); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Setup some default options. |
70 | 70 | $options = array(); |
71 | 71 | |
72 | 72 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
73 | - if ( empty( $current_version ) ) { |
|
74 | - $options = array_merge( $options, give_get_default_settings() ); |
|
73 | + if (empty($current_version)) { |
|
74 | + $options = array_merge($options, give_get_default_settings()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Populate the default values. |
78 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
78 | + update_option('give_settings', array_merge($give_options, $options)); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Run plugin upgrades. |
82 | 82 | * |
83 | 83 | * @since 1.8 |
84 | 84 | */ |
85 | - do_action( 'give_upgrades' ); |
|
85 | + do_action('give_upgrades'); |
|
86 | 86 | |
87 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
88 | - update_option( 'give_version', GIVE_VERSION ); |
|
87 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
88 | + update_option('give_version', GIVE_VERSION); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Create Give roles. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Set api version, end point and refresh permalink. |
97 | 97 | $api = new Give_API(); |
98 | 98 | $api->add_endpoint(); |
99 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
99 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
100 | 100 | |
101 | 101 | flush_rewrite_rules(); |
102 | 102 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $give_sessions->use_php_sessions(); |
106 | 106 | |
107 | 107 | // Add a temporary option to note that Give pages have been created. |
108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
109 | 109 | |
110 | - if ( ! $current_version ) { |
|
110 | + if ( ! $current_version) { |
|
111 | 111 | |
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
113 | 113 | |
114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
115 | 115 | $upgrade_routines = array( |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | 'v1813_update_donor_user_roles' |
126 | 126 | ); |
127 | 127 | |
128 | - foreach ( $upgrade_routines as $upgrade ) { |
|
129 | - give_set_upgrade_complete( $upgrade ); |
|
128 | + foreach ($upgrade_routines as $upgrade) { |
|
129 | + give_set_upgrade_complete($upgrade); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Bail if activating from network, or bulk. |
134 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
134 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Add the transient to redirect. |
139 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
139 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * @param int $site_id The Site ID. |
154 | 154 | * @param array $meta Blog Meta. |
155 | 155 | */ |
156 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
156 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
157 | 157 | |
158 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
158 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
159 | 159 | |
160 | - switch_to_blog( $blog_id ); |
|
160 | + switch_to_blog($blog_id); |
|
161 | 161 | give_install(); |
162 | 162 | restore_current_blog(); |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
168 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return array The tables to drop. |
180 | 180 | */ |
181 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
181 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
182 | 182 | |
183 | - switch_to_blog( $blog_id ); |
|
183 | + switch_to_blog($blog_id); |
|
184 | 184 | $donors_db = new Give_DB_Donors(); |
185 | 185 | $donor_meta_db = new Give_DB_Donor_Meta(); |
186 | 186 | |
187 | - if ( $donors_db->installed() ) { |
|
187 | + if ($donors_db->installed()) { |
|
188 | 188 | $tables[] = $donors_db->table_name; |
189 | 189 | $tables[] = $donor_meta_db->table_name; |
190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
197 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Post-installation |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function give_after_install() { |
208 | 208 | |
209 | - if ( ! is_admin() ) { |
|
209 | + if ( ! is_admin()) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | 212 | |
213 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
214 | - $give_table_check = get_option( '_give_table_check', false ); |
|
213 | + $give_options = Give_Cache::get('_give_installed', true); |
|
214 | + $give_table_check = get_option('_give_table_check', false); |
|
215 | 215 | |
216 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
216 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
217 | 217 | |
218 | - if ( ! @Give()->donor_meta->installed() ) { |
|
218 | + if ( ! @Give()->donor_meta->installed()) { |
|
219 | 219 | |
220 | 220 | // Create the donor meta database. |
221 | 221 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! @Give()->donors->installed() ) { |
|
226 | + if ( ! @Give()->donors->installed()) { |
|
227 | 227 | // Create the donor database. |
228 | 228 | // (this ensures it creates it on multisite instances where it is network activated). |
229 | 229 | @Give()->donors->create_table(); |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param array $give_options Give plugin options. |
237 | 237 | */ |
238 | - do_action( 'give_after_install', $give_options ); |
|
238 | + do_action('give_after_install', $give_options); |
|
239 | 239 | } |
240 | 240 | |
241 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
241 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Delete the transient |
246 | - if ( false !== $give_options ) { |
|
247 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
246 | + if (false !== $give_options) { |
|
247 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | 251 | } |
252 | 252 | |
253 | -add_action( 'admin_init', 'give_after_install' ); |
|
253 | +add_action('admin_init', 'give_after_install'); |
|
254 | 254 | |
255 | 255 | |
256 | 256 | /** |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | global $wp_roles; |
267 | 267 | |
268 | - if ( ! is_object( $wp_roles ) ) { |
|
268 | + if ( ! is_object($wp_roles)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
272 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
273 | 273 | |
274 | 274 | // Create Give plugin roles |
275 | 275 | $roles = new Give_Roles(); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
283 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Default core setting values. |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | 'uninstall_on_delete' => 'disabled', |
319 | 319 | 'the_content_filter' => 'enabled', |
320 | 320 | 'scripts_footer' => 'disabled', |
321 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
321 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
322 | 322 | 'agreement_text' => give_get_default_agreement_text(), |
323 | 323 | |
324 | 324 | // Paypal IPN verification. |
325 | 325 | 'paypal_verification' => 'enabled', |
326 | 326 | |
327 | 327 | // Default is manual gateway. |
328 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
328 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
329 | 329 | 'default_gateway' => 'manual', |
330 | 330 | |
331 | 331 | // Offline gateway setup. |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | function give_get_default_agreement_text() { |
355 | 355 | |
356 | - $org_name = get_bloginfo( 'name' ); |
|
356 | + $org_name = get_bloginfo('name'); |
|
357 | 357 | |
358 | 358 | $agreement = sprintf( |
359 | 359 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $org_name |
368 | 368 | ); |
369 | 369 | |
370 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
370 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -376,22 +376,22 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @since 1.8.11 |
378 | 378 | */ |
379 | -function give_create_pages(){ |
|
379 | +function give_create_pages() { |
|
380 | 380 | |
381 | 381 | // Bailout if pages already created. |
382 | - if( get_option( 'give_install_pages_created') ) { |
|
382 | + if (get_option('give_install_pages_created')) { |
|
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $options = array(); |
387 | 387 | |
388 | 388 | // Checks if the Success Page option exists AND that the page exists. |
389 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
389 | + if ( ! get_post(give_get_option('success_page'))) { |
|
390 | 390 | |
391 | 391 | // Donation Confirmation (Success) Page |
392 | 392 | $success = wp_insert_post( |
393 | 393 | array( |
394 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
394 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
395 | 395 | 'post_content' => '[give_receipt]', |
396 | 396 | 'post_status' => 'publish', |
397 | 397 | 'post_author' => 1, |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | // Checks if the Failure Page option exists AND that the page exists. |
408 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
408 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
409 | 409 | |
410 | 410 | // Failed Donation Page |
411 | 411 | $failed = wp_insert_post( |
412 | 412 | array( |
413 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
414 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
413 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
414 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
415 | 415 | 'post_status' => 'publish', |
416 | 416 | 'post_author' => 1, |
417 | 417 | 'post_type' => 'page', |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Checks if the History Page option exists AND that the page exists. |
426 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
426 | + if ( ! get_post(give_get_option('history_page'))) { |
|
427 | 427 | // Donation History Page |
428 | 428 | $history = wp_insert_post( |
429 | 429 | array( |
430 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
430 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
431 | 431 | 'post_content' => '[donation_history]', |
432 | 432 | 'post_status' => 'publish', |
433 | 433 | 'post_author' => 1, |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $options['history_page'] = $history; |
440 | 440 | } |
441 | 441 | |
442 | - if( ! empty( $options ) ) { |
|
443 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
442 | + if ( ! empty($options)) { |
|
443 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
444 | 444 | } |
445 | 445 | |
446 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
446 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
447 | 447 | } |
448 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
448 | +add_action('admin_init', 'give_create_pages', -1); |
@@ -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 | |
@@ -25,52 +25,52 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | -function give_update_payment_details( $data ) { |
|
28 | +function give_update_payment_details($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
34 | + check_admin_referer('give_update_payment_details_nonce'); |
|
35 | 35 | |
36 | 36 | // Retrieve the payment ID. |
37 | - $payment_id = absint( $data['give_payment_id'] ); |
|
37 | + $payment_id = absint($data['give_payment_id']); |
|
38 | 38 | |
39 | 39 | /* @var Give_Payment $payment */ |
40 | - $payment = new Give_Payment( $payment_id ); |
|
40 | + $payment = new Give_Payment($payment_id); |
|
41 | 41 | |
42 | 42 | // Retrieve existing payment meta. |
43 | 43 | $meta = $payment->get_meta(); |
44 | 44 | $user_info = $payment->user_info; |
45 | 45 | |
46 | 46 | $status = $data['give-payment-status']; |
47 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
48 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
47 | + $date = sanitize_text_field($data['give-payment-date']); |
|
48 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
49 | 49 | |
50 | 50 | // Restrict to our high and low. |
51 | - if ( $hour > 23 ) { |
|
51 | + if ($hour > 23) { |
|
52 | 52 | $hour = 23; |
53 | - } elseif ( $hour < 0 ) { |
|
53 | + } elseif ($hour < 0) { |
|
54 | 54 | $hour = 00; |
55 | 55 | } |
56 | 56 | |
57 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
57 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
58 | 58 | |
59 | 59 | // Restrict to our high and low. |
60 | - if ( $minute > 59 ) { |
|
60 | + if ($minute > 59) { |
|
61 | 61 | $minute = 59; |
62 | - } elseif ( $minute < 0 ) { |
|
62 | + } elseif ($minute < 0) { |
|
63 | 63 | $minute = 00; |
64 | 64 | } |
65 | 65 | |
66 | - $address = give_clean( $data['give-payment-address'][0] ); |
|
66 | + $address = give_clean($data['give-payment-address'][0]); |
|
67 | 67 | |
68 | 68 | $curr_total = $payment->total; |
69 | - $new_total = give_maybe_sanitize_amount( $data['give-payment-total'] ); |
|
70 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $new_total = give_maybe_sanitize_amount($data['give-payment-total']); |
|
70 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
71 | 71 | |
72 | - $curr_donor_id = sanitize_text_field( $data['give-current-donor'] ); |
|
73 | - $new_donor_id = sanitize_text_field( $data['donor-id'] ); |
|
72 | + $curr_donor_id = sanitize_text_field($data['give-current-donor']); |
|
73 | + $new_donor_id = sanitize_text_field($data['donor-id']); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Fires before updating edited donation. |
@@ -80,98 +80,98 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $payment_id The ID of the payment. |
82 | 82 | */ |
83 | - do_action( 'give_update_edited_donation', $payment_id ); |
|
83 | + do_action('give_update_edited_donation', $payment_id); |
|
84 | 84 | |
85 | 85 | $payment->date = $date; |
86 | 86 | $updated = $payment->save(); |
87 | 87 | |
88 | - if ( 0 === $updated ) { |
|
89 | - wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
88 | + if (0 === $updated) { |
|
89 | + wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $donor_changed = false; |
93 | 93 | |
94 | - if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) { |
|
94 | + if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') { |
|
95 | 95 | |
96 | - $email = isset( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : ''; |
|
97 | - $names = isset( $data['give-new-donor-name'] ) ? sanitize_text_field( $data['give-new-donor-name'] ) : ''; |
|
96 | + $email = isset($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : ''; |
|
97 | + $names = isset($data['give-new-donor-name']) ? sanitize_text_field($data['give-new-donor-name']) : ''; |
|
98 | 98 | |
99 | - if ( empty( $email ) || empty( $names ) ) { |
|
100 | - wp_die( esc_html__( 'New donors require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
99 | + if (empty($email) || empty($names)) { |
|
100 | + wp_die(esc_html__('New donors require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
101 | 101 | } |
102 | 102 | |
103 | - $donor = new Give_Donor( $email ); |
|
104 | - if ( empty( $donor->id ) ) { |
|
105 | - $donor_data = array( 'name' => $names, 'email' => $email ); |
|
106 | - $user_id = email_exists( $email ); |
|
107 | - if ( false !== $user_id ) { |
|
103 | + $donor = new Give_Donor($email); |
|
104 | + if (empty($donor->id)) { |
|
105 | + $donor_data = array('name' => $names, 'email' => $email); |
|
106 | + $user_id = email_exists($email); |
|
107 | + if (false !== $user_id) { |
|
108 | 108 | $donor_data['user_id'] = $user_id; |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! $donor->create( $donor_data ) ) { |
|
111 | + if ( ! $donor->create($donor_data)) { |
|
112 | 112 | // Failed to crete the new donor, assume the previous donor. |
113 | 113 | $donor_changed = false; |
114 | - $donor = new Give_Donor( $curr_donor_id ); |
|
115 | - give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) ); |
|
114 | + $donor = new Give_Donor($curr_donor_id); |
|
115 | + give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give')); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | $new_donor_id = $donor->id; |
120 | 120 | |
121 | - $previous_donor = new Give_Donor( $curr_donor_id ); |
|
121 | + $previous_donor = new Give_Donor($curr_donor_id); |
|
122 | 122 | |
123 | 123 | $donor_changed = true; |
124 | 124 | |
125 | - } elseif ( $curr_donor_id !== $new_donor_id ) { |
|
125 | + } elseif ($curr_donor_id !== $new_donor_id) { |
|
126 | 126 | |
127 | - $donor = new Give_Donor( $new_donor_id ); |
|
127 | + $donor = new Give_Donor($new_donor_id); |
|
128 | 128 | $email = $donor->email; |
129 | 129 | $names = $donor->name; |
130 | 130 | |
131 | - $previous_donor = new Give_Donor( $curr_donor_id ); |
|
131 | + $previous_donor = new Give_Donor($curr_donor_id); |
|
132 | 132 | |
133 | 133 | $donor_changed = true; |
134 | 134 | |
135 | 135 | } else { |
136 | 136 | |
137 | - $donor = new Give_Donor( $curr_donor_id ); |
|
137 | + $donor = new Give_Donor($curr_donor_id); |
|
138 | 138 | $email = $donor->email; |
139 | 139 | $names = $donor->name; |
140 | 140 | |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Setup first and last name from input values. |
144 | - $names = explode( ' ', $names ); |
|
145 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
144 | + $names = explode(' ', $names); |
|
145 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
146 | 146 | $last_name = ''; |
147 | - if ( ! empty( $names[1] ) ) { |
|
148 | - unset( $names[0] ); |
|
149 | - $last_name = implode( ' ', $names ); |
|
147 | + if ( ! empty($names[1])) { |
|
148 | + unset($names[0]); |
|
149 | + $last_name = implode(' ', $names); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( $donor_changed ) { |
|
152 | + if ($donor_changed) { |
|
153 | 153 | |
154 | 154 | // Remove the stats and payment from the previous donor and attach it to the new donor. |
155 | - $previous_donor->remove_payment( $payment_id, false ); |
|
156 | - $donor->attach_payment( $payment_id, false ); |
|
155 | + $previous_donor->remove_payment($payment_id, false); |
|
156 | + $donor->attach_payment($payment_id, false); |
|
157 | 157 | |
158 | - if ( 'publish' == $status ) { |
|
158 | + if ('publish' == $status) { |
|
159 | 159 | |
160 | 160 | // Reduce previous user donation count and amount. |
161 | 161 | $previous_donor->decrease_donation_count(); |
162 | - $previous_donor->decrease_value( $curr_total ); |
|
162 | + $previous_donor->decrease_value($curr_total); |
|
163 | 163 | |
164 | 164 | // If donation was completed adjust stats of new donors. |
165 | 165 | $donor->increase_purchase_count(); |
166 | - $donor->increase_value( $new_total ); |
|
166 | + $donor->increase_value($new_total); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $payment->customer_id = $donor->id; |
170 | 170 | } else { |
171 | 171 | |
172 | - if ( 'publish' === $status ) { |
|
172 | + if ('publish' === $status) { |
|
173 | 173 | // Update user donation stat. |
174 | - $donor->update_donation_value( $curr_total, $new_total ); |
|
174 | + $donor->update_donation_value($curr_total, $new_total); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | $payment->total = $new_total; |
185 | 185 | |
186 | 186 | // Check for payment notes. |
187 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
187 | + if ( ! empty($data['give-payment-note'])) { |
|
188 | 188 | |
189 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
190 | - give_insert_payment_note( $payment_id, $note ); |
|
189 | + $note = wp_kses($data['give-payment-note'], array()); |
|
190 | + give_insert_payment_note($payment_id, $note); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | $payment->status = $status; |
196 | 196 | |
197 | 197 | // Adjust total store earnings if the payment total has been changed. |
198 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
198 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
199 | 199 | |
200 | - if ( $new_total > $curr_total ) { |
|
200 | + if ($new_total > $curr_total) { |
|
201 | 201 | // Increase if our new total is higher. |
202 | 202 | $difference = $new_total - $curr_total; |
203 | - give_increase_total_earnings( $difference ); |
|
203 | + give_increase_total_earnings($difference); |
|
204 | 204 | |
205 | - } elseif ( $curr_total > $new_total ) { |
|
205 | + } elseif ($curr_total > $new_total) { |
|
206 | 206 | // Decrease if our new total is lower. |
207 | 207 | $difference = $curr_total - $new_total; |
208 | - give_decrease_total_earnings( $difference ); |
|
208 | + give_decrease_total_earnings($difference); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | } |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | $payment->save(); |
214 | 214 | |
215 | 215 | // Get new give form ID. |
216 | - $new_form_id = absint( $data['give-payment-form-select'] ); |
|
217 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
216 | + $new_form_id = absint($data['give-payment-form-select']); |
|
217 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
218 | 218 | |
219 | 219 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
220 | 220 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
221 | 221 | // Check if user want to transfer current payment to new give form id. |
222 | - if ( $new_form_id != $current_form_id ) { |
|
222 | + if ($new_form_id != $current_form_id) { |
|
223 | 223 | |
224 | 224 | // Get new give form title. |
225 | - $new_form_title = get_the_title( $new_form_id ); |
|
225 | + $new_form_title = get_the_title($new_form_id); |
|
226 | 226 | |
227 | 227 | // Update new give form data in payment data. |
228 | 228 | $payment_meta = $payment->get_meta(); |
@@ -230,43 +230,43 @@ discard block |
||
230 | 230 | $payment_meta['form_id'] = $new_form_id; |
231 | 231 | |
232 | 232 | // Update price id post meta data for set donation form. |
233 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
233 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
234 | 234 | $payment_meta['price_id'] = ''; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Update payment give form meta data. |
238 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
239 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
240 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
238 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
239 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
240 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
241 | 241 | |
242 | 242 | // Update price id payment metadata. |
243 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
244 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
243 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
244 | + $payment->update_meta('_give_payment_price_id', ''); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // If donation was completed, adjust stats of forms. |
248 | - if ( 'publish' == $status ) { |
|
248 | + if ('publish' == $status) { |
|
249 | 249 | |
250 | 250 | // Decrease sale of old give form. For other payment status. |
251 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
251 | + $current_form = new Give_Donate_Form($current_form_id); |
|
252 | 252 | $current_form->decrease_sales(); |
253 | - $current_form->decrease_earnings( $curr_total ); |
|
253 | + $current_form->decrease_earnings($curr_total); |
|
254 | 254 | |
255 | 255 | // Increase sale of new give form. |
256 | - $new_form = new Give_Donate_Form( $new_form_id ); |
|
256 | + $new_form = new Give_Donate_Form($new_form_id); |
|
257 | 257 | $new_form->increase_sales(); |
258 | - $new_form->increase_earnings( $new_total ); |
|
258 | + $new_form->increase_earnings($new_total); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Re setup payment to update new meta value in object. |
262 | - $payment->update_payment_setup( $payment->ID ); |
|
262 | + $payment->update_payment_setup($payment->ID); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | // Update price id if current form is variable form. |
266 | 266 | /* @var Give_Donate_Form $form */ |
267 | - $form = new Give_Donate_Form( $payment->form_id ); |
|
267 | + $form = new Give_Donate_Form($payment->form_id); |
|
268 | 268 | |
269 | - if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) { |
|
269 | + if (isset($data['give-variable-price']) && $form->has_variable_prices()) { |
|
270 | 270 | |
271 | 271 | // Get payment meta data. |
272 | 272 | $payment_meta = $payment->get_meta(); |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | $price_id = ''; |
276 | 276 | |
277 | 277 | // Get price info |
278 | - if( 0 <= $data['give-variable-price'] ) { |
|
279 | - foreach ( $form->prices as $variable_price ) { |
|
280 | - if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) { |
|
278 | + if (0 <= $data['give-variable-price']) { |
|
279 | + foreach ($form->prices as $variable_price) { |
|
280 | + if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) { |
|
281 | 281 | $price_info = $variable_price; |
282 | 282 | break; |
283 | 283 | } |
@@ -285,15 +285,15 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | // Set price id. |
288 | - if( ! empty( $price_info ) ) { |
|
288 | + if ( ! empty($price_info)) { |
|
289 | 289 | $price_id = $data['give-variable-price']; |
290 | 290 | |
291 | - if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) { |
|
291 | + if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) { |
|
292 | 292 | // Set price id to amount match. |
293 | 293 | $price_id = $price_info['_give_id']['level_id']; |
294 | 294 | } |
295 | 295 | |
296 | - } elseif( $form->is_custom_price_mode() ){ |
|
296 | + } elseif ($form->is_custom_price_mode()) { |
|
297 | 297 | $price_id = 'custom'; |
298 | 298 | } |
299 | 299 | |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | $payment_meta['price_id'] = $price_id; |
302 | 302 | |
303 | 303 | // Update payment give form meta data. |
304 | - $payment->update_meta( '_give_payment_price_id', $price_id ); |
|
305 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
304 | + $payment->update_meta('_give_payment_price_id', $price_id); |
|
305 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
306 | 306 | |
307 | 307 | // Re setup payment to update new meta value in object. |
308 | - $payment->update_payment_setup( $payment->ID ); |
|
308 | + $payment->update_payment_setup($payment->ID); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @param int $payment_id The ID of the payment. |
318 | 318 | */ |
319 | - do_action( 'give_updated_edited_donation', $payment_id ); |
|
319 | + do_action('give_updated_edited_donation', $payment_id); |
|
320 | 320 | |
321 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
321 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id='.$payment_id)); |
|
322 | 322 | exit; |
323 | 323 | } |
324 | 324 | |
325 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
325 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Trigger a Donation Deletion. |
@@ -333,48 +333,48 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @return void |
335 | 335 | */ |
336 | -function give_trigger_donation_delete( $data ) { |
|
337 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) { |
|
336 | +function give_trigger_donation_delete($data) { |
|
337 | + if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) { |
|
338 | 338 | |
339 | - $payment_id = absint( $data['purchase_id'] ); |
|
339 | + $payment_id = absint($data['purchase_id']); |
|
340 | 340 | |
341 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
342 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
341 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
342 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
343 | 343 | } |
344 | 344 | |
345 | - give_delete_donation( $payment_id ); |
|
346 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) ); |
|
345 | + give_delete_donation($payment_id); |
|
346 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted')); |
|
347 | 347 | give_die(); |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'give_delete_payment', 'give_trigger_donation_delete' ); |
|
351 | +add_action('give_delete_payment', 'give_trigger_donation_delete'); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * AJAX Store Donation Note |
355 | 355 | */ |
356 | 356 | function give_ajax_store_payment_note() { |
357 | 357 | |
358 | - $payment_id = absint( $_POST['payment_id'] ); |
|
359 | - $note = wp_kses( $_POST['note'], array() ); |
|
358 | + $payment_id = absint($_POST['payment_id']); |
|
359 | + $note = wp_kses($_POST['note'], array()); |
|
360 | 360 | |
361 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
362 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
361 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
362 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
363 | 363 | } |
364 | 364 | |
365 | - if ( empty( $payment_id ) ) { |
|
366 | - die( '-1' ); |
|
365 | + if (empty($payment_id)) { |
|
366 | + die('-1'); |
|
367 | 367 | } |
368 | 368 | |
369 | - if ( empty( $note ) ) { |
|
370 | - die( '-1' ); |
|
369 | + if (empty($note)) { |
|
370 | + die('-1'); |
|
371 | 371 | } |
372 | 372 | |
373 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
374 | - die( give_get_payment_note_html( $note_id ) ); |
|
373 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
374 | + die(give_get_payment_note_html($note_id)); |
|
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
377 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Triggers a donation note deletion without ajax |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return void |
387 | 387 | */ |
388 | -function give_trigger_payment_note_deletion( $data ) { |
|
388 | +function give_trigger_payment_note_deletion($data) { |
|
389 | 389 | |
390 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
390 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
391 | 391 | return; |
392 | 392 | } |
393 | 393 | |
394 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
395 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
394 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
395 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
396 | 396 | } |
397 | 397 | |
398 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
398 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id='.absint($data['payment_id'])); |
|
399 | 399 | |
400 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
400 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
401 | 401 | |
402 | - wp_redirect( $edit_order_url ); |
|
402 | + wp_redirect($edit_order_url); |
|
403 | 403 | } |
404 | 404 | |
405 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
405 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
406 | 406 | |
407 | 407 | /** |
408 | 408 | * Delete a payment note deletion with ajax |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | */ |
414 | 414 | function give_ajax_delete_payment_note() { |
415 | 415 | |
416 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
417 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
416 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
417 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
418 | 418 | } |
419 | 419 | |
420 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
421 | - die( '1' ); |
|
420 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
421 | + die('1'); |
|
422 | 422 | } else { |
423 | - die( '-1' ); |
|
423 | + die('-1'); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | } |
427 | 427 | |
428 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
428 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |
@@ -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,44 +238,44 @@ 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 | } else { |
254 | 254 | } |
255 | 255 | } else { |
256 | 256 | // Add is used to ensure duplicate emails are not added |
257 | - if ( $donor_data->email != $data['email'] ) { |
|
258 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
257 | + if ($donor_data->email != $data['email']) { |
|
258 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
259 | 259 | } |
260 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
260 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
264 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
265 | 265 | |
266 | - $donor_data = new Give_Donor( $data['email'] ); |
|
267 | - if ( empty( $donor_data->id ) ) { |
|
268 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
266 | + $donor_data = new Give_Donor($data['email']); |
|
267 | + if (empty($donor_data->id)) { |
|
268 | + $donor_data = get_user_by('email', $data['email']); |
|
269 | 269 | |
270 | - if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
271 | - $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' ) ) ); |
|
270 | + if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
271 | + $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'))); |
|
272 | 272 | $donor_args = array( |
273 | 273 | 'user_login' => $data['email'], |
274 | 274 | 'user_email' => $data['email'], |
275 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
275 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
276 | 276 | 'user_first' => $data['first_name'], |
277 | 277 | 'user_last' => $data['last_name'], |
278 | - 'user_pass' => wp_generate_password( 8, true ), |
|
278 | + 'user_pass' => wp_generate_password(8, true), |
|
279 | 279 | 'role' => $give_role, |
280 | 280 | ); |
281 | 281 | |
@@ -284,56 +284,56 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 1.8.13 |
286 | 286 | */ |
287 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
287 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
288 | 288 | |
289 | 289 | // This action was added to remove the login when using the give register function. |
290 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
291 | - $customer_id = give_register_and_login_new_user( $donor_args ); |
|
292 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
290 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
291 | + $customer_id = give_register_and_login_new_user($donor_args); |
|
292 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
293 | 293 | |
294 | - update_user_meta( $customer_id, '_give_payment_import', true ); |
|
295 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
294 | + update_user_meta($customer_id, '_give_payment_import', true); |
|
295 | + $donor_data = new Give_Donor($customer_id, true); |
|
296 | 296 | } else { |
297 | - $customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
297 | + $customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
298 | 298 | } |
299 | 299 | |
300 | - if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
301 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
300 | + if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
301 | + $donor_data = new Give_Donor($customer_id, true); |
|
302 | 302 | |
303 | - if ( empty( $donor_data->id ) ) { |
|
303 | + if (empty($donor_data->id)) { |
|
304 | 304 | |
305 | - if ( ! empty( $data['form_id'] ) ) { |
|
306 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
305 | + if ( ! empty($data['form_id'])) { |
|
306 | + $form = new Give_Donate_Form($data['form_id']); |
|
307 | 307 | } |
308 | 308 | |
309 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
309 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
310 | 310 | $donor_args = array( |
311 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
311 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
312 | 312 | 'email' => $data['email'], |
313 | 313 | ); |
314 | 314 | |
315 | - if ( ! empty( $customer_id ) ) { |
|
315 | + if ( ! empty($customer_id)) { |
|
316 | 316 | $donor_args['user_id'] = $customer_id; |
317 | 317 | } |
318 | 318 | |
319 | - $donor_data->create( $donor_args ); |
|
319 | + $donor_data->create($donor_args); |
|
320 | 320 | |
321 | 321 | // Adding notes that donor is being imported from CSV. |
322 | 322 | $current_user = wp_get_current_user(); |
323 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
323 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
324 | 324 | |
325 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
325 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
326 | 326 | } else { |
327 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
327 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } else { |
331 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
331 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
332 | 332 | } |
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,33 +369,33 @@ 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' ), |
|
374 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
375 | - 'post_date' => __( 'Donation Date', 'give' ), |
|
376 | - 'first_name' => __( 'Donor First Name', 'give' ), |
|
377 | - 'last_name' => __( 'Donor Last Name', 'give' ), |
|
378 | - 'line1' => __( 'Address 1', 'give' ), |
|
379 | - 'line2' => __( 'Address 2', 'give' ), |
|
380 | - 'city' => __( 'City', 'give' ), |
|
381 | - 'state' => __( 'State', 'give' ), |
|
372 | + return (array) apply_filters('give_import_donations_options', array( |
|
373 | + 'id' => __('Donation ID', 'give'), |
|
374 | + 'amount' => __('Donation Amount', 'give'), |
|
375 | + 'post_date' => __('Donation Date', 'give'), |
|
376 | + 'first_name' => __('Donor First Name', 'give'), |
|
377 | + 'last_name' => __('Donor Last Name', 'give'), |
|
378 | + 'line1' => __('Address 1', 'give'), |
|
379 | + 'line2' => __('Address 2', 'give'), |
|
380 | + 'city' => __('City', 'give'), |
|
381 | + 'state' => __('State', 'give'), |
|
382 | 382 | 'country' => array( |
383 | - __( 'Country', 'give' ), |
|
384 | - __( 'County', 'give' ), |
|
385 | - __( 'Region', 'give' ), |
|
386 | - __( 'Province', 'give' ), |
|
383 | + __('Country', 'give'), |
|
384 | + __('County', 'give'), |
|
385 | + __('Region', 'give'), |
|
386 | + __('Province', 'give'), |
|
387 | 387 | ), |
388 | 388 | 'zip' => array( |
389 | - __( 'Zip', 'give' ), |
|
390 | - __( 'Postal Code', 'give' ), |
|
389 | + __('Zip', 'give'), |
|
390 | + __('Postal Code', 'give'), |
|
391 | 391 | ), |
392 | - 'email' => __( 'Donor Email', 'give' ), |
|
393 | - 'post_status' => __( 'Donation Status', 'give' ), |
|
394 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
395 | - 'notes' => __( 'Notes', 'give' ), |
|
396 | - 'mode' => __( 'Test Mode', 'give' ), |
|
397 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
398 | - ) ); |
|
392 | + 'email' => __('Donor Email', 'give'), |
|
393 | + 'post_status' => __('Donation Status', 'give'), |
|
394 | + 'gateway' => __('Payment Method', 'give'), |
|
395 | + 'notes' => __('Notes', 'give'), |
|
396 | + 'mode' => __('Test Mode', 'give'), |
|
397 | + 'post_meta' => __('Import as Meta', 'give'), |
|
398 | + )); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return array |
413 | 413 | */ |
414 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
415 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
416 | - 'user_id' => __( 'User ID', 'give' ), |
|
417 | - ) ); |
|
414 | + return (array) apply_filters('give_import_donor_options', array( |
|
415 | + 'donor_id' => __('Donor ID', 'give'), |
|
416 | + 'user_id' => __('User ID', 'give'), |
|
417 | + )); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return array |
432 | 432 | */ |
433 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
434 | - 'form_title' => __( 'Donation Form Title', 'give' ), |
|
435 | - 'form_id' => __( 'Donation Form ID', 'give' ), |
|
436 | - 'form_level' => __( 'Donation Level', 'give' ), |
|
437 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
438 | - ) ); |
|
433 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
434 | + 'form_title' => __('Donation Form Title', 'give'), |
|
435 | + 'form_id' => __('Donation Form ID', 'give'), |
|
436 | + 'form_level' => __('Donation Level', 'give'), |
|
437 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
438 | + )); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return array |
450 | 450 | */ |
451 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
451 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
452 | 452 | /** |
453 | 453 | * Filter to modify delimiter of Import. |
454 | 454 | * |
@@ -457,19 +457,19 @@ discard block |
||
457 | 457 | * |
458 | 458 | * Return string $delimiter. |
459 | 459 | */ |
460 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
460 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
461 | 461 | |
462 | 462 | $raw_data = array(); |
463 | - $file_dir = get_attached_file( $file_id ); |
|
463 | + $file_dir = get_attached_file($file_id); |
|
464 | 464 | $count = 0; |
465 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
466 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
467 | - if ( $count >= $start && $count <= $end ) { |
|
465 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
466 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
467 | + if ($count >= $start && $count <= $end) { |
|
468 | 468 | $raw_data[] = $row; |
469 | 469 | } |
470 | - $count ++; |
|
470 | + $count++; |
|
471 | 471 | } |
472 | - fclose( $handle ); |
|
472 | + fclose($handle); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $raw_data; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return bool |
487 | 487 | */ |
488 | -function give_log_user_in_on_register_callback( $value ) { |
|
488 | +function give_log_user_in_on_register_callback($value) { |
|
489 | 489 | return false; |
490 | 490 | } |
491 | 491 | |
@@ -501,22 +501,22 @@ discard block |
||
501 | 501 | * |
502 | 502 | * @return bool |
503 | 503 | */ |
504 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
505 | - $data = array_combine( $raw_key, $row_data ); |
|
504 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
505 | + $data = array_combine($raw_key, $row_data); |
|
506 | 506 | $price_id = false; |
507 | 507 | $customer_id = 0; |
508 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
508 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
509 | 509 | |
510 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
510 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
511 | 511 | |
512 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
512 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
513 | 513 | |
514 | 514 | // Here come the login function. |
515 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
516 | - if ( ! empty( $donor_data->id ) ) { |
|
517 | - if ( ! empty( $donor_data->user_id ) ) { |
|
515 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
516 | + if ( ! empty($donor_data->id)) { |
|
517 | + if ( ! empty($donor_data->user_id)) { |
|
518 | 518 | $customer_id = $donor_data->user_id; |
519 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
519 | + } elseif ( ! empty($data['user_id'])) { |
|
520 | 520 | $customer_id = $data['user_id']; |
521 | 521 | } |
522 | 522 | } else { |
@@ -524,95 +524,95 @@ discard block |
||
524 | 524 | } |
525 | 525 | |
526 | 526 | // get form data or register a form data. |
527 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
528 | - if ( false == $form ) { |
|
527 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
528 | + if (false == $form) { |
|
529 | 529 | return false; |
530 | 530 | } else { |
531 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
531 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | $address = array( |
536 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
537 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
538 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
539 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
540 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
541 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
536 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
537 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
538 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
539 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
540 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
541 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
542 | 542 | ); |
543 | 543 | |
544 | 544 | //Create payment_data array |
545 | 545 | $payment_data = array( |
546 | 546 | 'donor_id' => $donor_data->id, |
547 | 547 | 'price' => $data['amount'], |
548 | - 'status' => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ), |
|
548 | + 'status' => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'), |
|
549 | 549 | 'currency' => give_get_currency(), |
550 | 550 | 'user_info' => array( |
551 | 551 | 'id' => $customer_id, |
552 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
553 | - '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 ) ), |
|
554 | - '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 ) ), |
|
552 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
553 | + '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)), |
|
554 | + '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)), |
|
555 | 555 | 'address' => $address, |
556 | 556 | ), |
557 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
558 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
557 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
558 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
559 | 559 | 'give_form_id' => (string) $form->get_ID(), |
560 | 560 | 'give_price_id' => $price_id, |
561 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
561 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
562 | 562 | 'user_email' => $data['email'], |
563 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
564 | - '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' ) ) ), |
|
563 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
564 | + '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'))), |
|
565 | 565 | ); |
566 | 566 | |
567 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
567 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
568 | 568 | |
569 | 569 | // Get the report |
570 | 570 | $report = give_import_donation_report(); |
571 | 571 | |
572 | 572 | // Check for duplicate code. |
573 | - if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) { |
|
574 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
573 | + if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) { |
|
574 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
575 | 575 | } else { |
576 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
577 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
578 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
579 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
580 | - $payment = give_insert_payment( $payment_data ); |
|
581 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
582 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
583 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
584 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
576 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
577 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
578 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
579 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
580 | + $payment = give_insert_payment($payment_data); |
|
581 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
582 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
583 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
584 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
585 | 585 | |
586 | - if ( $payment ) { |
|
586 | + if ($payment) { |
|
587 | 587 | |
588 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
588 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
589 | 589 | |
590 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
590 | + update_post_meta($payment, '_give_payment_import', true); |
|
591 | 591 | |
592 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
593 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
592 | + if ( ! empty($import_setting['csv'])) { |
|
593 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | // Insert Notes. |
597 | - if ( ! empty( $data['notes'] ) ) { |
|
598 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
597 | + if ( ! empty($data['notes'])) { |
|
598 | + give_insert_payment_note($payment, $data['notes']); |
|
599 | 599 | } |
600 | 600 | |
601 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
602 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
603 | - foreach ( $meta_exists as $meta_exist ) { |
|
604 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
605 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
601 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
602 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
603 | + foreach ($meta_exists as $meta_exist) { |
|
604 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
605 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | } |
609 | 609 | } else { |
610 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
610 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
614 | 614 | // update the report |
615 | - give_import_donation_report_update( $report ); |
|
615 | + give_import_donation_report_update($report); |
|
616 | 616 | |
617 | 617 | return true; |
618 | 618 | } |
@@ -628,12 +628,12 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @return Give_Donor |
630 | 630 | */ |
631 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
631 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
632 | 632 | $old_donor = $donor; |
633 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
634 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
635 | - $donor = new Give_Donor( $donor_id ); |
|
636 | - if ( ! empty( $donor->id ) ) { |
|
633 | + if ( ! empty($payment_data['donor_id'])) { |
|
634 | + $donor_id = absint($payment_data['donor_id']); |
|
635 | + $donor = new Give_Donor($donor_id); |
|
636 | + if ( ! empty($donor->id)) { |
|
637 | 637 | return $donor; |
638 | 638 | } |
639 | 639 | } |
@@ -646,12 +646,12 @@ discard block |
||
646 | 646 | * |
647 | 647 | * @since 1.8.13 |
648 | 648 | */ |
649 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
649 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
650 | 650 | // Update Give Customers purchase_count |
651 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
652 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
653 | - if ( ! empty( $donor_id ) ) { |
|
654 | - $donor = new Give_Donor( $donor_id ); |
|
651 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
652 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
653 | + if ( ! empty($donor_id)) { |
|
654 | + $donor = new Give_Donor($donor_id); |
|
655 | 655 | $donor->increase_purchase_count(); |
656 | 656 | } |
657 | 657 | } |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @since 1.8.13 |
664 | 664 | */ |
665 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
666 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
665 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
666 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
667 | 667 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
668 | 668 | } |
669 | 669 | |
@@ -675,11 +675,11 @@ discard block |
||
675 | 675 | * |
676 | 676 | * @since 1.8.13 |
677 | 677 | */ |
678 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
678 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
679 | 679 | $return = false; |
680 | - if ( ! empty( $data['post_date'] ) ) { |
|
681 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
682 | - $post_date = explode( '-', $post_date ); |
|
680 | + if ( ! empty($data['post_date'])) { |
|
681 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
682 | + $post_date = explode('-', $post_date); |
|
683 | 683 | $args = array( |
684 | 684 | 'post_type' => 'give_payment', |
685 | 685 | 'cache_results' => false, |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'meta_query' => array( |
701 | 701 | array( |
702 | 702 | 'key' => '_give_payment_total', |
703 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
703 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
704 | 704 | 'compare' => 'LIKE', |
705 | 705 | ), |
706 | 706 | array( |
@@ -717,9 +717,9 @@ discard block |
||
717 | 717 | ), |
718 | 718 | ); |
719 | 719 | |
720 | - $payments = new Give_Payments_Query( $args ); |
|
720 | + $payments = new Give_Payments_Query($args); |
|
721 | 721 | $donations = $payments->get_payments(); |
722 | - if ( ! empty( $donations ) ) { |
|
722 | + if ( ! empty($donations)) { |
|
723 | 723 | return true; |
724 | 724 | } |
725 | 725 | } |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return void |
738 | 738 | */ |
739 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
739 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
740 | 740 | $current_user = wp_get_current_user(); |
741 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
741 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | * |
751 | 751 | * @return string URL |
752 | 752 | */ |
753 | -function give_import_page_url( $parameter = array() ) { |
|
753 | +function give_import_page_url($parameter = array()) { |
|
754 | 754 | $defalut_query_arg = array( |
755 | 755 | 'post_type' => 'give_forms', |
756 | 756 | 'page' => 'give-tools', |
757 | 757 | 'tab' => 'import', |
758 | 758 | 'importer-type' => 'import_donations', |
759 | 759 | ); |
760 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
760 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
761 | 761 | |
762 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
762 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
763 | 763 | } |
764 | 764 | \ No newline at end of file |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Advanced' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Advanced')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Advanced. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'advanced'; |
30 | - $this->label = __( 'Advanced', 'give' ); |
|
30 | + $this->label = __('Advanced', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'advanced-options'; |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $current_section = give_get_current_setting_section(); |
47 | 47 | |
48 | - switch ( $current_section ) { |
|
48 | + switch ($current_section) { |
|
49 | 49 | case 'advanced-options': |
50 | 50 | $settings = array( |
51 | 51 | array( |
@@ -53,19 +53,19 @@ discard block |
||
53 | 53 | 'type' => 'title', |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => __( 'Remove Data on Uninstall', 'give' ), |
|
57 | - 'desc' => __( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ), |
|
56 | + 'name' => __('Remove Data on Uninstall', 'give'), |
|
57 | + 'desc' => __('When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give'), |
|
58 | 58 | 'id' => 'uninstall_on_delete', |
59 | 59 | 'type' => 'radio_inline', |
60 | 60 | 'default' => 'disabled', |
61 | 61 | 'options' => array( |
62 | - 'enabled' => __( 'Yes, Remove all data', 'give' ), |
|
63 | - 'disabled' => __( 'No, keep my Give settings and donation data', 'give' ), |
|
62 | + 'enabled' => __('Yes, Remove all data', 'give'), |
|
63 | + 'disabled' => __('No, keep my Give settings and donation data', 'give'), |
|
64 | 64 | ), |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'Default User Role', 'give' ), |
|
68 | - 'desc' => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ), |
|
67 | + 'name' => __('Default User Role', 'give'), |
|
68 | + 'desc' => __('Assign default user roles for donors when donors opt to register as a WP User.', 'give'), |
|
69 | 69 | 'id' => 'donor_default_user_role', |
70 | 70 | 'type' => 'select', |
71 | 71 | 'default' => 'give_donor', |
@@ -73,44 +73,44 @@ discard block |
||
73 | 73 | ), |
74 | 74 | array( |
75 | 75 | /* translators: %s: the_content */ |
76 | - 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ), |
|
76 | + 'name' => sprintf(__('%s filter', 'give'), '<code>the_content</code>'), |
|
77 | 77 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
78 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
78 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
79 | 79 | 'id' => 'the_content_filter', |
80 | 80 | 'default' => 'enabled', |
81 | 81 | 'type' => 'radio_inline', |
82 | 82 | 'options' => array( |
83 | - 'enabled' => __( 'Enabled', 'give' ), |
|
84 | - 'disabled' => __( 'Disabled', 'give' ), |
|
83 | + 'enabled' => __('Enabled', 'give'), |
|
84 | + 'disabled' => __('Disabled', 'give'), |
|
85 | 85 | ), |
86 | 86 | ), |
87 | 87 | array( |
88 | - 'name' => __( 'Script Loading Location', 'give' ), |
|
89 | - 'desc' => __( 'This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give' ), |
|
88 | + 'name' => __('Script Loading Location', 'give'), |
|
89 | + 'desc' => __('This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give'), |
|
90 | 90 | 'id' => 'scripts_footer', |
91 | 91 | 'type' => 'radio_inline', |
92 | 92 | 'default' => 'disabled', |
93 | 93 | 'options' => array( |
94 | - 'enabled' => __( 'Footer', 'give' ), |
|
95 | - 'disabled' => __( 'Head', 'give' ), |
|
94 | + 'enabled' => __('Footer', 'give'), |
|
95 | + 'disabled' => __('Head', 'give'), |
|
96 | 96 | ), |
97 | 97 | ), |
98 | 98 | array( |
99 | - 'name' => __( 'Akismet SPAM Protection', 'give' ), |
|
100 | - 'desc' => __( 'Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give' ), |
|
99 | + 'name' => __('Akismet SPAM Protection', 'give'), |
|
100 | + 'desc' => __('Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give'), |
|
101 | 101 | 'id' => 'akismet_spam_protection', |
102 | 102 | 'type' => 'radio_inline', |
103 | - 'default' => ( give_check_akismet_key() ) ? 'enabled' : 'disabled', |
|
103 | + 'default' => (give_check_akismet_key()) ? 'enabled' : 'disabled', |
|
104 | 104 | 'options' => array( |
105 | - 'enabled' => __( 'Enabled', 'give' ), |
|
106 | - 'disabled' => __( 'Disabled', 'give' ), |
|
105 | + 'enabled' => __('Enabled', 'give'), |
|
106 | + 'disabled' => __('Disabled', 'give'), |
|
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | array( |
110 | - 'name' => __( 'Advanced Settings Docs Link', 'give' ), |
|
110 | + 'name' => __('Advanced Settings Docs Link', 'give'), |
|
111 | 111 | 'id' => 'advanced_settings_docs_link', |
112 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
113 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
112 | + 'url' => esc_url('http://docs.givewp.com/settings-advanced'), |
|
113 | + 'title' => __('Advanced Settings', 'give'), |
|
114 | 114 | 'type' => 'give_docs_link', |
115 | 115 | ), |
116 | 116 | array( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * Filter the advanced settings. |
127 | 127 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
128 | 128 | */ |
129 | - $settings = apply_filters( 'give_settings_advanced', $settings ); |
|
129 | + $settings = apply_filters('give_settings_advanced', $settings); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Filter the settings. |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $settings |
137 | 137 | */ |
138 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
138 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
139 | 139 | |
140 | 140 | // Output. |
141 | 141 | return $settings; |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function get_sections() { |
151 | 151 | $sections = array( |
152 | - 'advanced-options' => __( 'Advanced Options', 'give' ), |
|
152 | + 'advanced-options' => __('Advanced Options', 'give'), |
|
153 | 153 | ); |
154 | 154 | |
155 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
155 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $font_style = ''; |
60 | 60 | |
61 | 61 | if ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) && |
62 | - in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
62 | + in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
63 | 63 | TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' ); |
64 | 64 | $custom_font = 'CODE2000'; |
65 | 65 | $font_style = 'B'; |
@@ -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 | |
@@ -25,130 +25,130 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( ! file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php' ) ) { |
|
39 | - wp_die( __( 'Dependency missing.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
38 | + if ( ! file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php')) { |
|
39 | + wp_die(__('Dependency missing.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
40 | 40 | } |
41 | 41 | |
42 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php'; |
|
42 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php'; |
|
43 | 43 | |
44 | 44 | $daterange = utf8_decode( |
45 | 45 | sprintf( |
46 | 46 | /* translators: 1: start date 2: end date */ |
47 | - __( '%1$s to %2$s', 'give' ), |
|
48 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
49 | - date_i18n( give_date_format() ) |
|
47 | + __('%1$s to %2$s', 'give'), |
|
48 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
49 | + date_i18n(give_date_format()) |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
54 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
53 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
54 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
55 | 55 | |
56 | - $pdf = new Give_PDF( 'L', 'mm', 'A', true, 'UTF-8', false ); |
|
57 | - $default_font = apply_filters( 'give_pdf_default_font', 'Helvetica' ); |
|
56 | + $pdf = new Give_PDF('L', 'mm', 'A', true, 'UTF-8', false); |
|
57 | + $default_font = apply_filters('give_pdf_default_font', 'Helvetica'); |
|
58 | 58 | $custom_font = 'dejavusans'; |
59 | 59 | $font_style = ''; |
60 | 60 | |
61 | - if ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) && |
|
62 | - in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
63 | - TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' ); |
|
61 | + if (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF') && |
|
62 | + in_array(give_get_currency(), array('RIAL', 'RUB'))) { |
|
63 | + TCPDF_FONTS::addTTFfont(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF', ''); |
|
64 | 64 | $custom_font = 'CODE2000'; |
65 | 65 | $font_style = 'B'; |
66 | 66 | } |
67 | 67 | |
68 | - $pdf->AddPage( 'L', 'A4' ); |
|
69 | - $pdf->setImageScale( 1.5 ); |
|
70 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
71 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
72 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
68 | + $pdf->AddPage('L', 'A4'); |
|
69 | + $pdf->setImageScale(1.5); |
|
70 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
71 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
72 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
73 | 73 | |
74 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
74 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
75 | 75 | |
76 | - $pdf->SetMargins( 8, 8, 8 ); |
|
77 | - $pdf->SetX( 8 ); |
|
76 | + $pdf->SetMargins(8, 8, 8); |
|
77 | + $pdf->SetX(8); |
|
78 | 78 | |
79 | - $pdf->SetFont( $default_font, '', 16 ); |
|
80 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
81 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
79 | + $pdf->SetFont($default_font, '', 16); |
|
80 | + $pdf->SetTextColor(50, 50, 50); |
|
81 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
82 | 82 | |
83 | - $pdf->SetFont( $default_font, '', 13 ); |
|
84 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
85 | - $pdf->Ln( 1 ); |
|
86 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
83 | + $pdf->SetFont($default_font, '', 13); |
|
84 | + $pdf->SetTextColor(150, 150, 150); |
|
85 | + $pdf->Ln(1); |
|
86 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
87 | 87 | $pdf->Ln(); |
88 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
89 | - $pdf->SetFont( $default_font, '', 14 ); |
|
90 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
91 | - $pdf->SetFont( $default_font, '', 12 ); |
|
88 | + $pdf->SetTextColor(50, 50, 50); |
|
89 | + $pdf->SetFont($default_font, '', 14); |
|
90 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
91 | + $pdf->SetFont($default_font, '', 12); |
|
92 | 92 | |
93 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
94 | - $pdf->SetTextColor( 0, 0, 0, 100 ); // Set Black color. |
|
95 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
96 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
93 | + $pdf->SetFillColor(238, 238, 238); |
|
94 | + $pdf->SetTextColor(0, 0, 0, 100); // Set Black color. |
|
95 | + $pdf->Cell(50, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
96 | + $pdf->Cell(50, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
97 | 97 | |
98 | 98 | // Display Categories Heading only, if user has opted for it. |
99 | - if ( $categories_enabled ) { |
|
100 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
99 | + if ($categories_enabled) { |
|
100 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Display Tags Heading only, if user has opted for it. |
104 | - if ( $tags_enabled ) { |
|
105 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
104 | + if ($tags_enabled) { |
|
105 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
106 | 106 | } |
107 | 107 | |
108 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
109 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
108 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
109 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
110 | 110 | |
111 | 111 | // Set Custom Font to support various currencies. |
112 | - $pdf->SetFont( apply_filters( 'give_pdf_custom_font', $custom_font ), $font_style, 12 ); |
|
112 | + $pdf->SetFont(apply_filters('give_pdf_custom_font', $custom_font), $font_style, 12); |
|
113 | 113 | |
114 | - $year = date( 'Y' ); |
|
115 | - $give_forms = get_posts( array( |
|
114 | + $year = date('Y'); |
|
115 | + $give_forms = get_posts(array( |
|
116 | 116 | 'post_type' => 'give_forms', |
117 | 117 | 'year' => $year, |
118 | - 'posts_per_page' => - 1, |
|
118 | + 'posts_per_page' => -1, |
|
119 | 119 | 'supply_filter' => false, |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | |
122 | - if ( $give_forms ) { |
|
123 | - $pdf->SetWidths( array( 50, 50, 45, 45, 45, 45 ) ); |
|
122 | + if ($give_forms) { |
|
123 | + $pdf->SetWidths(array(50, 50, 45, 45, 45, 45)); |
|
124 | 124 | |
125 | - foreach ( $give_forms as $form ): |
|
126 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
125 | + foreach ($give_forms as $form): |
|
126 | + $pdf->SetFillColor(255, 255, 255); |
|
127 | 127 | |
128 | 128 | $title = $form->post_title; |
129 | 129 | |
130 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
131 | - $price = html_entity_decode( give_price_range( $form->ID, false ) ); |
|
130 | + if (give_has_variable_prices($form->ID)) { |
|
131 | + $price = html_entity_decode(give_price_range($form->ID, false)); |
|
132 | 132 | } else { |
133 | - $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
|
133 | + $price = give_currency_filter(give_get_form_price($form->ID), '', true); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Display Categories Data only, if user has opted for it. |
137 | 137 | $categories = array(); |
138 | - if ( $categories_enabled ) { |
|
139 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
140 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
138 | + if ($categories_enabled) { |
|
139 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
140 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // Display Tags Data only, if user has opted for it. |
144 | 144 | $tags = array(); |
145 | - if ( $tags_enabled ) { |
|
146 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
147 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
145 | + if ($tags_enabled) { |
|
146 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
147 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
148 | 148 | } |
149 | 149 | |
150 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
151 | - $earnings = give_currency_filter( give_format_amount( give_get_form_earnings_stats( $form->ID ), array( 'sanitize' => false, ) ), '', true ); |
|
150 | + $sales = give_get_form_sales_stats($form->ID); |
|
151 | + $earnings = give_currency_filter(give_format_amount(give_get_form_earnings_stats($form->ID), array('sanitize' => false,)), '', true); |
|
152 | 152 | |
153 | 153 | // This will help filter data before appending it to PDF Receipt. |
154 | 154 | $prepare_pdf_data = array(); |
@@ -156,53 +156,53 @@ discard block |
||
156 | 156 | $prepare_pdf_data[] = $price; |
157 | 157 | |
158 | 158 | // Append Categories Data only, if user has opted for it. |
159 | - if ( $categories_enabled ) { |
|
159 | + if ($categories_enabled) { |
|
160 | 160 | $prepare_pdf_data[] = $categories; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Append Tags Data only, if user has opted for it. |
164 | - if ( $tags_enabled ) { |
|
164 | + if ($tags_enabled) { |
|
165 | 165 | $prepare_pdf_data[] = $tags; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $prepare_pdf_data[] = $sales; |
169 | 169 | $prepare_pdf_data[] = $earnings; |
170 | 170 | |
171 | - $pdf->Row( $prepare_pdf_data ); |
|
171 | + $pdf->Row($prepare_pdf_data); |
|
172 | 172 | |
173 | 173 | endforeach; |
174 | 174 | } else { |
175 | 175 | |
176 | 176 | // Fix: Minor Styling Alignment Issue for PDF. |
177 | - if ( $categories_enabled && $tags_enabled ) { |
|
177 | + if ($categories_enabled && $tags_enabled) { |
|
178 | 178 | $no_found_width = 280; |
179 | - } elseif ( $categories_enabled || $tags_enabled ) { |
|
179 | + } elseif ($categories_enabled || $tags_enabled) { |
|
180 | 180 | $no_found_width = 235; |
181 | 181 | } else { |
182 | 182 | $no_found_width = 190; |
183 | 183 | } |
184 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
185 | - $pdf->MultiCell( $no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false ); |
|
184 | + $title = utf8_decode(__('No forms found.', 'give')); |
|
185 | + $pdf->MultiCell($no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false); |
|
186 | 186 | }// End if(). |
187 | 187 | $pdf->Ln(); |
188 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
189 | - $pdf->SetFont( $default_font, '', 14 ); |
|
188 | + $pdf->SetTextColor(50, 50, 50); |
|
189 | + $pdf->SetFont($default_font, '', 14); |
|
190 | 190 | |
191 | 191 | // Output Graph on a new page. |
192 | - $pdf->AddPage( 'L', 'A4' ); |
|
193 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
194 | - $pdf->SetFont( $default_font, '', 12 ); |
|
192 | + $pdf->AddPage('L', 'A4'); |
|
193 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
194 | + $pdf->SetFont($default_font, '', 12); |
|
195 | 195 | |
196 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
197 | - $image = str_replace( ' ', '%20', $image ); |
|
196 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
197 | + $image = str_replace(' ', '%20', $image); |
|
198 | 198 | |
199 | - $pdf->SetX( 25 ); |
|
200 | - $pdf->Image( $image . '&file=.png' ); |
|
201 | - $pdf->Ln( 7 ); |
|
202 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
199 | + $pdf->SetX(25); |
|
200 | + $pdf->Image($image.'&file=.png'); |
|
201 | + $pdf->Ln(7); |
|
202 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
203 | 203 | } |
204 | 204 | |
205 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
205 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Draws Chart for PDF Report. |
@@ -219,38 +219,38 @@ discard block |
||
219 | 219 | * @return string $chart->getUrl() URL for the Google Chart |
220 | 220 | */ |
221 | 221 | function give_draw_chart_image() { |
222 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
223 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
224 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
222 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
223 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
224 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
225 | 225 | |
226 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
226 | + $chart = new GoogleChart('lc', 900, 330); |
|
227 | 227 | |
228 | 228 | $i = 1; |
229 | 229 | $earnings = ""; |
230 | 230 | $sales = ""; |
231 | 231 | |
232 | - while ( $i <= 12 ) : |
|
233 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
234 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
235 | - $i ++; |
|
232 | + while ($i <= 12) : |
|
233 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
234 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
235 | + $i++; |
|
236 | 236 | endwhile; |
237 | 237 | |
238 | - $earnings_array = explode( ",", $earnings ); |
|
239 | - $sales_array = explode( ",", $sales ); |
|
238 | + $earnings_array = explode(",", $earnings); |
|
239 | + $sales_array = explode(",", $sales); |
|
240 | 240 | |
241 | 241 | $i = 0; |
242 | - while ( $i <= 11 ) { |
|
243 | - if ( empty( $sales_array[ $i ] ) ) { |
|
244 | - $sales_array[ $i ] = 0; |
|
242 | + while ($i <= 11) { |
|
243 | + if (empty($sales_array[$i])) { |
|
244 | + $sales_array[$i] = 0; |
|
245 | 245 | } |
246 | - $i ++; |
|
246 | + $i++; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | $min_earnings = 0; |
250 | - $max_earnings = max( $earnings_array ); |
|
251 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
250 | + $max_earnings = max($earnings_array); |
|
251 | + $earnings_scale = round($max_earnings, - 1); |
|
252 | 252 | |
253 | - $data = new GoogleChartData( array( |
|
253 | + $data = new GoogleChartData(array( |
|
254 | 254 | $earnings_array[0], |
255 | 255 | $earnings_array[1], |
256 | 256 | $earnings_array[2], |
@@ -263,25 +263,25 @@ discard block |
||
263 | 263 | $earnings_array[9], |
264 | 264 | $earnings_array[10], |
265 | 265 | $earnings_array[11], |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | |
268 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
269 | - $data->setColor( '1b58a3' ); |
|
270 | - $chart->addData( $data ); |
|
268 | + $data->setLegend(__('Income', 'give')); |
|
269 | + $data->setColor('1b58a3'); |
|
270 | + $chart->addData($data); |
|
271 | 271 | |
272 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
273 | - $shape_marker->setColor( '000000' ); |
|
274 | - $shape_marker->setSize( 7 ); |
|
275 | - $shape_marker->setBorder( 2 ); |
|
276 | - $shape_marker->setData( $data ); |
|
277 | - $chart->addMarker( $shape_marker ); |
|
272 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
273 | + $shape_marker->setColor('000000'); |
|
274 | + $shape_marker->setSize(7); |
|
275 | + $shape_marker->setBorder(2); |
|
276 | + $shape_marker->setData($data); |
|
277 | + $chart->addMarker($shape_marker); |
|
278 | 278 | |
279 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
280 | - $value_marker->setColor( '000000' ); |
|
281 | - $value_marker->setData( $data ); |
|
282 | - $chart->addMarker( $value_marker ); |
|
279 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
280 | + $value_marker->setColor('000000'); |
|
281 | + $value_marker->setData($data); |
|
282 | + $chart->addMarker($value_marker); |
|
283 | 283 | |
284 | - $data = new GoogleChartData( array( |
|
284 | + $data = new GoogleChartData(array( |
|
285 | 285 | $sales_array[0], |
286 | 286 | $sales_array[1], |
287 | 287 | $sales_array[2], |
@@ -294,46 +294,46 @@ discard block |
||
294 | 294 | $sales_array[9], |
295 | 295 | $sales_array[10], |
296 | 296 | $sales_array[11], |
297 | - ) ); |
|
298 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
299 | - $data->setColor( 'ff6c1c' ); |
|
300 | - $chart->addData( $data ); |
|
301 | - |
|
302 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
303 | - |
|
304 | - $chart->setScale( 0, $max_earnings ); |
|
305 | - |
|
306 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
307 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
308 | - $chart->addAxis( $y_axis ); |
|
309 | - |
|
310 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
311 | - $x_axis->setTickMarks( 5 ); |
|
312 | - $x_axis->setLabels( array( |
|
313 | - __( 'Jan', 'give' ), |
|
314 | - __( 'Feb', 'give' ), |
|
315 | - __( 'Mar', 'give' ), |
|
316 | - __( 'Apr', 'give' ), |
|
317 | - __( 'May', 'give' ), |
|
318 | - __( 'June', 'give' ), |
|
319 | - __( 'July', 'give' ), |
|
320 | - __( 'Aug', 'give' ), |
|
321 | - __( 'Sept', 'give' ), |
|
322 | - __( 'Oct', 'give' ), |
|
323 | - __( 'Nov', 'give' ), |
|
324 | - __( 'Dec', 'give' ), |
|
325 | - ) ); |
|
326 | - $chart->addAxis( $x_axis ); |
|
327 | - |
|
328 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
329 | - $shape_marker->setSize( 6 ); |
|
330 | - $shape_marker->setBorder( 2 ); |
|
331 | - $shape_marker->setData( $data ); |
|
332 | - $chart->addMarker( $shape_marker ); |
|
333 | - |
|
334 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
335 | - $value_marker->setData( $data ); |
|
336 | - $chart->addMarker( $value_marker ); |
|
297 | + )); |
|
298 | + $data->setLegend(__('Donations', 'give')); |
|
299 | + $data->setColor('ff6c1c'); |
|
300 | + $chart->addData($data); |
|
301 | + |
|
302 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
303 | + |
|
304 | + $chart->setScale(0, $max_earnings); |
|
305 | + |
|
306 | + $y_axis = new GoogleChartAxis('y'); |
|
307 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
308 | + $chart->addAxis($y_axis); |
|
309 | + |
|
310 | + $x_axis = new GoogleChartAxis('x'); |
|
311 | + $x_axis->setTickMarks(5); |
|
312 | + $x_axis->setLabels(array( |
|
313 | + __('Jan', 'give'), |
|
314 | + __('Feb', 'give'), |
|
315 | + __('Mar', 'give'), |
|
316 | + __('Apr', 'give'), |
|
317 | + __('May', 'give'), |
|
318 | + __('June', 'give'), |
|
319 | + __('July', 'give'), |
|
320 | + __('Aug', 'give'), |
|
321 | + __('Sept', 'give'), |
|
322 | + __('Oct', 'give'), |
|
323 | + __('Nov', 'give'), |
|
324 | + __('Dec', 'give'), |
|
325 | + )); |
|
326 | + $chart->addAxis($x_axis); |
|
327 | + |
|
328 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
329 | + $shape_marker->setSize(6); |
|
330 | + $shape_marker->setBorder(2); |
|
331 | + $shape_marker->setData($data); |
|
332 | + $chart->addMarker($shape_marker); |
|
333 | + |
|
334 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
335 | + $value_marker->setData($data); |
|
336 | + $chart->addMarker($value_marker); |
|
337 | 337 | |
338 | 338 | return $chart->getUrl(); |
339 | 339 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * |
1158 | 1158 | * @todo Remove this, when WordPress Core ticket is resolved (https://core.trac.wordpress.org/ticket/16828). |
1159 | 1159 | * |
1160 | - * @return bool |
|
1160 | + * @return false|null |
|
1161 | 1161 | */ |
1162 | 1162 | function give_donation_metabox_menu() { |
1163 | 1163 | |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | * @param int $id |
1541 | 1541 | * @param string $meta_key |
1542 | 1542 | * @param mixed $meta_value |
1543 | - * @param mixed $prev_value |
|
1543 | + * @param string $prev_value |
|
1544 | 1544 | * |
1545 | 1545 | * @return mixed |
1546 | 1546 | */ |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | * @since 1.8.13 |
1748 | 1748 | * |
1749 | 1749 | * @param array $list List of objects or arrays |
1750 | - * @param int|string $field Field from the object to place instead of the entire object |
|
1750 | + * @param string $field Field from the object to place instead of the entire object |
|
1751 | 1751 | * @param int|string $index_key Optional. Field from the object to use as keys for the new array. |
1752 | 1752 | * Default null. |
1753 | 1753 | * |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return string The currency code |
42 | 42 | */ |
43 | -function give_get_currency( $donation_or_form_id = null, $args = array() ) { |
|
43 | +function give_get_currency($donation_or_form_id = null, $args = array()) { |
|
44 | 44 | |
45 | 45 | // Get currency from donation |
46 | - if ( is_numeric( $donation_or_form_id ) && 'give_payment' === get_post_type( $donation_or_form_id ) ) { |
|
47 | - $donation_meta = give_get_meta( $donation_or_form_id, '_give_payment_meta', true ); |
|
46 | + if (is_numeric($donation_or_form_id) && 'give_payment' === get_post_type($donation_or_form_id)) { |
|
47 | + $donation_meta = give_get_meta($donation_or_form_id, '_give_payment_meta', true); |
|
48 | 48 | |
49 | - if ( ! empty( $donation_meta['currency'] ) ) { |
|
49 | + if ( ! empty($donation_meta['currency'])) { |
|
50 | 50 | $currency = $donation_meta['currency']; |
51 | 51 | } else { |
52 | - $currency = give_get_option( 'currency', 'USD' ); |
|
52 | + $currency = give_get_option('currency', 'USD'); |
|
53 | 53 | } |
54 | 54 | } else { |
55 | - $currency = give_get_option( 'currency', 'USD' ); |
|
55 | + $currency = give_get_option('currency', 'USD'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.0 |
62 | 62 | */ |
63 | - return apply_filters( 'give_currency', $currency, $donation_or_form_id, $args ); |
|
63 | + return apply_filters('give_currency', $currency, $donation_or_form_id, $args); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function give_get_currency_position() { |
74 | 74 | |
75 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
75 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
76 | 76 | |
77 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
77 | + return apply_filters('give_currency_position', $currency_pos); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return array $currencies A list of the available currencies |
89 | 89 | */ |
90 | -function give_get_currencies( $info = 'admin_label' ) { |
|
90 | +function give_get_currencies($info = 'admin_label') { |
|
91 | 91 | $currencies = array( |
92 | 92 | 'USD' => array( |
93 | - 'admin_label' => __( 'US Dollars ($)', 'give' ), |
|
93 | + 'admin_label' => __('US Dollars ($)', 'give'), |
|
94 | 94 | 'symbol' => '$', |
95 | 95 | 'setting' => array( |
96 | 96 | 'currency_position' => 'before', |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ), |
101 | 101 | ), |
102 | 102 | 'EUR' => array( |
103 | - 'admin_label' => __( 'Euros (€)', 'give' ), |
|
103 | + 'admin_label' => __('Euros (€)', 'give'), |
|
104 | 104 | 'symbol' => '€', |
105 | 105 | 'setting' => array( |
106 | 106 | 'currency_position' => 'before', |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | ), |
111 | 111 | ), |
112 | 112 | 'GBP' => array( |
113 | - 'admin_label' => __( 'Pounds Sterling (£)', 'give' ), |
|
113 | + 'admin_label' => __('Pounds Sterling (£)', 'give'), |
|
114 | 114 | 'symbol' => '£', |
115 | 115 | 'setting' => array( |
116 | 116 | 'currency_position' => 'before', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ), |
121 | 121 | ), |
122 | 122 | 'AUD' => array( |
123 | - 'admin_label' => __( 'Australian Dollars ($)', 'give' ), |
|
123 | + 'admin_label' => __('Australian Dollars ($)', 'give'), |
|
124 | 124 | 'symbol' => '$', |
125 | 125 | 'setting' => array( |
126 | 126 | 'currency_position' => 'before', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ), |
131 | 131 | ), |
132 | 132 | 'BRL' => array( |
133 | - 'admin_label' => __( 'Brazilian Real (R$)', 'give' ), |
|
133 | + 'admin_label' => __('Brazilian Real (R$)', 'give'), |
|
134 | 134 | 'symbol' => 'R$', |
135 | 135 | 'setting' => array( |
136 | 136 | 'currency_position' => 'before', |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ), |
141 | 141 | ), |
142 | 142 | 'CAD' => array( |
143 | - 'admin_label' => __( 'Canadian Dollars ($)', 'give' ), |
|
143 | + 'admin_label' => __('Canadian Dollars ($)', 'give'), |
|
144 | 144 | 'symbol' => '$', |
145 | 145 | 'setting' => array( |
146 | 146 | 'currency_position' => 'before', |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ), |
151 | 151 | ), |
152 | 152 | 'CZK' => array( |
153 | - 'admin_label' => __( 'Czech Koruna (Kč)', 'give' ), |
|
153 | + 'admin_label' => __('Czech Koruna (Kč)', 'give'), |
|
154 | 154 | 'symbol' => 'Kč', |
155 | 155 | 'setting' => array( |
156 | 156 | 'currency_position' => 'before', |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ), |
161 | 161 | ), |
162 | 162 | 'DKK' => array( |
163 | - 'admin_label' => __( 'Danish Krone (kr.)', 'give' ), |
|
163 | + 'admin_label' => __('Danish Krone (kr.)', 'give'), |
|
164 | 164 | 'symbol' => ' kr. ', |
165 | 165 | 'setting' => array( |
166 | 166 | 'currency_position' => 'before', |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | ), |
171 | 171 | ), |
172 | 172 | 'HKD' => array( |
173 | - 'admin_label' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
173 | + 'admin_label' => __('Hong Kong Dollar ($)', 'give'), |
|
174 | 174 | 'symbol' => '$', |
175 | 175 | 'setting' => array( |
176 | 176 | 'currency_position' => 'before', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | ), |
181 | 181 | ), |
182 | 182 | 'HUF' => array( |
183 | - 'admin_label' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
183 | + 'admin_label' => __('Hungarian Forint (Ft)', 'give'), |
|
184 | 184 | 'symbol' => 'Ft', |
185 | 185 | 'setting' => array( |
186 | 186 | 'currency_position' => 'before', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ), |
191 | 191 | ), |
192 | 192 | 'ILS' => array( |
193 | - 'admin_label' => __( 'Israeli Shekel (₪)', 'give' ), |
|
193 | + 'admin_label' => __('Israeli Shekel (₪)', 'give'), |
|
194 | 194 | 'symbol' => '₪', |
195 | 195 | 'setting' => array( |
196 | 196 | 'currency_position' => 'before', |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ), |
201 | 201 | ), |
202 | 202 | 'JPY' => array( |
203 | - 'admin_label' => __( 'Japanese Yen (¥)', 'give' ), |
|
203 | + 'admin_label' => __('Japanese Yen (¥)', 'give'), |
|
204 | 204 | 'symbol' => '¥', |
205 | 205 | 'setting' => array( |
206 | 206 | 'currency_position' => 'before', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ), |
211 | 211 | ), |
212 | 212 | 'MYR' => array( |
213 | - 'admin_label' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
213 | + 'admin_label' => __('Malaysian Ringgits (RM)', 'give'), |
|
214 | 214 | 'symbol' => 'RM', |
215 | 215 | 'setting' => array( |
216 | 216 | 'currency_position' => 'before', |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ), |
221 | 221 | ), |
222 | 222 | 'MXN' => array( |
223 | - 'admin_label' => __( 'Mexican Peso ($)', 'give' ), |
|
223 | + 'admin_label' => __('Mexican Peso ($)', 'give'), |
|
224 | 224 | 'symbol' => '$', |
225 | 225 | 'setting' => array( |
226 | 226 | 'currency_position' => 'before', |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ), |
231 | 231 | ), |
232 | 232 | 'MAD' => array( |
233 | - 'admin_label' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
233 | + 'admin_label' => __('Moroccan Dirham (.د.م)', 'give'), |
|
234 | 234 | 'symbol' => '.د.م', |
235 | 235 | 'setting' => array( |
236 | 236 | 'currency_position' => 'before', |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | ), |
241 | 241 | ), |
242 | 242 | 'NZD' => array( |
243 | - 'admin_label' => __( 'New Zealand Dollar ($)', 'give' ), |
|
243 | + 'admin_label' => __('New Zealand Dollar ($)', 'give'), |
|
244 | 244 | 'symbol' => '$', |
245 | 245 | 'setting' => array( |
246 | 246 | 'currency_position' => 'before', |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | ), |
251 | 251 | ), |
252 | 252 | 'NOK' => array( |
253 | - 'admin_label' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
253 | + 'admin_label' => __('Norwegian Krone (Kr.)', 'give'), |
|
254 | 254 | 'symbol' => 'kr.', |
255 | 255 | 'setting' => array( |
256 | 256 | 'currency_position' => 'before', |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | ), |
261 | 261 | ), |
262 | 262 | 'PHP' => array( |
263 | - 'admin_label' => __( 'Philippine Pesos (₱)', 'give' ), |
|
263 | + 'admin_label' => __('Philippine Pesos (₱)', 'give'), |
|
264 | 264 | 'symbol' => '₱', |
265 | 265 | 'setting' => array( |
266 | 266 | 'currency_position' => 'before', |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | ), |
271 | 271 | ), |
272 | 272 | 'PLN' => array( |
273 | - 'admin_label' => __( 'Polish Zloty (zł)', 'give' ), |
|
273 | + 'admin_label' => __('Polish Zloty (zł)', 'give'), |
|
274 | 274 | 'symbol' => 'zł', |
275 | 275 | 'setting' => array( |
276 | 276 | 'currency_position' => 'before', |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | ), |
281 | 281 | ), |
282 | 282 | 'SGD' => array( |
283 | - 'admin_label' => __( 'Singapore Dollar ($)', 'give' ), |
|
283 | + 'admin_label' => __('Singapore Dollar ($)', 'give'), |
|
284 | 284 | 'symbol' => '$', |
285 | 285 | 'setting' => array( |
286 | 286 | 'currency_position' => 'before', |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | ), |
291 | 291 | ), |
292 | 292 | 'KRW' => array( |
293 | - 'admin_label' => __( 'South Korean Won (₩)', 'give' ), |
|
293 | + 'admin_label' => __('South Korean Won (₩)', 'give'), |
|
294 | 294 | 'symbol' => '₩', |
295 | 295 | 'setting' => array( |
296 | 296 | 'currency_position' => 'before', |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ), |
301 | 301 | ), |
302 | 302 | 'ZAR' => array( |
303 | - 'admin_label' => __( 'South African Rand (R)', 'give' ), |
|
303 | + 'admin_label' => __('South African Rand (R)', 'give'), |
|
304 | 304 | 'symbol' => 'R', |
305 | 305 | 'setting' => array( |
306 | 306 | 'currency_position' => 'before', |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | ), |
311 | 311 | ), |
312 | 312 | 'SEK' => array( |
313 | - 'admin_label' => __( 'Swedish Krona (kr)', 'give' ), |
|
313 | + 'admin_label' => __('Swedish Krona (kr)', 'give'), |
|
314 | 314 | 'symbol' => ' kr. ', |
315 | 315 | 'setting' => array( |
316 | 316 | 'currency_position' => 'before', |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ), |
321 | 321 | ), |
322 | 322 | 'CHF' => array( |
323 | - 'admin_label' => __( 'Swiss Franc (CHF)', 'give' ), |
|
323 | + 'admin_label' => __('Swiss Franc (CHF)', 'give'), |
|
324 | 324 | 'symbol' => 'CHF', |
325 | 325 | 'setting' => array( |
326 | 326 | 'currency_position' => 'before', |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | ), |
331 | 331 | ), |
332 | 332 | 'TWD' => array( |
333 | - 'admin_label' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
333 | + 'admin_label' => __('Taiwan New Dollars (NT$)', 'give'), |
|
334 | 334 | 'symbol' => 'NT$', |
335 | 335 | 'setting' => array( |
336 | 336 | 'currency_position' => 'before', |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | ), |
341 | 341 | ), |
342 | 342 | 'THB' => array( |
343 | - 'admin_label' => __( 'Thai Baht (฿)', 'give' ), |
|
343 | + 'admin_label' => __('Thai Baht (฿)', 'give'), |
|
344 | 344 | 'symbol' => '฿', |
345 | 345 | 'setting' => array( |
346 | 346 | 'currency_position' => 'before', |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | ), |
351 | 351 | ), |
352 | 352 | 'INR' => array( |
353 | - 'admin_label' => __( 'Indian Rupee (₹)', 'give' ), |
|
353 | + 'admin_label' => __('Indian Rupee (₹)', 'give'), |
|
354 | 354 | 'symbol' => '₹', |
355 | 355 | 'setting' => array( |
356 | 356 | 'currency_position' => 'before', |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | ), |
361 | 361 | ), |
362 | 362 | 'TRY' => array( |
363 | - 'admin_label' => __( 'Turkish Lira (₺)', 'give' ), |
|
363 | + 'admin_label' => __('Turkish Lira (₺)', 'give'), |
|
364 | 364 | 'symbol' => '₺', |
365 | 365 | 'setting' => array( |
366 | 366 | 'currency_position' => 'before', |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | ), |
371 | 371 | ), |
372 | 372 | 'RIAL' => array( |
373 | - 'admin_label' => __( 'Iranian Rial (﷼)', 'give' ), |
|
373 | + 'admin_label' => __('Iranian Rial (﷼)', 'give'), |
|
374 | 374 | 'symbol' => '﷼', |
375 | 375 | 'setting' => array( |
376 | 376 | 'currency_position' => 'after', |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | ), |
381 | 381 | ), |
382 | 382 | 'RUB' => array( |
383 | - 'admin_label' => __( 'Russian Rubles (руб)', 'give' ), |
|
383 | + 'admin_label' => __('Russian Rubles (руб)', 'give'), |
|
384 | 384 | 'symbol' => '₽', |
385 | 385 | 'setting' => array( |
386 | 386 | 'currency_position' => 'before', |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @param array $currencies |
408 | 408 | */ |
409 | - $currencies = apply_filters( 'give_currencies', $currencies ); |
|
409 | + $currencies = apply_filters('give_currencies', $currencies); |
|
410 | 410 | |
411 | 411 | // Backward compatibility: handle old way of currency registration. |
412 | 412 | // Backward compatibility: Return desired result. |
413 | - if ( ! empty( $currencies ) ) { |
|
414 | - foreach ( $currencies as $currency_code => $currency_setting ) { |
|
415 | - if ( is_string( $currency_setting ) ) { |
|
416 | - $currencies[ $currency_code ] = array( |
|
413 | + if ( ! empty($currencies)) { |
|
414 | + foreach ($currencies as $currency_code => $currency_setting) { |
|
415 | + if (is_string($currency_setting)) { |
|
416 | + $currencies[$currency_code] = array( |
|
417 | 417 | 'admin_label' => $currency_setting, |
418 | 418 | 'symbol' => '', |
419 | 419 | 'setting' => array(), |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if ( ! empty( $info ) && is_string( $info ) && 'all' !== $info ) { |
|
425 | - $currencies = wp_list_pluck( $currencies, $info ); |
|
424 | + if ( ! empty($info) && is_string($info) && 'all' !== $info) { |
|
425 | + $currencies = wp_list_pluck($currencies, $info); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return array |
441 | 441 | */ |
442 | -function give_currency_symbols( $decode_currencies = false ) { |
|
443 | - $currencies = give_get_currencies('symbol' ); |
|
442 | +function give_currency_symbols($decode_currencies = false) { |
|
443 | + $currencies = give_get_currencies('symbol'); |
|
444 | 444 | |
445 | - if ( $decode_currencies ) { |
|
446 | - $currencies = array_map( 'html_entity_decode', $currencies ); |
|
445 | + if ($decode_currencies) { |
|
446 | + $currencies = array_map('html_entity_decode', $currencies); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param array $currencies |
455 | 455 | */ |
456 | - return apply_filters( 'give_currency_symbols', $currencies ); |
|
456 | + return apply_filters('give_currency_symbols', $currencies); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -470,14 +470,14 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return string The symbol to use for the currency |
472 | 472 | */ |
473 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
473 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
474 | 474 | |
475 | - if ( empty( $currency ) ) { |
|
475 | + if (empty($currency)) { |
|
476 | 476 | $currency = give_get_currency(); |
477 | 477 | } |
478 | 478 | |
479 | - $currencies = give_currency_symbols( $decode_currency ); |
|
480 | - $symbol = array_key_exists( $currency, $currencies ) ? $currencies[ $currency ] : $currency; |
|
479 | + $currencies = give_currency_symbols($decode_currency); |
|
480 | + $symbol = array_key_exists($currency, $currencies) ? $currencies[$currency] : $currency; |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Filter the currency symbol |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param string $symbol |
488 | 488 | * @param string $currency |
489 | 489 | */ |
490 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
490 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | |
@@ -500,13 +500,13 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return string |
502 | 502 | */ |
503 | -function give_get_currency_name( $currency_code ) { |
|
503 | +function give_get_currency_name($currency_code) { |
|
504 | 504 | $currency_name = ''; |
505 | 505 | $currency_names = give_get_currencies(); |
506 | 506 | |
507 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
508 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
509 | - $currency_name = trim( current( $currency_name ) ); |
|
507 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
508 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
509 | + $currency_name = trim(current($currency_name)); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param string $currency_name |
518 | 518 | * @param string $currency_code |
519 | 519 | */ |
520 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
520 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | |
532 | 532 | global $wp; |
533 | 533 | |
534 | - if ( get_option( 'permalink_structure' ) ) { |
|
535 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
534 | + if (get_option('permalink_structure')) { |
|
535 | + $base = trailingslashit(home_url($wp->request)); |
|
536 | 536 | } else { |
537 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
538 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
537 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
538 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | $scheme = is_ssl() ? 'https' : 'http'; |
542 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
542 | + $current_uri = set_url_scheme($base, $scheme); |
|
543 | 543 | |
544 | - if ( is_front_page() ) { |
|
545 | - $current_uri = home_url( '/' ); |
|
544 | + if (is_front_page()) { |
|
545 | + $current_uri = home_url('/'); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @param string $current_uri |
554 | 554 | */ |
555 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
555 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
556 | 556 | |
557 | 557 | } |
558 | 558 | |
@@ -574,11 +574,11 @@ discard block |
||
574 | 574 | */ |
575 | 575 | $gateways = give_get_enabled_payment_gateways(); |
576 | 576 | |
577 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
577 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
578 | 578 | $ret = true; |
579 | - } elseif ( count( $gateways ) == 1 ) { |
|
579 | + } elseif (count($gateways) == 1) { |
|
580 | 580 | $ret = false; |
581 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
581 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
582 | 582 | $ret = false; |
583 | 583 | } |
584 | 584 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @param bool $ret |
591 | 591 | */ |
592 | - return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret ); |
|
592 | + return (bool) apply_filters('give_is_cc_verify_enabled', $ret); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -601,26 +601,26 @@ discard block |
||
601 | 601 | function give_get_timezone_id() { |
602 | 602 | |
603 | 603 | // if site timezone string exists, return it. |
604 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
604 | + if ($timezone = get_option('timezone_string')) { |
|
605 | 605 | return $timezone; |
606 | 606 | } |
607 | 607 | |
608 | 608 | // get UTC offset, if it isn't set return UTC. |
609 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
609 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
610 | 610 | return 'UTC'; |
611 | 611 | } |
612 | 612 | |
613 | 613 | // attempt to guess the timezone string from the UTC offset. |
614 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
614 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
615 | 615 | |
616 | 616 | // last try, guess timezone string manually. |
617 | - if ( $timezone === false ) { |
|
617 | + if ($timezone === false) { |
|
618 | 618 | |
619 | - $is_dst = date( 'I' ); |
|
619 | + $is_dst = date('I'); |
|
620 | 620 | |
621 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
622 | - foreach ( $abbr as $city ) { |
|
623 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
621 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
622 | + foreach ($abbr as $city) { |
|
623 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
624 | 624 | return $city['timezone_id']; |
625 | 625 | } |
626 | 626 | } |
@@ -644,17 +644,17 @@ discard block |
||
644 | 644 | |
645 | 645 | $ip = '127.0.0.1'; |
646 | 646 | |
647 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
647 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
648 | 648 | // check ip from share internet |
649 | 649 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
650 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
650 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
651 | 651 | // to check ip is pass from proxy |
652 | 652 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
653 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
653 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
654 | 654 | $ip = $_SERVER['REMOTE_ADDR']; |
655 | 655 | } |
656 | 656 | |
657 | - return apply_filters( 'give_get_ip', $ip ); |
|
657 | + return apply_filters('give_get_ip', $ip); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -669,9 +669,9 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @uses Give()->session->set() |
671 | 671 | */ |
672 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
673 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
674 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
672 | +function give_set_purchase_session($purchase_data = array()) { |
|
673 | + Give()->session->set('give_purchase', $purchase_data); |
|
674 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @return mixed array | false |
686 | 686 | */ |
687 | 687 | function give_get_purchase_session() { |
688 | - return Give()->session->get( 'give_purchase' ); |
|
688 | + return Give()->session->get('give_purchase'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -697,33 +697,33 @@ discard block |
||
697 | 697 | * |
698 | 698 | * @return string |
699 | 699 | */ |
700 | -function give_payment_gateway_item_title( $payment_data ) { |
|
701 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
700 | +function give_payment_gateway_item_title($payment_data) { |
|
701 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
702 | 702 | $item_name = $payment_data['post_data']['give-form-title']; |
703 | - $is_custom_amount = give_is_setting_enabled( give_get_meta( $form_id, '_give_custom_amount', true ) ); |
|
703 | + $is_custom_amount = give_is_setting_enabled(give_get_meta($form_id, '_give_custom_amount', true)); |
|
704 | 704 | |
705 | 705 | // Verify has variable prices. |
706 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
706 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
707 | 707 | |
708 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
709 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
708 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
709 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
710 | 710 | |
711 | 711 | // Donation given doesn't match selected level (must be a custom amount). |
712 | - if ( $price_level_amount !== give_maybe_sanitize_amount( $payment_data['post_data']['give-amount'] ) ) { |
|
713 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
712 | + if ($price_level_amount !== give_maybe_sanitize_amount($payment_data['post_data']['give-amount'])) { |
|
713 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
714 | 714 | |
715 | 715 | // user custom amount text if any, fallback to default if not. |
716 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
716 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
717 | 717 | |
718 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
718 | + } elseif ( ! empty($item_price_level_text)) { |
|
719 | 719 | // Matches a donation level - append level text. |
720 | - $item_name .= ' - ' . $item_price_level_text; |
|
720 | + $item_name .= ' - '.$item_price_level_text; |
|
721 | 721 | } |
722 | 722 | } // End if(). |
723 | - elseif ( $is_custom_amount && give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['post_data']['give-amount'] ) ) { |
|
724 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
723 | + elseif ($is_custom_amount && give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['post_data']['give-amount'])) { |
|
724 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
725 | 725 | // user custom amount text if any, fallback to default if not. |
726 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
726 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | * |
738 | 738 | * @return string |
739 | 739 | */ |
740 | - return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data ); |
|
740 | + return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -753,36 +753,36 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @return string |
755 | 755 | */ |
756 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
757 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
756 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
757 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
758 | 758 | |
759 | 759 | // Form title. |
760 | - $summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) ); |
|
760 | + $summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give'))); |
|
761 | 761 | |
762 | 762 | // Form multilevel if applicable. |
763 | - if ( isset( $donation_data['post_data']['give-price-id'] ) ) { |
|
764 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
763 | + if (isset($donation_data['post_data']['give-price-id'])) { |
|
764 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | // Add Donor's name + email if requested. |
768 | - if ( $name_and_email ) { |
|
768 | + if ($name_and_email) { |
|
769 | 769 | |
770 | 770 | // First name |
771 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
772 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
771 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
772 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
773 | 773 | } |
774 | 774 | |
775 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
776 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
775 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
776 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
777 | 777 | } |
778 | 778 | |
779 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
779 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | // Cut the length |
783 | - $summary = substr( $summary, 0, $length ); |
|
783 | + $summary = substr($summary, 0, $length); |
|
784 | 784 | |
785 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
785 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -797,31 +797,31 @@ discard block |
||
797 | 797 | function give_get_host() { |
798 | 798 | $host = false; |
799 | 799 | |
800 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
800 | + if (defined('WPE_APIKEY')) { |
|
801 | 801 | $host = 'WP Engine'; |
802 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
802 | + } elseif (defined('PAGELYBIN')) { |
|
803 | 803 | $host = 'Pagely'; |
804 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
804 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
805 | 805 | $host = 'ICDSoft'; |
806 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
806 | + } elseif (DB_HOST == 'mysqlv5') { |
|
807 | 807 | $host = 'NetworkSolutions'; |
808 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
808 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
809 | 809 | $host = 'iPage'; |
810 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
810 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
811 | 811 | $host = 'IPower'; |
812 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
812 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
813 | 813 | $host = 'MediaTemple Grid'; |
814 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
814 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
815 | 815 | $host = 'pair Networks'; |
816 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
816 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
817 | 817 | $host = 'Rackspace Cloud'; |
818 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
818 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
819 | 819 | $host = 'SysFix.eu Power Hosting'; |
820 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
820 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
821 | 821 | $host = 'Flywheel'; |
822 | 822 | } else { |
823 | 823 | // Adding a general fallback for data gathering |
824 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
824 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | return $host; |
@@ -837,67 +837,67 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @return bool true if host matches, false if not |
839 | 839 | */ |
840 | -function give_is_host( $host = false ) { |
|
840 | +function give_is_host($host = false) { |
|
841 | 841 | |
842 | 842 | $return = false; |
843 | 843 | |
844 | - if ( $host ) { |
|
845 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
844 | + if ($host) { |
|
845 | + $host = str_replace(' ', '', strtolower($host)); |
|
846 | 846 | |
847 | - switch ( $host ) { |
|
847 | + switch ($host) { |
|
848 | 848 | case 'wpengine': |
849 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
849 | + if (defined('WPE_APIKEY')) { |
|
850 | 850 | $return = true; |
851 | 851 | } |
852 | 852 | break; |
853 | 853 | case 'pagely': |
854 | - if ( defined( 'PAGELYBIN' ) ) { |
|
854 | + if (defined('PAGELYBIN')) { |
|
855 | 855 | $return = true; |
856 | 856 | } |
857 | 857 | break; |
858 | 858 | case 'icdsoft': |
859 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
859 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
860 | 860 | $return = true; |
861 | 861 | } |
862 | 862 | break; |
863 | 863 | case 'networksolutions': |
864 | - if ( DB_HOST == 'mysqlv5' ) { |
|
864 | + if (DB_HOST == 'mysqlv5') { |
|
865 | 865 | $return = true; |
866 | 866 | } |
867 | 867 | break; |
868 | 868 | case 'ipage': |
869 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
869 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
870 | 870 | $return = true; |
871 | 871 | } |
872 | 872 | break; |
873 | 873 | case 'ipower': |
874 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
874 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
875 | 875 | $return = true; |
876 | 876 | } |
877 | 877 | break; |
878 | 878 | case 'mediatemplegrid': |
879 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
879 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
880 | 880 | $return = true; |
881 | 881 | } |
882 | 882 | break; |
883 | 883 | case 'pairnetworks': |
884 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
884 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
885 | 885 | $return = true; |
886 | 886 | } |
887 | 887 | break; |
888 | 888 | case 'rackspacecloud': |
889 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
889 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
890 | 890 | $return = true; |
891 | 891 | } |
892 | 892 | break; |
893 | 893 | case 'sysfix.eu': |
894 | 894 | case 'sysfix.eupowerhosting': |
895 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
895 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
896 | 896 | $return = true; |
897 | 897 | } |
898 | 898 | break; |
899 | 899 | case 'flywheel': |
900 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
900 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
901 | 901 | $return = true; |
902 | 902 | } |
903 | 903 | break; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * @param string $replacement Optional. The function that should have been called. |
931 | 931 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
932 | 932 | */ |
933 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
933 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
934 | 934 | |
935 | 935 | /** |
936 | 936 | * Fires while give deprecated function call occurs. |
@@ -943,19 +943,19 @@ discard block |
||
943 | 943 | * @param string $replacement Optional. The function that should have been called. |
944 | 944 | * @param string $version The plugin version that deprecated the function. |
945 | 945 | */ |
946 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
946 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
947 | 947 | |
948 | - $show_errors = current_user_can( 'manage_options' ); |
|
948 | + $show_errors = current_user_can('manage_options'); |
|
949 | 949 | |
950 | 950 | // Allow plugin to filter the output error trigger. |
951 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
952 | - if ( ! is_null( $replacement ) ) { |
|
953 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
954 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
951 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
952 | + if ( ! is_null($replacement)) { |
|
953 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
954 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
955 | 955 | // Alternatively we could dump this to a file. |
956 | 956 | } else { |
957 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
958 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
957 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
958 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
959 | 959 | // Alternatively we could dump this to a file. |
960 | 960 | } |
961 | 961 | } |
@@ -969,8 +969,8 @@ discard block |
||
969 | 969 | * @return string $post_id |
970 | 970 | */ |
971 | 971 | function give_get_admin_post_id() { |
972 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
973 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
972 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
973 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
974 | 974 | $post_id = $_POST['post_id']; |
975 | 975 | } |
976 | 976 | |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @return string Arg separator output |
985 | 985 | */ |
986 | 986 | function give_get_php_arg_separator_output() { |
987 | - return ini_get( 'arg_separator.output' ); |
|
987 | + return ini_get('arg_separator.output'); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | |
@@ -999,10 +999,10 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return string Short month name |
1001 | 1001 | */ |
1002 | -function give_month_num_to_name( $n ) { |
|
1003 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
1002 | +function give_month_num_to_name($n) { |
|
1003 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
1004 | 1004 | |
1005 | - return date_i18n( 'M', $timestamp ); |
|
1005 | + return date_i18n('M', $timestamp); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | |
@@ -1015,10 +1015,10 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return bool Whether or not function is disabled. |
1017 | 1017 | */ |
1018 | -function give_is_func_disabled( $function ) { |
|
1019 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
1018 | +function give_is_func_disabled($function) { |
|
1019 | + $disabled = explode(',', ini_get('disable_functions')); |
|
1020 | 1020 | |
1021 | - return in_array( $function, $disabled ); |
|
1021 | + return in_array($function, $disabled); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | function give_get_newsletter() { |
1030 | 1030 | ?> |
1031 | 1031 | |
1032 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
1032 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
1033 | 1033 | |
1034 | 1034 | <div class="give-newsletter-form-wrap"> |
1035 | 1035 | |
@@ -1037,33 +1037,33 @@ discard block |
||
1037 | 1037 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
1038 | 1038 | target="_blank" novalidate> |
1039 | 1039 | <div class="give-newsletter-confirmation"> |
1040 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
1040 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
1041 | 1041 | </div> |
1042 | 1042 | |
1043 | 1043 | <table class="form-table give-newsletter-form"> |
1044 | 1044 | <tr valign="middle"> |
1045 | 1045 | <td> |
1046 | 1046 | <label for="mce-EMAIL" |
1047 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
1047 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
1048 | 1048 | <input type="email" name="EMAIL" id="mce-EMAIL" |
1049 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
1049 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
1050 | 1050 | class="required email" value=""> |
1051 | 1051 | </td> |
1052 | 1052 | <td> |
1053 | 1053 | <label for="mce-FNAME" |
1054 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
1054 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
1055 | 1055 | <input type="text" name="FNAME" id="mce-FNAME" |
1056 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
1056 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
1057 | 1057 | </td> |
1058 | 1058 | <td> |
1059 | 1059 | <label for="mce-LNAME" |
1060 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
1060 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
1061 | 1061 | <input type="text" name="LNAME" id="mce-LNAME" |
1062 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
1062 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
1063 | 1063 | </td> |
1064 | 1064 | <td> |
1065 | 1065 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
1066 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
1066 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
1067 | 1067 | </td> |
1068 | 1068 | </tr> |
1069 | 1069 | </table> |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string |
1118 | 1118 | */ |
1119 | -function give_svg_icons( $icon ) { |
|
1119 | +function give_svg_icons($icon) { |
|
1120 | 1120 | |
1121 | 1121 | // Store your SVGs in an associative array |
1122 | 1122 | $svgs = array( |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | ); |
1129 | 1129 | |
1130 | 1130 | // Return the chosen icon's SVG string |
1131 | - return $svgs[ $icon ]; |
|
1131 | + return $svgs[$icon]; |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | /** |
@@ -1140,15 +1140,15 @@ discard block |
||
1140 | 1140 | * |
1141 | 1141 | * @return mixed |
1142 | 1142 | */ |
1143 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
1144 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
1145 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
1143 | +function modify_nav_menu_meta_box_object($post_type) { |
|
1144 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
1145 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | return $post_type; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
1151 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
1152 | 1152 | |
1153 | 1153 | /** |
1154 | 1154 | * Show Donation Forms Post Type in Appearance > Menus by default on fresh install. |
@@ -1167,35 +1167,35 @@ discard block |
||
1167 | 1167 | // Proceed, if current screen is navigation menus. |
1168 | 1168 | if ( |
1169 | 1169 | 'nav-menus' === $screen->id && |
1170 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && |
|
1171 | - ! get_user_option( 'give_is_donation_forms_menu_updated' ) |
|
1170 | + give_is_setting_enabled(give_get_option('forms_singular')) && |
|
1171 | + ! get_user_option('give_is_donation_forms_menu_updated') |
|
1172 | 1172 | ) { |
1173 | 1173 | |
1174 | 1174 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
1175 | 1175 | if ( |
1176 | 1176 | ! is_admin() || |
1177 | - ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) |
|
1177 | + ( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) |
|
1178 | 1178 | ) { |
1179 | 1179 | return false; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
1183 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
1183 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
1184 | 1184 | return false; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | // Exclude 'Donation Form' value from hidden meta box's list. |
1188 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
1188 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
1189 | 1189 | |
1190 | 1190 | // Get current user ID. |
1191 | 1191 | $user = wp_get_current_user(); |
1192 | 1192 | |
1193 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
1194 | - update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true ); |
|
1193 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
1194 | + update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
1198 | -add_action( 'current_screen', 'give_donation_metabox_menu' ); |
|
1198 | +add_action('current_screen', 'give_donation_metabox_menu'); |
|
1199 | 1199 | |
1200 | 1200 | /** |
1201 | 1201 | * Array_column backup usage |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | * @license https://opensource.org/licenses/MIT MIT |
1209 | 1209 | */ |
1210 | 1210 | |
1211 | -if ( ! function_exists( 'array_column' ) ) { |
|
1211 | +if ( ! function_exists('array_column')) { |
|
1212 | 1212 | /** |
1213 | 1213 | * Returns the values from a single column of the input array, identified by |
1214 | 1214 | * the $columnKey. |
@@ -1227,53 +1227,53 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return array |
1229 | 1229 | */ |
1230 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
1230 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
1231 | 1231 | // Using func_get_args() in order to check for proper number of |
1232 | 1232 | // parameters and trigger errors exactly as the built-in array_column() |
1233 | 1233 | // does in PHP 5.5. |
1234 | 1234 | $argc = func_num_args(); |
1235 | 1235 | $params = func_get_args(); |
1236 | 1236 | |
1237 | - if ( $argc < 2 ) { |
|
1238 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
1237 | + if ($argc < 2) { |
|
1238 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
1239 | 1239 | |
1240 | 1240 | return null; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - if ( ! is_array( $params[0] ) ) { |
|
1244 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
1243 | + if ( ! is_array($params[0])) { |
|
1244 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
1245 | 1245 | |
1246 | 1246 | return null; |
1247 | 1247 | } |
1248 | 1248 | |
1249 | - if ( ! is_int( $params[1] ) |
|
1250 | - && ! is_float( $params[1] ) |
|
1251 | - && ! is_string( $params[1] ) |
|
1249 | + if ( ! is_int($params[1]) |
|
1250 | + && ! is_float($params[1]) |
|
1251 | + && ! is_string($params[1]) |
|
1252 | 1252 | && $params[1] !== null |
1253 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
1253 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
1254 | 1254 | ) { |
1255 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
1255 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
1256 | 1256 | |
1257 | 1257 | return false; |
1258 | 1258 | } |
1259 | 1259 | |
1260 | - if ( isset( $params[2] ) |
|
1261 | - && ! is_int( $params[2] ) |
|
1262 | - && ! is_float( $params[2] ) |
|
1263 | - && ! is_string( $params[2] ) |
|
1264 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
1260 | + if (isset($params[2]) |
|
1261 | + && ! is_int($params[2]) |
|
1262 | + && ! is_float($params[2]) |
|
1263 | + && ! is_string($params[2]) |
|
1264 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
1265 | 1265 | ) { |
1266 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
1266 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
1267 | 1267 | |
1268 | 1268 | return false; |
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | $paramsInput = $params[0]; |
1272 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
1272 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
1273 | 1273 | |
1274 | 1274 | $paramsIndexKey = null; |
1275 | - if ( isset( $params[2] ) ) { |
|
1276 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
1275 | + if (isset($params[2])) { |
|
1276 | + if (is_float($params[2]) || is_int($params[2])) { |
|
1277 | 1277 | $paramsIndexKey = (int) $params[2]; |
1278 | 1278 | } else { |
1279 | 1279 | $paramsIndexKey = (string) $params[2]; |
@@ -1282,26 +1282,26 @@ discard block |
||
1282 | 1282 | |
1283 | 1283 | $resultArray = array(); |
1284 | 1284 | |
1285 | - foreach ( $paramsInput as $row ) { |
|
1285 | + foreach ($paramsInput as $row) { |
|
1286 | 1286 | $key = $value = null; |
1287 | 1287 | $keySet = $valueSet = false; |
1288 | 1288 | |
1289 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
1289 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
1290 | 1290 | $keySet = true; |
1291 | - $key = (string) $row[ $paramsIndexKey ]; |
|
1291 | + $key = (string) $row[$paramsIndexKey]; |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | - if ( $paramsColumnKey === null ) { |
|
1294 | + if ($paramsColumnKey === null) { |
|
1295 | 1295 | $valueSet = true; |
1296 | 1296 | $value = $row; |
1297 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
1297 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
1298 | 1298 | $valueSet = true; |
1299 | - $value = $row[ $paramsColumnKey ]; |
|
1299 | + $value = $row[$paramsColumnKey]; |
|
1300 | 1300 | } |
1301 | 1301 | |
1302 | - if ( $valueSet ) { |
|
1303 | - if ( $keySet ) { |
|
1304 | - $resultArray[ $key ] = $value; |
|
1302 | + if ($valueSet) { |
|
1303 | + if ($keySet) { |
|
1304 | + $resultArray[$key] = $value; |
|
1305 | 1305 | } else { |
1306 | 1306 | $resultArray[] = $value; |
1307 | 1307 | } |
@@ -1321,40 +1321,40 @@ discard block |
||
1321 | 1321 | * |
1322 | 1322 | * @return bool Whether the receipt is visible or not. |
1323 | 1323 | */ |
1324 | -function give_can_view_receipt( $payment_key = '' ) { |
|
1324 | +function give_can_view_receipt($payment_key = '') { |
|
1325 | 1325 | |
1326 | 1326 | $return = false; |
1327 | 1327 | |
1328 | - if ( empty( $payment_key ) ) { |
|
1328 | + if (empty($payment_key)) { |
|
1329 | 1329 | return $return; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | global $give_receipt_args; |
1333 | 1333 | |
1334 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
1334 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
1335 | 1335 | |
1336 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
1336 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
1337 | 1337 | |
1338 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
1338 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
1339 | 1339 | |
1340 | - if ( is_user_logged_in() ) { |
|
1341 | - if ( $user_id === (int) get_current_user_id() ) { |
|
1340 | + if (is_user_logged_in()) { |
|
1341 | + if ($user_id === (int) get_current_user_id()) { |
|
1342 | 1342 | $return = true; |
1343 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
1343 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
1344 | 1344 | $return = true; |
1345 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
1345 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
1346 | 1346 | $return = true; |
1347 | 1347 | } |
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | $session = give_get_purchase_session(); |
1351 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
1352 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
1351 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
1352 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
1353 | 1353 | $return = true; |
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
1357 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
1358 | 1358 | |
1359 | 1359 | } |
1360 | 1360 | |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
1365 | 1365 | */ |
1366 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
1366 | +if ( ! function_exists('cal_days_in_month')) { |
|
1367 | 1367 | /** |
1368 | 1368 | * cal_days_in_month |
1369 | 1369 | * |
@@ -1373,8 +1373,8 @@ discard block |
||
1373 | 1373 | * |
1374 | 1374 | * @return bool|string |
1375 | 1375 | */ |
1376 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
1377 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
1376 | + function cal_days_in_month($calendar, $month, $year) { |
|
1377 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | |
@@ -1393,42 +1393,42 @@ discard block |
||
1393 | 1393 | */ |
1394 | 1394 | function give_get_plugins() { |
1395 | 1395 | $plugins = get_plugins(); |
1396 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
1396 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
1397 | 1397 | |
1398 | - if ( is_multisite() ) { |
|
1399 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
1400 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
1398 | + if (is_multisite()) { |
|
1399 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
1400 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
1403 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
1404 | 1404 | // Is plugin active? |
1405 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
1406 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
1405 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
1406 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
1407 | 1407 | } else { |
1408 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
1408 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
1411 | + $dirname = strtolower(dirname($plugin_path)); |
|
1412 | 1412 | |
1413 | 1413 | // Is plugin a Give add-on by WordImpress? |
1414 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
1414 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
1415 | 1415 | // Plugin is a Give-addon. |
1416 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
1416 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
1417 | 1417 | |
1418 | 1418 | // Get license info from database. |
1419 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
1420 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
1421 | - $license_active = get_option( $db_option ); |
|
1419 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
1420 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
1421 | + $license_active = get_option($db_option); |
|
1422 | 1422 | |
1423 | 1423 | // Does a valid license exist? |
1424 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
1425 | - $plugins[ $plugin_path ]['License'] = true; |
|
1424 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
1425 | + $plugins[$plugin_path]['License'] = true; |
|
1426 | 1426 | } else { |
1427 | - $plugins[ $plugin_path ]['License'] = false; |
|
1427 | + $plugins[$plugin_path]['License'] = false; |
|
1428 | 1428 | } |
1429 | 1429 | } else { |
1430 | 1430 | // Plugin is not a Give add-on. |
1431 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
1431 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1432 | 1432 | } |
1433 | 1433 | } |
1434 | 1434 | |
@@ -1445,16 +1445,16 @@ discard block |
||
1445 | 1445 | * |
1446 | 1446 | * @return bool |
1447 | 1447 | */ |
1448 | -function give_is_terms_enabled( $form_id ) { |
|
1449 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1448 | +function give_is_terms_enabled($form_id) { |
|
1449 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1450 | 1450 | |
1451 | 1451 | if ( |
1452 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1453 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1452 | + give_is_setting_enabled($form_option, 'global') |
|
1453 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1454 | 1454 | ) { |
1455 | 1455 | return true; |
1456 | 1456 | |
1457 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1457 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1458 | 1458 | return true; |
1459 | 1459 | |
1460 | 1460 | } else { |
@@ -1478,9 +1478,9 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @return WP_Error|bool |
1480 | 1480 | */ |
1481 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1481 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1482 | 1482 | // Delete all cache. |
1483 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1483 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1484 | 1484 | |
1485 | 1485 | /** |
1486 | 1486 | * Fire the action when donation stats delete. |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | * @param string|array $date_range |
1491 | 1491 | * @param array $args |
1492 | 1492 | */ |
1493 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1493 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1494 | 1494 | |
1495 | 1495 | return $status; |
1496 | 1496 | } |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | * |
1509 | 1509 | * @return mixed |
1510 | 1510 | */ |
1511 | -function give_get_meta( $id, $meta_key, $single = false, $default = false ) { |
|
1511 | +function give_get_meta($id, $meta_key, $single = false, $default = false) { |
|
1512 | 1512 | /** |
1513 | 1513 | * Filter the meta value |
1514 | 1514 | * |
@@ -1516,14 +1516,14 @@ discard block |
||
1516 | 1516 | */ |
1517 | 1517 | $meta_value = apply_filters( |
1518 | 1518 | 'give_get_meta', |
1519 | - get_post_meta( $id, $meta_key, $single ), |
|
1519 | + get_post_meta($id, $meta_key, $single), |
|
1520 | 1520 | $id, |
1521 | 1521 | $meta_key, |
1522 | 1522 | $default |
1523 | 1523 | ); |
1524 | 1524 | |
1525 | 1525 | if ( |
1526 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
1526 | + (empty($meta_key) || empty($meta_value)) |
|
1527 | 1527 | && $default |
1528 | 1528 | ) { |
1529 | 1529 | $meta_value = $default; |
@@ -1544,15 +1544,15 @@ discard block |
||
1544 | 1544 | * |
1545 | 1545 | * @return mixed |
1546 | 1546 | */ |
1547 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1548 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
1547 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
1548 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
1549 | 1549 | |
1550 | 1550 | /** |
1551 | 1551 | * Filter the meta value update status |
1552 | 1552 | * |
1553 | 1553 | * @since 1.8.8 |
1554 | 1554 | */ |
1555 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
1555 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | /** |
@@ -1566,15 +1566,15 @@ discard block |
||
1566 | 1566 | * |
1567 | 1567 | * @return mixed |
1568 | 1568 | */ |
1569 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
1570 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
1569 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
1570 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
1571 | 1571 | |
1572 | 1572 | /** |
1573 | 1573 | * Filter the meta value delete status |
1574 | 1574 | * |
1575 | 1575 | * @since 1.8.8 |
1576 | 1576 | */ |
1577 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
1577 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | /** |
@@ -1586,15 +1586,15 @@ discard block |
||
1586 | 1586 | * |
1587 | 1587 | * @return bool If the action has been added to the completed actions array |
1588 | 1588 | */ |
1589 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
1589 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
1590 | 1590 | |
1591 | - if ( empty( $upgrade_action ) ) { |
|
1591 | + if (empty($upgrade_action)) { |
|
1592 | 1592 | return false; |
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | $completed_upgrades = give_get_completed_upgrades(); |
1596 | 1596 | |
1597 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
1597 | + return in_array($upgrade_action, $completed_upgrades); |
|
1598 | 1598 | |
1599 | 1599 | } |
1600 | 1600 | |
@@ -1606,8 +1606,8 @@ discard block |
||
1606 | 1606 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
1607 | 1607 | */ |
1608 | 1608 | function give_maybe_resume_upgrade() { |
1609 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
1610 | - if ( empty( $doing_upgrade ) ) { |
|
1609 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
1610 | + if (empty($doing_upgrade)) { |
|
1611 | 1611 | return false; |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1623,9 +1623,9 @@ discard block |
||
1623 | 1623 | * |
1624 | 1624 | * @return bool If the function was successfully added |
1625 | 1625 | */ |
1626 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
1626 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
1627 | 1627 | |
1628 | - if ( empty( $upgrade_action ) ) { |
|
1628 | + if (empty($upgrade_action)) { |
|
1629 | 1629 | return false; |
1630 | 1630 | } |
1631 | 1631 | |
@@ -1633,16 +1633,16 @@ discard block |
||
1633 | 1633 | $completed_upgrades[] = $upgrade_action; |
1634 | 1634 | |
1635 | 1635 | // Remove any blanks, and only show uniques. |
1636 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
1636 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
1637 | 1637 | |
1638 | 1638 | /** |
1639 | 1639 | * Fire the action when any upgrade set to complete. |
1640 | 1640 | * |
1641 | 1641 | * @since 1.8.12 |
1642 | 1642 | */ |
1643 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
1643 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
1644 | 1644 | |
1645 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
1645 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | * @return array The array of completed upgrades |
1653 | 1653 | */ |
1654 | 1654 | function give_get_completed_upgrades() { |
1655 | - return (array) get_option( 'give_completed_upgrades' ); |
|
1655 | + return (array) get_option('give_completed_upgrades'); |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | 1658 | /** |
@@ -1662,21 +1662,21 @@ discard block |
||
1662 | 1662 | * |
1663 | 1663 | * @param \WP_Query |
1664 | 1664 | */ |
1665 | -function give_remove_pages_from_search( $query ) { |
|
1666 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
1667 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
1668 | - $success_page = give_get_option( 'success_page', 0 ); |
|
1665 | +function give_remove_pages_from_search($query) { |
|
1666 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
1667 | + $transaction_failed = give_get_option('failure_page', 0); |
|
1668 | + $success_page = give_get_option('success_page', 0); |
|
1669 | 1669 | $args = apply_filters( |
1670 | 1670 | 'give_remove_pages_from_search', array( |
1671 | 1671 | $transaction_failed, |
1672 | 1672 | $success_page, |
1673 | 1673 | ), $query |
1674 | 1674 | ); |
1675 | - $query->set( 'post__not_in', $args ); |
|
1675 | + $query->set('post__not_in', $args); |
|
1676 | 1676 | } |
1677 | 1677 | } |
1678 | 1678 | |
1679 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
1679 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
1680 | 1680 | |
1681 | 1681 | /** |
1682 | 1682 | * Inserts a new key/value before a key in the array. |
@@ -1692,14 +1692,14 @@ discard block |
||
1692 | 1692 | * |
1693 | 1693 | * @see array_insert_before() |
1694 | 1694 | */ |
1695 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
1696 | - if ( array_key_exists( $key, $array ) ) { |
|
1695 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
1696 | + if (array_key_exists($key, $array)) { |
|
1697 | 1697 | $new = array(); |
1698 | - foreach ( $array as $k => $value ) { |
|
1699 | - if ( $k === $key ) { |
|
1700 | - $new[ $new_key ] = $new_value; |
|
1698 | + foreach ($array as $k => $value) { |
|
1699 | + if ($k === $key) { |
|
1700 | + $new[$new_key] = $new_value; |
|
1701 | 1701 | } |
1702 | - $new[ $k ] = $value; |
|
1702 | + $new[$k] = $value; |
|
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | return $new; |
@@ -1722,13 +1722,13 @@ discard block |
||
1722 | 1722 | * |
1723 | 1723 | * @see array_insert_before() |
1724 | 1724 | */ |
1725 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
1726 | - if ( array_key_exists( $key, $array ) ) { |
|
1725 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
1726 | + if (array_key_exists($key, $array)) { |
|
1727 | 1727 | $new = array(); |
1728 | - foreach ( $array as $k => $value ) { |
|
1729 | - $new[ $k ] = $value; |
|
1730 | - if ( $k === $key ) { |
|
1731 | - $new[ $new_key ] = $new_value; |
|
1728 | + foreach ($array as $k => $value) { |
|
1729 | + $new[$k] = $value; |
|
1730 | + if ($k === $key) { |
|
1731 | + $new[$new_key] = $new_value; |
|
1732 | 1732 | } |
1733 | 1733 | } |
1734 | 1734 | |
@@ -1755,21 +1755,21 @@ discard block |
||
1755 | 1755 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
1756 | 1756 | * `$list` will be preserved in the results. |
1757 | 1757 | */ |
1758 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
1758 | +function give_list_pluck($list, $field, $index_key = null) { |
|
1759 | 1759 | |
1760 | - if ( ! $index_key ) { |
|
1760 | + if ( ! $index_key) { |
|
1761 | 1761 | /* |
1762 | 1762 | * This is simple. Could at some point wrap array_column() |
1763 | 1763 | * if we knew we had an array of arrays. |
1764 | 1764 | */ |
1765 | - foreach ( $list as $key => $value ) { |
|
1766 | - if ( is_object( $value ) ) { |
|
1767 | - if ( isset( $value->$field ) ) { |
|
1768 | - $list[ $key ] = $value->$field; |
|
1765 | + foreach ($list as $key => $value) { |
|
1766 | + if (is_object($value)) { |
|
1767 | + if (isset($value->$field)) { |
|
1768 | + $list[$key] = $value->$field; |
|
1769 | 1769 | } |
1770 | 1770 | } else { |
1771 | - if ( isset( $value[ $field ] ) ) { |
|
1772 | - $list[ $key ] = $value[ $field ]; |
|
1771 | + if (isset($value[$field])) { |
|
1772 | + $list[$key] = $value[$field]; |
|
1773 | 1773 | } |
1774 | 1774 | } |
1775 | 1775 | } |
@@ -1782,18 +1782,18 @@ discard block |
||
1782 | 1782 | * to the end of the stack. This is how array_column() behaves. |
1783 | 1783 | */ |
1784 | 1784 | $newlist = array(); |
1785 | - foreach ( $list as $value ) { |
|
1786 | - if ( is_object( $value ) ) { |
|
1787 | - if ( isset( $value->$index_key ) ) { |
|
1788 | - $newlist[ $value->$index_key ] = $value->$field; |
|
1785 | + foreach ($list as $value) { |
|
1786 | + if (is_object($value)) { |
|
1787 | + if (isset($value->$index_key)) { |
|
1788 | + $newlist[$value->$index_key] = $value->$field; |
|
1789 | 1789 | } else { |
1790 | 1790 | $newlist[] = $value->$field; |
1791 | 1791 | } |
1792 | 1792 | } else { |
1793 | - if ( isset( $value[ $index_key ] ) ) { |
|
1794 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
1793 | + if (isset($value[$index_key])) { |
|
1794 | + $newlist[$value[$index_key]] = $value[$field]; |
|
1795 | 1795 | } else { |
1796 | - $newlist[] = $value[ $field ]; |
|
1796 | + $newlist[] = $value[$field]; |
|
1797 | 1797 | } |
1798 | 1798 | } |
1799 | 1799 | } |
@@ -1816,8 +1816,8 @@ discard block |
||
1816 | 1816 | * |
1817 | 1817 | * @return int|false Meta ID on success, false on failure. |
1818 | 1818 | */ |
1819 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
1820 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
1819 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
1820 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | /** |
@@ -1835,8 +1835,8 @@ discard block |
||
1835 | 1835 | * |
1836 | 1836 | * @return bool True on success, false on failure. |
1837 | 1837 | */ |
1838 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
1839 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
1838 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
1839 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | /** |
@@ -1851,8 +1851,8 @@ discard block |
||
1851 | 1851 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
1852 | 1852 | * is true. |
1853 | 1853 | */ |
1854 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
1855 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
1854 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
1855 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
1856 | 1856 | } |
1857 | 1857 | |
1858 | 1858 | /** |
@@ -1869,8 +1869,8 @@ discard block |
||
1869 | 1869 | * |
1870 | 1870 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
1871 | 1871 | */ |
1872 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1873 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
1872 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
1873 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
1874 | 1874 | } |
1875 | 1875 | |
1876 | 1876 | /* |
@@ -1880,15 +1880,15 @@ discard block |
||
1880 | 1880 | * |
1881 | 1881 | * @param int $form_id Form id of which recalculation needs to be done. |
1882 | 1882 | */ |
1883 | -function give_recount_form_income_donation( $form_id = false ) { |
|
1883 | +function give_recount_form_income_donation($form_id = false) { |
|
1884 | 1884 | // Check if form id is not empty. |
1885 | - if ( ! empty( $form_id ) ) { |
|
1885 | + if ( ! empty($form_id)) { |
|
1886 | 1886 | /** |
1887 | 1887 | * Filter to modify payment status. |
1888 | 1888 | * |
1889 | 1889 | * @since 1.8.13 |
1890 | 1890 | */ |
1891 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
1891 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
1892 | 1892 | |
1893 | 1893 | /** |
1894 | 1894 | * Filter to modify args of payment query before recalculating the form total |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | 'give_recount_form_stats_args', array( |
1900 | 1900 | 'give_forms' => $form_id, |
1901 | 1901 | 'status' => $accepted_statuses, |
1902 | - 'posts_per_page' => - 1, |
|
1902 | + 'posts_per_page' => -1, |
|
1903 | 1903 | 'fields' => 'ids', |
1904 | 1904 | ) |
1905 | 1905 | ); |
@@ -1909,28 +1909,28 @@ discard block |
||
1909 | 1909 | 'earnings' => 0, |
1910 | 1910 | ); |
1911 | 1911 | |
1912 | - $payments = new Give_Payments_Query( $args ); |
|
1912 | + $payments = new Give_Payments_Query($args); |
|
1913 | 1913 | $payments = $payments->get_payments(); |
1914 | 1914 | |
1915 | - if ( $payments ) { |
|
1916 | - foreach ( $payments as $payment ) { |
|
1915 | + if ($payments) { |
|
1916 | + foreach ($payments as $payment) { |
|
1917 | 1917 | // Ensure acceptible status only |
1918 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
1918 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
1919 | 1919 | continue; |
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | // Ensure only payments for this form are counted |
1923 | - if ( $payment->form_id != $form_id ) { |
|
1923 | + if ($payment->form_id != $form_id) { |
|
1924 | 1924 | continue; |
1925 | 1925 | } |
1926 | 1926 | |
1927 | - $totals['sales'] ++; |
|
1927 | + $totals['sales']++; |
|
1928 | 1928 | $totals['earnings'] += $payment->total; |
1929 | 1929 | |
1930 | 1930 | } |
1931 | 1931 | } |
1932 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
1933 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
1932 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
1933 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
1934 | 1934 | }// End if(). |
1935 | 1935 | } |
1936 | 1936 | |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | * |
1946 | 1946 | * @return bool |
1947 | 1947 | */ |
1948 | -function give_is_zero_based_currency( $currency = '' ) { |
|
1948 | +function give_is_zero_based_currency($currency = '') { |
|
1949 | 1949 | $zero_based_currency = array( |
1950 | 1950 | 'PYG', // Paraguayan Guarani. |
1951 | 1951 | 'GNF', // Guinean Franc. |
@@ -1965,12 +1965,12 @@ discard block |
||
1965 | 1965 | ); |
1966 | 1966 | |
1967 | 1967 | // Set default currency. |
1968 | - if( empty( $currency ) ) { |
|
1968 | + if (empty($currency)) { |
|
1969 | 1969 | $currency = give_get_currency(); |
1970 | 1970 | } |
1971 | 1971 | |
1972 | 1972 | // Check for Zero Based Currency. |
1973 | - if ( in_array( $currency, $zero_based_currency ) ) { |
|
1973 | + if (in_array($currency, $zero_based_currency)) { |
|
1974 | 1974 | return true; |
1975 | 1975 | } |
1976 | 1976 |
@@ -3,33 +3,33 @@ discard block |
||
3 | 3 | * This template is used to display the donation history of the current user. |
4 | 4 | */ |
5 | 5 | |
6 | -$donation_history_args = Give()->session->get( 'give_donation_history_args' ); |
|
6 | +$donation_history_args = Give()->session->get('give_donation_history_args'); |
|
7 | 7 | |
8 | 8 | $donations = array(); |
9 | 9 | |
10 | 10 | // User's Donations. |
11 | -if ( is_user_logged_in() ) { |
|
12 | - $donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' ); |
|
13 | -} elseif ( Give()->email_access->token_exists ) { |
|
11 | +if (is_user_logged_in()) { |
|
12 | + $donations = give_get_users_donations(get_current_user_id(), 20, true, 'any'); |
|
13 | +} elseif (Give()->email_access->token_exists) { |
|
14 | 14 | // Email Access Token? |
15 | - $donations = give_get_users_donations( 0, 20, true, 'any' ); |
|
16 | -} elseif ( Give()->session->get_session_expiration() !== false ) { |
|
15 | + $donations = give_get_users_donations(0, 20, true, 'any'); |
|
16 | +} elseif (Give()->session->get_session_expiration() !== false) { |
|
17 | 17 | // Session active? |
18 | - $email = Give()->session->get( 'give_email' ); |
|
19 | - $donations = give_get_users_donations( $email, 20, true, 'any' ); |
|
18 | + $email = Give()->session->get('give_email'); |
|
19 | + $donations = give_get_users_donations($email, 20, true, 'any'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | -if ( $donations ) : ?> |
|
23 | +if ($donations) : ?> |
|
24 | 24 | <?php |
25 | 25 | $table_headings = array( |
26 | - 'id' => __( 'ID', 'give' ), |
|
27 | - 'date' => __( 'Date', 'give' ), |
|
28 | - 'donor' => __( 'Donor', 'give' ), |
|
29 | - 'amount' => __( 'Amount', 'give' ), |
|
30 | - 'status' => __( 'Status', 'give' ), |
|
31 | - 'payment_method' => __( 'Payment Method', 'give' ), |
|
32 | - 'details' => __( 'Details', 'give' ), |
|
26 | + 'id' => __('ID', 'give'), |
|
27 | + 'date' => __('Date', 'give'), |
|
28 | + 'donor' => __('Donor', 'give'), |
|
29 | + 'amount' => __('Amount', 'give'), |
|
30 | + 'status' => __('Status', 'give'), |
|
31 | + 'payment_method' => __('Payment Method', 'give'), |
|
32 | + 'details' => __('Details', 'give'), |
|
33 | 33 | ); |
34 | 34 | ?> |
35 | 35 | <table id="give_user_history" class="give-table"> |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @since 1.7 |
45 | 45 | */ |
46 | - do_action( 'give_donation_history_header_before' ); |
|
46 | + do_action('give_donation_history_header_before'); |
|
47 | 47 | |
48 | - foreach ( $donation_history_args as $index => $value ) { |
|
49 | - if ( filter_var( $donation_history_args[ $index ], FILTER_VALIDATE_BOOLEAN ) ) : |
|
48 | + foreach ($donation_history_args as $index => $value) { |
|
49 | + if (filter_var($donation_history_args[$index], FILTER_VALIDATE_BOOLEAN)) : |
|
50 | 50 | echo sprintf( |
51 | 51 | '<th scope="col" class="give-donation-%1$s>">%2$s</th>', |
52 | 52 | $index, |
53 | - $table_headings[ $index ] |
|
53 | + $table_headings[$index] |
|
54 | 54 | ); |
55 | 55 | endif; |
56 | 56 | } |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.7 |
64 | 64 | */ |
65 | - do_action( 'give_donation_history_header_after' ); |
|
65 | + do_action('give_donation_history_header_after'); |
|
66 | 66 | ?> |
67 | 67 | </tr> |
68 | 68 | </thead> |
69 | - <?php foreach ( $donations as $post ) : |
|
70 | - setup_postdata( $post ); |
|
71 | - $donation_data = give_get_payment_meta( $post->ID ); ?> |
|
69 | + <?php foreach ($donations as $post) : |
|
70 | + setup_postdata($post); |
|
71 | + $donation_data = give_get_payment_meta($post->ID); ?> |
|
72 | 72 | <tr class="give-donation-row"> |
73 | 73 | <?php |
74 | 74 | /** |
@@ -81,37 +81,37 @@ discard block |
||
81 | 81 | * @param int $post_id The ID of the post. |
82 | 82 | * @param mixed $donation_data Payment meta data. |
83 | 83 | */ |
84 | - do_action( 'give_donation_history_row_start', $post->ID, $donation_data ); |
|
84 | + do_action('give_donation_history_row_start', $post->ID, $donation_data); |
|
85 | 85 | |
86 | - if ( filter_var( $donation_history_args['id'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
86 | + if (filter_var($donation_history_args['id'], FILTER_VALIDATE_BOOLEAN)) : |
|
87 | 87 | echo sprintf( |
88 | 88 | '<td class="give-donation-id">#%s</td>', |
89 | - give_get_payment_number( $post->ID ) |
|
89 | + give_get_payment_number($post->ID) |
|
90 | 90 | ); |
91 | 91 | endif; |
92 | 92 | |
93 | - if ( filter_var( $donation_history_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
93 | + if (filter_var($donation_history_args['date'], FILTER_VALIDATE_BOOLEAN)) : |
|
94 | 94 | echo sprintf( |
95 | 95 | '<td class="give-donation-date">#%s</td>', |
96 | - date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ) |
|
96 | + date_i18n(give_date_format(), strtotime(get_post_field('post_date', $post->ID))) |
|
97 | 97 | ); |
98 | 98 | endif; |
99 | 99 | |
100 | - if ( filter_var( $donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
100 | + if (filter_var($donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN)) : |
|
101 | 101 | echo sprintf( |
102 | 102 | '<td class="give-donation-donor">#%s</td>', |
103 | - give_get_donor_name_by( $post->ID ) |
|
103 | + give_get_donor_name_by($post->ID) |
|
104 | 104 | ); |
105 | 105 | endif; |
106 | 106 | ?> |
107 | 107 | |
108 | - <?php if ( filter_var( $donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
|
108 | + <?php if (filter_var($donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN)) : ?> |
|
109 | 109 | <td class="give-donation-amount"> |
110 | 110 | <span class="give-donation-amount"> |
111 | 111 | <?php |
112 | - $currency_code = give_get_payment_currency_code( $post->ID ); |
|
112 | + $currency_code = give_get_payment_currency_code($post->ID); |
|
113 | 113 | $donation_amount = give_currency_filter( |
114 | - give_format_amount( give_get_payment_amount( $post->ID ), array( |
|
114 | + give_format_amount(give_get_payment_amount($post->ID), array( |
|
115 | 115 | 'sanitize' => false, |
116 | 116 | 'currency' => $currency_code, |
117 | 117 | )), |
@@ -128,42 +128,42 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return int |
130 | 130 | */ |
131 | - echo apply_filters( 'give_donation_history_row_amount', $donation_amount, $post->ID ); |
|
131 | + echo apply_filters('give_donation_history_row_amount', $donation_amount, $post->ID); |
|
132 | 132 | ?> |
133 | 133 | </span> |
134 | 134 | </td> |
135 | 135 | <?php endif; ?> |
136 | 136 | |
137 | 137 | <?php |
138 | - if ( filter_var( $donation_history_args['status'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
138 | + if (filter_var($donation_history_args['status'], FILTER_VALIDATE_BOOLEAN)) : |
|
139 | 139 | echo sprintf( |
140 | 140 | '<td class="give-donation-status">#%s</td>', |
141 | - give_get_payment_status( $post, true ) |
|
141 | + give_get_payment_status($post, true) |
|
142 | 142 | ); |
143 | 143 | endif; |
144 | 144 | |
145 | - if ( filter_var( $donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
145 | + if (filter_var($donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN)) : |
|
146 | 146 | echo sprintf( |
147 | 147 | '<td class="give-donation-payment-method">#%s</td>', |
148 | - give_get_gateway_checkout_label( give_get_payment_gateway( $post->ID ) ) |
|
148 | + give_get_gateway_checkout_label(give_get_payment_gateway($post->ID)) |
|
149 | 149 | ); |
150 | 150 | endif; |
151 | 151 | ?> |
152 | 152 | <td class="give-donation-details"> |
153 | 153 | <?php |
154 | 154 | // Display View Receipt or. |
155 | - if ( 'publish' !== $post->post_status && 'subscription' !== $post->post_status ) : |
|
155 | + if ('publish' !== $post->post_status && 'subscription' !== $post->post_status) : |
|
156 | 156 | echo sprintf( |
157 | 157 | '<a href="%1$s"><span class="give-donation-status %2$s">%3$s</span></a>', |
158 | 158 | esc_url( |
159 | 159 | add_query_arg( |
160 | 160 | 'payment_key', |
161 | - give_get_payment_key( $post->ID ), |
|
161 | + give_get_payment_key($post->ID), |
|
162 | 162 | give_get_history_page_uri() |
163 | 163 | ) |
164 | 164 | ), |
165 | 165 | $post->post_status, |
166 | - __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »' |
|
166 | + __('View', 'give').' '.give_get_payment_status($post, true).' »' |
|
167 | 167 | ); |
168 | 168 | |
169 | 169 | else : |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | esc_url( |
173 | 173 | add_query_arg( |
174 | 174 | 'payment_key', |
175 | - give_get_payment_key( $post->ID ), |
|
175 | + give_get_payment_key($post->ID), |
|
176 | 176 | give_get_history_page_uri() |
177 | 177 | ) |
178 | 178 | ), |
179 | - __( 'View Receipt »', 'give' ) |
|
179 | + __('View Receipt »', 'give') |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | endif; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param int $post_id The ID of the post. |
194 | 194 | * @param mixed $donation_data Payment meta data. |
195 | 195 | */ |
196 | - do_action( 'give_donation_history_row_end', $post->ID, $donation_data ); |
|
196 | + do_action('give_donation_history_row_end', $post->ID, $donation_data); |
|
197 | 197 | ?> |
198 | 198 | </tr> |
199 | 199 | <?php endforeach; ?> |
@@ -201,15 +201,15 @@ discard block |
||
201 | 201 | <div id="give-donation-history-pagination" class="give_pagination navigation"> |
202 | 202 | <?php |
203 | 203 | $big = 999999; |
204 | - echo paginate_links( array( |
|
205 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
204 | + echo paginate_links(array( |
|
205 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
206 | 206 | 'format' => '?paged=%#%', |
207 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
208 | - 'total' => ceil( give_count_donations_of_donor() / 20 ) // 20 items per page |
|
209 | - ) ); |
|
207 | + 'current' => max(1, get_query_var('paged')), |
|
208 | + 'total' => ceil(give_count_donations_of_donor() / 20) // 20 items per page |
|
209 | + )); |
|
210 | 210 | ?> |
211 | 211 | </div> |
212 | 212 | <?php wp_reset_postdata(); ?> |
213 | 213 | <?php else : ?> |
214 | - <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
|
214 | + <?php Give()->notices->print_frontend_notice(__('It looks like you haven\'t made any donations.', 'give'), true, 'success'); ?> |
|
215 | 215 | <?php endif; |
@@ -166,7 +166,8 @@ discard block |
||
166 | 166 | __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »' |
167 | 167 | ); |
168 | 168 | |
169 | - else : |
|
169 | + else { |
|
170 | + : |
|
170 | 171 | echo sprintf( |
171 | 172 | '<a href="%1$s">%2$s</a>', |
172 | 173 | esc_url( |
@@ -178,6 +179,7 @@ discard block |
||
178 | 179 | ), |
179 | 180 | __( 'View Receipt »', 'give' ) |
180 | 181 | ); |
182 | + } |
|
181 | 183 | |
182 | 184 | endif; |
183 | 185 | ?> |
@@ -210,6 +212,9 @@ discard block |
||
210 | 212 | ?> |
211 | 213 | </div> |
212 | 214 | <?php wp_reset_postdata(); ?> |
213 | -<?php else : ?> |
|
214 | - <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
|
215 | +<?php else { |
|
216 | + : ?> |
|
217 | + <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); |
|
218 | +} |
|
219 | +?> |
|
215 | 220 | <?php endif; |