Skip to content

Instantly share code, notes, and snippets.

@L422Y
Created December 13, 2018 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L422Y/859720950b00e4d478a39b7e2deecdc4 to your computer and use it in GitHub Desktop.
Save L422Y/859720950b00e4d478a39b7e2deecdc4 to your computer and use it in GitHub Desktop.
Dequeue Contact Forms 7 scripts and reCaptcha from WordPress pages without forms
// 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