WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Remove or hide WooCommerce widgets from admin (3 posts)

  1. geertvanderheide
    Member
    Posted 10 months ago #

    WooCommerce introduces a whole set of new widgets to the admin page "Appearance -> Widgets". They're very useful for most online stores, but the site I'm building does not require any of them. I'm creating a website with just one or two products for sale, so I'd like to keep the admin as simple as possible. Therefore, my question is: How would I remove these widgets from the widget management page in the admin, so that my client won't need to sift through them? I'm hoping to achieve this without editing plugin files that would get overwritten on the next update of WooCommerce. Thanks in advance for your support.

    http://wordpress.org/plugins/woocommerce/

  2. Roy Ho
    Member
    Posted 10 months ago #

  3. geertvanderheide
    Member
    Posted 10 months ago #

    Thanks for putting me on the right track! After reading the article you linked to, I checked the code to find where WooCommerce was creating the widgets. I found a bunch of calls to "register_widget" all nicely listed together. That gave me the class names I needed, and so this is the code required to remove them:

    function remove_woo_widgets() {
      unregister_widget( 'WC_Widget_Recent_Products' );
      unregister_widget( 'WC_Widget_Featured_Products' );
      unregister_widget( 'WC_Widget_Product_Categories' );
      unregister_widget( 'WC_Widget_Product_Tag_Cloud' );
      unregister_widget( 'WC_Widget_Cart' );
      unregister_widget( 'WC_Widget_Layered_Nav' );
      unregister_widget( 'WC_Widget_Layered_Nav_Filters' );
      unregister_widget( 'WC_Widget_Price_Filter' );
      unregister_widget( 'WC_Widget_Product_Search' );
      unregister_widget( 'WC_Widget_Top_Rated_Products' );
      unregister_widget( 'WC_Widget_Recent_Reviews' );
      unregister_widget( 'WC_Widget_Recently_Viewed' );
      unregister_widget( 'WC_Widget_Best_Sellers' );
      unregister_widget( 'WC_Widget_Onsale' );
      unregister_widget( 'WC_Widget_Random_Products' );
    }
    add_action( 'widgets_init', 'remove_woo_widgets' );

    Yay! The widget screen is nice and clean once more. I always try to limit administrative complexity for my clients, and this definitely helps.

    To anyone else looking for this: Put the above code in your functions.php, or inside a plugin.

Reply

You must log in to post.

About this Plugin

About this Topic