Last active
September 27, 2020 22:53
-
-
Save marklchaves/48666eecdc5af5007f5913e4ac7f23e1 to your computer and use it in GitHub Desktop.
PHP code to prevent loading of Revolution Slider and Contact Form 7. Test the Rev Slider code. I recall having trouble deregistering Themepunch.
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 | |
/** | |
* Don't load Revolution Slider & Contact Form 7 plugins | |
* if the page doesn't need them. | |
*/ | |
function my_deregister_javascript() { | |
if ( !is_page(YOURPAGEGOESHERE) ) { | |
wp_deregister_script( 'jquery.themepunch.tools' ); | |
wp_dequeue_script( 'jquery.themepunch.tools' ); | |
wp_deregister_script( 'jquery.themepunch.revolution' ); | |
wp_dequeue_script( 'jquery.themepunch.revolution' ); | |
} | |
if ( !is_page(YOURPAGEGOESHERE) ) { | |
wp_deregister_script( 'contact-form-7' ); | |
wp_dequeue_script( 'contact-form-7' ); | |
wp_deregister_script( 'avada-contact-form-7' ); | |
wp_dequeue_script( 'avada-contact-form-7' ); | |
} | |
} | |
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); | |
/** | |
* Really make sure the Revolution Slider JS don't load | |
* if the above does not work. | |
*/ | |
function wra_remove_wphead_filter(){ | |
if ( !is_page(YOURPAGEGOESHERE) ) { | |
remove_action('wp_head', 'jquery.themepunch.tools', 10); | |
remove_action('wp_head', 'jquery.themepunch.revolution', 10); | |
} | |
} | |
add_action('wp_print_head_scripts', 'wra_remove_wphead_filter', 100000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment