How to disable reCaptcha v3 except on Contact Form 7 pages?
Contact form 7 is loading reCaptcha v3 scripts on all the pages of the sites which is making the website slow.
So I was using the script below which was working fine before two weeks from now, but now it stopped working and it's now loading even more scripts. Why could it be?
I don't want to use extra plugins.
function contactform_dequeue_scripts() {
$load_scripts = false;
if( is_singular() ) {
$post = get_post();
if( has_shortcode($post-post_content, 'contact-form-7') ) {
$load_scripts = true;
}
}
if( ! $load_scripts ) {
wp_dequeue_script( 'contact-form-7' );
wp_dequeue_script('google-recaptcha');
wp_dequeue_style( 'contact-form-7' );
}
}
add_action( 'wp_enqueue_scripts', 'contactform_dequeue_scripts', 99 );
Topic captcha plugin-contact-form-7 plugin-development Wordpress
Category Web