Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/menu.php

    r16471 r18109  
    103103        $_wp_menu_nopriv[$data[2]] = true;
    104104
     105    // If there is only one submenu and it is has same destination as the parent,
     106    // remove the submenu.
     107    if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) {
     108        $subs = $submenu[$data[2]];
     109        $first_sub = array_shift($subs);
     110        if ( $data[2] == $first_sub[2] )
     111            unset( $submenu[$data[2]] );
     112    }
     113
    105114    // If submenu is empty...
    106115    if ( empty($submenu[$data[2]]) ) {
     
    111120    }
    112121}
    113 unset($id, $data);
    114 
    115 // Remove any duplicated seperators
    116 $seperator_found = false;
     122unset($id, $data, $subs, $first_sub);
     123
     124// Remove any duplicated separators
     125$separator_found = false;
    117126foreach ( $menu as $id => $data ) {
    118127    if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
    119         if (false == $seperator_found) {
    120             $seperator_found = true;
     128        if (false == $separator_found) {
     129            $separator_found = true;
    121130        } else {
    122131            unset($menu[$id]);
    123             $seperator_found = false;
     132            $separator_found = false;
    124133        }
    125134    } else {
    126         $seperator_found = false;
     135        $separator_found = false;
    127136    }
    128137}
     
    206215}
    207216
     217// Remove the last menu item if it is a separator.
     218$last_menu_key = array_pop( array_keys( $menu ) );
     219if ( 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] )
     220    unset( $menu[ $last_menu_key ] );
     221unset( $last_menu_key );
     222
    208223if ( !user_can_access_admin_page() ) {
    209224    do_action('admin_page_access_denied');
Note: See TracChangeset for help on using the changeset viewer.