When you are developing a WordPress powered website for a client, the dashboard can be a little in your face with all the widgets, menu items and WordPress branding. So to make the dashboard more user friendly and customisable to a client needs, you can do a few things to clean it up.
Please note: the code below is one way to clean up the dashboard if you just want to add a block of code to your functions.php. I prefer to do this as a private plugin.
You can also view this on GitHub Gist – WP Minimize Dashboard
I will do a post on each in the future to show what each part does, but for now, please feel free to use and make your next client happy with a personalised WordPress dashboard. For your client or personal dashboard you may not need all the code so pick the parts you need, refer to the //Comments.
// Custom Dashboard widgets
function custom_dashboard_widgets() {
global $wp_meta_boxes;
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] );
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments'] );
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts'] );
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] );
// Intro Widget
function custom_dashboard_intro() {
echo '<p>Give your client a personal welcome message</p>';
echo '<p>Put in your contact info, eg, email, phone, skype etc.</p>';
}
// Media Widget
function custom_dashboard_media_info() {
echo '<p>Notes: Add details of image sizes here</p>';
}
// Add the custom widget areas
wp_add_dashboard_widget( 'custom_intro_widget', 'Theme Support Intro', 'custom_dashboard_intro' );
wp_add_dashboard_widget( 'custom_media_widgets', 'Theme Media Support', 'custom_dashboard_media_info' );
}
add_action( 'wp_dashboard_setup', 'custom_dashboard_widgets' );
// Add Dashboard Logo
function custom_admin_logo() {
echo '<style type="text/css">#header-logo { background-image: url(' . get_bloginfo('template_directory') . '/images/logo_admin_dashboard.png) !important; }</style>';
}
add_action( 'admin_head', 'custom_admin_logo' );
// Change Dashboard Footer Attribution
function remove_footer_admin() {
echo '<span id="footer-thankyou">Developed by <a href="http://www.YOURWEBSITE.com"; target="_blank">YOUR NAME</a></span>';
}
add_filter( 'admin_footer_text', 'remove_footer_admin' );
// Remove Menu Items > Removes Tools and Users
function remove_menus() {
global $menu;
$restricted = array(__('Tools'),__('Users'));
end ($menu);
while ( prev( $menu ) ) {
$value = explode( ' ',$menu[key($menu)][0] );
if( in_array( $value[0] != NULL ? $value[0] : '' , $restricted ) ) {
unset( $menu[key($menu)] );
}
}
}
add_action( 'admin_menu', 'remove_menus' );
// Remove Sub Menu Items > menu-ID:s are found in wp-admin/menu.php
function remove_submenus() {
global $submenu;
unset( $submenu['themes.php'][5] ); // Removes 'Themes'.
}
add_action( 'admin_menu', 'remove_submenus' );
// Hide 'Screen Options' tab
function remove_screen_options_tab() {
return false;
}
add_filter( 'screen_options_show_screen', 'remove_screen_options_tab' );
// Hide Help tab
function hide_help() {
echo '<style type="text/css">#contextual-help-link-wrap { display: none !important; }</style>';
}
add_action( 'admin_head', 'hide_help' );
// Remove WordPress menu from WP logo
function wplogomenu_admin_bar_remove() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action( 'wp_before_admin_bar_render', 'wplogomenu_admin_bar_remove', 0 );
// Change Welcome In Admin Bar
function wp_user_admin_bar_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
if ( 0 != $user_id ) {
// Add the My Account" menu
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Welcome back %1$s'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';
$wp_admin_bar->add_menu(
array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => $class,
),
)
);
}
}
add_action( 'admin_bar_menu', 'wp_user_admin_bar_menu', 11 );
A Quick Heads Up: A shout out to Aaron Rutley (@AaronRutley), Aaron has a plugin that can help you get that customised dashboard with a few extra cool modifications, check it out – Minimal Admin