Ticket #23770: 23770.4.diff
File 23770.4.diff, 9.3 KB (added by , 11 years ago) |
---|
-
wp-admin/css/wp-admin.css
166 166 padding: 0 7px; 167 167 } 168 168 169 #col-left-locations { 170 width: 40%; 171 } 172 169 173 /* utility classes */ 170 174 .alignleft { 171 175 float: left; … … 2423 2427 width: 8%; 2424 2428 } 2425 2429 2430 .fixed .column-posts, 2426 2431 .fixed .column-date, 2427 2432 .fixed .column-parent, 2428 2433 .fixed .column-links, … … 2439 2444 width: 15%; 2440 2445 } 2441 2446 2447 .fixed .column-slug { 2448 width: 25%; 2449 } 2450 2451 .fixed .column-locations { 2452 width: 35%; 2453 } 2454 2442 2455 .fixed .column-comments { 2443 2456 width: 4em; 2444 2457 padding: 8px 0; … … 2453 2466 float: left; 2454 2467 } 2455 2468 2456 .fixed .column-slug {2457 width: 25%;2458 }2459 2460 .fixed .column-posts {2461 width: 10%;2462 }2463 2464 2469 .fixed .column-icon { 2465 2470 width: 80px; 2466 2471 } … … 7402 7407 filter: alpha(opacity=50); 7403 7408 } 7404 7409 7410 #menu-locations-wrap { 7411 width: 55%; 7412 } 7413 7405 7414 .metabox-holder-disabled .button-controls .select-all { 7406 7415 display: none; 7407 7416 } … … 7562 7571 margin-top: -2px; 7563 7572 } 7564 7573 7574 .menu-location-title { 7575 position: relative; 7576 top: 10px; 7577 } 7578 7579 #locations-nav-menu-wrapper { 7580 padding: 5px 0; 7581 } 7582 7583 .locations-nav-menu-select select { 7584 float: left; 7585 width: 160px; 7586 margin-right: 5px; 7587 } 7588 7589 #locations-row-links { 7590 display: inline-block; 7591 position: relative; 7592 top: 3px; 7593 } 7594 7595 #locations-edit-menu-link, 7596 #locations-add-menu-link { 7597 margin: 0 2px; 7598 } 7599 7600 #locations-edit-menu-link { 7601 width: 15%; 7602 } 7603 7604 #locations-add-menu-link { 7605 width: 12%; 7606 } 7607 7565 7608 #wpbody .open-label { 7566 7609 display: block; 7567 7610 float:left; -
wp-admin/nav-menus.php
37 37 // The menu id of the current menu being edited 38 38 $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0; 39 39 40 // Get existing menu locations assignments 41 $locations = get_registered_nav_menus(); 42 $menu_locations = get_nav_menu_locations(); 43 $num_locations = count( array_keys( $locations ) ); 44 40 45 // Allowed actions: add, update, delete 41 46 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; 42 47 … … 262 267 case 'update': 263 268 check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); 264 269 265 // Get existing menu locations assignments266 $locations = get_registered_nav_menus();267 $menu_locations = get_nav_menu_locations();268 269 270 // Remove menu locations that have been unchecked 270 271 foreach ( $locations as $location => $description ) { 271 272 if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) … … 341 342 } 342 343 } 343 344 break; 345 case 'locations': 346 add_filter( 'screen_options_show_screen', '__return_false' ); 347 348 if ( isset( $_POST['menu-locations'] ) ) { 349 check_admin_referer( 'save-menu-locations' ); 350 351 $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); 352 $menu_locations = array_merge( $menu_locations, $new_menu_locations ); 353 // Set menu locations 354 set_theme_mod( 'nav_menu_locations', $menu_locations ); 355 356 $messages[] = '<div id="message" class="updated"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; 357 } 358 break; 344 359 } 345 360 346 361 // Get all nav menus … … 350 365 // Are we on the add new screen? 351 366 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; 352 367 368 $locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false; 369 353 370 // If we have one theme location, and zero menus, we take them right into editing their first menu 354 371 $page_count = wp_count_posts( 'page' ); 355 372 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false; … … 474 491 ?> 475 492 <div class="wrap"> 476 493 <?php screen_icon(); ?> 477 <h2><?php _e( 'Menus' ); ?> <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, ), admin_url( 'nav-menus.php' ) ) ); ?>" class="add-new-h2"><?php _ex( 'Add New', 'menu' ); ?></a></h2> 494 <h2 class="nav-tab-wrapper"> 495 <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a> 496 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a> 497 </h2> 478 498 <?php 479 499 foreach( $messages as $message ) : 480 500 echo $message . "\n"; 481 501 endforeach; 482 502 ?> 503 <?php 504 if ( $locations_screen ) : 505 echo '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu you would like to use below.', 'Your theme supports %s menus. Select a menu to use for each theme location below.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>'; 506 ?> 507 <div id="menu-locations-wrap"> 508 <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>"> 509 <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> 510 <table class="widefat fixed" cellspacing="0" id="menu-locations-table"> 511 <thead> 512 <tr> 513 <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> 514 <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> 515 </tr> 516 </thead> 517 <tfoot> 518 <tr> 519 <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> 520 <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> 521 </tr> 522 </tfoot> 523 <tbody class="menu-locations"> 524 <?php foreach ( $locations as $_location => $_name ) { ?> 525 <tr id="menu-locations-row"> 526 <td class="menu-location-title"><strong><?php echo $_name; ?></strong></td> 527 <td class="menu-location-menus"> 528 <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>"> 529 <option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> 530 <?php foreach ( $nav_menus as $menu ) : ?> 531 <option<?php selected( isset( $menu_locations[ $_location ] ) && $menu_locations[ $_location ] == $menu->term_id ); ?> 532 value="<?php echo $menu->term_id; ?>"> 533 <?php $truncated_name = wp_html_excerpt( $menu->name, 40 ); 534 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…'; ?> 535 </option> 536 <?php endforeach; ?> 537 </select> 538 <div id="locations-row-links"> 539 <span id="locations-edit-menu-link"> 540 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu->term_id ), admin_url( 'nav-menus.php' ) ) ); ?>"> 541 <?php _ex( 'Edit', 'menu' ); ?> 542 </a> 543 </span> | 544 <span id="locations-add-menu-link"> 545 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ); ?>"> 546 <?php _ex( 'Add New', 'menu' ); ?> 547 </a> 548 </span> 549 </div><!-- #locations-row-links --> 550 </td><!-- .menu-location-menus --> 551 </tr><!-- #menu-locations-row --> 552 <?php } // foreach ?> 553 </tbody> 554 </table> 555 <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> 556 <?php wp_nonce_field( 'save-menu-locations' ); ?> 557 <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> 558 </form> 559 </div><!-- #menu-locations-wrap --> 560 <?php else : ?> 483 561 <div class="manage-menus"> 484 <?php if ( $menu_count < 2 ) : ?>562 <?php if ( $menu_count < 2 ) : ?> 485 563 <span class="add-edit-menu-action"> 486 564 <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?> 487 565 </span><!-- /add-edit-menu-action --> 488 <?php else : ?>489 <form method=" post" action="<?php echo admin_url( 'nav-menus.php' ); ?>">566 <?php else : ?> 567 <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> 490 568 <input type="hidden" name="action" value="edit" /> 491 569 <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> 492 570 <select name="menu" id="menu"> … … 520 598 <?php printf( __( 'or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?> 521 599 </span><!-- /add-new-menu-action --> 522 600 </form> 523 <?php endif; ?>601 <?php endif; ?> 524 602 </div><!-- /manage-menus --> 525 603 <div id="nav-menus-frame"> 526 604 <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>"> … … 633 711 </div><!-- /#menu-management --> 634 712 </div><!-- /#menu-management-liquid --> 635 713 </div><!-- /#nav-menus-frame --> 714 <?php endif; ?> 636 715 </div><!-- /.wrap--> 637 716 <?php include( './admin-footer.php' ); ?>