Created
January 28, 2013 21:47
-
-
Save deckerweb/4659412 to your computer and use it in GitHub Desktop.
Contact Form 7 plugin: Clean up global scripts & styles.
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
<?php | |
add_action( 'wp_enqueue_scripts', 'ddw_cf7_cleanup' ); | |
/** | |
* Contact Form 7 plugin: Cleanup global scripts & styles. | |
* | |
* @author David Decker - DECKERWEB | |
* @link http://deckerweb.de/twitter | |
*/ | |
function ddw_cf7_cleanup() { | |
/** Dequeue globally enqueued scripts & styles */ | |
wp_dequeue_script( 'contact-form-7' ); | |
wp_dequeue_style( 'contact-form-7' ); | |
/** Only enqueue stuff on the used page ID */ | |
if ( is_page( '12' ) ) { | |
wp_enqueue_script( 'contact-form-7' ); | |
wp_enqueue_style( 'contact-form-7' ); | |
} // end if | |
} // end function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Above code will load only on specific page/post. Instead, use below code to load CF7 JS and CSS when content contains CF7 shortcodes. It will work with any post type.
https://gist.github.com/cyberwani/38f945007e83600ca0bf0bc48d99361b