I’m developing a new wordpress plugin, I’d like to check if my admin menu slug “xyz” is used bu another plugin in the site.

Is there any method to check the current used slugs?

Please note that I'm looking for slugs in admin menus NOT posts slugs

  • I Found the solution here This is exactly what I'm looking for Commented Mar 6, 2017 at 17:34

1 Answer 1


There is no official way as far as I know. You should be prefixing your menu_slug's with some string that is almost guaranteed to be unique (e.g., 'your_company_name_your_plugin_name_your_menu_slug').

That said, looking into the source for add_submenu_page(), the following should work, but I offer no guarantees (and, see the BIG caveat below):

 * test whether $menu_slug is already used in $parent_slug in admin menus
 * This function should be called **no sooner** than the 'admin_menu' action!
 * Note: this has only been tested in WP 4.7 and relies on undocumented internals,
 * and MIGHT not work in ANY other version of WP!!
 * @param $menu_slug string the proposed menu slug
 * @param $parent_slug string the parent slug
 * @return bool true if $menu_slug already exists in $parent_menu, false otherwise
is_menu_slug_available ($menu_slug, $parent_slug)
    global $_registered_pages ;

    $menu_slug = plugin_basename ($menu_slug) ;
    $parent_slug = plugin_basename ($parent_slug) ;

    $hookname = get_plugin_page_hookname ($menu_slug, $parent_slug) ;

    return (!(isset ($_registered_pages[$hookname]) && true === $_registered_pages[$hookname])) ;


It is almost always a BAD IDEA to rely on undocumented internals such as this! Since they are undocumented, the WP team could change how things work under the hood at ANY time and you'd be screwed!

  • if this is really important to you, then you should propose an enhancement to WP thru Trac Commented Mar 6, 2017 at 16:10
  • I understand the (caveat) and appreciate your efforts, but it seems that the global variable $_registered_pages is null Commented Mar 6, 2017 at 16:27
  • $_registered_pages will likely be null if you call the func before the admin_menu action has been fired. But since you shouldn't be calling add_submenu_page() before then, anyway, you should be fine. BTW, are you using WP 4.7? As the comment in the code says, I've only tested it in 4.7, if you're using any other version your "mileage may very". Commented Mar 6, 2017 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.