Submenu construction improvement.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-12-04 05:02:07 +00:00
parent 0563f1101c
commit 497b71996a

View File

@ -744,9 +744,23 @@ function add_menu_page($page_title, $menu_title, $access_level, $file) {
function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file) {
global $submenu;
global $menu;
$parent = plugin_basename($parent);
$file = plugin_basename($file);
// If the parent doesn't already have a submenu, add a link to the parent
// as the first item in the submenu. If the submenu file is the same as the
// parent file someone is trying to link back to the parent manually. In
// this case, don't automatically add a link back to avoid duplication.
if (! isset($submenu[$parent]) && $file != $parent) {
foreach ($menu as $parent_menu) {
if ($parent_menu[2] == $parent) {
$submenu[$parent][] = $parent_menu;
}
}
}
$submenu[$parent][] = array($menu_title, $access_level, $file, $page_title);
}