From 485c6b83dbaa02bbbbb8e7fa82ef72eb18bd2333 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 30 Aug 2021 04:11:30 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@51688 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/nav-menus.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index 272aa9b9e6..d340fb6b67 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -316,6 +316,7 @@ switch ( $action ) { check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); // Merge new and existing menu locations if any new ones are set. + $new_menu_locations = array(); if ( isset( $_POST['menu-locations'] ) ) { $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); $menu_locations = array_merge( $menu_locations, $new_menu_locations ); @@ -353,6 +354,15 @@ switch ( $action ) { break; // There should only be 1. } + set_theme_mod( 'nav_menu_locations', $locations ); + } elseif ( count( $new_menu_locations ) > 0 ) { + // If locations have been selected for the new menu, save those. + $locations = get_nav_menu_locations(); + + foreach ( array_keys( $new_menu_locations ) as $location ) { + $locations[ $location ] = $nav_menu_selected_id; + } + set_theme_mod( 'nav_menu_locations', $locations ); }