Ticket #13220: 13220.add.home.link.and.friends.1.patch
File 13220.add.home.link.and.friends.1.patch, 7.4 KB (added by , 14 years ago) |
---|
-
wp-includes/script-loader.php
395 395 // Custom Navigation 396 396 $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100504' ); 397 397 $scripts->localize( 'nav-menu', 'navMenuL10n', array( 398 'home' => _x('Home', 'nav menu home label'), 399 'homeurl' => home_url('/'), 398 400 'custom' => _x('Custom', 'menu nav item type'), 399 401 'thickbox' => _x('Edit Menu Item', 'Thickbox Title'), 400 402 'edit' => _x('Edit', 'menu item edit text'), -
wp-admin/includes/nav-menu.php
314 314 wp_nav_menu_post_type_meta_boxes(); 315 315 wp_nav_menu_taxonomy_meta_boxes(); 316 316 317 318 317 // Register advanced menu items (columns) 319 318 add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns'); 320 319 321 320 add_filter( 'columns_prefs_header', create_function( '', "return __('Show advanced menu properties');" )); 322 321 323 324 325 322 // If first time editing, disable advanced items by default. 326 323 if( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { 327 324 $user = wp_get_current_user(); 328 update_user_option($user->ID, "managenav-menuscolumnshidden",329 array 325 update_user_option($user->ID, 'managenav-menuscolumnshidden', 326 array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', ), 330 327 true); 331 328 } 332 329 } … … 449 446 </p> 450 447 451 448 <p class="button-controls"> 449 <span class="list-controls"> 450 <a href="#" class="select-all add-home-link"><?php _e('Add Home Link'); ?></a> 451 </span> 452 452 <span class="add-to-menu"> 453 453 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 454 454 <input type="submit" class="button-secondary" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" /> -
wp-admin/js/nav-menu.dev.js
182 182 183 183 this.attachTabsPanelListeners(); 184 184 185 this.attachHomeLinkListener(); 186 185 187 if( menuList.length ) // If no menu, we're in the + tab. 186 188 this.initSortables(); 187 189 … … 190 192 this.initTabManager(); 191 193 192 194 this.initAddMenuItemDraggables(); 195 196 this.checkForEmptyMenu(); 193 197 }, 194 198 195 199 initToggles : function() { … … 349 353 // Set us to be the ajax target 350 354 targetList = target.children('.menu-item-transport'); 351 355 // Get all checked elements and assemble selected items. 352 items = menuItems.filter('.selected-menu-item').children().not( ui.helper ).clone();356 items = li.parents('.tabs-panel').find('.selected-menu-item').children().not( ui.helper ).clone(); 353 357 ui.helper.children('.additional-menu-items').append( items ); 354 358 // This class tells the sortables to treat it as a new item. 355 359 ui.helper.addClass('new-menu-item'); … … 372 376 stop: function(e, ui) { 373 377 // Reset the targetList and unselect the menu items 374 378 targetList = menuList; 375 menuItems.filter('.selected-menu-item').deselectItem();379 $(e.target).parents('.tabs-panel').find('.selected-menu-item').deselectItem(); 376 380 } 377 381 }); 378 382 }, … … 478 482 }); 479 483 }, 480 484 481 addCustomLink : function() { 482 var url = $('#custom-menu-item-url').val(), 483 label = $('#custom-menu-item-name').val(), 485 addCustomLink : function(url, label, addToTop) { 486 var url = url || $('#custom-menu-item-url').val(), 487 label = label || $('#custom-menu-item-name').val(), 488 addToTop = addToTop || false, 484 489 menu = $('#menu').val(), 485 490 nonce = $('#menu-settings-column-nonce').val(), 486 491 params = {}, … … 506 511 } 507 512 }; 508 513 509 processMethod = that.eventAddMenuItem;510 514 processMethod = addToTop ? that.addMenuItemToTop : that.addMenuItemToBottom; 515 511 516 $.post( ajaxurl, params, function(menuMarkup) { 512 517 processMethod.call(that, menuMarkup, params); 513 518 514 519 // Remove the ajax spinner 515 520 $('.customlinkdiv img.waiting').hide(); 521 522 // Reset the form 523 wpNavMenu.resetCustomLinkForm(); 516 524 }); 517 525 }, 526 527 resetCustomLinkForm : function() { 528 // set custom link form back to defaults 529 $('#custom-menu-item-name').val('').blur(); 530 $('#custom-menu-item-url').val('http://'); 531 }, 532 533 attachHomeLinkListener : function() { 534 $('.add-home-link', '.customlinkdiv').click(function(e) { 535 wpNavMenu.addCustomLink( navMenuL10n.homeurl, navMenuL10n.home, true); 536 return false; 537 }); 538 }, 518 539 519 540 attachTabsPanelListeners : function() { 520 541 $('#menu-settings-column').bind('click', function(e) { … … 726 747 727 748 eventOnClickMenuDelete : function(clickedEl) { 728 749 // Delete warning AYS 729 if ( confirm( navMenuL10n.warnDeleteMenu ) ) {750 if ( confirm( navMenuL10n.warnDeleteMenu ) ) 730 751 return true; 731 } else {752 else 732 753 return false; 733 }734 754 }, 735 755 736 756 eventOnClickMenuItemDelete : function(clickedEl) { … … 768 788 * 769 789 * @param string id The id of the metabox 770 790 */ 771 addItemsToMenu : function(id ) {791 addItemsToMenu : function(id, addToTop) { 772 792 var items = $( '.tabs-panel-active .categorychecklist li input:checked', '#' + id), 773 793 menu = $('#menu').val(), 774 794 nonce = $('#menu-settings-column-nonce').val(), 775 795 params = {}, 776 796 that = this, 797 addToTop = addToTop || false, 777 798 processMethod = function(){}, 778 799 re = new RegExp('menu-item\\[(\[^\\]\]*)'); 779 800 780 processMethod = that.eventAddMenuItem;801 processMethod = addToTop ? that.addMenuItemToTop : that.addMenuItemToBottom; 781 802 782 803 // If no items are checked, bail. 783 804 if ( !items.length ) … … 806 827 }); 807 828 808 829 // Uncheck the item 809 $(this). attr('checked', false);830 $(this).parent().prev().deselectItem(); 810 831 }); 811 832 812 833 // Remove the ajax spinner … … 819 840 * @param string menuMarkup The text server response of menu item markup. 820 841 * @param object req The request arguments. 821 842 */ 822 eventAddMenuItem : function( menuMarkup, req ) {843 addMenuItemToBottom : function( menuMarkup, req ) { 823 844 $(menuMarkup).hideAdvancedMenuItemFields().appendTo( targetList ); 824 845 }, 846 847 addMenuItemToTop : function( menuMarkup, req ) { 848 $(menuMarkup).hideAdvancedMenuItemFields().prependTo( targetList ); 849 }, 825 850 826 851 /** 827 852 * Process the quick search response into a search result … … 886 911 removeMenuItem : function(el) { 887 912 el = $(el) 888 913 var children = el.childMenuItems(); 914 var that = this; 889 915 890 916 el.addClass('deleting').fadeOut( 350 , function() { 891 917 el.remove(); 892 918 children.shiftDepthClass(-1).updateParentMenuItemDBId(); 893 919 recalculateMenuItemPositions(); 920 that.checkForEmptyMenu(); 894 921 }); 922 }, 923 924 checkForEmptyMenu : function() { 925 if( menuList.children().length ) return; 926 menuList.height(80).one('sortstop', function(){ 927 $(this).height('auto'); 928 }); 895 929 } 896 930 } 897 931 } -
wp-admin/css/nav-menu.dev.css
313 313 padding-top:1em; 314 314 } 315 315 316 #menu-to-edit { 317 padding: 1em 0; 318 } 319 316 320 .menu ul { width: 100%; } 317 321 .menu ul.sub-menu { 318 322 }