WordPress.org

Make WordPress Core

Changeset 1912


Ignore:
Timestamp:
12/04/2004 05:02:07 AM (13 years ago)
Author:
rboren
Message:

Submenu construction improvement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r1908 r1912  
    745745function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file) {
    746746    global $submenu;
    747 
     747    global $menu;
     748
     749    $parent = plugin_basename($parent);
    748750    $file = plugin_basename($file);
    749751
     752    // If the parent doesn't already have a submenu, add a link to the parent
     753    // as the first item in the submenu.  If the submenu file is the same as the
     754    // parent file someone is trying to link back to the parent manually.  In
     755    // this case, don't automatically add a link back to avoid duplication.
     756    if (! isset($submenu[$parent]) && $file != $parent) {
     757        foreach ($menu as $parent_menu) {
     758            if ($parent_menu[2] == $parent) {
     759                $submenu[$parent][] = $parent_menu;
     760            }
     761        }
     762    }
     763   
    750764    $submenu[$parent][] = array($menu_title, $access_level, $file, $page_title);
    751765}
Note: See TracChangeset for help on using the changeset viewer.