Skip to content

Instantly share code, notes, and snippets.

@mkret
Created August 18, 2010 06:33
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 mkret/533713 to your computer and use it in GitHub Desktop.
Save mkret/533713 to your computer and use it in GitHub Desktop.
<?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
Copy link

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