Make WordPress Core

Changeset 25195


Ignore:
Timestamp:
08/31/2013 01:36:49 AM (13 years ago)
Author:
nacin
Message:

Nav menus: Allow assigning a new menu to an existing location when no theme setting is currently saved.

props ocean90.
see #25064, for trunk.

File:
1 edited

Legend:

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

    r24981 r25195  
    301301                                                wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title );
    302302                                                // Auto-save nav_menu_locations
    303                                                 $locations = get_theme_mod( 'nav_menu_locations' );
    304                                                 foreach ( (array) $locations as $location => $menu_id ) {
     303                                                $locations = get_nav_menu_locations();
     304                                                foreach ( $locations as $location => $menu_id ) {
    305305                                                                $locations[ $location ] = $nav_menu_selected_id;
    306306                                                                break; // There should only be 1
     
    309309                                        }
    310310                                        if ( isset( $_REQUEST['use-location'] ) ) {
    311                                                 $locations = get_theme_mod( 'nav_menu_locations' );
    312                                                 if ( isset( $locations[$_REQUEST['use-location']] ) )
    313                                                         $locations[$_REQUEST['use-location']] = $nav_menu_selected_id;
    314                                                 set_theme_mod( 'nav_menu_locations', $locations );
     311                                                $locations = get_registered_nav_menus();
     312                                                $menu_locations = get_nav_menu_locations();
     313                                                if ( isset( $locations[ $_REQUEST['use-location'] ] ) )
     314                                                        $menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id;
     315                                                set_theme_mod( 'nav_menu_locations', $menu_locations );
    315316                                        }
    316317                                        // $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>';
Note: See TracChangeset for help on using the changeset viewer.