我们在插件、主题开发时需要删除后台一些不需要的菜单功能。下面我们给出具体的代码段
/**
* Removes some menus by page.
*/
function wpdocs_remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'wpdocs_remove_menus' );
?>
官方文档:https://developer.wordpress.org/reference/functions/remove_menu_page/