| @@ -26,8 +26,13 @@ | ||
| 26 | 26 | |
| 27 | 27 | global $post; |
| 28 | 28 | static $count = 1; |
| 29 | 29 | |
| 30 | + /** | |
| 31 | + * @since 3.11.0 sanitize $args | |
| 32 | + */ | |
| 33 | + $args = give_clean($args); | |
| 34 | + | |
| 30 | 35 | $args = wp_parse_args( $args, give_get_default_form_shortcode_args() ); |
| 31 | 36 | |
| 32 | 37 | // Backward compatibility for `form_id` function param. |
| 33 | 38 | // If are calling this function directly with `form_id` the use `id` instead. |
| @@ -740,8 +745,9 @@ | ||
| 740 | 745 | |
| 741 | 746 | /** |
| 742 | 747 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
| 743 | 748 | * |
| 749 | + * @since 3.1.0 Add the give_user_info_fields_user_info filter | |
| 744 | 750 | * @since 2.25.0 add radio group to conditionally enable/disable company name field |
| 745 | 751 | * @since 1.0 |
| 746 | 752 | * |
| 747 | 753 | * @param int $form_id The form ID. |
| @@ -751,9 +757,10 @@ | ||
| 751 | 757 | */ |
| 752 | 758 | function give_user_info_fields( $form_id ) { |
| 753 | 759 | |
| 754 | 760 | // Get user info. |
| 755 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); | |
| 761 | + $give_user_info = apply_filters('give_user_info_fields_user_info', _give_get_prefill_form_field_values( $form_id ), $form_id ); | |
| 762 | + | |
| 756 | 763 | $title = ! empty( $give_user_info['give_title'] ) ? $give_user_info['give_title'] : ''; |
| 757 | 764 | $first_name = ! empty( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; |
| 758 | 765 | $last_name = ! empty( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; |
| 759 | 766 | $company_name = ! empty( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; |
| @@ -1192,16 +1199,20 @@ | ||
| 1192 | 1199 | |
| 1193 | 1200 | /** |
| 1194 | 1201 | * Outputs the default credit card address fields. |
| 1195 | 1202 | * |
| 1203 | + * @since 3.1.0 Add the give_default_cc_address_fields_user_info filter | |
| 1204 | + * @since 1.0 | |
| 1205 | + * | |
| 1196 | 1206 | * @param int $form_id The form ID. |
| 1207 | + * @param bool $return Whether to return the output or echo it. * | |
| 1197 | 1208 | * |
| 1198 | - * @return void | |
| 1199 | - * @since 1.0 | |
| 1209 | + * @return void|string | |
| 1200 | 1210 | */ |
| 1201 | -function give_default_cc_address_fields( $form_id ) { | |
| 1211 | +function give_default_cc_address_fields($form_id, $return = false) | |
| 1212 | +{ | |
| 1202 | 1213 | // Get user info. |
| 1203 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); | |
| 1214 | + $give_user_info = apply_filters('give_default_cc_address_fields_user_info', _give_get_prefill_form_field_values( $form_id ), $form_id); | |
| 1204 | 1215 | |
| 1205 | 1216 | ob_start(); |
| 1206 | 1217 | ?> |
| 1207 | 1218 | <fieldset id="give_cc_address" class="cc-address"> |
| @@ -1418,8 +1429,13 @@ | ||
| 1418 | 1429 | do_action( 'give_cc_billing_bottom' ); |
| 1419 | 1430 | ?> |
| 1420 | 1431 | </fieldset> |
| 1421 | 1432 | <?php |
| 1433 | + | |
| 1434 | + if ($return) { | |
| 1435 | + return ob_get_clean(); | |
| 1436 | + } | |
| 1437 | + | |
| 1422 | 1438 | echo ob_get_clean(); |
| 1423 | 1439 | } |
| 1424 | 1440 | |
| 1425 | 1441 | add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
| @@ -1660,8 +1676,10 @@ | ||
| 1660 | 1676 | <a href="<?php echo wp_lostpassword_url(); ?>" target="_blank"><?php _e( 'Reset Password', 'give' ); ?></a> |
| 1661 | 1677 | </span> |
| 1662 | 1678 | </div> |
| 1663 | 1679 | </div> |
| 1680 | + <input type="hidden" name="give_login_nonce" | |
| 1681 | + value="<?php echo wp_create_nonce( 'give-login-nonce' ); ?>"/> | |
| 1664 | 1682 | <?php |
| 1665 | 1683 | /** |
| 1666 | 1684 | * Fires while rendering checkout login form, after the fields. |
| 1667 | 1685 | * |
| @@ -1691,10 +1709,9 @@ | ||
| 1691 | 1709 | * @return void |
| 1692 | 1710 | * @since 1.0 |
| 1693 | 1711 | */ |
| 1694 | 1712 | function give_payment_mode_select( $form_id, $args ) { |
| 1695 | - | |
| 1696 | - $gateways = give_get_enabled_payment_gateways( $form_id ); | |
| 1713 | + $gateways = give_get_enabled_payment_gateways($form_id, 2); | |
| 1697 | 1714 | $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
| 1698 | 1715 | |
| 1699 | 1716 | /** |
| 1700 | 1717 | * Fires while selecting payment gateways, before the fields. |
| @@ -2005,13 +2022,15 @@ | ||
| 2005 | 2022 | |
| 2006 | 2023 | /** |
| 2007 | 2024 | * Give Donation form submit button. |
| 2008 | 2025 | * |
| 2026 | + * @since 4.16.2 Escape submit button label in form markup. | |
| 2027 | + * @since 1.8.8 | |
| 2028 | + * | |
| 2009 | 2029 | * @param int $form_id The form ID. |
| 2010 | 2030 | * @param array $args |
| 2011 | 2031 | * |
| 2012 | 2032 | * @return string |
| 2013 | - * @since 1.8.8 | |
| 2014 | 2033 | */ |
| 2015 | 2034 | function give_get_donation_form_submit_button( $form_id, $args = [] ) { |
| 2016 | 2035 | |
| 2017 | 2036 | $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
| @@ -2020,9 +2039,9 @@ | ||
| 2020 | 2039 | ob_start(); |
| 2021 | 2040 | ?> |
| 2022 | 2041 | <div class="give-submit-button-wrap give-clearfix"> |
| 2023 | 2042 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" |
| 2024 | - value="<?php echo $display_label; ?>" data-before-validation-label="<?php echo $display_label; ?>"/> | |
| 2043 | + value="<?php echo esc_attr( $display_label ); ?>" data-before-validation-label="<?php echo esc_attr( $display_label ); ?>"/> | |
| 2025 | 2044 | <span class="give-loading-animation"></span> |
| 2026 | 2045 | </div> |
| 2027 | 2046 | <?php |
| 2028 | 2047 | return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id, $args ); |
| @@ -2333,11 +2352,12 @@ | ||
| 2333 | 2352 | * @param int $form_id |
| 2334 | 2353 | * @param array $args |
| 2335 | 2354 | * @param Give_Donate_Form $form |
| 2336 | 2355 | * |
| 2356 | + * @since 4.9.0 rename function - PHP 8 compatibility | |
| 2337 | 2357 | * @since 1.8.17 |
| 2338 | 2358 | */ |
| 2339 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { | |
| 2359 | +function give_form_add_donation_hidden_field( $form_id, $args, $form ) { | |
| 2340 | 2360 | $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
| 2341 | 2361 | ?> |
| 2342 | 2362 | <input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/> |
| 2343 | 2363 | <input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/> |
| @@ -2384,9 +2404,9 @@ | ||
| 2384 | 2404 | ); |
| 2385 | 2405 | } |
| 2386 | 2406 | } |
| 2387 | 2407 | |
| 2388 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); | |
| 2408 | +add_action( 'give_donation_form_top', 'give_form_add_donation_hidden_field', 0, 3 ); | |
| 2389 | 2409 | |
| 2390 | 2410 | /** |
| 2391 | 2411 | * Add currency settings on donation form. |
| 2392 | 2412 | * |
| @@ -2393,11 +2413,13 @@ | ||
| 2393 | 2413 | * @param array $form_html_tags |
| 2394 | 2414 | * @param Give_Donate_Form $form |
| 2395 | 2415 | * |
| 2396 | 2416 | * @return array |
| 2417 | + * | |
| 2418 | + * @since 4.9.0 rename function - PHP 8 compatibility | |
| 2397 | 2419 | * @since 1.8.17 |
| 2398 | 2420 | */ |
| 2399 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { | |
| 2421 | +function give_form_add_currency_settings( $form_html_tags, $form ) { | |
| 2400 | 2422 | $form_currency = give_get_currency( $form->ID ); |
| 2401 | 2423 | $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
| 2402 | 2424 | |
| 2403 | 2425 | // Check if currency exist. |
| @@ -2416,9 +2438,9 @@ | ||
| 2416 | 2438 | |
| 2417 | 2439 | return $form_html_tags; |
| 2418 | 2440 | } |
| 2419 | 2441 | |
| 2420 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); | |
| 2442 | +add_filter( 'give_form_html_tags', 'give_form_add_currency_settings', 0, 2 ); | |
| 2421 | 2443 | |
| 2422 | 2444 | /** |
| 2423 | 2445 | * Adds classes to progress bar container. |
| 2424 | 2446 | * |