• I have code that disables the CF7 resources, including reCAPTCHA, on pages that don’t contain any forms. However, the footer script is still included on those pages, and I’d like to stop this from happening.

    In a wp_enqueue_scripts action, I have this code, but it doesn’t work:

    
    if ( class_exists( 'ABCF7_captcha' ) ) {
    	remove_action( 'wp_footer', array( 'ABCF7_captcha', 'ABCF7_footer_script' ), 100 );
    }
    

    A simpler way would be to provide a filter, which defaults to true, and determines whether the footer script should be loaded.

    Alternatively, ABCF7_remove_google_captcha_js() can check if any reCAPTCHA resources are enqueued and add the footer action, instead of adding it unconditionally during init.

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

Viewing 1 replies (of 1 total)
  • Thread Starter Gal Baras

    (@galbaras)

    Turns out this works:

    
    global $abcf7;
    remove_action( 'wp_footer', array( $abcf7, 'ABCF7_footer_script' ), 100 );
    

    But I still think what I proposed is cleaner and easier.

    • This reply was modified 3 years, 11 months ago by Gal Baras.
Viewing 1 replies (of 1 total)
  • The topic ‘Filter for excluding footer script on page’ is closed to new replies.