Last active
July 11, 2018 08:41
-
-
Save DmitriyRF/1568a28ce6be8a460ba072270cdf0563 to your computer and use it in GitHub Desktop.
Remove all style and scripts for template page in wordpress
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
//If is loading current page template | |
if ( is_page_template( 'page-templates/template.php' ) ) { | |
global $wp_scripts; | |
global $wp_styles; | |
$styles_to_keep = array("wp-admin", "admin-bar", "dashicons", "open-sans", "avia-popup-css"); | |
// loop over all of the registered scripts | |
foreach ($wp_styles->registered as $handle_st => $data) | |
{ | |
if ( in_array($handle_st, $styles_to_keep) ) continue; | |
// remove it | |
// wp_deregister_style($handle_st); | |
// wp_dequeue_style($handle_st); | |
} | |
foreach ($wp_scripts->registered as $handle_sc => $data) | |
{ | |
// remove it | |
// wp_deregister_script($handle_sc); | |
wp_dequeue_script($handle_sc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment