How to unload select2 script/styles loaded by new WooCommerce 2.3.x?

前端 未结 4 1590
野的像风
野的像风 2021-01-06 01:10

we are theme developers and we already use select2 (http://select2.github.io/) script for SELECT boxes in HTML in our wordpress theme. New WooCommerce 2.3.x that just relase

4条回答
  •  臣服心动
    2021-01-06 01:44

    There's been some recent changes to WooCommerce (v 3.2.1) in which they forked the select2 script and so the code above by @Dmitry is no longer functional. The new code which worked for me is below..

    add_action( 'wp_enqueue_scripts', 'agentwp_dequeue_stylesandscripts', 100 );
    
    function agentwp_dequeue_stylesandscripts() {
        if ( class_exists( 'woocommerce' ) ) {
        wp_dequeue_style( 'selectWoo' );
        wp_deregister_style( 'selectWoo' );
    
        wp_dequeue_script( 'selectWoo');
        wp_deregister_script('selectWoo');
    
       }
    }
    

提交回复
热议问题