• Hell Team,

    The plugin contact form 7 is loading the Google reCaptcha script on all the pages, before last update the below code was working fine for me a disabling the scripts on other pages than contact form.

    But now it’s not working anymore, please help me, i don’t want to use extra plugin to make this right.

    function dd_wpcf7_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', 'dd_wpcf7_dequeue_scripts', 99 );

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Contact Form 7 Loading reCaptcha script on all the pages in the website’ is closed to new replies.