Created
February 26, 2022 06:13
-
-
Save zarei-dev/9f12f068a677b07442d79a9929fe4027 to your computer and use it in GitHub Desktop.
Dequeue recaptcha from not needed pages
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
<?php | |
/** | |
* Dequeue recaptcha from not needed pages | |
*/ | |
add_action('wp_enqueue_scripts', function () { | |
global $post; | |
if ( is_a( $post, 'WP_Post' ) && !has_shortcode( $post->post_content, 'contact-form-7') ) { | |
wp_dequeue_script('google-recaptcha'); | |
add_filter( 'wpcf7_load_js', '__return_false' ); | |
add_filter( 'wpcf7_load_css', '__return_false' ); | |
remove_action( 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts', 20 ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment