Make WordPress Core


Ignore:
Timestamp:
08/30/2021 04:11:30 AM (2 years ago)
Author:
peterwilsoncc
Message:

Menus: Save display locations for new menus.

Fixes a bug preventing the locations saving when creating a new menu. Introduced in [50938].

Props dlh, andraganescu, mukesh27, desrosj.
Fixes #53877.

File:
1 edited

Legend:

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

    r51539 r51688  
    317317
    318318        // Merge new and existing menu locations if any new ones are set.
     319        $new_menu_locations = array();
    319320        if ( isset( $_POST['menu-locations'] ) ) {
    320321            $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
     
    352353                                $locations[ $location ] = $nav_menu_selected_id;
    353354                                break; // There should only be 1.
     355                        }
     356
     357                        set_theme_mod( 'nav_menu_locations', $locations );
     358                    } elseif ( count( $new_menu_locations ) > 0 ) {
     359                        // If locations have been selected for the new menu, save those.
     360                        $locations = get_nav_menu_locations();
     361
     362                        foreach ( array_keys( $new_menu_locations ) as $location ) {
     363                            $locations[ $location ] = $nav_menu_selected_id;
    354364                        }
    355365
Note: See TracChangeset for help on using the changeset viewer.