Ticket #23119: 23119-C.diff
| File 23119-C.diff, 15.4 KB (added by lessbloat, 5 months ago) |
|---|
-
wp-admin/includes/nav-menu.php
382 382 **/ 383 383 function wp_nav_menu_setup() { 384 384 // Register meta boxes 385 if ( wp_get_nav_menus() )386 add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );387 385 add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); 388 386 wp_nav_menu_post_type_meta_boxes(); 389 387 wp_nav_menu_taxonomy_meta_boxes(); … … 471 469 } 472 470 473 471 /** 474 * Displays a metabox for the nav menu theme locations.475 *476 * @since 3.0.0477 */478 function wp_nav_menu_locations_meta_box() {479 global $nav_menu_selected_id;480 481 if ( ! current_theme_supports( 'menus' ) ) {482 // We must only support widgets. Leave a message and bail.483 echo '<p class="howto">' . __('The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '</p>';484 return;485 }486 487 $locations = get_registered_nav_menus();488 $menus = wp_get_nav_menus();489 $menu_locations = get_nav_menu_locations();490 $num_locations = count( array_keys($locations) );491 492 echo '<p class="howto">' . sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n($num_locations) ) . '</p>';493 494 foreach ( $locations as $location => $description ) {495 ?>496 <p>497 <label class="howto" for="locations-<?php echo $location; ?>">498 <span><?php echo $description; ?></span>499 <select name="menu-locations[<?php echo $location; ?>]" id="locations-<?php echo $location; ?>">500 <option value="0"></option>501 <?php foreach ( $menus as $menu ) : ?>502 <option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?>503 value="<?php echo $menu->term_id; ?>"><?php504 $truncated_name = wp_html_excerpt( $menu->name, 40 );505 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…';506 ?></option>507 <?php endforeach; ?>508 </select>509 </label>510 </p>511 <?php512 }513 ?>514 <p class="button-controls">515 <?php submit_button( __( 'Save' ), 'primary right', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false ) ); ?>516 <span class="spinner"></span>517 </p>518 <?php519 }520 521 /**522 472 * Displays a metabox for the custom links menu item. 523 473 * 524 474 * @since 3.0.0 -
wp-admin/js/nav-menu.js
47 47 48 48 this.initToggles(); 49 49 50 this.init TabManager();50 this.initSelectMenuDropdown(); 51 51 }, 52 52 53 53 jQueryExtensions : function() { … … 222 222 } 223 223 }); 224 224 }, 225 226 initSelectMenuDropdown : function () { 227 var menuSelector = $('.menu-selector select'); 228 229 menuSelector.on('change', function () { 230 var url = $(this).val(); 231 232 if (url && '--' !== url) { 233 $('.menu-selector .spinner').show(); 234 window.location = url; 235 } 236 }); 237 }, 225 238 226 239 initToggles : function() { 227 240 // init postboxes … … 461 474 if( '' == $t.val() ) 462 475 $t.addClass( name ).val( $t.data(name) ); 463 476 }); 477 478 $('.blank-slate .input-with-default-title').focus(); 464 479 }, 465 480 466 481 attachThemeLocationsListeners : function() { … … 688 703 }); 689 704 }, 690 705 691 initTabManager : function() {692 var fixed = $('.nav-tabs-wrapper'),693 fluid = fixed.children('.nav-tabs'),694 active = fluid.children('.nav-tab-active'),695 tabs = fluid.children('.nav-tab'),696 tabsWidth = 0,697 fixedRight, fixedLeft,698 arrowLeft, arrowRight, resizeTimer, css = {},699 marginFluid = api.isRTL ? 'margin-right' : 'margin-left',700 marginFixed = api.isRTL ? 'margin-left' : 'margin-right',701 msPerPx = 2;702 703 /**704 * Refreshes the menu tabs.705 * Will show and hide arrows where necessary.706 * Scrolls to the active tab by default.707 *708 * @param savePosition {boolean} Optional. Prevents scrolling so709 * that the current position is maintained. Default false.710 **/711 api.refreshMenuTabs = function( savePosition ) {712 var fixedWidth = fixed.width(),713 margin = 0, css = {};714 fixedLeft = fixed.offset().left;715 fixedRight = fixedLeft + fixedWidth;716 717 if( !savePosition )718 active.makeTabVisible();719 720 // Prevent space from building up next to the last tab if there's more to show721 if( tabs.last().isTabVisible() ) {722 margin = fixed.width() - tabsWidth;723 margin = margin > 0 ? 0 : margin;724 css[marginFluid] = margin + 'px';725 fluid.animate( css, 100, "linear" );726 }727 728 // Show the arrows only when necessary729 if( fixedWidth > tabsWidth )730 arrowLeft.add( arrowRight ).hide();731 else732 arrowLeft.add( arrowRight ).show();733 }734 735 $.fn.extend({736 makeTabVisible : function() {737 var t = this.eq(0), left, right, css = {}, shift = 0;738 739 if( ! t.length ) return this;740 741 left = t.offset().left;742 right = left + t.outerWidth();743 744 if( right > fixedRight )745 shift = fixedRight - right;746 else if ( left < fixedLeft )747 shift = fixedLeft - left;748 749 if( ! shift ) return this;750 751 css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px';752 fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" );753 return this;754 },755 isTabVisible : function() {756 var t = this.eq(0),757 left = t.offset().left,758 right = left + t.outerWidth();759 return ( right <= fixedRight && left >= fixedLeft ) ? true : false;760 }761 });762 763 // Find the width of all tabs764 tabs.each(function(){765 tabsWidth += $(this).outerWidth(true);766 });767 768 // Set up fixed margin for overflow, unset padding769 css['padding'] = 0;770 css[marginFixed] = (-1 * tabsWidth) + 'px';771 fluid.css( css );772 773 // Build tab navigation774 arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>«</a></div>');775 arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>»</a></div>');776 // Attach to the document777 fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight );778 779 // Set the menu tabs780 api.refreshMenuTabs();781 // Make sure the tabs reset on resize782 $(window).resize(function() {783 if( resizeTimer ) clearTimeout(resizeTimer);784 resizeTimer = setTimeout( api.refreshMenuTabs, 200);785 });786 787 // Build arrow functions788 $.each([{789 arrow : arrowLeft,790 next : "next",791 last : "first",792 operator : "+="793 },{794 arrow : arrowRight,795 next : "prev",796 last : "last",797 operator : "-="798 }], function(){799 var that = this;800 this.arrow.mousedown(function(){801 var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ),802 shift = marginFluidVal,803 css = {};804 805 if( "-=" == that.operator )806 shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal;807 808 if( ! shift ) return;809 810 css[marginFluid] = that.operator + shift + 'px';811 fluid.animate( css, shift * msPerPx, "linear" );812 }).mouseup(function(){813 var tab, next;814 fluid.stop(true);815 tab = tabs[that.last]();816 while( (next = tab[that.next]()) && next.length && ! next.isTabVisible() ) {817 tab = next;818 }819 tab.makeTabVisible();820 });821 });822 },823 824 706 eventOnClickEditLink : function(clickedEl) { 825 707 var settings, item, 826 708 matchedSection = /#(.*)$/.exec(clickedEl.href); -
wp-admin/nav-menus.php
460 460 ?> 461 461 <div class="wrap"> 462 462 <?php screen_icon(); ?> 463 <h2><?php esc_html_e('Menus'); ?></h2> 463 <h2><?php esc_html_e('Menus'); ?> <a href="<?php 464 echo esc_url(add_query_arg( 465 array( 466 'action' => 'edit', 467 'menu' => 0, 468 ), 469 admin_url( 'nav-menus.php' ) 470 )); 471 ?>" class="add-new-h2">Add New</a></h2> 464 472 <?php 465 473 foreach( $messages as $message ) : 466 474 echo $message . "\n"; 467 475 endforeach; 468 476 ?> 477 <?php if ( 1 < count( $nav_menus ) ) : ?> 478 <p class="menu-selector"> 479 <span class="spinner"></span> 480 <select> 481 <option value="" selected="selected">Select a menu</option> 482 <?php 483 foreach( (array) $nav_menus as $_nav_menu ) : ?> 484 <option value="<?php 485 echo esc_url(add_query_arg( 486 array( 487 'action' => 'edit', 488 'menu' => $_nav_menu->term_id, 489 ), 490 admin_url( 'nav-menus.php' ) 491 )); 492 ?>"> 493 <?php echo esc_html( $_nav_menu->truncated_name ); ?> 494 </option> 495 <?php endforeach; ?> 496 </select> 497 </p> 498 <?php endif; ?> 469 499 <div id="nav-menus-frame"> 470 500 <div id="menu-settings-column" class="metabox-holder<?php if ( !$nav_menu_selected_id ) { echo ' metabox-holder-disabled'; } ?>"> 471 501 … … 494 524 <?php submit_button( __( 'Select' ), 'secondary', 'select_menu', false ); ?> 495 525 </form> 496 526 </div> 497 <div class="nav-tabs-wrapper">498 <div class="nav-tabs">499 <?php500 foreach( (array) $nav_menus as $_nav_menu ) :501 if ( $nav_menu_selected_id == $_nav_menu->term_id ) : ?><span class="nav-tab nav-tab-active">502 <?php echo esc_html( $_nav_menu->truncated_name ); ?>503 </span><?php else : ?><a href="<?php504 echo esc_url(add_query_arg(505 array(506 'action' => 'edit',507 'menu' => $_nav_menu->term_id,508 ),509 admin_url( 'nav-menus.php' )510 ));511 ?>" class="nav-tab hide-if-no-js">512 <?php echo esc_html( $_nav_menu->truncated_name ); ?>513 </a><?php endif;514 endforeach;515 if ( 0 == $nav_menu_selected_id ) : ?><span class="nav-tab menu-add-new nav-tab-active">516 <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>517 </span><?php else : ?><a href="<?php518 echo esc_url(add_query_arg(519 array(520 'action' => 'edit',521 'menu' => 0,522 ),523 admin_url( 'nav-menus.php' )524 ));525 ?>" class="nav-tab menu-add-new">526 <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>527 </a><?php endif; ?>528 </div>529 </div>530 527 <div class="menu-edit"> 531 528 <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> 532 529 <div id="nav-menu-header"> 533 530 <div id="submitpost" class="submitbox"> 534 <div class="major-publishing-actions ">531 <div class="major-publishing-actions <?php if ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) echo 'blank-slate'; ?>"> 535 532 <label class="menu-name-label howto open-label" for="menu-name"> 536 533 <span><?php _e('Menu Name'); ?></span> 537 534 <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Enter menu name here'); ?>" value="<?php echo esc_attr( $nav_menu_selected_title ); ?>" /> … … 602 599 </div><!-- /#menu-management --> 603 600 </div><!-- /#menu-management-liquid --> 604 601 </div><!-- /#nav-menus-frame --> 602 <div class="menu-locations"> 603 <h3>Select menus for your theme</h3> 604 <?php 605 if ( ! current_theme_supports( 'menus' ) ) { 606 // We must only support widgets. Leave a message and bail. 607 echo '<p class="howto">' . __('The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '</p>'; 608 } 609 610 if ( wp_get_nav_menus() ) : 611 612 $locations = get_registered_nav_menus(); 613 $menus = wp_get_nav_menus(); 614 $menu_locations = get_nav_menu_locations(); 615 $num_locations = count( array_keys($locations) ); 616 617 echo '<p>' . sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n($num_locations) ) . '</p>'; 618 ?> 619 <form enctype="multipart/form-data" method="post" class="nav-menu-meta" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> 620 <input type="hidden" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" id="nav-menu-meta-object-id" name="menu"> 621 <input type="hidden" value="add-menu-item" name="action"> 622 <?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?> 623 <?php 624 625 foreach ( $locations as $location => $description ) { 626 ?> 627 <p> 628 <label class="desc" for="locations-<?php echo $location; ?>"><?php echo $description; ?></label> 629 <select name="menu-locations[<?php echo $location; ?>]" id="locations-<?php echo $location; ?>"> 630 <option value="0"></option> 631 <?php foreach ( $menus as $menu ) : ?> 632 <option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?> 633 value="<?php echo $menu->term_id; ?>"><?php 634 $truncated_name = wp_html_excerpt( $menu->name, 40 ); 635 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…'; 636 ?></option> 637 <?php endforeach; ?> 638 </select> 639 </p> 640 <?php } ?> 641 <?php submit_button( __( 'Save' ), 'primary', 'nav-menu-locations', false ); ?> 642 <span class="spinner"></span> 643 <?php endif; ?> 644 </form> 645 </div> 605 646 </div><!-- /.wrap--> 606 647 607 648 <?php include( './admin-footer.php' ); ?> -
wp-admin/css/wp-admin.css
6760 6760 margin-left: -300px; 6761 6761 clear: both; 6762 6762 float: left; 6763 padding-top: 24px;6763 padding-top: 0; 6764 6764 } 6765 6765 6766 6766 .no-js #wpbody-content #menu-settings-column { … … 6785 6785 position: relative; 6786 6786 } 6787 6787 6788 .menu-selector { 6789 float: right; 6790 } 6791 6792 .menu-selector .spinner { 6793 float: left; 6794 } 6795 6796 .blank-slate br { 6797 display: none; 6798 } 6799 6800 .blank-slate .menu-name { 6801 height: 2em; 6802 } 6803 6804 .menu-locations { 6805 border-top: 1px solid #ddd; 6806 } 6807 6808 .menu-locations .desc { 6809 width: 200px; 6810 } 6811 6812 .menu-locations .spinner { 6813 float: none; 6814 } 6815 6788 6816 /* Menu Container */ 6789 6817 #menu-management-liquid { 6790 6818 float: left; 6791 6819 min-width: 100%; 6820 margin-top: 3px; 6792 6821 } 6793 6822 6794 6823 #menu-management { … … 6835 6864 font-weight:bold; 6836 6865 } 6837 6866 6838 /* Menu Tabs */6839 6840 #menu-management .nav-tabs-nav {6841 margin: 0 20px;6842 }6843 6844 #menu-management .nav-tabs-arrow {6845 width: 10px;6846 padding: 0 5px 4px;6847 cursor: pointer;6848 position: absolute;6849 top: 0;6850 line-height: 22px;6851 font-size: 18px;6852 text-shadow: 0 1px 0 #fff;6853 }6854 6855 #menu-management .nav-tabs-arrow-left {6856 left: 0;6857 }6858 6859 #menu-management .nav-tabs-arrow-right {6860 right: 0;6861 text-align: right;6862 }6863 6864 #menu-management .nav-tabs-wrapper {6865 width: 100%;6866 height: 28px;6867 margin-bottom: -1px;6868 overflow: hidden;6869 }6870 6871 #menu-management .nav-tabs {6872 padding-left: 20px;6873 padding-right: 10px;6874 }6875 6876 .js #menu-management .nav-tabs {6877 float: left;6878 margin-left: 0px;6879 margin-right: -400px;6880 }6881 6882 #menu-management .nav-tab {6883 margin-bottom: 0;6884 font-size: 14px;6885 }6886 6887 6867 #select-nav-menu-container { 6888 6868 text-align: right; 6889 6869 padding: 0 10px 3px 10px; … … 7326 7306 margin: 5px 0 1px; 7327 7307 } 7328 7308 7309 .nav-menus-php .blank-slate .publishing-action { 7310 float: left; 7311 margin: 1px 0 0; 7312 } 7313 7329 7314 .nav-menus-php .major-publishing-actions .delete-action { 7330 7315 vertical-align: middle; 7331 7316 text-align: left;
