这里是如何添加新菜单和删除旧菜单的代码
add_action(\'admin_menu\', \'change_menus_position\');
function change_menus_position() {
// Remove old menu
remove_submenu_page( \'themes.php\', \'nav-menus.php\' );
//Add new menu page
add_menu_page(
\'Menus\',
\'Menus\',
\'edit_theme_options\',
\'nav-menus.php\',
\'\',
\'dashicons-list-view\',
68
);
}
之后,可能会出现一些打开“外观”的bug,但您可以使用css修复它
您可以转储所有菜单
global $menu,$submenu;
echo \'<pre>\';
print_r($menu);
print_r($submenu);
echo \'</pre>\';
wp_die();
也可以添加自定义分隔符(菜单之间的间距)
function add_admin_menu_separator( $position ) {
global $menu;
$menu[ $position ] = array(
0 => \'\',
1 => \'read\',
2 => \'separator\' . $position,
3 => \'\',
4 => \'wp-menu-separator\'
);
}
和使用
add_admin_menu_separator(\'21\');
add_admin_menu_separator({custom_position});