Last active
June 22, 2018 02:08
-
-
Save aj-adl/e3cdd06a19edab3ec959 to your computer and use it in GitHub Desktop.
Intermediate CF7 example of Style/JS removal
This file contains hidden or 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 | |
// 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_custom' ); | |
// returns false, used for setting filters to false | |
function return_false() { | |
return false; | |
} | |
function BSHP_cf7_conditionally_load_assets_custom() { | |
// Any Number of conditional statments can go here ( using || for OR, && for AND ) | |
if ( !is_page( 'contact-us') && !is_page( 46 ) &&!is_page_template( 'contact.php' ) { | |
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