• Resolved lsdevign

    (@lsdevign)


    Dear Support,

    Since your latest update, my script below to only load the recaptcha scripts on pages that require them, stopped working:

    add_filter( 'wpcf7_load_js', '__return_false' );
    
    function contact_scripts() {
        wp_dequeue_script('wpcf7-recaptcha');
        wp_dequeue_script('google-recaptcha');
        if (is_front_page() || is_singular('portfolio') || is_post_type_archive('nieuws') || is_singular('nieuws') || is_page_template(array('page-templates/template-info.php', 'page-templates/template-contact.php')) || is_checkout()) {
            if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
                wpcf7_enqueue_scripts();
                wp_enqueue_script( 'wpcf7-recaptcha' );
                wp_enqueue_script( 'google-recaptcha' );
            }
        }
    }
    add_action( 'wp_enqueue_scripts', 'contact_scripts' );

    Any idea on how to make this work again?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t not dequeue recaptcha scripts’ is closed to new replies.