这是来自Bill Erickson\'s Core Functionality 插件。
/**
* Remove Menu Items
* @since 1.0.0
*
* Remove unused menu items by adding them to the array.
* See the commented list of menu items for reference.
*
*/
function ni_remove_menus () {
global $menu;
// Example:
//$restricted = array(__(\'Dashboard\'), __(\'Posts\'), __(\'Media\'), __(\'Links\'), __(\'Pages\'), __(\'Appearance\'), __(\'Tools\'), __(\'Users\'), __(\'Settings\'), __(\'Comments\'), __(\'Plugins\'));
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\', \'ni_remove_menus\' );
取消对受限数组的注释,并包括要隐藏的菜单项。该示例包含所有供参考的菜单项。