Skip to content

Instantly share code, notes, and snippets.

@jpSimkins
Created April 17, 2018 19:08
Show Gist options
  • Save jpSimkins/215546c4f0ebf4def7a26c0b55c5114a to your computer and use it in GitHub Desktop.
Save jpSimkins/215546c4f0ebf4def7a26c0b55c5114a to your computer and use it in GitHub Desktop.
Remove dashboard widgets from users dashboard and allows admin full dashboard experience.
<?php
/**
* Remove dashboard widgets from users dashboard
* Allows Admin full dashboard experience
*/
// Deny direct access
defined('ABSPATH') or die("No script kiddies please!");
/**
* Class Dashboard
*/
class Dashboard {
public function __construct() {
\add_action('wp_dashboard_setup', array($this, 'dashboardSetup'), 50);
}
public function dashboardSetup() {
global $wp_meta_boxes, $user;
// Not main admin, you get no love (I only needed user ID 1 but this can easily be extended or removed)
if (1 != $user->ID) {
unset(
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'],
$wp_meta_boxes['dashboard']['normal']['high']['dashboard_browser_nag'],
$wp_meta_boxes['dashboard']['normal']['core']['e-dashboard-overview'],
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'],
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity'],
$wp_meta_boxes['dashboard']['normal']['core']['wordfence_activity_report_widget'],
// Side Column (right):
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'],
$wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment