Skip to main content

Remove Dashboard Clutter

PropertyValue
descriptionRemove default WordPress dashboard clutter.
tagslib, php, wp, oop
rating

Overview

Remove default WordPress dashboard widgets and the Welcome panel for a cleaner admin dashboard.

The snippet removes common core dashboard widgets, disables the Welcome panel, and hides empty dashboard widget containers on the dashboard screen.

Variants

<?php
/**
* Remove default WordPress dashboard clutter.
*/

if ( ! function_exists( 'mac_get_dashboard_clutter_widgets' ) ) {

/**
* Dashboard widget IDs and contexts.
*
* @return array<string,string>
*/
function mac_get_dashboard_clutter_widgets(): array {

return [
'dashboard_activity' => 'normal',
'dashboard_right_now' => 'normal',
'dashboard_incoming_links' => 'normal',
'dashboard_plugins' => 'normal',
'dashboard_quick_press' => 'side',
'dashboard_recent_drafts' => 'side',
'dashboard_primary' => 'side',
'dashboard_secondary' => 'side',
];
}
}

/**
* Remove common non-comment dashboard widgets.
*/
if ( ! function_exists( 'mac_remove_dashboard_clutter_widgets' ) ) {

function mac_remove_dashboard_clutter_widgets(): void {

foreach ( mac_get_dashboard_clutter_widgets() as $widget_id => $context ) {
remove_meta_box( $widget_id, 'dashboard', $context );
}
}
}

add_action( 'wp_dashboard_setup', 'mac_remove_dashboard_clutter_widgets', 20 );

/**
* Remove the Welcome panel.
*/
if ( ! function_exists( 'mac_remove_dashboard_welcome_panel' ) ) {

function mac_remove_dashboard_welcome_panel(): void {
remove_action( 'welcome_panel', 'wp_welcome_panel' );
}
}

add_action( 'welcome_panel', 'mac_remove_dashboard_welcome_panel', 0 );
add_filter( 'show_welcome_panel', '__return_false' );

/**
* Hide empty dashboard containers for a cleaner UI.
*/
if ( ! function_exists( 'mac_hide_empty_dashboard_containers' ) ) {

function mac_hide_empty_dashboard_containers(): void {
echo '<style>#dashboard-widgets .empty-container{display:none}</style>';
}
}

add_action( 'admin_head-index.php', 'mac_hide_empty_dashboard_containers' );