Search code examples
wordpresswoocommerce

Remove WooCommerce admin header


I want to remove the WooCommerce admin header bar. It takes up screen real estate for users who don't need to see it (eg. fulfilment staff), is buggy (shows tasks that can not be completed, shows as unfinished when task list is disabled) and does not do anything useful.

I don't just want to hide it, I also want to prevent the API calls the admin bar makes to retrieve task lists and options every time a fulfilment operator opens an order or refreshes the admin list.

The fixes in Remove header from the WooCommerce administrator panel are all CSS based and do not solve.


Solution

  • I found this snippet on GitHub which directly addresses my problem https://gist.github.com/wpadmin/8599641feabee05ee3b211eda150bf0a

    add_action( 'admin_head', function (){
        remove_action( 'in_admin_header', array( 'Automattic\WooCommerce\Internal\Admin\Loader', 'embed_page_header' ) );
        print '<style>#wpadminbar + #wpbody { margin-top:0; }</style>';
    });
    

    Hope this helps someone!