@@ -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_purchase_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_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_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,18 +97,18 @@ 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'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $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']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
163 | +add_action('give_purchase', 'give_process_donation_form'); |
|
164 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer. |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,55 +247,55 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
274 | + if (give_is_terms_enabled($form_id)) { |
|
275 | 275 | give_purchase_form_validate_agree_to_terms(); |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
279 | 279 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
280 | 280 | if ( |
281 | - ! give_logged_in_only( $form_id ) |
|
282 | - && isset( $_POST['give-purchase-var'] ) |
|
281 | + ! give_logged_in_only($form_id) |
|
282 | + && isset($_POST['give-purchase-var']) |
|
283 | 283 | && $_POST['give-purchase-var'] == 'needs-to-register' |
284 | - && empty( $_POST['give_user_login'] ) |
|
284 | + && empty($_POST['give_user_login']) |
|
285 | 285 | ) { |
286 | - unset( $_POST['give-purchase-var'] ); |
|
286 | + unset($_POST['give-purchase-var']); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( is_user_logged_in() ) { |
|
289 | + if (is_user_logged_in()) { |
|
290 | 290 | // Collect logged in user data |
291 | 291 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
292 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
292 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
293 | 293 | // Set new user registration as required |
294 | 294 | $valid_data['need_new_user'] = true; |
295 | 295 | // Validate new user data |
296 | 296 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
297 | 297 | // Check if login validation is needed |
298 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
298 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
299 | 299 | // Set user login as required |
300 | 300 | $valid_data['need_user_login'] = true; |
301 | 301 | // Validate users login info |
@@ -320,41 +320,41 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function give_purchase_form_validate_gateway() { |
322 | 322 | |
323 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
324 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
325 | - $gateway = give_get_default_gateway( $form_id ); |
|
323 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
324 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
325 | + $gateway = give_get_default_gateway($form_id); |
|
326 | 326 | |
327 | 327 | // Check if a gateway value is present |
328 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
328 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
329 | 329 | |
330 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
330 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
331 | 331 | |
332 | 332 | // Is amount being donated in LIVE mode 0.00? If so, error: |
333 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
333 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
334 | 334 | |
335 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
335 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
336 | 336 | |
337 | 337 | } //Check for a minimum custom amount |
338 | - elseif ( ! give_verify_minimum_price() ) { |
|
338 | + elseif ( ! give_verify_minimum_price()) { |
|
339 | 339 | // translators: %s: minimum donation amount. |
340 | 340 | give_set_error( |
341 | 341 | 'invalid_donation_minimum', |
342 | 342 | sprintf( |
343 | 343 | /* translators: %s: minimum donation amount */ |
344 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
345 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
344 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
345 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
346 | 346 | ) |
347 | 347 | ); |
348 | 348 | |
349 | 349 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
350 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
350 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
351 | 351 | |
352 | 352 | $gateway = 'manual'; |
353 | 353 | |
354 | 354 | } //Check if this gateway is active. |
355 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
355 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
356 | 356 | |
357 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
357 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | } |
@@ -372,23 +372,23 @@ discard block |
||
372 | 372 | */ |
373 | 373 | function give_verify_minimum_price() { |
374 | 374 | |
375 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
376 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
377 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
378 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
375 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
376 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
377 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
378 | + $variable_prices = give_has_variable_prices($form_id); |
|
379 | 379 | |
380 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
380 | + if ($variable_prices && ! empty($price_id)) { |
|
381 | 381 | |
382 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
382 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
383 | 383 | |
384 | - if ( $price_level_amount == $amount ) { |
|
384 | + if ($price_level_amount == $amount) { |
|
385 | 385 | return true; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
389 | + $minimum = give_get_form_minimum_price($form_id); |
|
390 | 390 | |
391 | - if ( $minimum > $amount ) { |
|
391 | + if ($minimum > $amount) { |
|
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | */ |
405 | 405 | function give_purchase_form_validate_agree_to_terms() { |
406 | 406 | // Validate agree to terms. |
407 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
407 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
408 | 408 | // User did not agree. |
409 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
409 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
@@ -420,43 +420,43 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @return array |
422 | 422 | */ |
423 | -function give_get_required_fields( $form_id ) { |
|
423 | +function give_get_required_fields($form_id) { |
|
424 | 424 | |
425 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
425 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
426 | 426 | |
427 | 427 | $required_fields = array( |
428 | 428 | 'give_email' => array( |
429 | 429 | 'error_id' => 'invalid_email', |
430 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
430 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
431 | 431 | ), |
432 | 432 | 'give_first' => array( |
433 | 433 | 'error_id' => 'invalid_first_name', |
434 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
434 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
435 | 435 | ), |
436 | 436 | ); |
437 | 437 | |
438 | - $require_address = give_require_billing_address( $payment_mode ); |
|
438 | + $require_address = give_require_billing_address($payment_mode); |
|
439 | 439 | |
440 | - if ( $require_address ) { |
|
441 | - $required_fields['card_address'] = array( |
|
440 | + if ($require_address) { |
|
441 | + $required_fields['card_address'] = array( |
|
442 | 442 | 'error_id' => 'invalid_card_address', |
443 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
443 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
444 | 444 | ); |
445 | - $required_fields['card_zip'] = array( |
|
445 | + $required_fields['card_zip'] = array( |
|
446 | 446 | 'error_id' => 'invalid_zip_code', |
447 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
447 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
448 | 448 | ); |
449 | - $required_fields['card_city'] = array( |
|
449 | + $required_fields['card_city'] = array( |
|
450 | 450 | 'error_id' => 'invalid_city', |
451 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
451 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
452 | 452 | ); |
453 | 453 | $required_fields['billing_country'] = array( |
454 | 454 | 'error_id' => 'invalid_country', |
455 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
455 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
456 | 456 | ); |
457 | - $required_fields['card_state'] = array( |
|
457 | + $required_fields['card_state'] = array( |
|
458 | 458 | 'error_id' => 'invalid_state', |
459 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
459 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
460 | 460 | ); |
461 | 461 | } |
462 | 462 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @since 1.7 |
467 | 467 | */ |
468 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
468 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
469 | 469 | |
470 | 470 | return $required_fields; |
471 | 471 | |
@@ -480,16 +480,16 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @return mixed|void |
482 | 482 | */ |
483 | -function give_require_billing_address( $payment_mode ) { |
|
483 | +function give_require_billing_address($payment_mode) { |
|
484 | 484 | |
485 | 485 | $return = false; |
486 | 486 | |
487 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
487 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
488 | 488 | $return = true; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Let payment gateways and other extensions determine if address fields should be required. |
492 | - return apply_filters( 'give_require_billing_address', $return ); |
|
492 | + return apply_filters('give_require_billing_address', $return); |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
@@ -503,42 +503,42 @@ discard block |
||
503 | 503 | function give_purchase_form_validate_logged_in_user() { |
504 | 504 | global $user_ID; |
505 | 505 | |
506 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
506 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
507 | 507 | |
508 | 508 | // Start empty array to collect valid user data. |
509 | 509 | $valid_user_data = array( |
510 | 510 | // Assume there will be errors. |
511 | - 'user_id' => - 1, |
|
511 | + 'user_id' => -1, |
|
512 | 512 | ); |
513 | 513 | |
514 | 514 | // Verify there is a user_ID. |
515 | - if ( $user_ID > 0 ) { |
|
515 | + if ($user_ID > 0) { |
|
516 | 516 | // Get the logged in user data. |
517 | - $user_data = get_userdata( $user_ID ); |
|
517 | + $user_data = get_userdata($user_ID); |
|
518 | 518 | |
519 | 519 | // Loop through required fields and show error messages. |
520 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
521 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
522 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
520 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
521 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
522 | + give_set_error($value['error_id'], $value['error_message']); |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
526 | 526 | // Verify data. |
527 | - if ( $user_data ) { |
|
527 | + if ($user_data) { |
|
528 | 528 | // Collected logged in user data. |
529 | 529 | $valid_user_data = array( |
530 | 530 | 'user_id' => $user_ID, |
531 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
532 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
533 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
531 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
532 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
533 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
534 | 534 | ); |
535 | 535 | |
536 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
537 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
536 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
537 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
538 | 538 | } |
539 | 539 | } else { |
540 | 540 | // Set invalid user error. |
541 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
541 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | // Default user data. |
558 | 558 | $default_user_data = array( |
559 | 559 | 'give-form-id' => '', |
560 | - 'user_id' => - 1, // Assume there will be errors. |
|
560 | + 'user_id' => -1, // Assume there will be errors. |
|
561 | 561 | 'user_first' => '', |
562 | 562 | 'user_last' => '', |
563 | 563 | 'give_user_login' => false, |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | ); |
568 | 568 | |
569 | 569 | // Get user data. |
570 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
570 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
571 | 571 | $registering_new_user = false; |
572 | - $form_id = absint( $user_data['give-form-id'] ); |
|
572 | + $form_id = absint($user_data['give-form-id']); |
|
573 | 573 | |
574 | 574 | // Start an empty array to collect valid user data. |
575 | 575 | $valid_user_data = array( |
576 | 576 | // Assume there will be errors. |
577 | - 'user_id' => - 1, |
|
577 | + 'user_id' => -1, |
|
578 | 578 | |
579 | 579 | // Get first name. |
580 | 580 | 'user_first' => $user_data['give_first'], |
@@ -584,25 +584,25 @@ discard block |
||
584 | 584 | ); |
585 | 585 | |
586 | 586 | // Loop through required fields and show error messages. |
587 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
588 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
589 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
587 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
588 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
589 | + give_set_error($value['error_id'], $value['error_message']); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
593 | 593 | // Check if we have an username to register. |
594 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
594 | + if (give_validate_username($user_data['give_user_login'])) { |
|
595 | 595 | $registering_new_user = true; |
596 | 596 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
597 | 597 | } |
598 | 598 | |
599 | 599 | // Check if we have an email to verify. |
600 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
600 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
601 | 601 | $valid_user_data['user_email'] = $user_data['give_email']; |
602 | 602 | } |
603 | 603 | |
604 | 604 | // Check password. |
605 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
605 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
606 | 606 | // All is good to go. |
607 | 607 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
608 | 608 | } |
@@ -622,36 +622,36 @@ discard block |
||
622 | 622 | // Start an array to collect valid user data. |
623 | 623 | $valid_user_data = array( |
624 | 624 | // Assume there will be errors |
625 | - 'user_id' => - 1, |
|
625 | + 'user_id' => -1, |
|
626 | 626 | ); |
627 | 627 | |
628 | 628 | // Username. |
629 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
630 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
629 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
630 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
631 | 631 | |
632 | 632 | return $valid_user_data; |
633 | 633 | } |
634 | 634 | |
635 | 635 | // Get the user by login. |
636 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
636 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
637 | 637 | |
638 | 638 | // Check if user exists. |
639 | - if ( $user_data ) { |
|
639 | + if ($user_data) { |
|
640 | 640 | // Get password. |
641 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
641 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
642 | 642 | |
643 | 643 | // Check user_pass. |
644 | - if ( $user_pass ) { |
|
644 | + if ($user_pass) { |
|
645 | 645 | // Check if password is valid. |
646 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
646 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
647 | 647 | // Incorrect password. |
648 | 648 | give_set_error( |
649 | 649 | 'password_incorrect', |
650 | 650 | sprintf( |
651 | 651 | '%1$s <a href="%2$s">%3$s</a>', |
652 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
653 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
654 | - esc_html__( 'Reset Password', 'give' ) |
|
652 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
653 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
654 | + esc_html__('Reset Password', 'give') |
|
655 | 655 | ) |
656 | 656 | ); |
657 | 657 | // All is correct. |
@@ -668,11 +668,11 @@ discard block |
||
668 | 668 | } |
669 | 669 | } else { |
670 | 670 | // Empty password. |
671 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
671 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
672 | 672 | } |
673 | 673 | } else { |
674 | 674 | // No username. |
675 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
675 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | return $valid_user_data; |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | */ |
688 | 688 | function give_purchase_form_validate_guest_user() { |
689 | 689 | |
690 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
690 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
691 | 691 | |
692 | 692 | // Start an array to collect valid user data. |
693 | 693 | $valid_user_data = array( |
@@ -696,38 +696,38 @@ discard block |
||
696 | 696 | ); |
697 | 697 | |
698 | 698 | // Show error message if user must be logged in. |
699 | - if ( give_logged_in_only( $form_id ) ) { |
|
700 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
699 | + if (give_logged_in_only($form_id)) { |
|
700 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | // Get the guest email. |
704 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
704 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
705 | 705 | |
706 | 706 | // Check email. |
707 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
707 | + if ($guest_email && strlen($guest_email) > 0) { |
|
708 | 708 | // Validate email. |
709 | - if ( ! is_email( $guest_email ) ) { |
|
709 | + if ( ! is_email($guest_email)) { |
|
710 | 710 | // Invalid email. |
711 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
711 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
712 | 712 | } else { |
713 | 713 | // All is good to go. |
714 | 714 | $valid_user_data['user_email'] = $guest_email; |
715 | 715 | |
716 | 716 | // Get user_id from donor if exist. |
717 | - $donor = new Give_Customer( $guest_email ); |
|
718 | - if ( $donor->id && $donor->user_id ) { |
|
717 | + $donor = new Give_Customer($guest_email); |
|
718 | + if ($donor->id && $donor->user_id) { |
|
719 | 719 | $valid_user_data['user_id'] = $donor->user_id; |
720 | 720 | } |
721 | 721 | } |
722 | 722 | } else { |
723 | 723 | // No email. |
724 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
724 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // Loop through required fields and show error messages. |
728 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
729 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
730 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
728 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
729 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
730 | + give_set_error($value['error_id'], $value['error_message']); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
@@ -743,36 +743,36 @@ discard block |
||
743 | 743 | * @since 1.0 |
744 | 744 | * @return integer |
745 | 745 | */ |
746 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
746 | +function give_register_and_login_new_user($user_data = array()) { |
|
747 | 747 | // Verify the array. |
748 | - if ( empty( $user_data ) ) { |
|
749 | - return - 1; |
|
748 | + if (empty($user_data)) { |
|
749 | + return -1; |
|
750 | 750 | } |
751 | 751 | |
752 | - if ( give_get_errors() ) { |
|
753 | - return - 1; |
|
752 | + if (give_get_errors()) { |
|
753 | + return -1; |
|
754 | 754 | } |
755 | 755 | |
756 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
757 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
758 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
759 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
760 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
761 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
762 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
763 | - 'role' => get_option( 'default_role' ), |
|
764 | - ), $user_data ); |
|
756 | + $user_args = apply_filters('give_insert_user_args', array( |
|
757 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
758 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
759 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
760 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
761 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
762 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
763 | + 'role' => get_option('default_role'), |
|
764 | + ), $user_data); |
|
765 | 765 | |
766 | 766 | // Insert new user. |
767 | - $user_id = wp_insert_user( $user_args ); |
|
767 | + $user_id = wp_insert_user($user_args); |
|
768 | 768 | |
769 | 769 | // Validate inserted user. |
770 | - if ( is_wp_error( $user_id ) ) { |
|
771 | - return - 1; |
|
770 | + if (is_wp_error($user_id)) { |
|
771 | + return -1; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | // Allow themes and plugins to filter the user data. |
775 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
775 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
776 | 776 | |
777 | 777 | /** |
778 | 778 | * Fires after inserting user. |
@@ -782,10 +782,10 @@ discard block |
||
782 | 782 | * @param int $user_id User id. |
783 | 783 | * @param array $user_data Array containing user data. |
784 | 784 | */ |
785 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
785 | + do_action('give_insert_user', $user_id, $user_data); |
|
786 | 786 | |
787 | 787 | // Login new user. |
788 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
788 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
789 | 789 | |
790 | 790 | // Return user id. |
791 | 791 | return $user_id; |
@@ -800,27 +800,27 @@ discard block |
||
800 | 800 | * @since 1.0 |
801 | 801 | * @return array |
802 | 802 | */ |
803 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
803 | +function give_get_purchase_form_user($valid_data = array()) { |
|
804 | 804 | |
805 | 805 | // Initialize user. |
806 | 806 | $user = false; |
807 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
807 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
808 | 808 | |
809 | - if ( $is_ajax ) { |
|
809 | + if ($is_ajax) { |
|
810 | 810 | // Do not create or login the user during the ajax submission (check for errors only). |
811 | 811 | return true; |
812 | - } elseif ( is_user_logged_in() ) { |
|
812 | + } elseif (is_user_logged_in()) { |
|
813 | 813 | // Set the valid user as the logged in collected data. |
814 | 814 | $user = $valid_data['logged_in_user']; |
815 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
815 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
816 | 816 | // New user registration. |
817 | - if ( $valid_data['need_new_user'] === true ) { |
|
817 | + if ($valid_data['need_new_user'] === true) { |
|
818 | 818 | // Set user. |
819 | 819 | $user = $valid_data['new_user_data']; |
820 | 820 | // Register and login new user. |
821 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
821 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
822 | 822 | // User login |
823 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
823 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
824 | 824 | |
825 | 825 | /* |
826 | 826 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -833,48 +833,48 @@ discard block |
||
833 | 833 | // Set user. |
834 | 834 | $user = $valid_data['login_user_data']; |
835 | 835 | // Login user. |
836 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
836 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
837 | 837 | } |
838 | 838 | } |
839 | 839 | |
840 | 840 | // Check guest checkout. |
841 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
841 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
842 | 842 | // Set user |
843 | 843 | $user = $valid_data['guest_user_data']; |
844 | 844 | } |
845 | 845 | |
846 | 846 | // Verify we have an user. |
847 | - if ( false === $user || empty( $user ) ) { |
|
847 | + if (false === $user || empty($user)) { |
|
848 | 848 | // Return false. |
849 | 849 | return false; |
850 | 850 | } |
851 | 851 | |
852 | 852 | // Get user first name. |
853 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
854 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
853 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
854 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | // Get user last name. |
858 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
859 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
858 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
859 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | // Get the user's billing address details. |
863 | 863 | $user['address'] = array(); |
864 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
865 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
866 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
867 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
868 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
869 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
870 | - |
|
871 | - if ( empty( $user['address']['country'] ) ) { |
|
864 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
865 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
866 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
867 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
868 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
869 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
870 | + |
|
871 | + if (empty($user['address']['country'])) { |
|
872 | 872 | $user['address'] = false; |
873 | 873 | } // Country will always be set if address fields are present. |
874 | 874 | |
875 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
875 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
876 | 876 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
877 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
877 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | // Return valid user. |
@@ -893,16 +893,16 @@ discard block |
||
893 | 893 | $card_data = give_get_purchase_cc_info(); |
894 | 894 | |
895 | 895 | // Validate the card zip. |
896 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
897 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
898 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
896 | + if ( ! empty($card_data['card_zip'])) { |
|
897 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
898 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | 902 | // Ensure no spaces. |
903 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
904 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
905 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
903 | + if ( ! empty($card_data['card_number'])) { |
|
904 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
905 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | // This should validate card numbers at some point too. |
@@ -918,17 +918,17 @@ discard block |
||
918 | 918 | */ |
919 | 919 | function give_get_purchase_cc_info() { |
920 | 920 | $cc_info = array(); |
921 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
922 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
923 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
924 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
925 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
926 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
927 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
928 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
929 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
930 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
931 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
921 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
922 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
923 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
924 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
925 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
926 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
927 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
928 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
929 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
930 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
931 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
932 | 932 | |
933 | 933 | // Return cc info |
934 | 934 | return $cc_info; |
@@ -944,14 +944,14 @@ discard block |
||
944 | 944 | * |
945 | 945 | * @return bool|mixed|void |
946 | 946 | */ |
947 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
947 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
948 | 948 | $ret = false; |
949 | 949 | |
950 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
950 | + if (empty($zip) || empty($country_code)) { |
|
951 | 951 | return $ret; |
952 | 952 | } |
953 | 953 | |
954 | - $country_code = strtoupper( $country_code ); |
|
954 | + $country_code = strtoupper($country_code); |
|
955 | 955 | |
956 | 956 | $zip_regex = array( |
957 | 957 | 'AD' => 'AD\d{3}', |
@@ -1111,11 +1111,11 @@ discard block |
||
1111 | 1111 | 'ZM' => '\d{5}', |
1112 | 1112 | ); |
1113 | 1113 | |
1114 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1114 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1115 | 1115 | $ret = true; |
1116 | 1116 | } |
1117 | 1117 | |
1118 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1118 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | |
@@ -1129,36 +1129,36 @@ discard block |
||
1129 | 1129 | * |
1130 | 1130 | * @return bool |
1131 | 1131 | */ |
1132 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1132 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1133 | 1133 | /* @var Give_Donate_Form $form */ |
1134 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1134 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1135 | 1135 | |
1136 | 1136 | $donation_level_matched = false; |
1137 | 1137 | |
1138 | - if ( $form->is_multi_type_donation_form() ) { |
|
1138 | + if ($form->is_multi_type_donation_form()) { |
|
1139 | 1139 | |
1140 | 1140 | // Bailout. |
1141 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1141 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1142 | 1142 | return false; |
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | // Sanitize donation amount. |
1146 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1146 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1147 | 1147 | |
1148 | 1148 | // Get number of decimals. |
1149 | 1149 | $default_decimals = give_get_price_decimals(); |
1150 | 1150 | |
1151 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1151 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1152 | 1152 | return true; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | // Find correct donation level from all donation levels. |
1156 | - foreach ( $variable_prices as $variable_price ) { |
|
1156 | + foreach ($variable_prices as $variable_price) { |
|
1157 | 1157 | // Sanitize level amount. |
1158 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1158 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1159 | 1159 | |
1160 | 1160 | // Set first match donation level ID. |
1161 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1161 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1162 | 1162 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1163 | 1163 | $donation_level_matched = true; |
1164 | 1164 | break; |
@@ -1169,19 +1169,19 @@ discard block |
||
1169 | 1169 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1170 | 1170 | if ( |
1171 | 1171 | ! $donation_level_matched |
1172 | - && ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1172 | + && (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1173 | 1173 | ) { |
1174 | 1174 | // Sanitize custom minimum amount. |
1175 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1175 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1176 | 1176 | |
1177 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1177 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1178 | 1178 | $_POST['give-price-id'] = 'custom'; |
1179 | 1179 | $donation_level_matched = true; |
1180 | 1180 | } |
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - return ( $donation_level_matched ? true : false ); |
|
1184 | + return ($donation_level_matched ? true : false); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1187 | +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 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @since 1.0 |
21 | 21 | */ |
22 | -class Give_Forms_Widget extends WP_Widget{ |
|
22 | +class Give_Forms_Widget extends WP_Widget { |
|
23 | 23 | /** |
24 | 24 | * The widget class name |
25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Instantiate the class |
32 | 32 | */ |
33 | - public function __construct(){ |
|
34 | - $this->self = get_class( $this ); |
|
33 | + public function __construct() { |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ){ |
|
55 | + public function admin_widget_scripts($hook) { |
|
56 | 56 | // Directories of assets |
57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
60 | 60 | |
61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
63 | 63 | |
64 | 64 | // Widget Script |
65 | - if ( $hook == 'widgets.php' ) { |
|
65 | + if ($hook == 'widgets.php') { |
|
66 | 66 | |
67 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
67 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
69 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
70 | 70 | |
71 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
71 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * before_widget, and after_widget. |
80 | 80 | * @param array $instance The settings for the particular instance of the widget. |
81 | 81 | */ |
82 | - public function widget( $args, $instance ){ |
|
83 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
84 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
82 | + public function widget($args, $instance) { |
|
83 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
84 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
85 | 85 | |
86 | 86 | echo $args['before_widget']; |
87 | 87 | |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 1.0 |
92 | 92 | */ |
93 | - do_action( 'give_before_forms_widget' ); |
|
93 | + do_action('give_before_forms_widget'); |
|
94 | 94 | |
95 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
95 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
96 | 96 | |
97 | - give_get_donation_form( $instance ); |
|
97 | + give_get_donation_form($instance); |
|
98 | 98 | |
99 | 99 | echo $args['after_widget']; |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @since 1.0 |
105 | 105 | */ |
106 | - do_action( 'give_after_forms_widget' ); |
|
106 | + do_action('give_after_forms_widget'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function form( $instance ){ |
|
116 | + public function form($instance) { |
|
117 | 117 | $defaults = array( |
118 | 118 | 'title' => '', |
119 | 119 | 'id' => '', |
@@ -123,84 +123,84 @@ discard block |
||
123 | 123 | 'continue_button_title' => '', |
124 | 124 | ); |
125 | 125 | |
126 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
126 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
127 | 127 | |
128 | 128 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
129 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
129 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
130 | 130 | |
131 | 131 | // Query Give Forms |
132 | 132 | $args = array( |
133 | 133 | 'post_type' => 'give_forms', |
134 | - 'posts_per_page' => - 1, |
|
134 | + 'posts_per_page' => -1, |
|
135 | 135 | 'post_status' => 'publish', |
136 | 136 | ); |
137 | 137 | |
138 | - $give_forms = get_posts( $args ); |
|
138 | + $give_forms = get_posts($args); |
|
139 | 139 | ?> |
140 | 140 | <div class="give_forms_widget_container"> |
141 | 141 | |
142 | 142 | <?php // Widget: widget Title. ?> |
143 | 143 | <p> |
144 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
145 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
146 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
144 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
145 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
146 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
147 | 147 | </p> |
148 | 148 | |
149 | 149 | <?php // Widget: Give Form?> |
150 | 150 | <p> |
151 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
152 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
153 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
154 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
155 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
156 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
151 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
152 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
153 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
154 | + <?php foreach ($give_forms as $give_form) { ?> |
|
155 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
156 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
157 | 157 | <?php } ?> |
158 | 158 | </select><br> |
159 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
159 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
160 | 160 | </p> |
161 | 161 | |
162 | 162 | <?php // Widget: Display Style ?> |
163 | 163 | <p class="give_forms_display_style_setting_row"> |
164 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
165 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
166 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
167 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
168 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
164 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
165 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
166 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
167 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
168 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
169 | 169 | <small class="give-field-description"> |
170 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
170 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
171 | 171 | </small> |
172 | 172 | </p> |
173 | 173 | |
174 | 174 | <?php // Widget: Continue Button Title. ?> |
175 | 175 | <p class="give_forms_continue_button_title_setting_row"> |
176 | - <label for="<?php echo $this->get_field_id( 'continue_button_title' ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label> |
|
177 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'continue_button_title' ); ?>" name="<?php echo $this->get_field_name( 'continue_button_title' ); ?>" value="<?php esc_attr_e( $instance['continue_button_title'] ); ?>" /><br> |
|
178 | - <small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small> |
|
176 | + <label for="<?php echo $this->get_field_id('continue_button_title'); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label> |
|
177 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('continue_button_title'); ?>" name="<?php echo $this->get_field_name('continue_button_title'); ?>" value="<?php esc_attr_e($instance['continue_button_title']); ?>" /><br> |
|
178 | + <small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small> |
|
179 | 179 | </p> |
180 | 180 | |
181 | 181 | <?php // Widget: Floating Labels ?> |
182 | 182 | <p> |
183 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
184 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
185 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
186 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
183 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
184 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
185 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
186 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
187 | 187 | <small class="give-field-description"> |
188 | 188 | <?php |
189 | 189 | printf( |
190 | 190 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
191 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
192 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
191 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
192 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
193 | 193 | ); |
194 | 194 | ?></small> |
195 | 195 | </p> |
196 | 196 | |
197 | 197 | <?php // Widget: Display Content ?> |
198 | 198 | <p> |
199 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
200 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
201 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
202 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
203 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
199 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
200 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
201 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
202 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
203 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
204 | 204 | </div> |
205 | 205 | <?php |
206 | 206 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return void |
212 | 212 | */ |
213 | - function widget_init(){ |
|
214 | - register_widget( $this->self ); |
|
213 | + function widget_init() { |
|
214 | + register_widget($this->self); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return array |
224 | 224 | */ |
225 | - public function update( $new_instance, $old_instance ){ |
|
225 | + public function update($new_instance, $old_instance) { |
|
226 | 226 | $this->flush_widget_cache(); |
227 | 227 | |
228 | 228 | return $new_instance; |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return void |
235 | 235 | */ |
236 | - public function flush_widget_cache(){ |
|
237 | - wp_cache_delete( $this->self, 'widget' ); |
|
236 | + public function flush_widget_cache() { |
|
237 | + wp_cache_delete($this->self, 'widget'); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,37 +25,37 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | break; |
41 | 41 | |
42 | - case version_compare( $give_version, '1.7', '<' ) : |
|
42 | + case version_compare($give_version, '1.7', '<') : |
|
43 | 43 | give_v17_upgrades(); |
44 | 44 | $did_upgrade = true; |
45 | 45 | break; |
46 | 46 | |
47 | - case version_compare( $give_version, '1.8', '<' ) : |
|
47 | + case version_compare($give_version, '1.8', '<') : |
|
48 | 48 | give_v18_upgrades(); |
49 | 49 | $did_upgrade = true; |
50 | 50 | } |
51 | 51 | |
52 | - if ( $did_upgrade ) { |
|
53 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
52 | + if ($did_upgrade) { |
|
53 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
58 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
57 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
58 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Display Upgrade Notices |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function give_show_upgrade_notices() { |
67 | 67 | // Don't show notices on the upgrades page. |
68 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
68 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | - $give_version = get_option( 'give_version' ); |
|
72 | + $give_version = get_option('give_version'); |
|
73 | 73 | |
74 | - if ( ! $give_version ) { |
|
74 | + if ( ! $give_version) { |
|
75 | 75 | // 1.0 is the first version to use this option so we must add it. |
76 | 76 | $give_version = '1.0'; |
77 | 77 | } |
78 | 78 | |
79 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
79 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
80 | 80 | |
81 | 81 | /* |
82 | 82 | * NOTICE: |
@@ -87,31 +87,31 @@ discard block |
||
87 | 87 | */ |
88 | 88 | |
89 | 89 | // v1.3.2 Upgrades |
90 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
90 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
91 | 91 | printf( |
92 | 92 | /* translators: %s: upgrade URL */ |
93 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
94 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
93 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
94 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
95 | 95 | ); |
96 | 96 | } |
97 | 97 | |
98 | 98 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
99 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
99 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
100 | 100 | printf( |
101 | 101 | /* translators: %s: upgrade URL */ |
102 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
103 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
102 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
103 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
104 | 104 | ); |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Check if we have a stalled upgrade. |
108 | 108 | $resume_upgrade = give_maybe_resume_upgrade(); |
109 | - if ( ! empty( $resume_upgrade ) ) { |
|
110 | - $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
|
109 | + if ( ! empty($resume_upgrade)) { |
|
110 | + $resume_url = add_query_arg($resume_upgrade, admin_url('index.php')); |
|
111 | 111 | echo Give_Notices::notice_html( |
112 | 112 | sprintf( |
113 | - __( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ), |
|
114 | - esc_url( $resume_url ) |
|
113 | + __('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'), |
|
114 | + esc_url($resume_url) |
|
115 | 115 | ) |
116 | 116 | ); |
117 | 117 | |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | // v1.8 form metadata upgrades. |
122 | - if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) { |
|
122 | + if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) { |
|
123 | 123 | echo Give_Notices::notice_html( |
124 | 124 | sprintf( |
125 | - esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ), |
|
126 | - '<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">', |
|
125 | + esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'), |
|
126 | + '<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">', |
|
127 | 127 | '</a>' |
128 | 128 | ) |
129 | 129 | ); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $upgrade_links.on( 'click', function(e){ |
139 | 139 | e.preventDefault(); |
140 | 140 | |
141 | - if( ! window.confirm( '<?php _e( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ); ?>' ) ) { |
|
141 | + if( ! window.confirm( '<?php _e('Please make sure to create a database backup before initiating the upgrade.', 'give'); ?>' ) ) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | <?php |
152 | 152 | } |
153 | 153 | |
154 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
154 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Triggers all upgrade functions |
@@ -163,29 +163,29 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function give_trigger_upgrades() { |
165 | 165 | |
166 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
167 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
166 | + if ( ! current_user_can('manage_give_settings')) { |
|
167 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
168 | 168 | 'response' => 403, |
169 | - ) ); |
|
169 | + )); |
|
170 | 170 | } |
171 | 171 | |
172 | - $give_version = get_option( 'give_version' ); |
|
172 | + $give_version = get_option('give_version'); |
|
173 | 173 | |
174 | - if ( ! $give_version ) { |
|
174 | + if ( ! $give_version) { |
|
175 | 175 | // 1.0 is the first version to use this option so we must add it. |
176 | 176 | $give_version = '1.0'; |
177 | - add_option( 'give_version', $give_version ); |
|
177 | + add_option('give_version', $give_version); |
|
178 | 178 | } |
179 | 179 | |
180 | - update_option( 'give_version', GIVE_VERSION ); |
|
181 | - delete_option( 'give_doing_upgrade' ); |
|
180 | + update_option('give_version', GIVE_VERSION); |
|
181 | + delete_option('give_doing_upgrade'); |
|
182 | 182 | |
183 | - if ( DOING_AJAX ) { |
|
184 | - die( 'complete' ); |
|
183 | + if (DOING_AJAX) { |
|
184 | + die('complete'); |
|
185 | 185 | } // End if(). |
186 | 186 | } |
187 | 187 | |
188 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
188 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Check if the upgrade routine has been run for a specific action |
@@ -196,15 +196,15 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return bool If the action has been added to the completed actions array |
198 | 198 | */ |
199 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
199 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
200 | 200 | |
201 | - if ( empty( $upgrade_action ) ) { |
|
201 | + if (empty($upgrade_action)) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | 205 | $completed_upgrades = give_get_completed_upgrades(); |
206 | 206 | |
207 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
207 | + return in_array($upgrade_action, $completed_upgrades); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
217 | 217 | */ |
218 | 218 | function give_maybe_resume_upgrade() { |
219 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
220 | - if ( empty( $doing_upgrade ) ) { |
|
219 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
220 | + if (empty($doing_upgrade)) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return bool If the function was successfully added |
235 | 235 | */ |
236 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
236 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
237 | 237 | |
238 | - if ( empty( $upgrade_action ) ) { |
|
238 | + if (empty($upgrade_action)) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | $completed_upgrades[] = $upgrade_action; |
244 | 244 | |
245 | 245 | // Remove any blanks, and only show uniques. |
246 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
246 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
247 | 247 | |
248 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
248 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | */ |
257 | 257 | function give_get_completed_upgrades() { |
258 | 258 | |
259 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
259 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
260 | 260 | |
261 | - if ( false === $completed_upgrades ) { |
|
261 | + if (false === $completed_upgrades) { |
|
262 | 262 | $completed_upgrades = array(); |
263 | 263 | } |
264 | 264 | |
@@ -275,31 +275,31 @@ discard block |
||
275 | 275 | */ |
276 | 276 | function give_v132_upgrade_give_payment_customer_id() { |
277 | 277 | global $wpdb; |
278 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
279 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
278 | + if ( ! current_user_can('manage_give_settings')) { |
|
279 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
280 | 280 | 'response' => 403, |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | } |
283 | 283 | |
284 | - ignore_user_abort( true ); |
|
284 | + ignore_user_abort(true); |
|
285 | 285 | |
286 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
287 | - @set_time_limit( 0 ); |
|
286 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
287 | + @set_time_limit(0); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // UPDATE DB METAKEYS. |
291 | 291 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
292 | - $query = $wpdb->query( $sql ); |
|
292 | + $query = $wpdb->query($sql); |
|
293 | 293 | |
294 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
295 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
296 | - delete_option( 'give_doing_upgrade' ); |
|
297 | - wp_redirect( admin_url() ); |
|
294 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
295 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
296 | + delete_option('give_doing_upgrade'); |
|
297 | + wp_redirect(admin_url()); |
|
298 | 298 | exit; |
299 | 299 | |
300 | 300 | } |
301 | 301 | |
302 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
302 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Upgrades the Offline Status |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | |
313 | 313 | global $wpdb; |
314 | 314 | |
315 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
316 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
315 | + if ( ! current_user_can('manage_give_settings')) { |
|
316 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
317 | 317 | 'response' => 403, |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | } |
320 | 320 | |
321 | - ignore_user_abort( true ); |
|
321 | + ignore_user_abort(true); |
|
322 | 322 | |
323 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
324 | - @set_time_limit( 0 ); |
|
323 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
324 | + @set_time_limit(0); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | // Get abandoned offline payments. |
@@ -331,31 +331,31 @@ discard block |
||
331 | 331 | $where .= "AND ( p.post_status = 'abandoned' )"; |
332 | 332 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
333 | 333 | |
334 | - $sql = $select . $join . $where; |
|
335 | - $found_payments = $wpdb->get_col( $sql ); |
|
334 | + $sql = $select.$join.$where; |
|
335 | + $found_payments = $wpdb->get_col($sql); |
|
336 | 336 | |
337 | - foreach ( $found_payments as $payment ) { |
|
337 | + foreach ($found_payments as $payment) { |
|
338 | 338 | |
339 | 339 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
340 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
340 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
341 | 341 | |
342 | 342 | // 1450124863 = 12/10/2015 20:42:25. |
343 | - if ( $modified_time >= 1450124863 ) { |
|
343 | + if ($modified_time >= 1450124863) { |
|
344 | 344 | |
345 | - give_update_payment_status( $payment, 'pending' ); |
|
345 | + give_update_payment_status($payment, 'pending'); |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
351 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
352 | - delete_option( 'give_doing_upgrade' ); |
|
353 | - wp_redirect( admin_url() ); |
|
350 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
351 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
352 | + delete_option('give_doing_upgrade'); |
|
353 | + wp_redirect(admin_url()); |
|
354 | 354 | exit; |
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
358 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Cleanup User Roles |
@@ -366,17 +366,17 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function give_v152_cleanup_users() { |
368 | 368 | |
369 | - $give_version = get_option( 'give_version' ); |
|
369 | + $give_version = get_option('give_version'); |
|
370 | 370 | |
371 | - if ( ! $give_version ) { |
|
371 | + if ( ! $give_version) { |
|
372 | 372 | // 1.0 is the first version to use this option so we must add it. |
373 | 373 | $give_version = '1.0'; |
374 | 374 | } |
375 | 375 | |
376 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
376 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
377 | 377 | |
378 | 378 | // v1.5.2 Upgrades |
379 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
379 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
380 | 380 | |
381 | 381 | // Delete all caps with "ss". |
382 | 382 | // Also delete all unused "campaign" roles. |
@@ -423,9 +423,9 @@ discard block |
||
423 | 423 | ); |
424 | 424 | |
425 | 425 | global $wp_roles; |
426 | - foreach ( $delete_caps as $cap ) { |
|
427 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
428 | - $wp_roles->remove_cap( $role, $cap ); |
|
426 | + foreach ($delete_caps as $cap) { |
|
427 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
428 | + $wp_roles->remove_cap($role, $cap); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
@@ -435,15 +435,15 @@ discard block |
||
435 | 435 | $roles->add_caps(); |
436 | 436 | |
437 | 437 | // The Update Ran. |
438 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
439 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
440 | - delete_option( 'give_doing_upgrade' ); |
|
438 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
439 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
440 | + delete_option('give_doing_upgrade'); |
|
441 | 441 | |
442 | 442 | }// End if(). |
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
446 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
447 | 447 | |
448 | 448 | /** |
449 | 449 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -483,53 +483,53 @@ discard block |
||
483 | 483 | |
484 | 484 | // Get addons license key. |
485 | 485 | $addons = array(); |
486 | - foreach ( $give_options as $key => $value ) { |
|
487 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
488 | - $addons[ $key ] = $value; |
|
486 | + foreach ($give_options as $key => $value) { |
|
487 | + if (false !== strpos($key, '_license_key')) { |
|
488 | + $addons[$key] = $value; |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | 492 | // Bailout: We do not have any addon license data to upgrade. |
493 | - if ( empty( $addons ) ) { |
|
493 | + if (empty($addons)) { |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
497 | - foreach ( $addons as $key => $addon_license ) { |
|
497 | + foreach ($addons as $key => $addon_license) { |
|
498 | 498 | |
499 | 499 | // Get addon shortname. |
500 | - $shortname = str_replace( '_license_key', '', $key ); |
|
500 | + $shortname = str_replace('_license_key', '', $key); |
|
501 | 501 | |
502 | 502 | // Addon license option name. |
503 | - $addon_license_option_name = $shortname . '_license_active'; |
|
503 | + $addon_license_option_name = $shortname.'_license_active'; |
|
504 | 504 | |
505 | 505 | // bailout if license is empty. |
506 | - if ( empty( $addon_license ) ) { |
|
507 | - delete_option( $addon_license_option_name ); |
|
506 | + if (empty($addon_license)) { |
|
507 | + delete_option($addon_license_option_name); |
|
508 | 508 | continue; |
509 | 509 | } |
510 | 510 | |
511 | 511 | // Get addon name. |
512 | 512 | $addon_name = array(); |
513 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
514 | - foreach ( $addon_name_parts as $name_part ) { |
|
513 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
514 | + foreach ($addon_name_parts as $name_part) { |
|
515 | 515 | |
516 | 516 | // Fix addon name |
517 | - switch ( $name_part ) { |
|
517 | + switch ($name_part) { |
|
518 | 518 | case 'authorizenet' : |
519 | 519 | $name_part = 'authorize.net'; |
520 | 520 | break; |
521 | 521 | } |
522 | 522 | |
523 | - $addon_name[] = ucfirst( $name_part ); |
|
523 | + $addon_name[] = ucfirst($name_part); |
|
524 | 524 | } |
525 | 525 | |
526 | - $addon_name = implode( ' ', $addon_name ); |
|
526 | + $addon_name = implode(' ', $addon_name); |
|
527 | 527 | |
528 | 528 | // Data to send to the API |
529 | 529 | $api_params = array( |
530 | 530 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
531 | 531 | 'license' => $addon_license, |
532 | - 'item_name' => urlencode( $addon_name ), |
|
532 | + 'item_name' => urlencode($addon_name), |
|
533 | 533 | 'url' => home_url(), |
534 | 534 | ); |
535 | 535 | |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | ); |
545 | 545 | |
546 | 546 | // Make sure there are no errors. |
547 | - if ( is_wp_error( $response ) ) { |
|
548 | - delete_option( $addon_license_option_name ); |
|
547 | + if (is_wp_error($response)) { |
|
548 | + delete_option($addon_license_option_name); |
|
549 | 549 | continue; |
550 | 550 | } |
551 | 551 | |
552 | 552 | // Tell WordPress to look for updates. |
553 | - set_site_transient( 'update_plugins', null ); |
|
553 | + set_site_transient('update_plugins', null); |
|
554 | 554 | |
555 | 555 | // Decode license data. |
556 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
557 | - update_option( $addon_license_option_name, $license_data ); |
|
556 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
557 | + update_option($addon_license_option_name, $license_data); |
|
558 | 558 | }// End foreach(). |
559 | 559 | } |
560 | 560 | |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | ); |
585 | 585 | |
586 | 586 | global $wp_roles; |
587 | - foreach ( $delete_caps as $cap ) { |
|
588 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
589 | - $wp_roles->remove_cap( $role, $cap ); |
|
587 | + foreach ($delete_caps as $cap) { |
|
588 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
589 | + $wp_roles->remove_cap($role, $cap); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | function give_v18_upgrades_core_setting() { |
621 | 621 | // Core settings which changes from checkbox to radio. |
622 | 622 | $core_setting_names = array_merge( |
623 | - array_keys( give_v18_renamed_core_settings() ), |
|
623 | + array_keys(give_v18_renamed_core_settings()), |
|
624 | 624 | array( |
625 | 625 | 'uninstall_on_delete', |
626 | 626 | 'scripts_footer', |
@@ -632,48 +632,48 @@ discard block |
||
632 | 632 | ); |
633 | 633 | |
634 | 634 | // Bailout: If not any setting define. |
635 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
635 | + if ($give_settings = get_option('give_settings')) { |
|
636 | 636 | |
637 | 637 | $setting_changed = false; |
638 | 638 | |
639 | 639 | // Loop: check each setting field. |
640 | - foreach ( $core_setting_names as $setting_name ) { |
|
640 | + foreach ($core_setting_names as $setting_name) { |
|
641 | 641 | // New setting name. |
642 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
642 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
643 | 643 | |
644 | 644 | // Continue: If setting already set. |
645 | 645 | if ( |
646 | - array_key_exists( $new_setting_name, $give_settings ) |
|
647 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
646 | + array_key_exists($new_setting_name, $give_settings) |
|
647 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
648 | 648 | ) { |
649 | 649 | continue; |
650 | 650 | } |
651 | 651 | |
652 | 652 | // Set checkbox value to radio value. |
653 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
653 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
654 | 654 | |
655 | 655 | // @see https://github.com/WordImpress/Give/issues/1063 |
656 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
656 | + if (false !== strpos($setting_name, 'disable_')) { |
|
657 | 657 | |
658 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
659 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
658 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
659 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
660 | 660 | |
661 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
661 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | // Tell bot to update core setting to db. |
665 | - if ( ! $setting_changed ) { |
|
665 | + if ( ! $setting_changed) { |
|
666 | 666 | $setting_changed = true; |
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | // Update setting only if they changed. |
671 | - if ( $setting_changed ) { |
|
672 | - update_option( 'give_settings', $give_settings ); |
|
671 | + if ($setting_changed) { |
|
672 | + update_option('give_settings', $give_settings); |
|
673 | 673 | } |
674 | 674 | }// End if(). |
675 | 675 | |
676 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
676 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -683,22 +683,22 @@ discard block |
||
683 | 683 | * @return void |
684 | 684 | */ |
685 | 685 | function give_v18_upgrades_form_metadata() { |
686 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
687 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
686 | + if ( ! current_user_can('manage_give_settings')) { |
|
687 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
688 | 688 | 'response' => 403, |
689 | - ) ); |
|
689 | + )); |
|
690 | 690 | } |
691 | 691 | |
692 | - ignore_user_abort( true ); |
|
692 | + ignore_user_abort(true); |
|
693 | 693 | |
694 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
695 | - @set_time_limit( 0 ); |
|
694 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
695 | + @set_time_limit(0); |
|
696 | 696 | } |
697 | 697 | |
698 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
698 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
699 | 699 | |
700 | 700 | // form query |
701 | - $forms = new WP_Query( array( |
|
701 | + $forms = new WP_Query(array( |
|
702 | 702 | 'paged' => $step, |
703 | 703 | 'status' => 'any', |
704 | 704 | 'order' => 'ASC', |
@@ -707,39 +707,39 @@ discard block |
||
707 | 707 | ) |
708 | 708 | ); |
709 | 709 | |
710 | - if ( $forms->have_posts() ) { |
|
711 | - while ( $forms->have_posts() ) { |
|
710 | + if ($forms->have_posts()) { |
|
711 | + while ($forms->have_posts()) { |
|
712 | 712 | $forms->the_post(); |
713 | 713 | |
714 | 714 | // Form content. |
715 | 715 | // Note in version 1.8 display content setting split into display content and content placement setting. |
716 | 716 | // You can delete _give_content_option in future |
717 | - $show_content = get_post_meta( get_the_ID(), '_give_content_option', true ); |
|
718 | - if ( $show_content && ! get_post_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
719 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
720 | - update_post_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
717 | + $show_content = get_post_meta(get_the_ID(), '_give_content_option', true); |
|
718 | + if ($show_content && ! get_post_meta(get_the_ID(), '_give_display_content', true)) { |
|
719 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
720 | + update_post_meta(get_the_ID(), '_give_display_content', $field_value); |
|
721 | 721 | |
722 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
723 | - update_post_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
722 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
723 | + update_post_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | // "Disable" Guest Donation. Checkbox |
727 | 727 | // See: https://github.com/WordImpress/Give/issues/1470 |
728 | - $guest_donation = get_post_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
729 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
730 | - update_post_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
728 | + $guest_donation = get_post_meta(get_the_ID(), '_give_logged_in_only', true); |
|
729 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
730 | + update_post_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
731 | 731 | |
732 | 732 | // Offline Donations |
733 | 733 | // See: https://github.com/WordImpress/Give/issues/1579 |
734 | - $offline_donation = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
735 | - if ( 'no' === $offline_donation ) { |
|
734 | + $offline_donation = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
735 | + if ('no' === $offline_donation) { |
|
736 | 736 | $offline_donation_newval = 'global'; |
737 | - } elseif ( 'yes' === $offline_donation ) { |
|
737 | + } elseif ('yes' === $offline_donation) { |
|
738 | 738 | $offline_donation_newval = 'enabled'; |
739 | 739 | } else { |
740 | 740 | $offline_donation_newval = 'disabled'; |
741 | 741 | } |
742 | - update_post_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
742 | + update_post_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
743 | 743 | |
744 | 744 | // Convert yes/no setting field to enabled/disabled. |
745 | 745 | $form_radio_settings = array( |
@@ -759,15 +759,15 @@ discard block |
||
759 | 759 | '_give_offline_donation_enable_billing_fields_single', |
760 | 760 | ); |
761 | 761 | |
762 | - foreach ( $form_radio_settings as $meta_key ) { |
|
762 | + foreach ($form_radio_settings as $meta_key) { |
|
763 | 763 | // Get value. |
764 | - $field_value = get_post_meta( get_the_ID(), $meta_key, true ); |
|
764 | + $field_value = get_post_meta(get_the_ID(), $meta_key, true); |
|
765 | 765 | |
766 | 766 | // Convert meta value only if it is in yes/no/none. |
767 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
767 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
768 | 768 | |
769 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
770 | - update_post_meta( get_the_ID(), $meta_key, $field_value ); |
|
769 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
770 | + update_post_meta(get_the_ID(), $meta_key, $field_value); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | }// End while(). |
@@ -775,27 +775,27 @@ discard block |
||
775 | 775 | wp_reset_postdata(); |
776 | 776 | |
777 | 777 | // Forms found so upgrade them |
778 | - $step ++; |
|
779 | - $redirect = add_query_arg( array( |
|
778 | + $step++; |
|
779 | + $redirect = add_query_arg(array( |
|
780 | 780 | 'page' => 'give-upgrades', |
781 | 781 | 'give-upgrade' => 'give_v18_upgrades_form_metadata', |
782 | 782 | 'step' => $step, |
783 | - ), admin_url( 'index.php' ) ); |
|
784 | - wp_redirect( $redirect ); |
|
783 | + ), admin_url('index.php')); |
|
784 | + wp_redirect($redirect); |
|
785 | 785 | exit(); |
786 | 786 | |
787 | 787 | } else { |
788 | 788 | // No more forms found, finish up. |
789 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
790 | - delete_option( 'give_doing_upgrade' ); |
|
791 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
789 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
790 | + delete_option('give_doing_upgrade'); |
|
791 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
792 | 792 | |
793 | - wp_redirect( admin_url() ); |
|
793 | + wp_redirect(admin_url()); |
|
794 | 794 | exit; |
795 | 795 | } |
796 | 796 | } |
797 | 797 | |
798 | -add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' ); |
|
798 | +add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata'); |
|
799 | 799 | |
800 | 800 | /** |
801 | 801 | * Get list of core setting renamed in version 1.8. |
@@ -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 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | |
27 | - $this->shortcode['title'] = esc_html__( 'Donation Form', 'give' ); |
|
28 | - $this->shortcode['label'] = esc_html__( 'Donation Form', 'give' ); |
|
27 | + $this->shortcode['title'] = esc_html__('Donation Form', 'give'); |
|
28 | + $this->shortcode['label'] = esc_html__('Donation Form', 'give'); |
|
29 | 29 | |
30 | - parent::__construct( 'give_form' ); |
|
30 | + parent::__construct('give_form'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | $create_form_link = sprintf( |
41 | 41 | /* translators: %s: create new form URL */ |
42 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
43 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
42 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
43 | + admin_url('post-new.php?post_type=give_forms') |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | return array( |
@@ -50,68 +50,68 @@ discard block |
||
50 | 50 | 'post_type' => 'give_forms', |
51 | 51 | ), |
52 | 52 | 'name' => 'id', |
53 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
54 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
53 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
54 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
55 | 55 | 'required' => array( |
56 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
57 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
56 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
57 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
58 | 58 | ), |
59 | 59 | ), |
60 | 60 | array( |
61 | 61 | 'type' => 'container', |
62 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
62 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
63 | 63 | ), |
64 | 64 | array( |
65 | 65 | 'type' => 'listbox', |
66 | 66 | 'name' => 'show_title', |
67 | - 'label' => esc_attr__( 'Show Title', 'give' ), |
|
68 | - 'tooltip' => esc_attr__( 'Do you want to display the form title?', 'give' ), |
|
67 | + 'label' => esc_attr__('Show Title', 'give'), |
|
68 | + 'tooltip' => esc_attr__('Do you want to display the form title?', 'give'), |
|
69 | 69 | 'options' => array( |
70 | - 'true' => esc_html__( 'Show', 'give' ), |
|
71 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
70 | + 'true' => esc_html__('Show', 'give'), |
|
71 | + 'false' => esc_html__('Hide', 'give'), |
|
72 | 72 | ), |
73 | 73 | ), |
74 | 74 | array( |
75 | 75 | 'type' => 'listbox', |
76 | 76 | 'name' => 'show_goal', |
77 | - 'label' => esc_attr__( 'Show Goal', 'give' ), |
|
78 | - 'tooltip' => esc_attr__( 'Do you want to display the donation goal?', 'give' ), |
|
77 | + 'label' => esc_attr__('Show Goal', 'give'), |
|
78 | + 'tooltip' => esc_attr__('Do you want to display the donation goal?', 'give'), |
|
79 | 79 | 'options' => array( |
80 | - 'true' => esc_html__( 'Show', 'give' ), |
|
81 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
80 | + 'true' => esc_html__('Show', 'give'), |
|
81 | + 'false' => esc_html__('Hide', 'give'), |
|
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | array( |
85 | 85 | 'type' => 'listbox', |
86 | 86 | 'name' => 'show_content', |
87 | 87 | 'minWidth' => 240, |
88 | - 'label' => esc_attr__( 'Display Content', 'give' ), |
|
89 | - 'tooltip' => esc_attr__( 'Do you want to display the form content?', 'give' ), |
|
88 | + 'label' => esc_attr__('Display Content', 'give'), |
|
89 | + 'tooltip' => esc_attr__('Do you want to display the form content?', 'give'), |
|
90 | 90 | 'options' => array( |
91 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
92 | - 'above' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
93 | - 'below' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
91 | + 'none' => esc_html__('No Content', 'give'), |
|
92 | + 'above' => esc_html__('Display content ABOVE the fields', 'give'), |
|
93 | + 'below' => esc_html__('Display content BELOW the fields', 'give'), |
|
94 | 94 | ), |
95 | 95 | ), |
96 | 96 | array( |
97 | 97 | 'type' => 'listbox', |
98 | 98 | 'name' => 'display_style', |
99 | 99 | 'classes' => 'give-display-style', |
100 | - 'label' => esc_attr__( 'Display Options', 'give' ), |
|
101 | - 'tooltip' => esc_attr__( 'How would you like to display donation information?', 'give' ), |
|
100 | + 'label' => esc_attr__('Display Options', 'give'), |
|
101 | + 'tooltip' => esc_attr__('How would you like to display donation information?', 'give'), |
|
102 | 102 | 'options' => array( |
103 | - 'onpage' => esc_html__( 'All Fields', 'give' ), |
|
104 | - 'modal' => esc_html__( 'Modal', 'give' ), |
|
105 | - 'reveal' => esc_html__( 'Reveal', 'give' ), |
|
106 | - 'button' => esc_html__( 'Button', 'give' ), |
|
103 | + 'onpage' => esc_html__('All Fields', 'give'), |
|
104 | + 'modal' => esc_html__('Modal', 'give'), |
|
105 | + 'reveal' => esc_html__('Reveal', 'give'), |
|
106 | + 'button' => esc_html__('Button', 'give'), |
|
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | array( |
110 | 110 | 'type' => 'textbox', |
111 | 111 | 'classes' => 'give-hidden give-continue-button-title', |
112 | 112 | 'name' => 'continue_button_title', |
113 | - 'label' => esc_attr__( 'Button Text', 'give' ), |
|
114 | - 'tooltip' => esc_attr__( 'The button label for displaying the additional payment fields.', 'give' ), |
|
113 | + 'label' => esc_attr__('Button Text', 'give'), |
|
114 | + 'tooltip' => esc_attr__('The button label for displaying the additional payment fields.', 'give'), |
|
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | } |
@@ -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_Logs' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Logs')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Logs. |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'logs'; |
46 | - $this->label = esc_html__( 'Logs', 'give' ); |
|
46 | + $this->label = esc_html__('Logs', 'give'); |
|
47 | 47 | |
48 | 48 | $this->default_tab = 'sales'; |
49 | 49 | |
50 | 50 | parent::__construct(); |
51 | 51 | |
52 | 52 | // Do not use main form for this tab. |
53 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
54 | - add_action( 'give-tools_open_form', '__return_empty_string' ); |
|
55 | - add_action( 'give-tools_close_form', '__return_empty_string' ); |
|
53 | + if (give_get_current_setting_tab() === $this->id) { |
|
54 | + add_action('give-tools_open_form', '__return_empty_string'); |
|
55 | + add_action('give-tools_close_form', '__return_empty_string'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - public function add_settings_page( $pages ) { |
|
69 | - $pages[ $this->id ] = $this->label; |
|
68 | + public function add_settings_page($pages) { |
|
69 | + $pages[$this->id] = $this->label; |
|
70 | 70 | |
71 | 71 | return $pages; |
72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $GLOBALS['give_hide_save_button'] = true; |
83 | 83 | |
84 | 84 | // Get settings. |
85 | - $settings = apply_filters( 'give_settings_logs', array( |
|
85 | + $settings = apply_filters('give_settings_logs', array( |
|
86 | 86 | array( |
87 | 87 | 'id' => 'give_tools_logs', |
88 | 88 | 'type' => 'title', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ), |
91 | 91 | array( |
92 | 92 | 'id' => 'api', |
93 | - 'name' => esc_html__( 'Log', 'give' ), |
|
93 | + 'name' => esc_html__('Log', 'give'), |
|
94 | 94 | 'type' => 'logs', |
95 | 95 | |
96 | 96 | ), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'type' => 'sectionend', |
100 | 100 | 'table_html' => false, |
101 | 101 | ), |
102 | - ) ); |
|
102 | + )); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Filter the settings. |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param array $settings |
110 | 110 | */ |
111 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
111 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
112 | 112 | |
113 | 113 | // Output. |
114 | 114 | return $settings; |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function get_sections() { |
124 | 124 | $sections = array( |
125 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
126 | - 'gateway_errors' => esc_html__( 'Payment Errors', 'give' ), |
|
127 | - 'api_requests' => esc_html__( 'API Requests', 'give' ), |
|
125 | + 'sales' => esc_html__('Donations', 'give'), |
|
126 | + 'gateway_errors' => esc_html__('Payment Errors', 'give'), |
|
127 | + 'api_requests' => esc_html__('API Requests', 'give'), |
|
128 | 128 | ); |
129 | 129 | |
130 | - $sections = apply_filters( 'give_log_views', $sections ); |
|
130 | + $sections = apply_filters('give_log_views', $sections); |
|
131 | 131 | |
132 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
132 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function output() { |
142 | 142 | $settings = $this->get_settings(); |
143 | 143 | |
144 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
144 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 |
@@ -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_API' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_API')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_API. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'api'; |
46 | - $this->label = esc_html__( 'API', 'give' ); |
|
46 | + $this->label = esc_html__('API', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $pages Lst of pages. |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function add_settings_page( $pages ) { |
|
60 | - $pages[ $this->id ] = $this->label; |
|
59 | + public function add_settings_page($pages) { |
|
60 | + $pages[$this->id] = $this->label; |
|
61 | 61 | |
62 | 62 | return $pages; |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $GLOBALS['give_hide_save_button'] = true; |
74 | 74 | |
75 | 75 | // Get settings. |
76 | - $settings = apply_filters( 'give_settings_api', array( |
|
76 | + $settings = apply_filters('give_settings_api', array( |
|
77 | 77 | array( |
78 | 78 | 'id' => 'give_tools_api', |
79 | 79 | 'type' => 'title', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ), |
82 | 82 | array( |
83 | 83 | 'id' => 'api', |
84 | - 'name' => esc_html__( 'API', 'give' ), |
|
84 | + 'name' => esc_html__('API', 'give'), |
|
85 | 85 | 'type' => 'api', |
86 | 86 | ), |
87 | 87 | array( |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @since 1.8 |
98 | 98 | * @param array $settings |
99 | 99 | */ |
100 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
100 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
101 | 101 | |
102 | 102 | // Output. |
103 | 103 | return $settings; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function output() { |
113 | 113 | $settings = $this->get_settings(); |
114 | 114 | |
115 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
115 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 |
@@ -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_Data' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Data')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Data. |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'data'; |
46 | - $this->label = esc_html__( 'Data', 'give' ); |
|
46 | + $this->label = esc_html__('Data', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | |
51 | 51 | // Do not use main form for this tab. |
52 | - if( give_get_current_setting_tab() === $this->id ) { |
|
53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
52 | + if (give_get_current_setting_tab() === $this->id) { |
|
53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $pages Lst of pages. |
63 | 63 | * @return array |
64 | 64 | */ |
65 | - public function add_settings_page( $pages ) { |
|
66 | - $pages[ $this->id ] = $this->label; |
|
65 | + public function add_settings_page($pages) { |
|
66 | + $pages[$this->id] = $this->label; |
|
67 | 67 | |
68 | 68 | return $pages; |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $GLOBALS['give_hide_save_button'] = true; |
80 | 80 | |
81 | 81 | // Get settings. |
82 | - $settings = apply_filters( 'give_settings_data', array( |
|
82 | + $settings = apply_filters('give_settings_data', array( |
|
83 | 83 | array( |
84 | 84 | 'id' => 'give_tools_tools', |
85 | 85 | 'type' => 'title', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ), |
88 | 88 | array( |
89 | 89 | 'id' => 'api', |
90 | - 'name' => esc_html__( 'Tools', 'give' ), |
|
90 | + 'name' => esc_html__('Tools', 'give'), |
|
91 | 91 | 'type' => 'data', |
92 | 92 | ), |
93 | 93 | array( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @since 1.8 |
104 | 104 | * @param array $settings |
105 | 105 | */ |
106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
107 | 107 | |
108 | 108 | // Output. |
109 | 109 | return $settings; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function output() { |
119 | 119 | $settings = $this->get_settings(); |
120 | 120 | |
121 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
121 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 |
@@ -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 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Determine access |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | */ |
45 | 45 | if ( |
46 | 46 | is_user_logged_in() || false !== Give()->session->get_session_expiration() |
47 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
47 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
48 | 48 | ) { |
49 | 49 | ob_start(); |
50 | - give_get_template_part( 'history', 'donations' ); |
|
50 | + give_get_template_part('history', 'donations'); |
|
51 | 51 | |
52 | 52 | return ob_get_clean(); |
53 | 53 | |
54 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
54 | + } elseif (give_is_setting_enabled($email_access)) { |
|
55 | 55 | //Is Email-based access enabled? |
56 | 56 | ob_start(); |
57 | - give_get_template_part( 'email', 'login-form' ); |
|
57 | + give_get_template_part('email', 'login-form'); |
|
58 | 58 | |
59 | 59 | return ob_get_clean(); |
60 | 60 | } else { |
61 | 61 | |
62 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
63 | - echo do_shortcode( '[give_login]' ); |
|
62 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
63 | + echo do_shortcode('[give_login]'); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
68 | +add_shortcode('donation_history', 'give_donation_history'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Donation Form Shortcode |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return string |
80 | 80 | */ |
81 | -function give_form_shortcode( $atts ) { |
|
82 | - $atts = shortcode_atts( array( |
|
81 | +function give_form_shortcode($atts) { |
|
82 | + $atts = shortcode_atts(array( |
|
83 | 83 | 'id' => '', |
84 | 84 | 'show_title' => true, |
85 | 85 | 'show_goal' => true, |
@@ -87,21 +87,21 @@ discard block |
||
87 | 87 | 'float_labels' => '', |
88 | 88 | 'display_style' => '', |
89 | 89 | 'continue_button_title' => '', |
90 | - ), $atts, 'give_form' ); |
|
90 | + ), $atts, 'give_form'); |
|
91 | 91 | |
92 | 92 | // Convert string to bool. |
93 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
94 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
93 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
94 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
95 | 95 | |
96 | 96 | //get the Give Form |
97 | 97 | ob_start(); |
98 | - give_get_donation_form( $atts ); |
|
98 | + give_get_donation_form($atts); |
|
99 | 99 | $final_output = ob_get_clean(); |
100 | 100 | |
101 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
101 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
102 | 102 | } |
103 | 103 | |
104 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
104 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Donation Form Goal Shortcode. |
@@ -114,37 +114,37 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function give_goal_shortcode( $atts ) { |
|
118 | - $atts = shortcode_atts( array( |
|
117 | +function give_goal_shortcode($atts) { |
|
118 | + $atts = shortcode_atts(array( |
|
119 | 119 | 'id' => '', |
120 | 120 | 'show_text' => true, |
121 | 121 | 'show_bar' => true, |
122 | - ), $atts, 'give_goal' ); |
|
122 | + ), $atts, 'give_goal'); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | //get the Give Form. |
126 | 126 | ob_start(); |
127 | 127 | |
128 | 128 | //Sanity check 1: ensure there is an ID Provided. |
129 | - if ( empty( $atts['id'] ) ) { |
|
130 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
129 | + if (empty($atts['id'])) { |
|
130 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | //Sanity check 2: Check the form even has Goals enabled. |
134 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
134 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
135 | 135 | |
136 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
136 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
137 | 137 | } else { |
138 | 138 | //Passed all sanity checks: output Goal. |
139 | - give_show_goal_progress( $atts['id'], $atts ); |
|
139 | + give_show_goal_progress($atts['id'], $atts); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $final_output = ob_get_clean(); |
143 | 143 | |
144 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
144 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
145 | 145 | } |
146 | 146 | |
147 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
147 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | /** |
@@ -161,22 +161,22 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return string |
163 | 163 | */ |
164 | -function give_login_form_shortcode( $atts ) { |
|
165 | - $atts = shortcode_atts( array( |
|
164 | +function give_login_form_shortcode($atts) { |
|
165 | + $atts = shortcode_atts(array( |
|
166 | 166 | // Add backward compatibility for redirect attribute. |
167 | 167 | 'redirect' => '', |
168 | 168 | |
169 | 169 | 'login-redirect' => '', |
170 | 170 | 'logout-redirect' => '', |
171 | - ), $atts, 'give_login' ); |
|
171 | + ), $atts, 'give_login'); |
|
172 | 172 | |
173 | 173 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
174 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
174 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
175 | 175 | |
176 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
176 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
177 | 177 | } |
178 | 178 | |
179 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
179 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Register Shortcode. |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string |
193 | 193 | */ |
194 | -function give_register_form_shortcode( $atts ) { |
|
195 | - $atts = shortcode_atts( array( |
|
194 | +function give_register_form_shortcode($atts) { |
|
195 | + $atts = shortcode_atts(array( |
|
196 | 196 | 'redirect' => '', |
197 | - ), $atts, 'give_register' ); |
|
197 | + ), $atts, 'give_register'); |
|
198 | 198 | |
199 | - return give_register_form( $atts['redirect'] ); |
|
199 | + return give_register_form($atts['redirect']); |
|
200 | 200 | } |
201 | 201 | |
202 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
202 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Receipt Shortcode. |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string |
214 | 214 | */ |
215 | -function give_receipt_shortcode( $atts ) { |
|
215 | +function give_receipt_shortcode($atts) { |
|
216 | 216 | |
217 | 217 | global $give_receipt_args, $payment; |
218 | 218 | |
219 | - $give_receipt_args = shortcode_atts( array( |
|
220 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
219 | + $give_receipt_args = shortcode_atts(array( |
|
220 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
221 | 221 | 'price' => true, |
222 | 222 | 'donor' => true, |
223 | 223 | 'date' => true, |
@@ -226,50 +226,50 @@ discard block |
||
226 | 226 | 'payment_id' => true, |
227 | 227 | 'payment_status' => false, |
228 | 228 | 'status_notice' => true, |
229 | - ), $atts, 'give_receipt' ); |
|
229 | + ), $atts, 'give_receipt'); |
|
230 | 230 | |
231 | 231 | //set $session var |
232 | 232 | $session = give_get_purchase_session(); |
233 | 233 | |
234 | 234 | //set payment key var |
235 | - if ( isset( $_GET['payment_key'] ) ) { |
|
236 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
237 | - } elseif ( $session ) { |
|
235 | + if (isset($_GET['payment_key'])) { |
|
236 | + $payment_key = urldecode($_GET['payment_key']); |
|
237 | + } elseif ($session) { |
|
238 | 238 | $payment_key = $session['purchase_key']; |
239 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
239 | + } elseif ($give_receipt_args['payment_key']) { |
|
240 | 240 | $payment_key = $give_receipt_args['payment_key']; |
241 | 241 | } |
242 | 242 | |
243 | - $email_access = give_get_option( 'email_access' ); |
|
243 | + $email_access = give_get_option('email_access'); |
|
244 | 244 | |
245 | 245 | // No payment_key found & Email Access is Turned on: |
246 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
246 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
247 | 247 | |
248 | 248 | ob_start(); |
249 | 249 | |
250 | - give_get_template_part( 'email-login-form' ); |
|
250 | + give_get_template_part('email-login-form'); |
|
251 | 251 | |
252 | 252 | return ob_get_clean(); |
253 | 253 | |
254 | - } elseif ( ! isset( $payment_key ) ) { |
|
254 | + } elseif ( ! isset($payment_key)) { |
|
255 | 255 | |
256 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
256 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
261 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
260 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
261 | + $user_can_view = give_can_view_receipt($payment_key); |
|
262 | 262 | |
263 | 263 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
264 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
264 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
265 | 265 | |
266 | 266 | ob_start(); |
267 | 267 | |
268 | - give_get_template_part( 'email-login-form' ); |
|
268 | + give_get_template_part('email-login-form'); |
|
269 | 269 | |
270 | 270 | return ob_get_clean(); |
271 | 271 | |
272 | - } elseif ( ! $user_can_view ) { |
|
272 | + } elseif ( ! $user_can_view) { |
|
273 | 273 | |
274 | 274 | global $give_login_redirect; |
275 | 275 | |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | |
278 | 278 | ob_start(); |
279 | 279 | |
280 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
280 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
281 | 281 | |
282 | - give_get_template_part( 'shortcode', 'login' ); |
|
282 | + give_get_template_part('shortcode', 'login'); |
|
283 | 283 | |
284 | 284 | $login_form = ob_get_clean(); |
285 | 285 | |
@@ -294,20 +294,20 @@ discard block |
||
294 | 294 | * or if user is logged in and the user can view sensitive shop data. |
295 | 295 | * |
296 | 296 | */ |
297 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
298 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
297 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
298 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | ob_start(); |
302 | 302 | |
303 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
303 | + give_get_template_part('shortcode', 'receipt'); |
|
304 | 304 | |
305 | 305 | $display = ob_get_clean(); |
306 | 306 | |
307 | 307 | return $display; |
308 | 308 | } |
309 | 309 | |
310 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
310 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
311 | 311 | |
312 | 312 | /** |
313 | 313 | * Profile Editor Shortcode. |
@@ -326,18 +326,18 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return string Output generated from the profile editor |
328 | 328 | */ |
329 | -function give_profile_editor_shortcode( $atts ) { |
|
329 | +function give_profile_editor_shortcode($atts) { |
|
330 | 330 | |
331 | 331 | ob_start(); |
332 | 332 | |
333 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
333 | + give_get_template_part('shortcode', 'profile-editor'); |
|
334 | 334 | |
335 | 335 | $display = ob_get_clean(); |
336 | 336 | |
337 | 337 | return $display; |
338 | 338 | } |
339 | 339 | |
340 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
340 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * Process Profile Updater Form. |
@@ -350,30 +350,30 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return bool |
352 | 352 | */ |
353 | -function give_process_profile_editor_updates( $data ) { |
|
353 | +function give_process_profile_editor_updates($data) { |
|
354 | 354 | // Profile field change request |
355 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
355 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
356 | 356 | return false; |
357 | 357 | } |
358 | 358 | |
359 | 359 | // Nonce security |
360 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
360 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | 364 | $user_id = get_current_user_id(); |
365 | - $old_user_data = get_userdata( $user_id ); |
|
366 | - |
|
367 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
368 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
369 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
370 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
371 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
372 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
373 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
374 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
375 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
376 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
365 | + $old_user_data = get_userdata($user_id); |
|
366 | + |
|
367 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
368 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
369 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
370 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
371 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
372 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
373 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
374 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
375 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
376 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
377 | 377 | |
378 | 378 | $userdata = array( |
379 | 379 | 'ID' => $user_id, |
@@ -401,46 +401,46 @@ discard block |
||
401 | 401 | * @param int $user_id The ID of the user. |
402 | 402 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
403 | 403 | */ |
404 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
404 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
405 | 405 | |
406 | 406 | // New password |
407 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
408 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
409 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
407 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
408 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
409 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
410 | 410 | } else { |
411 | 411 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | - if ( empty( $email ) ) { |
|
415 | + if (empty($email)) { |
|
416 | 416 | // Make sure email should not be empty. |
417 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
417 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
418 | 418 | |
419 | - } else if ( ! is_email( $email ) ) { |
|
419 | + } else if ( ! is_email($email)) { |
|
420 | 420 | // Make sure email should be valid. |
421 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
421 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
422 | 422 | |
423 | - } else if ( $email != $old_user_data->user_email ) { |
|
423 | + } else if ($email != $old_user_data->user_email) { |
|
424 | 424 | // Make sure the new email doesn't belong to another user |
425 | - if ( email_exists( $email ) ) { |
|
426 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
425 | + if (email_exists($email)) { |
|
426 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | // Check for errors |
431 | 431 | $errors = give_get_errors(); |
432 | 432 | |
433 | - if ( $errors ) { |
|
433 | + if ($errors) { |
|
434 | 434 | // Send back to the profile editor if there are errors |
435 | - wp_redirect( $data['give_redirect'] ); |
|
435 | + wp_redirect($data['give_redirect']); |
|
436 | 436 | give_die(); |
437 | 437 | } |
438 | 438 | |
439 | 439 | // Update the user |
440 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
441 | - $updated = wp_update_user( $userdata ); |
|
440 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
441 | + $updated = wp_update_user($userdata); |
|
442 | 442 | |
443 | - if ( $updated ) { |
|
443 | + if ($updated) { |
|
444 | 444 | |
445 | 445 | /** |
446 | 446 | * Fires after updating user profile. |
@@ -450,12 +450,12 @@ discard block |
||
450 | 450 | * @param int $user_id The ID of the user. |
451 | 451 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
452 | 452 | */ |
453 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
454 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
453 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
454 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
455 | 455 | give_die(); |
456 | 456 | } |
457 | 457 | |
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | |
461 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
461 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -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,25 +25,25 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
39 | - 'currency_sign' => give_currency_filter( '' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | + 'currency_sign' => give_currency_filter(''), |
|
40 | 40 | 'currency_pos' => give_get_currency_position(), |
41 | 41 | 'thousands_separator' => give_get_price_thousand_separator(), |
42 | 42 | 'decimal_separator' => give_get_price_decimal_separator(), |
43 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
44 | - 'bad_minimum' => __( 'The minimum donation amount for this form is', 'give' ), |
|
45 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
46 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
43 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
44 | + 'bad_minimum' => __('The minimum donation amount for this form is', 'give'), |
|
45 | + 'general_loading' => __('Loading...', 'give'), |
|
46 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
47 | 47 | 'number_decimals' => give_get_price_decimals(), |
48 | 48 | 'give_version' => GIVE_VERSION, |
49 | 49 | 'magnific_options' => apply_filters( |
@@ -57,81 +57,81 @@ discard block |
||
57 | 57 | 'give_form_translation_js', |
58 | 58 | array( |
59 | 59 | // Field name Validation message. |
60 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
61 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
62 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
63 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
64 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
65 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
66 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
60 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
61 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
62 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
63 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
64 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
65 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
66 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
67 | 67 | ) |
68 | 68 | ), |
69 | - ) ); |
|
69 | + )); |
|
70 | 70 | |
71 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
71 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
72 | 72 | 'ajaxurl' => give_get_ajax_url(), |
73 | - 'loading' => __( 'Loading', 'give' ), |
|
73 | + 'loading' => __('Loading', 'give'), |
|
74 | 74 | // General loading message. |
75 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
75 | + 'select_option' => __('Please select an option', 'give'), |
|
76 | 76 | // Variable pricing error with multi-donation option enabled. |
77 | - 'default_gateway' => give_get_default_gateway( null ), |
|
78 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
77 | + 'default_gateway' => give_get_default_gateway(null), |
|
78 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
79 | 79 | 'number_decimals' => give_get_price_decimals(), |
80 | - ) ); |
|
80 | + )); |
|
81 | 81 | |
82 | 82 | // DEBUG is On. |
83 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
83 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
84 | 84 | |
85 | - if ( give_is_cc_verify_enabled() ) { |
|
86 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
87 | - wp_enqueue_script( 'give-cc-validator' ); |
|
85 | + if (give_is_cc_verify_enabled()) { |
|
86 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
87 | + wp_enqueue_script('give-cc-validator'); |
|
88 | 88 | } |
89 | 89 | |
90 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
91 | - wp_enqueue_script( 'give-float-labels' ); |
|
90 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
91 | + wp_enqueue_script('give-float-labels'); |
|
92 | 92 | |
93 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-blockui' ); |
|
93 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-blockui'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-qtip' ); |
|
96 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-qtip'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-accounting' ); |
|
99 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-accounting'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-magnific' ); |
|
102 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-magnific'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-checkout-global' ); |
|
105 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-checkout-global'); |
|
107 | 107 | |
108 | 108 | // General scripts. |
109 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
110 | - wp_enqueue_script( 'give-scripts' ); |
|
109 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
110 | + wp_enqueue_script('give-scripts'); |
|
111 | 111 | |
112 | 112 | // Load AJAX scripts, if enabled. |
113 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
114 | - wp_enqueue_script( 'give-ajax' ); |
|
113 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
114 | + wp_enqueue_script('give-ajax'); |
|
115 | 115 | |
116 | 116 | // Localize / Pass AJAX vars from PHP, |
117 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
118 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
117 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
118 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
119 | 119 | |
120 | 120 | } else { |
121 | 121 | |
122 | 122 | // DEBUG is OFF (one JS file to rule them all!). |
123 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
124 | - wp_enqueue_script( 'give' ); |
|
123 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
124 | + wp_enqueue_script('give'); |
|
125 | 125 | |
126 | 126 | // Localize / Pass AJAX vars from PHP. |
127 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
128 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
127 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
128 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
134 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Register styles. |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function give_register_styles() { |
146 | 146 | |
147 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
147 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
152 | - wp_enqueue_style( 'give-styles' ); |
|
151 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
152 | + wp_enqueue_style('give-styles'); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
156 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | function give_get_stylesheet_uri() { |
167 | 167 | |
168 | 168 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
169 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
169 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
170 | 170 | |
171 | 171 | // LTR or RTL files. |
172 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
172 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
173 | 173 | |
174 | - $file = 'give' . $direction . $suffix . '.css'; |
|
174 | + $file = 'give'.$direction.$suffix.'.css'; |
|
175 | 175 | $templates_dir = give_get_theme_template_dir_name(); |
176 | 176 | |
177 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
178 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
179 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
180 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
181 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
177 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
178 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
179 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
180 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
181 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
182 | 182 | |
183 | 183 | $uri = false; |
184 | 184 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
189 | 189 | * This allows users to copy just give.css to their theme. |
190 | 190 | */ |
191 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
192 | - if ( ! empty( $nonmin ) ) { |
|
193 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
191 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
192 | + if ( ! empty($nonmin)) { |
|
193 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
194 | 194 | } else { |
195 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
195 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
196 | 196 | } |
197 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
198 | - if ( ! empty( $nonmin ) ) { |
|
199 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
197 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
198 | + if ( ! empty($nonmin)) { |
|
199 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
200 | 200 | } else { |
201 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
201 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
202 | 202 | } |
203 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
204 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
203 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
204 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
205 | 205 | } |
206 | 206 | |
207 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
207 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,76 +221,76 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return void |
223 | 223 | */ |
224 | -function give_load_admin_scripts( $hook ) { |
|
224 | +function give_load_admin_scripts($hook) { |
|
225 | 225 | |
226 | 226 | global $post, $post_type; |
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // Directories of assets. |
231 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
232 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
233 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
231 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
232 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
233 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
234 | 234 | |
235 | 235 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
236 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
236 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
237 | 237 | |
238 | 238 | // LTR or RTL files. |
239 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
239 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
240 | 240 | |
241 | 241 | // Global Admin. |
242 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
243 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
242 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
243 | + wp_enqueue_style('give-admin-bar-notification'); |
|
244 | 244 | |
245 | 245 | // Give Admin Only. |
246 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
246 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // CSS. |
251 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
252 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
253 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
254 | - wp_enqueue_style( 'give-admin' ); |
|
255 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
256 | - wp_enqueue_style( 'jquery-chosen' ); |
|
257 | - wp_enqueue_style( 'thickbox' ); |
|
258 | - wp_enqueue_style( 'wp-color-picker' ); |
|
251 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
252 | + wp_enqueue_style('jquery-ui-css'); |
|
253 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
254 | + wp_enqueue_style('give-admin'); |
|
255 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
256 | + wp_enqueue_style('jquery-chosen'); |
|
257 | + wp_enqueue_style('thickbox'); |
|
258 | + wp_enqueue_style('wp-color-picker'); |
|
259 | 259 | |
260 | 260 | |
261 | 261 | // JS. |
262 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
263 | - wp_enqueue_script( 'jquery-chosen' ); |
|
262 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
263 | + wp_enqueue_script('jquery-chosen'); |
|
264 | 264 | |
265 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
266 | - wp_enqueue_script( 'give-accounting' ); |
|
265 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
266 | + wp_enqueue_script('give-accounting'); |
|
267 | 267 | |
268 | - wp_enqueue_script( 'wp-color-picker' ); |
|
269 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
270 | - wp_enqueue_script( 'thickbox' ); |
|
268 | + wp_enqueue_script('wp-color-picker'); |
|
269 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
270 | + wp_enqueue_script('thickbox'); |
|
271 | 271 | |
272 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker' ), GIVE_VERSION, false ); |
|
273 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
272 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker'), GIVE_VERSION, false); |
|
273 | + wp_enqueue_script('give-admin-scripts'); |
|
274 | 274 | |
275 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
276 | - wp_enqueue_script( 'jquery-flot' ); |
|
275 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
276 | + wp_enqueue_script('jquery-flot'); |
|
277 | 277 | |
278 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
279 | - wp_enqueue_script( 'give-qtip' ); |
|
278 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
279 | + wp_enqueue_script('give-qtip'); |
|
280 | 280 | |
281 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
282 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
281 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
282 | + wp_enqueue_script('give-repeatable-fields'); |
|
283 | 283 | |
284 | 284 | // Forms CPT Script. |
285 | - if ( $post_type === 'give_forms' ) { |
|
286 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
287 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
285 | + if ($post_type === 'give_forms') { |
|
286 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
287 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // Settings Scripts. |
291 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
292 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
293 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
291 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
292 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
293 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Price Separators. |
@@ -298,59 +298,59 @@ discard block |
||
298 | 298 | $decimal_separator = give_get_price_decimal_separator(); |
299 | 299 | |
300 | 300 | // Localize strings & variables for JS. |
301 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
302 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
301 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
302 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
303 | 303 | 'give_version' => GIVE_VERSION, |
304 | 304 | 'thousands_separator' => $thousand_separator, |
305 | 305 | 'decimal_separator' => $decimal_separator, |
306 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
307 | - 'delete_payment' => __( 'Are you sure you wish to delete this payment?', 'give' ), |
|
308 | - 'delete_payment_note' => __( 'Are you sure you wish to delete this note?', 'give' ), |
|
309 | - 'revoke_api_key' => __( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
310 | - 'regenerate_api_key' => __( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
311 | - 'resend_receipt' => __( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
312 | - 'logo' => __( 'Logo', 'give' ), |
|
313 | - 'use_this_image' => __( 'Use this image', 'give' ), |
|
314 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
315 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
316 | - 'currency_sign' => give_currency_filter( '' ), |
|
317 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
318 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
319 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
320 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
321 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
322 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
306 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
307 | + 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), |
|
308 | + 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), |
|
309 | + 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), |
|
310 | + 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), |
|
311 | + 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), |
|
312 | + 'logo' => __('Logo', 'give'), |
|
313 | + 'use_this_image' => __('Use this image', 'give'), |
|
314 | + 'one_option' => __('Choose a form', 'give'), |
|
315 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
316 | + 'currency_sign' => give_currency_filter(''), |
|
317 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
318 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
319 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
320 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
321 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
322 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
323 | 323 | /* translators : %s: Donation form options metabox */ |
324 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
325 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
326 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
324 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
325 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
326 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
327 | 327 | 'bulk_action' => array( |
328 | 328 | 'delete' => array( |
329 | - 'zero_payment_selected' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
330 | - 'delete_payment' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
331 | - 'delete_payments' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
329 | + 'zero_payment_selected' => __('You must choose at least one or more payments to delete.', 'give'), |
|
330 | + 'delete_payment' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
331 | + 'delete_payments' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
332 | 332 | ), |
333 | 333 | 'resend_receipt' => array( |
334 | - 'zero_recipient_selected' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
335 | - 'resend_receipt' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
336 | - 'resend_receipts' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
334 | + 'zero_recipient_selected' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
335 | + 'resend_receipt' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
336 | + 'resend_receipts' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
337 | 337 | ), |
338 | 338 | ), |
339 | 339 | 'metabox_fields' => array( |
340 | 340 | 'media' => array( |
341 | - 'button_title' => esc_html__( 'Choose Attachment', 'give' ), |
|
341 | + 'button_title' => esc_html__('Choose Attachment', 'give'), |
|
342 | 342 | ) |
343 | 343 | ) |
344 | - ) ); |
|
344 | + )); |
|
345 | 345 | |
346 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
346 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
347 | 347 | // call for new media manager. |
348 | 348 | wp_enqueue_media(); |
349 | 349 | } |
350 | 350 | |
351 | 351 | } |
352 | 352 | |
353 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
353 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Admin Give Icon |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | ?> |
366 | 366 | <style type="text/css" media="screen"> |
367 | 367 | |
368 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
368 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
369 | 369 | @font-face { |
370 | 370 | font-family: 'give-icomoon'; |
371 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
372 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
373 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
374 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
371 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
372 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
373 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
374 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
375 | 375 | font-weight: normal; |
376 | 376 | font-style: normal; |
377 | 377 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | <?php |
391 | 391 | } |
392 | 392 | |
393 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
393 | +add_action('admin_head', 'give_admin_icon'); |
|
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Admin js code |
@@ -420,4 +420,4 @@ discard block |
||
420 | 420 | <?php |
421 | 421 | } |
422 | 422 | |
423 | -add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' ); |
|
423 | +add_action('admin_head', 'give_admin_hide_notice_shortly_js'); |