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

前端 未结 4 1588
野的像风
野的像风 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:38

    I found a solution:

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

提交回复
热议问题