From 34d8dd914ce0082b19d75107e977cf0c3154a854 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 30 Aug 2021 04:12:57 +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. Built from https://develop.svn.wordpress.org/trunk@51688 git-svn-id: http://core.svn.wordpress.org/trunk@51294 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/nav-menus.php | 10 ++++++++++ wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index 272aa9b9e6..d340fb6b67 100644 --- a/wp-admin/nav-menus.php +++ b/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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 2eda09e506..ba8c7f1f7f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51686'; +$wp_version = '5.9-alpha-51688'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.