удалить скрипты и стили woo со страниц без WooCommerce
Wed Jan 05 2022 08:19:21 GMT+0000 (Coordinated Universal Time)
Saved by
@mastaklance
/**
* Remove Woo Styles and Scripts from non-Woo Pages
*/
add_action( 'template_redirect', 'bt_remove_woocommerce_styles_scripts', 999 );
function bt_remove_woocommerce_styles_scripts() {
// Skip Woo Pages
if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
return;
}
// Otherwise...
remove_action('wp_enqueue_scripts', [WC_Frontend_Scripts::class, 'load_scripts']);
remove_action('wp_print_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5);
remove_action('wp_print_footer_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5);
}
content_copyCOPY
Comments