Ticket #23770: 23770.5.diff
File 23770.5.diff, 11.1 KB (added by , 12 years ago) |
---|
-
wp-admin/js/nav-menu.js
48 48 if ( menus.oneThemeLocationNoMenus ) 49 49 $( '#posttype-page' ).addSelectedToMenu( api.addMenuItemToBottom ); 50 50 51 this.initManageLocations(); 52 51 53 this.initAccessibility(); 52 54 53 55 this.initToggles(); … … 735 737 } 736 738 }, 737 739 740 initManageLocations : function () { 741 $('.menu-location-menus select').on('change', function () { 742 var editLink = $('.locations-edit-menu-link'); 743 if ($(this).find('option:selected').data('orig')) 744 editLink.show(); 745 else 746 editLink.hide(); 747 }); 748 }, 749 738 750 attachMenuEditListeners : function() { 739 751 var that = this; 740 752 $('#update-nav-menu').bind('click', function(e) { … … 927 939 }, 928 940 929 941 attachUnsavedChangesListener : function() { 930 $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea ').change(function(){942 $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').change(function(){ 931 943 api.registerChange(); 932 944 }); 933 945 934 if ( 0 != $('#menu-to-edit').length ) {946 if ( 0 != $('#menu-to-edit').length || 0 != $('.menu-location-menus select').length ) { 935 947 window.onbeforeunload = function(){ 936 948 if ( api.menusChanged ) 937 949 return navMenuL10n.saveAlert; -
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 <?php $selected = isset( $menu_locations[ $_location ] ) && $menu_locations[ $_location ] == $menu->term_id; ?> 532 <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected($selected ); ?> 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 class="locations-row-links"> 539 <?php if ( isset( $menu_locations[ $_location ] ) && 0 != $menu_locations[ $_location ] ) : ?> 540 <span class="locations-edit-menu-link"> 541 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu->term_id ), admin_url( 'nav-menus.php' ) ) ); ?>"> 542 <?php _ex( 'Edit', 'menu' ); ?> 543 </a> 544 </span> 545 <?php endif; ?> 546 <span class="locations-add-menu-link"> 547 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ); ?>"> 548 <?php _ex( 'Use new menu', 'menu' ); ?> 549 </a> 550 </span> 551 </div><!-- #locations-row-links --> 552 </td><!-- .menu-location-menus --> 553 </tr><!-- #menu-locations-row --> 554 <?php } // foreach ?> 555 </tbody> 556 </table> 557 <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> 558 <?php wp_nonce_field( 'save-menu-locations' ); ?> 559 <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> 560 </form> 561 </div><!-- #menu-locations-wrap --> 562 <?php else : ?> 483 563 <div class="manage-menus"> 484 <?php if ( $menu_count < 2 ) : ?>564 <?php if ( $menu_count < 2 ) : ?> 485 565 <span class="add-edit-menu-action"> 486 566 <?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 567 </span><!-- /add-edit-menu-action --> 488 <?php else : ?>489 <form method=" post" action="<?php echo admin_url( 'nav-menus.php' ); ?>">568 <?php else : ?> 569 <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> 490 570 <input type="hidden" name="action" value="edit" /> 491 571 <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> 492 572 <select name="menu" id="menu"> … … 520 600 <?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 601 </span><!-- /add-new-menu-action --> 522 602 </form> 523 <?php endif; ?>603 <?php endif; ?> 524 604 </div><!-- /manage-menus --> 525 605 <div id="nav-menus-frame"> 526 606 <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>"> … … 633 713 </div><!-- /#menu-management --> 634 714 </div><!-- /#menu-management-liquid --> 635 715 </div><!-- /#nav-menus-frame --> 716 <?php endif; ?> 636 717 </div><!-- /.wrap--> 637 718 <?php include( './admin-footer.php' ); ?> -
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: 25%; 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 } … … 7380 7385 7381 7386 #nav-menus-frame { 7382 7387 margin-left: 300px; 7383 margin-top: 2 8px;7388 margin-top: 23px; 7384 7389 } 7385 7390 7386 7391 #wpbody-content #menu-settings-column { … … 7428 7433 } 7429 7434 7430 7435 .manage-menus { 7431 margin-top: 13px;7436 margin-top: 23px; 7432 7437 padding: 10px; 7433 7438 overflow: hidden; 7434 7439 -webkit-border-radius: 3px; … … 7562 7567 margin-top: -2px; 7563 7568 } 7564 7569 7570 .widefat td.menu-location-menus { 7571 padding-bottom: 5px; 7572 } 7573 7574 .menu-location-menus select { 7575 float: left; 7576 } 7577 7578 #locations-nav-menu-wrapper { 7579 padding: 5px 0; 7580 } 7581 7582 .locations-nav-menu-select select { 7583 float: left; 7584 width: 160px; 7585 margin-right: 5px; 7586 } 7587 7588 .locations-row-links { 7589 float: left; 7590 margin: 6px 0 0 6px; 7591 } 7592 7593 .locations-edit-menu-link, 7594 .locations-add-menu-link { 7595 margin: 0 3px; 7596 } 7597 7598 .locations-edit-menu-link { 7599 padding-right: 3px; 7600 border-right: 1px solid #ccc; 7601 } 7602 7565 7603 #wpbody .open-label { 7566 7604 display: block; 7567 7605 float:left;