Conditionally load reCaptcha
-
To load reCaptcha on every-single-page of the site is a major design flaw.
It is a crime against user experience to arrive at a home page and have to prove to google that you aren’t a robot.
Luckily all this can be fixed by conditionally loading your scripts.
function recaptcha_shortcode_scripts() {
global $post;
if( is_a( $post, ‘WP_Post’ ) && has_shortcode( $post->post_content, ‘contact-form-7’) ) {
wp_enqueue_script( ‘https://www.google.com/recaptcha/api.js…’);
}
}
add_action( ‘wp_enqueue_scripts’, ‘recaptcha_shortcode_scripts’);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Conditionally load reCaptcha’ is closed to new replies.