-
-
Save spirokovac/32b3ebbe3ddeb1ea5ab949f90e7c1578 to your computer and use it in GitHub Desktop.
Stop loading of Contact Form 7 files on all blog posts unless there is a shortcode 'contact-form-7'
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
//Stop loading Contact From 7 CSS and Javascript on all pages. | |
if( is_singular () ) { | |
$post = get_post (); | |
if( has_shortcode( $post -> post_content, 'contact-form-7' ) ) { | |
$check_cf7 = true; | |
} | |
} | |
if( !$check_cf7 ) { | |
wp_dequeue_script( 'contact-form-7' ); | |
wp_dequeue_style ( 'contact-form-7' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment