Created
April 14, 2019 05:10
-
-
Save schutzsmith/29947a96b5d137ce5fd5340e62ad5429 to your computer and use it in GitHub Desktop.
Remove unnecessary dashboard widgets in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove unnecessary dashboard widgets | |
function remove_dashboard_widgets(){ | |
global $wp_meta_boxes; | |
// only remove "Right Now" for non-administrators | |
if (!current_user_can('activate_plugins')) { | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); | |
} | |
// remove widgets for everyone | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); | |
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); | |
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); | |
} | |
add_action('wp_dashboard_setup', 'remove_dashboard_widgets'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment