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. git-svn-id: https://develop.svn.wordpress.org/trunk@48051 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1d5e59c538
commit
5cb54881e8
@ -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;
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user