Created
December 13, 2018 18:05
-
-
Save L422Y/859720950b00e4d478a39b7e2deecdc4 to your computer and use it in GitHub Desktop.
Dequeue Contact Forms 7 scripts and reCaptcha from WordPress pages without forms
This file contains 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
// career posts and the page w/ ID 13 both have forms, | |
// as long as we are not on one of those, we | |
// dequeue CF7 and reCaptcha to remove the v3 badge | |
// add to functions.php | |
add_action('wp_print_scripts', function () { | |
global $post; | |
$is_career = (is_single() && $post->post_type == 'career'); | |
if (!$is_career && !is_page(array('13'))) { | |
wp_dequeue_script('contact-form-7'); | |
wp_dequeue_script('google-recaptcha'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment