diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/nav-menus.php --- a/wp/wp-admin/nav-menus.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-admin/nav-menus.php Wed Sep 21 18:19:35 2022 +0200 @@ -316,6 +316,7 @@ 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 ); @@ -339,15 +340,6 @@ 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 ); @@ -363,6 +355,15 @@ } 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 ); } if ( isset( $_REQUEST['use-location'] ) ) { @@ -424,7 +425,7 @@ // If the menu ID changed, redirect to the new URL. if ( $nav_menu_selected_id !== $_nav_menu_selected_id ) { - wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) ); + wp_redirect( admin_url( 'nav-menus.php?menu=' . (int) $_nav_menu_selected_id ) ); exit; } } @@ -494,6 +495,10 @@ 'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), /* translators: 1: Item name, 2: Item position, 3: Parent item name. */ 'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), + /* translators: %s: Item name. */ + 'menuItemDeletion' => __( 'item %s' ), + /* translators: %s: Item name. */ + 'itemsDeleted' => __( 'Deleted menu item: %s.' ), ); wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); @@ -596,8 +601,8 @@ /* translators: 1: URL to Widgets screen, 2 and 3: The names of the default themes. */ __( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a “Navigation Menu” widget on the Widgets screen. If your theme does not support the navigation menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.' ), admin_url( 'widgets.php' ), - 'Twenty Nineteen', - 'Twenty Twenty' + 'Twenty Twenty', + 'Twenty Twenty-One' ) . '

'; $overview .= '

' . __( 'From this screen you can:' ) . '

'; $overview .= '