Getting List of all registered Dashboard Widgets

The reason for this is that dashboard widgets don’t use the metabox API directly, they use an API that wraps around it, and are only registered on wp_dashboard_setup and wp_network_dashboard_setup.

They’re also named dashboard widgets rather than metaboxes, so most users will not know what you’re referring to if you talk about metaboxes. Dashboard metaboxes could refer to any metabox in WP Admin.

This means on your custom admin page, those hooks don’t fire, resulting in the global variable not containing dashboard widgets.

Additionally, the default WP widgets don’t display themselves via those hooks, but instead are added in the same function that displays the dashboard itself, wp_dashboard_setup. This function registers the core dashboard widgets, fires the hooks for plugins to add their own, then triggers the metabox API to display them.

So you would need to:

  • call wp_dashboard_setup on your custom pages
  • move your code to the wp_dashboard_setup hook, and make sure it runs last/late
  • add and remove widgets according to the options you set

It may be easier to remove and replace the main dashboard UI completely, the API was never intended to be used for what you’re trying to do with it.

Just keep in mind that the screen options UI will not reflect your changes, and might actively interfere with what you’re doing.