Here’s a quick snippet for removing all Dashboard widgets in the admin area. As always, I’m game for a better way Image may be NSFW.
Clik here to view. – Something about four foreach loops does not strike me as efficient.
<?php // Create the function to use in the action hook function remove_dashboard_widgets() { global $wp_meta_boxes; if ( !array( $wp_meta_boxes ) ) return; foreach ( $wp_meta_boxes as $widget_section => $widget_locations ) { if ( $widget_section == 'dashboard' ) { foreach ( $widget_locations as $widget_location => $widget_types ) { foreach ( $widget_types as $widget_type => $widgets ) { foreach ( $widgets as $widget_name => $widget ) { remove_meta_box( $widget_name, $widget_section, $widget_location ); } } } } } } // Hoook into the 'wp_dashboard_setup' action to register our function add_action('wp_dashboard_setup', 'remove_dashboard_widgets', 11 ); ?>
The post Removing All Dashboard Widgets appeared first on WordPress and Ajax.