Menus: Provide menu settings when creating a new menu.

This simplifies the steps in the process of adding new menus.

Props: garrett-eclipse, audrasjb, ianjvr. 

Built from https://develop.svn.wordpress.org/trunk@48051


git-svn-id: http://core.svn.wordpress.org/trunk@47818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-06-15 23:22:06 +00:00
parent 28d29b35f7
commit d3c44a690d
6 changed files with 24 additions and 44 deletions

View File

@ -66,13 +66,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;
@ -750,10 +743,6 @@ body.menu-max-depth-11 { min-width: 1280px !important; }
float: left;
}
.nav-menus-php .blank-slate .menu-settings {
display: none;
}
/* Same as the Publish Meta Box #delete-action */
.nav-menus-php .delete-action {
float: right;

File diff suppressed because one or more lines are too long

View File

@ -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;

File diff suppressed because one or more lines are too long

View File

@ -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[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
}
// Update existing menu.
// Update existing menu.
} else {
// 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 ] );
}
}
// Set menu locations.
set_theme_mod( 'nav_menu_locations', $menu_locations );
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
@ -893,14 +901,8 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<div id="menu-management-liquid">
<div id="menu-management">
<form id="update-nav-menu" method="post" enctype="multipart/form-data">
<?php
$new_screen_class = '';
if ( $add_new_screen ) {
$new_screen_class = 'blank-slate';
}
?>
<h2><?php _e( 'Menu structure' ); ?></h2>
<div class="menu-edit <?php echo $new_screen_class; ?>">
<div class="menu-edit">
<input type="hidden" name="nav-menu-data">
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );

View File

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