Ticket #13220: add_home_link_hawtness.diff
File add_home_link_hawtness.diff, 5.3 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
161 161 162 162 this.attachTabsPanelListeners(); 163 163 164 this.attachHomeLinkListener(); 165 164 166 if( menuList.length ) // If no menu, we're in the + tab. 165 167 this.initSortables(); 166 168 … … 481 483 }); 482 484 }, 483 485 484 addCustomLink : function() { 485 var url = $('#custom-menu-item-url').val(), 486 label = $('#custom-menu-item-name').val(), 486 addCustomLink : function(url, label, addToTop) { 487 var url = url || $('#custom-menu-item-url').val(), 488 label = label || $('#custom-menu-item-name').val(), 489 addToTop = addToTop || false, 487 490 menu = $('#menu').val(), 488 491 nonce = $('#menu-settings-column-nonce').val(), 489 492 params = {}, … … 509 512 } 510 513 }; 511 514 512 processMethod = that.eventAddMenuItem;513 515 processMethod = addToTop ? that.addMenuItemToTop : that.addMenuItemToBottom; 516 514 517 $.post( ajaxurl, params, function(menuMarkup) { 515 518 processMethod.call(that, menuMarkup, params); 516 519 517 520 // Remove the ajax spinner 518 521 $('.customlinkdiv img.waiting').hide(); 522 523 // Reset the form 524 wpNavMenu.resetCustomLinkForm(); 519 525 }); 520 526 }, 527 528 resetCustomLinkForm : function() { 529 // set custom link form back to defaults 530 $('#custom-menu-item-name').val('').blur(); 531 $('#custom-menu-item-url').val('http://'); 532 }, 533 534 attachHomeLinkListener : function() { 535 $('.add-home-link', '.customlinkdiv').click(function(e) { 536 wpNavMenu.addCustomLink( navMenuL10n.homeurl, navMenuL10n.home, true); 537 return false; 538 }); 539 }, 521 540 522 541 attachTabsPanelListeners : function() { 523 542 $('#menu-settings-column').bind('click', function(e) { … … 725 744 726 745 eventOnClickMenuDelete : function(clickedEl) { 727 746 // Delete warning AYS 728 if ( confirm( navMenuL10n.warnDeleteMenu ) ) {747 if ( confirm( navMenuL10n.warnDeleteMenu ) ) 729 748 return true; 730 } else {749 else 731 750 return false; 732 }733 751 }, 734 752 735 753 eventOnClickMenuItemDelete : function(clickedEl) { … … 767 785 * 768 786 * @param string id The id of the metabox 769 787 */ 770 addItemsToMenu : function(id ) {788 addItemsToMenu : function(id, addToTop) { 771 789 var items = $( '.tabs-panel-active .categorychecklist li input:checked', '#' + id), 772 790 menu = $('#menu').val(), 773 791 nonce = $('#menu-settings-column-nonce').val(), 774 792 params = {}, 775 793 that = this, 794 addToTop = addToTop || false, 776 795 processMethod = function(){}, 777 796 re = new RegExp('menu-item\\[(\[^\\]\]*)'); 778 797 779 processMethod = that.eventAddMenuItem;798 processMethod = addToTop ? that.AddMenuItemToTop : that.AddMenuItemToBottom; 780 799 781 800 // If no items are checked, bail. 782 801 if ( !items.length ) … … 818 837 * @param string menuMarkup The text server response of menu item markup. 819 838 * @param object req The request arguments. 820 839 */ 821 eventAddMenuItem : function( menuMarkup, req ) {840 addMenuItemToBottom : function( menuMarkup, req ) { 822 841 $(menuMarkup).hideAdvancedMenuItemFields().appendTo( targetList ); 823 842 }, 843 844 addMenuItemToTop : function( menuMarkup, req ) { 845 $(menuMarkup).hideAdvancedMenuItemFields().prependTo( targetList ); 846 }, 824 847 825 848 /** 826 849 * Process the quick search response into a search result