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.
Merges [50938] in to the 5.7 branch.
Fixes #52949.

Built from https://develop.svn.wordpress.org/branches/5.7@50988


git-svn-id: http://core.svn.wordpress.org/branches/5.7@50597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2021-05-25 05:19:05 +00:00
parent a6d9325574
commit 1cdead833e
2 changed files with 9 additions and 11 deletions

View File

@ -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';
<legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend>
<?php
foreach ( $locations as $location => $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;
}
?>
<div class="menu-settings-input checkbox-input">
<input type="checkbox"<?php checked( $checked ); ?> name="menu-locations[<?php echo esc_attr( $location ); ?>]" id="locations-<?php echo esc_attr( $location ); ?>" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7.3-alpha-50937';
$wp_version = '5.7.3-alpha-50988';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.