Skip to content

Instantly share code, notes, and snippets.

@arod2634
Created September 21, 2012 03:05
Show Gist options
  • Save arod2634/3759523 to your computer and use it in GitHub Desktop.
Save arod2634/3759523 to your computer and use it in GitHub Desktop.
Customize Wordpress Admin Menus
<?php
//Remove any unnecessary admin menus & sub-menus
function remove_menus () {
global $menu;
$restricted = array(__('Links' , 'themeName'), __('Comments' , 'themeName'));
// Additional options - > __('Dashboard'), __('Pages'), , __('Comments'), __('Media')
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');
function remove_submenus() {
global $submenu;
//Dashboard menu
unset($submenu['index.php'][10]); // Removes Updates
//Posts menu
//unset($submenu['edit.php'][5]); // Leads to listing of available posts to edit
unset($submenu['edit.php'][10]); // Add new post
//unset($submenu['edit.php'][15]); // Remove categories
//unset($submenu['edit.php'][16]); // Removes Post Tags
//Media Menu
//unset($submenu['upload.php'][5]); // View the Media library
unset($submenu['upload.php'][10]); // Add to Media library
//Links Menu
unset($submenu['link-manager.php'][5]); // Link manager
unset($submenu['link-manager.php'][10]); // Add new link
unset($submenu['link-manager.php'][15]); // Link Categories
//Pages Menu
//unset($submenu['edit.php?post_type=page'][5]); // The Pages listing
unset($submenu['edit.php?post_type=page'][10]); // Add New page
//Appearance Menu
unset($submenu['themes.php'][5]); // Removes 'Themes'
//unset($submenu['themes.php'][7]); // Widgets
//unset($submenu['themes.php'][15]); // Removes Theme Installer tab
//Plugins Menu
//unset($submenu['plugins.php'][5]); // Plugin Manager
unset($submenu['plugins.php'][10]); // Add New Plugins
unset($submenu['plugins.php'][15]); // Plugin Editor
//Users Menu
//unset($submenu['users.php'][5]); // Users list
unset($submenu['users.php'][10]); // Add new user
unset($submenu['users.php'][15]); // Edit your profile
//Tools Menu
unset($submenu['tools.php'][5]); // Tools area
//unset($submenu['tools.php'][10]); // Import
//unset($submenu['tools.php'][15]); // Export
//unset($submenu['tools.php'][20]); // Upgrade plugins and core files
//Settings Menu
//unset($submenu['options-general.php'][10]); // General Options
//unset($submenu['options-general.php'][15]); // Writing
//unset($submenu['options-general.php'][20]); // Reading
//unset($submenu['options-general.php'][25]); // Discussion
//unset($submenu['options-general.php'][30]); // Media
//unset($submenu['options-general.php'][35]); // Privacy
//unset($submenu['options-general.php'][40]); // Permalinks
//unset($submenu['options-general.php'][45]); // Misc
}
add_action('admin_menu', 'remove_submenus');
// Remove Theme Editor
function my_remove_menu_elements()
{
remove_submenu_page( 'themes.php', 'theme-editor.php' );
}
add_action('admin_init', 'my_remove_menu_elements', 102);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment