Created
November 17, 2012 23:07
-
-
Save ataylorme/4101193 to your computer and use it in GitHub Desktop.
Remove all enqueue'd scripts and styles for a custom post type
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
| /* ========== START REMOVE ALL ENQUEUED EXISTING SCRIPTS AND STYLEs ========== */ | |
| if( !function_exists('clean_wp_head') ): | |
| function clean_wp_head(){ | |
| if( !function_exists('MY_CUSTOM_POST_TYPE_remove_all_scripts') ): | |
| function MY_CUSTOM_POST_TYPE_remove_all_scripts() { | |
| global $wp_scripts; $wp_scripts->queue = array(); | |
| }//end MY_CUSTOM_POST_TYPE_remove_all_scripts function | |
| endif; | |
| if( !function_exists('MY_CUSTOM_POST_TYPE_remove_all_styles') AND !is_admin() ): | |
| function MY_CUSTOM_POST_TYPE_remove_all_styles() { | |
| global $wp_styles; $wp_styles->queue = array(); | |
| }//end MY_CUSTOM_POST_TYPE_remove_all_scripts function | |
| endif; | |
| if ( get_post_type() == 'MY_CUSTOM_POST_TYPE' AND !is_admin() ): | |
| add_action('wp_print_scripts', 'MY_CUSTOM_POST_TYPE_remove_all_scripts', 100); | |
| add_action('wp_print_styles', 'MY_CUSTOM_POST_TYPE_remove_all_styles', 100); | |
| endif; | |
| }//end clean_wp_head function | |
| endif; | |
| add_action('wp_head', 'clean_wp_head', 1); | |
| /* ========== END REMOVE ALL ENQUEUED EXISTING SCRIPTS AND STYLEs ========== */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment