Removing an action, or dequeueing style – Both not working

What I am wanting to achieve is to remove an action called inside of another action.

The action is calling a style, and although I have tried to deregister, and dequeue the style, it is still displaying on the admin pages.

Read More

Here is the code snippet (inside of WooCommerce):

function woocommerce_admin_menu() {
    global $menu, $woocommerce;...

    $print_css_on = apply_filters( 'woocommerce_screen_ids', array( 'toplevel_page_woocommerce', 'woocommerce_page_woocommerce_settings', 'woocommerce_page_woocommerce_reports', 'woocommerce_page_woocommerce_status', 'product_page_woocommerce_attributes', 'edit-tags.php', 'edit.php', 'index.php', 'post-new.php', 'post.php' ) );

    foreach ( $print_css_on as $page )
        add_action( 'admin_print_styles-'. $page, 'woocommerce_admin_css' );
}
add_action('admin_menu', 'woocommerce_admin_menu', 9);

What I’ve tried to do:

add_action('init', 'remove_action_123', 999);
function remove_action_123() {
        $print_css_on = apply_filters( 'woocommerce_screen_ids', array( 'toplevel_page_woocommerce', 'woocommerce_page_woocommerce_settings', 'woocommerce_page_woocommerce_reports', 'woocommerce_page_woocommerce_status', 'product_page_woocommerce_attributes', 'edit-tags.php', 'edit.php', 'index.php', 'post-new.php', 'post.php' ) );add_action('init', 'remove_action', 999);

        // Remove 'woocommerce_admin_menu'
    foreach ( $print_css_on as $page )
    remove_action( 'admin_print_styles-'. $page, 'woocommerce_admin_css' );
}

This is how it’s being enqueued:

function woocommerce_admin_css() {
    global $woocommerce, $typenow, $post, $wp_scripts;...

    if ( $typenow == '' || $typenow == "product" || $typenow == "shop_order" || $typenow == "shop_coupon" ) {
        wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css' );
    }

    do_action('woocommerce_admin_css');
}

So I also tried:

wp_dequeue_style( 'woocommerce_admin_styles' )

But it is still not working.

Any ideas on how to successfully remove this css?

Thanks!
Roc.

Related posts

1 comment

  1. To clean up a complete array use the helper function __return_empty_array() as callback:

    add_filter( 'woocommerce_screen_ids', '__return_empty_array', );
    

    Similar helpers for further usage are:

    • __return_true()
    • __return_false()
    • __return_zero()
    • __return_null()

Comments are closed.