Skip to content

Instantly share code, notes, and snippets.

@grok
Last active October 11, 2015 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grok/3933759 to your computer and use it in GitHub Desktop.
Save grok/3933759 to your computer and use it in GitHub Desktop.
WordPress: Hiding admin menu and hiding dashboard widgets.
<?php
// ...class declaration...
// function that adds these actions.
add_action('admin_menu', array(&$this, 'remove_administration_menu'));
add_action('wp_dashboard_setup', array(&$this, 'remove_dashboard_widgets'));
public function remove_administration_menu() {
global $menu;
foreach($menu as $item) {
$slug = $item[2];
remove_menu_page($slug);
}
}
public function remove_dashboard_widgets() {
global $wp_meta_boxes;
$dashboard_boxes = isset($wp_meta_boxes['dashboard']) ? $wp_meta_boxes['dashboard'] : false;
foreach($dashboard_boxes as $section_name => $section_data) {
foreach($section_data as $box) {
foreach($box as $name => $data) {
remove_meta_box($name, 'dashboard', $section_name);
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment