Ticket #44286: 44286.2.diff
| File 44286.2.diff, 4.2 KB (added by , 6 years ago) |
|---|
-
src/wp-admin/css/nav-menus.css
65 65 position: relative; 66 66 } 67 67 68 .blank-slate .menu-settings {69 border: none;70 margin-top: 0;71 padding-top: 0;72 overflow: hidden;73 }74 75 68 .is-submenu { 76 69 color: #555d66; /* #fafafa background */ 77 70 font-style: italic; … … 749 742 float: right; 750 743 } 751 744 752 .nav-menus-php .blank-slate .menu-settings {753 display: none;754 }755 756 745 /* Same as the Publish Meta Box #delete-action */ 757 746 .nav-menus-php .delete-action { 758 747 float: left; -
src/wp-admin/nav-menus.php
300 300 case 'update': 301 301 check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); 302 302 303 // Remove menu locations that have been unchecked.304 foreach ( $locations as $location => $description ) {305 if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) {306 unset( $menu_locations[ $location ] );307 }308 }309 310 303 // Merge new and existing menu locations if any new ones are set. 311 304 if ( isset( $_POST['menu-locations'] ) ) { 312 305 $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); … … 313 306 $menu_locations = array_merge( $menu_locations, $new_menu_locations ); 314 307 } 315 308 316 // Set menu locations.317 set_theme_mod( 'nav_menu_locations', $menu_locations );318 319 309 // Add Menu. 320 310 if ( 0 == $nav_menu_selected_id ) { 321 311 $new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); … … 332 322 if ( isset( $_REQUEST['menu-item'] ) ) { 333 323 wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); 334 324 } 335 if ( isset( $_REQUEST['zero-menu-state'] ) ) { 325 // Set the menu_location value correctly for the newly created menu. 326 foreach ( $menu_locations as $location => $id ) { 327 if ( 0 === $id ) { 328 $menu_locations[ $location ] = $nav_menu_selected_id; 329 } 330 } 331 set_theme_mod( 'nav_menu_locations', $menu_locations ); 332 if ( isset( $_REQUEST['zero-menu-state'] ) || ! empty( $_POST['auto-add-pages'] ) ) { 336 333 // If there are menu items, add them. 337 334 wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); 335 } 336 if ( isset( $_REQUEST['zero-menu-state'] ) ) { 338 337 // Auto-save nav_menu_locations. 339 338 $locations = get_nav_menu_locations(); 340 339 foreach ( $locations as $location => $menu_id ) { … … 360 359 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; 361 360 } 362 361 363 // Update existing menu.362 // Update existing menu. 364 363 } else { 364 // Remove menu locations that have been unchecked. 365 foreach ( $locations as $location => $description ) { 366 if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) { 367 unset( $menu_locations[ $location ] ); 368 } 369 } 365 370 371 // Set menu locations. 372 set_theme_mod( 'nav_menu_locations', $menu_locations ); 373 366 374 $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); 367 375 368 376 $menu_title = trim( esc_html( $_POST['menu-name'] ) ); … … 887 895 <div id="menu-management-liquid"> 888 896 <div id="menu-management"> 889 897 <form id="update-nav-menu" method="post" enctype="multipart/form-data"> 890 <?php891 $new_screen_class = '';892 if ( $add_new_screen ) {893 $new_screen_class = 'blank-slate';894 }895 ?>896 898 <h2><?php _e( 'Menu structure' ); ?></h2> 897 <div class="menu-edit <?php echo $new_screen_class; ?>">899 <div class="menu-edit"> 898 900 <input type="hidden" name="nav-menu-data"> 899 901 <?php 900 902 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );