diff --git a/src/wp-admin/css/nav-menus.css b/src/wp-admin/css/nav-menus.css index 8b68ac5400..83907c6240 100644 --- a/src/wp-admin/css/nav-menus.css +++ b/src/wp-admin/css/nav-menus.css @@ -65,13 +65,6 @@ ul.add-menu-item-tabs li { position: relative; } -.blank-slate .menu-settings { - border: none; - margin-top: 0; - padding-top: 0; - overflow: hidden; -} - .is-submenu { color: #555d66; /* #fafafa background */ font-style: italic; @@ -749,10 +742,6 @@ body.menu-max-depth-11 { min-width: 1280px !important; } float: right; } -.nav-menus-php .blank-slate .menu-settings { - display: none; -} - /* Same as the Publish Meta Box #delete-action */ .nav-menus-php .delete-action { float: left; diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index 70393b4a79..b9aee875f1 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -300,22 +300,12 @@ switch ( $action ) { case 'update': check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); - // Remove menu locations that have been unchecked. - foreach ( $locations as $location => $description ) { - if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) { - unset( $menu_locations[ $location ] ); - } - } - // Merge new and existing menu locations if any new ones are set. if ( isset( $_POST['menu-locations'] ) ) { $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); $menu_locations = array_merge( $menu_locations, $new_menu_locations ); } - // Set menu locations. - set_theme_mod( 'nav_menu_locations', $menu_locations ); - // Add Menu. if ( 0 == $nav_menu_selected_id ) { $new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); @@ -332,9 +322,18 @@ switch ( $action ) { if ( isset( $_REQUEST['menu-item'] ) ) { wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); } - if ( isset( $_REQUEST['zero-menu-state'] ) ) { + // 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 ); + } + if ( isset( $_REQUEST['zero-menu-state'] ) ) { // Auto-save nav_menu_locations. $locations = get_nav_menu_locations(); foreach ( $locations as $location => $menu_id ) { @@ -359,8 +358,17 @@ switch ( $action ) { $messages[] = '
' . __( 'Please enter a valid menu name.' ) . '