Created
October 31, 2014 23:24
-
-
Save natebot/0b13251e44f7513b8505 to your computer and use it in GitHub Desktop.
SailThru plugin hack to prevent unnecessary loading of scrips and 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 | |
/** | |
* Force the unregistering of SailThru widgets and dequeue unused scripts and styles. | |
* If you don't have the SailThru widget on your site the plugin should not load the widget's styes and scripts. | |
* @todo the SailThru plugin should be improved to only enqueue when widgets are active | |
* I've submitted the fix patch: https://github.com/sailthru/sailthru-wordpress-plugin/pull/21 | |
* Only use this hack if you never intend to use the SailThru widget, as it will break the Sailthru widget if you choose to activate it. | |
*/ | |
add_action( 'widgets_init', function(){ | |
unregister_widget( 'Sailthru_Subscribe_Widget' ); | |
unregister_widget( 'Sailthru_Scout_Widget' ); | |
}); | |
add_action( 'wp_enqueue_scripts', function(){ | |
wp_dequeue_script( 'sailthru-subscribe-script' ); | |
wp_dequeue_style( 'sailthru-subscribe-widget-styles' ); | |
}, 11); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment