Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created September 19, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tommcfarlin/f4a31feab1a5601496afa644f21e2956 to your computer and use it in GitHub Desktop.
Save tommcfarlin/f4a31feab1a5601496afa644f21e2956 to your computer and use it in GitHub Desktop.
[WordPress] WordPress Admin Menu: Re-ordering Submenu Items
<?php
add_action('custom_menu_order', __NAMESPACE__.'\\acmeReorderSubmenuItems);
/**
* Reorders the menu by placing the second item before the first item.
*/
function acmeReorderSubmenuItems()
{
global $submenu;
$newSubmenu = [];
foreach ($submenu as $menuName => $menuItems) {
if ('acme-api-tools' === $menuName) {
$newSubmenu[0] = $menuItems[1];
$newSubmenu[1] = $menuItems[0];
$submenu['acme-api-tools'] = $newSubmenu;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment