This action is used to add extra submenus and menu options to the admin panel’s menu structure. It runs after the basic admin panel menu structure is in place.
This action mustn’t be placed in an admin_init action function because the admin_init action is called after admin_menu.
You may come across the fact that deleting items having the slug like admin.php?page=jetpack in the admin_menu hook does not affect the menu in any way and the items remain in their places. To fix it, define correct slugs to delete with remove_menu_page() function.
Try this code:
function wpdocs_list_menus() {
global $menu;
var_dump( $menu );
}
add_action( 'admin_menu', 'wpdocs_list_menus', 99999 );
If you want to change a menu label, you can hook this action and change the
global $menu, $submenu values
,This snippet add admin menu and submenu HTML content
Let’s say you’re building a plugin and you need to register an overview or dashboard menu option for your plugin page, you can do it like so:
You may come across the fact that deleting items having the slug like admin.php?page=jetpack in the admin_menu hook does not affect the menu in any way and the items remain in their places. To fix it, define correct slugs to delete with remove_menu_page() function.
Try this code:
Example migrated from Codex:
The example comes from the wpautop-control plugin, in which the code is used to add an options page to the “Settings” menu.