WordPress.org

Make WordPress Core

Changeset 14758


Ignore:
Timestamp:
05/20/2010 04:57:48 PM (8 years ago)
Author:
ryan
Message:

Make the next available tab active after deleting a tab. Props koopersmith. fixes #13338

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/nav-menus.php

    r14751 r14758  
    242242
    243243        if ( is_nav_menu( $nav_menu_selected_id ) ) {
     244            $deleted_nav_menu = wp_get_nav_menu_object( $nav_menu_selected_id );
    244245            $delete_nav_menu = wp_delete_nav_menu( $nav_menu_selected_id );
    245246
     
    248249            } else {
    249250                $messages[] = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>';
    250                 $nav_menu_selected_id = 0; // Reset the selected menu
    251                 unset($_REQUEST['menu']);
    252             }
    253             unset( $delete_nav_menu );
     251                // Select the next available menu
     252                $nav_menu_selected_id = 0;
     253                $_nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
     254                foreach( $_nav_menus as $index => $_nav_menu ) {
     255                    if ( strcmp( $_nav_menu->name, $deleted_nav_menu->name ) >= 0
     256                     || $index == count( $_nav_menus ) - 1 ) {
     257                        $nav_menu_selected_id = $_nav_menu->term_id;
     258                        break;
     259                    }
     260                }
     261            }
     262            unset( $delete_nav_menu, $deleted_nav_menu, $_nav_menus );
     263        } else {
     264            // Reset the selected menu
     265            $nav_menu_selected_id = 0;
     266            unset( $_REQUEST['menu'] );
    254267        }
    255268        break;
Note: See TracChangeset for help on using the changeset viewer.