Make WordPress Core

Changeset 51690


Ignore:
Timestamp:
08/30/2021 01:38:26 PM (3 years ago)
Author:
desrosj
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, peterwilsoncc.
Merges [51688] to the 5.8 branch.
Fixes #53877.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/src/wp-admin/nav-menus.php

    r51596 r51690  
    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.