Removing unwanted WordPress widgets from editor panel

I often find that most of my clients who use WordPress don’t use most of the standard widgets – often because they are using it as a CMS and not a heavy duty Blog.

A lot of the standard widgetst are features for comments, archives and a like.  A while ago I came a function in WordPress that you can use to unregister (and thus hide) these from the WordPress interface for your clients.  I’ve used it for a while but completely forgot until I needed to use it again recently.  So to help others (you lot probably already knew! lol) here’s the code:

As a heads up – you simply drop this into your functions.php in the theme you’re running.

// unregister all widgets
 function unregister_default_widgets() {
     unregister_widget('WP_Widget_Pages');
     unregister_widget('WP_Widget_Calendar');
     unregister_widget('WP_Widget_Archives');
     unregister_widget('WP_Widget_Links');
     unregister_widget('WP_Widget_Meta');
     unregister_widget('WP_Widget_Search');
     unregister_widget('WP_Widget_Text');
     unregister_widget('WP_Widget_Categories');
     unregister_widget('WP_Widget_Recent_Posts');
     unregister_widget('WP_Widget_Recent_Comments');
     unregister_widget('WP_Widget_RSS');
     unregister_widget('WP_Widget_Tag_Cloud');
     unregister_widget('WP_Nav_Menu_Widget');
     unregister_widget('Twenty_Eleven_Ephemera_Widget');
 }
 add_action('widgets_init', 'unregister_default_widgets', 11);