没有official 据我所知。您应该在menu\\u slug的前面加上一些几乎可以保证唯一的字符串(例如,“your\\u company\\u name\\u your\\u plugin\\u name\\u your\\u menu\\u slug”)。
也就是说,调查add_submenu_page(), 以下内容应该有效,但我不提供任何保证(并且,请参见BIG 以下警告):
/**
* 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
*/
function
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])) ;
}
警告几乎总是
BAD IDEA 依靠这样的未记录的内部构件!由于它们没有记录在案,WP团队可以改变发动机罩下的工作方式
at ANY time 你会完蛋的!