Skip to content

Instantly share code, notes, and snippets.

@lumivient
Created December 15, 2016 16:52
Show Gist options
  • Select an option

  • Save lumivient/819df6b4a6a894318f336757a573ceea to your computer and use it in GitHub Desktop.

Select an option

Save lumivient/819df6b4a6a894318f336757a573ceea to your computer and use it in GitHub Desktop.
Remove an item from the Admin menu
<?php
/**
* remove_menu
*
* Remove an item from the Admin menu
* If top-level menu item, pass the slug as a string
* If submenu item, pass an array of parent and submenu slugs
*
* @param string|array $item Slug or parent slug & slug to be removed
*/
function remove_menu( $item ) {
add_action( 'admin_menu', function() use ( $item ) {
if ( is_string( $item ) ) {
remove_menu_page( $item );
} else {
remove_submenu_page( $item[0], htmlentities( $item[1] ) );
}
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment