Ticket #23770: 23770.6.diff
File 23770.6.diff, 12.2 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin-rtl.css
697 697 .fixed .column-comments a { 698 698 float: right; 699 699 } 700 .fixed .column-menus { 701 text-align: right; 702 } 700 703 .sorting-indicator { 701 704 margin-left: 0; 702 705 margin-right: 7px; … … 2083 2086 float: right; 2084 2087 } 2085 2088 2089 .menu-location-menus select { 2090 float: right; 2091 } 2092 2093 .locations-row-links { 2094 float: right; 2095 margin: 4px 6px 0 0; 2096 } 2097 2098 .locations-add-menu-link { 2099 direction: rtl; 2100 } 2101 2102 .locations-edit-menu-link { 2103 border-left: 1px solid #CCCCCC; 2104 border-right: 0; 2105 padding-left: 6px; 2106 padding-right: 0; 2107 float: right; 2108 } 2109 2086 2110 /* Menu Container */ 2087 2111 #menu-management-liquid { 2088 2112 float: right; -
wp-admin/css/wp-admin.css
2423 2423 width: 8%; 2424 2424 } 2425 2425 2426 .fixed .column-posts, 2426 2427 .fixed .column-date, 2427 2428 .fixed .column-parent, 2428 2429 .fixed .column-links, … … 2439 2440 width: 15%; 2440 2441 } 2441 2442 2443 .fixed .column-slug { 2444 width: 25%; 2445 } 2446 2447 .fixed .column-locations { 2448 width: 35%; 2449 } 2450 2442 2451 .fixed .column-comments { 2443 2452 width: 4em; 2444 2453 padding: 8px 0; … … 2453 2462 float: left; 2454 2463 } 2455 2464 2456 .fixed .column-slug {2457 width: 25%;2458 }2459 2460 .fixed .column-posts {2461 width: 10%;2462 }2463 2464 2465 .fixed .column-icon { 2465 2466 width: 80px; 2466 2467 } … … 2547 2548 margin-top: 3px; 2548 2549 } 2549 2550 2551 #menu-locations-wrap .widefat { 2552 width: 60%; 2553 } 2554 2550 2555 .widefat th.sortable, 2551 2556 .widefat th.sorted { 2552 2557 padding: 0; … … 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 { … … 7397 7402 margin: 10px 0 0; 7398 7403 } 7399 7404 7400 .metabox-holder-disabled .postbox { 7405 .metabox-holder-disabled .postbox, 7406 .metabox-holder-disabled .accordion-section-content { 7401 7407 opacity: 0.5; 7402 7408 filter: alpha(opacity=50); 7403 7409 } … … 7428 7434 } 7429 7435 7430 7436 .manage-menus { 7431 margin-top: 13px;7437 margin-top: 23px; 7432 7438 padding: 10px; 7433 7439 overflow: hidden; 7434 7440 -webkit-border-radius: 3px; … … 7562 7568 margin-top: -2px; 7563 7569 } 7564 7570 7571 .widefat td.menu-location-menus { 7572 padding-bottom: 5px; 7573 } 7574 7575 .menu-location-menus select { 7576 float: left; 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 float: left; 7591 margin: 6px 0 0 6px; 7592 } 7593 7594 .locations-edit-menu-link, 7595 .locations-add-menu-link { 7596 margin: 0 3px; 7597 } 7598 7599 .locations-edit-menu-link { 7600 padding-right: 3px; 7601 border-right: 1px solid #ccc; 7602 } 7603 7565 7604 #wpbody .open-label { 7566 7605 display: block; 7567 7606 float:left; -
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_locations[$_location] ), 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 do_action( 'after_menu_locations_table' ); ?> 563 <?php else : ?> 483 564 <div class="manage-menus"> 484 <?php if ( $menu_count < 2 ) : ?>565 <?php if ( $menu_count < 2 ) : ?> 485 566 <span class="add-edit-menu-action"> 486 567 <?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 568 </span><!-- /add-edit-menu-action --> 488 <?php else : ?>489 <form method=" post" action="<?php echo admin_url( 'nav-menus.php' ); ?>">569 <?php else : ?> 570 <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> 490 571 <input type="hidden" name="action" value="edit" /> 491 572 <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> 492 573 <select name="menu" id="menu"> … … 520 601 <?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 602 </span><!-- /add-new-menu-action --> 522 603 </form> 523 <?php endif; ?>604 <?php endif; ?> 524 605 </div><!-- /manage-menus --> 525 606 <div id="nav-menus-frame"> 526 607 <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>"> … … 633 714 </div><!-- /#menu-management --> 634 715 </div><!-- /#menu-management-liquid --> 635 716 </div><!-- /#nav-menus-frame --> 717 <?php endif; ?> 636 718 </div><!-- /.wrap--> 637 719 <?php include( './admin-footer.php' ); ?>