Changeset 23810
- Timestamp:
- 03/27/2013 11:46:08 AM (11 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin-rtl.css
r23808 r23810 698 698 float: right; 699 699 } 700 .fixed .column-menus { 701 text-align: right; 702 } 700 703 .sorting-indicator { 701 704 margin-left: 0; … … 2081 2084 margin-right: -300px; 2082 2085 margin-left: 0; 2086 float: right; 2087 } 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; 2083 2107 float: right; 2084 2108 } -
trunk/wp-admin/css/wp-admin.css
r23805 r23810 2424 2424 } 2425 2425 2426 .fixed .column-posts, 2426 2427 .fixed .column-date, 2427 2428 .fixed .column-parent, … … 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; … … 2452 2461 .fixed .column-comments a { 2453 2462 float: left; 2454 }2455 2456 .fixed .column-slug {2457 width: 25%;2458 }2459 2460 .fixed .column-posts {2461 width: 10%;2462 2463 } 2463 2464 … … 2546 2547 .fixed .column-comments .sorting-indicator { 2547 2548 margin-top: 3px; 2549 } 2550 2551 #menu-locations-wrap .widefat { 2552 width: 60%; 2548 2553 } 2549 2554 … … 7385 7390 #nav-menus-frame { 7386 7391 margin-left: 300px; 7387 margin-top: 2 8px;7392 margin-top: 23px; 7388 7393 } 7389 7394 … … 7402 7407 } 7403 7408 7404 .metabox-holder-disabled .postbox { 7409 .metabox-holder-disabled .postbox, 7410 .metabox-holder-disabled .accordion-section-content { 7405 7411 opacity: 0.5; 7406 7412 filter: alpha(opacity=50); … … 7433 7439 7434 7440 .manage-menus { 7435 margin-top: 13px;7441 margin-top: 23px; 7436 7442 padding: 10px; 7437 7443 overflow: hidden; … … 7565 7571 #menu-name-label { 7566 7572 margin-top: -2px; 7573 } 7574 7575 .widefat td.menu-location-menus { 7576 padding-bottom: 5px; 7577 } 7578 7579 .menu-location-menus select { 7580 float: left; 7581 } 7582 7583 #locations-nav-menu-wrapper { 7584 padding: 5px 0; 7585 } 7586 7587 .locations-nav-menu-select select { 7588 float: left; 7589 width: 160px; 7590 margin-right: 5px; 7591 } 7592 7593 .locations-row-links { 7594 float: left; 7595 margin: 6px 0 0 6px; 7596 } 7597 7598 .locations-edit-menu-link, 7599 .locations-add-menu-link { 7600 margin: 0 3px; 7601 } 7602 7603 .locations-edit-menu-link { 7604 padding-right: 3px; 7605 border-right: 1px solid #ccc; 7567 7606 } 7568 7607 -
trunk/wp-admin/js/nav-menu.js
r23761 r23810 48 48 if ( menus.oneThemeLocationNoMenus ) 49 49 $( '#posttype-page' ).addSelectedToMenu( api.addMenuItemToBottom ); 50 51 this.initManageLocations(); 50 52 51 53 this.initAccessibility(); … … 736 738 }, 737 739 740 initManageLocations : function () { 741 $('#menu-locations-wrap form').submit(function(){ 742 window.onbeforeunload = null; 743 }); 744 $('.menu-location-menus select').on('change', function () { 745 var editLink = $(this).closest('tr').find('.locations-edit-menu-link'); 746 if ($(this).find('option:selected').data('orig')) 747 editLink.show(); 748 else 749 editLink.hide(); 750 }); 751 }, 752 738 753 attachMenuEditListeners : function() { 739 754 var that = this; … … 928 943 929 944 attachUnsavedChangesListener : function() { 930 $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea ').change(function(){945 $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').change(function(){ 931 946 api.registerChange(); 932 947 }); 933 948 934 if ( 0 != $('#menu-to-edit').length ) {949 if ( 0 != $('#menu-to-edit').length || 0 != $('.menu-location-menus select').length ) { 935 950 window.onbeforeunload = function(){ 936 951 if ( api.menusChanged ) -
trunk/wp-admin/nav-menus.php
r23807 r23810 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 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 ) ); 39 44 40 45 // Allowed actions: add, update, delete … … 262 267 case 'update': 263 268 check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); 264 265 // Get existing menu locations assignments266 $locations = get_registered_nav_menus();267 $menu_locations = get_nav_menu_locations();268 269 269 270 // Remove menu locations that have been unchecked … … 308 309 set_theme_mod( 'nav_menu_locations', $locations ); 309 310 } 310 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>'; 311 if ( isset( $_REQUEST['use-location'] ) ) { 312 $locations = get_theme_mod( 'nav_menu_locations' ); 313 if ( isset( $locations[$_REQUEST['use-location']] ) ) 314 $locations[$_REQUEST['use-location']] = $nav_menu_selected_id; 315 set_theme_mod( 'nav_menu_locations', $locations ); 316 } 317 // $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>'; 318 wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) ); 319 exit(); 311 320 } 312 321 } else { … … 342 351 } 343 352 break; 353 case 'locations': 354 add_filter( 'screen_options_show_screen', '__return_false' ); 355 356 if ( isset( $_POST['menu-locations'] ) ) { 357 check_admin_referer( 'save-menu-locations' ); 358 359 $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); 360 $menu_locations = array_merge( $menu_locations, $new_menu_locations ); 361 // Set menu locations 362 set_theme_mod( 'nav_menu_locations', $menu_locations ); 363 364 $messages[] = '<div id="message" class="updated"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; 365 } 366 break; 344 367 } 345 368 … … 350 373 // Are we on the add new screen? 351 374 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; 375 376 $locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false; 352 377 353 378 // If we have one theme location, and zero menus, we take them right into editing their first menu … … 475 500 <div class="wrap"> 476 501 <?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> 502 <h2 class="nav-tab-wrapper"> 503 <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> 504 <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> 505 </h2> 478 506 <?php 479 507 foreach( $messages as $message ) : … … 481 509 endforeach; 482 510 ?> 511 <?php 512 if ( $locations_screen ) : 513 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>'; 514 ?> 515 <div id="menu-locations-wrap"> 516 <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>"> 517 <table class="widefat fixed" cellspacing="0" id="menu-locations-table"> 518 <thead> 519 <tr> 520 <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> 521 <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> 522 </tr> 523 </thead> 524 <!--<tfoot> 525 <tr> 526 <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> 527 <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> 528 </tr> 529 </tfoot>--> 530 <tbody class="menu-locations"> 531 <?php foreach ( $locations as $_location => $_name ) { ?> 532 <tr id="menu-locations-row"> 533 <td class="menu-location-title"><strong><?php echo $_name; ?></strong></td> 534 <td class="menu-location-menus"> 535 <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>"> 536 <option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> 537 <?php foreach ( $nav_menus as $menu ) : ?> 538 <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?> 539 <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> 540 <?php $truncated_name = wp_html_excerpt( $menu->name, 40 ); 541 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…'; ?> 542 </option> 543 <?php endforeach; ?> 544 </select> 545 <div class="locations-row-links"> 546 <?php if ( isset( $menu_locations[ $_location ] ) && 0 != $menu_locations[ $_location ] ) : ?> 547 <span class="locations-edit-menu-link"> 548 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu_locations[$_location] ), admin_url( 'nav-menus.php' ) ) ); ?>"> 549 <?php _ex( 'Edit', 'menu' ); ?> 550 </a> 551 </span> 552 <?php endif; ?> 553 <span class="locations-add-menu-link"> 554 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, 'use-location' => $_location ), admin_url( 'nav-menus.php' ) ) ); ?>"> 555 <?php _ex( 'Use new menu', 'menu' ); ?> 556 </a> 557 </span> 558 </div><!-- #locations-row-links --> 559 </td><!-- .menu-location-menus --> 560 </tr><!-- #menu-locations-row --> 561 <?php } // foreach ?> 562 </tbody> 563 </table> 564 <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> 565 <?php wp_nonce_field( 'save-menu-locations' ); ?> 566 <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> 567 </form> 568 </div><!-- #menu-locations-wrap --> 569 <?php do_action( 'after_menu_locations_table' ); ?> 570 <?php else : ?> 483 571 <div class="manage-menus"> 484 <?php if ( $menu_count < 2 ) : ?>572 <?php if ( $menu_count < 2 ) : ?> 485 573 <span class="add-edit-menu-action"> 486 574 <?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 575 </span><!-- /add-edit-menu-action --> 488 <?php else : ?>489 <form method="get" action="">576 <?php else : ?> 577 <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> 490 578 <input type="hidden" name="action" value="edit" /> 491 579 <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> … … 579 667 <?php if ( $add_new_screen ) : ?> 580 668 <p class="post-body-plain"><?php _e( 'Give your menu a name above, then click Create Menu.' ); ?></p> 669 <?php if ( isset( $_GET['use-location'] ) ) : ?> 670 <input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" /> 671 <?php endif; ?> 581 672 <?php endif; ?> 582 673 <div class="menu-settings" <?php if ( $one_theme_location_no_menus ) { ?>style="display: none;"<?php } ?>> … … 634 725 </div><!-- /#menu-management-liquid --> 635 726 </div><!-- /#nav-menus-frame --> 727 <?php endif; ?> 636 728 </div><!-- /.wrap--> 637 729 <?php include( './admin-footer.php' ); ?>
Note: See TracChangeset
for help on using the changeset viewer.