Get a list of all Widgets registered in WordPress admin widgets-area

Widgets are stored in a public variable $widgets in the class WP_Widget_Factory. You can access this class per global variable $wp_widget_factory.

To get all registered widgets, list the keys:

add_action( 'wp_footer', function()
{
    if ( empty ( $GLOBALS['wp_widget_factory'] ) )
        return;

    $widgets = array_keys( $GLOBALS['wp_widget_factory']->widgets );
    print '<pre>$widgets=" . esc_html( var_export( $widgets, TRUE ) ) . "</pre>';
});

To remove all widgets either unregister each widget separately with unregister_widget() (preferred) or empty the array in one run:

add_action( 'widgets_init', function()
{
    if ( empty ( $GLOBALS['wp_widget_factory'] ) )
        return;

    $GLOBALS['wp_widget_factory']->widgets = array();
}, 20);

Leave a Comment