Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// Customize menus
function slt_customizeAdminMenus() {
// Remove theme / plugin editors
// slt_removeSubmenu( 'themes.php', 'theme-editor.php' );
// slt_removeSubmenu( 'plugins.php', 'plugin-editor.php' );
// Remove comments / categories / tags
slt_removeMenu( 'edit-comments.php' );
slt_removeMenu( 'link-manager.php' );
slt_removeMenu( 'upload.php' );
slt_removeMenu( 'edit.php' );
}
add_action( 'admin_head', 'slt_customizeAdminMenus' );
// Remove item from a submenu
function slt_removeSubmenu( $parentMenuItem, $item ) {
global $submenu, $menu;
foreach ( $submenu as $menuKey => $menuItem ) {
if ( $menuKey == $parentMenuItem ) {
foreach ( $menuItem as $submenuKey => $submenuItems ) {
if ( $submenuItems[2] == $item ) {
unset( $submenu[$menuKey][$submenuKey] );
break;
}
}
}
}
}
// Remove item from the main menu
function slt_removeMenu( $item ) {
global $menu;
foreach ( $menu as $menuKey => $menuItem ) {
if ( $menuItem[2] == $item ) {
unset( $menu[$menuKey] );
break;
}
}
}
?>
@celorodovalho

This comment has been minimized.

Copy link

celorodovalho commented Apr 25, 2013

If I need to remove a link of a plugin, for example the PageNavi... this is not in the array $submenu... what can I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.