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
This commit is contained in:
Peter Wilson 2021-05-20 04:52:56 +00:00
parent cf90ff2427
commit fabf5334a5
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'] ) ); 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 ( isset( $_REQUEST['zero-menu-state'] ) || ! empty( $_POST['auto-add-pages'] ) ) {
// If there are menu items, add them. // If there are menu items, add them.
wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); 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> <legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend>
<?php <?php
foreach ( $locations as $location => $description ) : 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"> <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 ); ?>" /> <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 * @global string $wp_version
*/ */
$wp_version = '5.8-alpha-50936'; $wp_version = '5.8-alpha-50938';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.