Skip to content

Instantly share code, notes, and snippets.

@staydecent
Created February 16, 2011 18:30
Show Gist options
  • Save staydecent/829869 to your computer and use it in GitHub Desktop.
Save staydecent/829869 to your computer and use it in GitHub Desktop.
Function to Remove a top level admin menu (taken from WP trac)
<?php
/*
Function taken from http://core.trac.wordpress.org/changeset/15753
Awaiting release of WP 3.1.0
Credits: scribu
*/
if ( ! function_exists('remove_menu_page') ) {
/**
* Remove a top level admin menu
*
* @since 3.1.0
*
* @param string $menu_slug The slug of the menu
* @return array|bool The removed menu on success, False if not found
*/
function remove_menu_page( $menu_slug ) {
global $menu;
foreach ( $menu as $i => $item ) {
if ( $menu_slug == $item[2] ) {
unset( $menu[$i] );
return $item;
}
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment