Last active
October 10, 2022 15:01
-
-
Save sitoexpress/428d4edf96b301ce5afad0512ae1bdc5 to your computer and use it in GitHub Desktop.
Using a caching system, Contact Form 7 sends an AJAX request for each form (taking at least 500ms) in order to handle Really Simple Captcha and Quiz Captcha updates. The request is being sent even using Google Recaptcha, which is useless. We're going to disable this unwanted behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Disables REFILL function in WPCF7 if Recaptcha is in use | |
*/ | |
add_action('wp_enqueue_scripts', 'wpcf7_recaptcha_no_refill', 15, 0); | |
function wpcf7_recaptcha_no_refill() { | |
$service = WPCF7_RECAPTCHA::get_instance(); | |
if ( ! $service->is_active() ) { | |
return; | |
} | |
wp_add_inline_script('contact-form-7', 'wpcf7.cached = 0;', 'before' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment