From b99332d260f038a7d5652ffb85579cf36bdc1a84 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 20 May 2021 04:51:16 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@50938 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/nav-menus.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index b08faf702a..a458bdbdce 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/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; + } ?>