Skip to content

Instantly share code, notes, and snippets.

@aj-adl
Last active August 29, 2015 14:13
Show Gist options
  • Save aj-adl/5f5e318a97874180ebba to your computer and use it in GitHub Desktop.
Save aj-adl/5f5e318a97874180ebba to your computer and use it in GitHub Desktop.
Removes Contact Form 7 Styles and Scripts Except on the 'Contact Us' page
<?php
// Make sure you only use opening / closing tags if needed!!!
// Removes Contact Form 7 scripts and Styles except on contact-us page
add_action( 'wp', 'BSHP_cf7_conditionally_load_assets_simple' );
// returns false, used for setting filters to false
function return_false() {
return false;
}
function BSHP_cf7_conditionally_load_assets_simple() {
// Any Number of conditional statments can go here ( using || for OR, && for AND )
if ( !is_page( 'contact-us') ) {
add_filter( 'wpcf7_load_css', 'return_false' );
add_filter( 'wpcf7_load_js', 'return_false' );
}
}
// Make sure you only use opening / closing tags if needed!!!
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment