From fabf5334a5fec3d875cc840a6f0b8914e0b9fc7d Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 20 May 2021 04:52:56 +0000 Subject: [PATCH] Menus: Do not auto-set locations for new menus. Do not auto-set new menus to all vacant locations on the Appearance > Menus screen in the dashboard. Follow up to [48051]. Props Chouby, audrasjb, davidbaumwald, mukesh27. Fixes #52949. Built from https://develop.svn.wordpress.org/trunk@50938 git-svn-id: http://core.svn.wordpress.org/trunk@50547 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/nav-menus.php | 18 ++++++++---------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index b08faf702a..a458bdbdce 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -339,15 +339,6 @@ switch ( $action ) { wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); } - // Set the menu_location value correctly for the newly created menu. - foreach ( $menu_locations as $location => $id ) { - if ( 0 === $id ) { - $menu_locations[ $location ] = $nav_menu_selected_id; - } - } - - set_theme_mod( 'nav_menu_locations', $menu_locations ); - if ( isset( $_REQUEST['zero-menu-state'] ) || ! empty( $_POST['auto-add-pages'] ) ) { // If there are menu items, add them. wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); @@ -1042,7 +1033,14 @@ require_once ABSPATH . 'wp-admin/admin-header.php'; $description ) : - $checked = isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] === $nav_menu_selected_id; + $checked = false; + + if ( isset( $menu_locations[ $location ] ) + && 0 !== $nav_menu_selected_id + && $menu_locations[ $location ] === $nav_menu_selected_id + ) { + $checked = true; + } ?>