Ticket #14325: 14325-patch1.diff
File 14325-patch1.diff, 4.2 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/nav-menu.php
722 722 <?php 723 723 $args['walker'] = $walker; 724 724 725 // if we're dealing with pages, let's put a checkbox for the front page at the top of the list726 if ( 'page' == $post_type_name ) {727 $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;728 if ( ! empty( $front_page ) ) {729 $front_page_obj = get_post( $front_page );730 $front_page_obj->_add_to_top = true;731 $front_page_obj->label = sprintf( _x('Home: %s', 'nav menu front page title'), $front_page_obj->post_title );732 array_unshift( $posts, $front_page_obj );733 } else {734 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;735 array_unshift( $posts, (object) array(736 '_add_to_top' => true,737 'ID' => 0,738 'object_id' => $_nav_menu_placeholder,739 'post_content' => '',740 'post_excerpt' => '',741 'post_parent' => '',742 'post_title' => _x('Home', 'nav menu home label'),743 'post_type' => 'nav_menu_item',744 'type' => 'custom',745 'url' => home_url('/'),746 ) );747 }748 }749 750 725 $posts = apply_filters( 'nav_menu_items_'.$post_type_name, $posts, $args, $post_type ); 751 726 $checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args ); 752 727 -
wp-admin/js/nav-menu.dev.js
39 39 this.attachThemeLocationsListeners(); 40 40 41 41 this.attachTabsPanelListeners(); 42 this.attachHomeLinkListener(); 42 43 43 44 this.attachUnsavedChangesListener(); 44 45 … … 554 555 } 555 556 }, processMethod, callback); 556 557 }, 558 559 addHomeLink : function() { 560 var url = $( '#home-link-url' ).val(); 561 var label = $( '#home-link-label' ).val(); 562 api.addLinkToMenu( url, label ); 563 }, 557 564 558 565 addItemToMenu : function(menuItem, processMethod, callback) { 559 566 var menu = $('#menu').val(), … … 611 618 registerChange : function() { 612 619 api.menusChanged = true; 613 620 }, 621 622 attachHomeLinkListener : function() { 623 $( '#add-home-link' ).bind( 'click', function( e ) { 624 api.registerChange(); 625 api.addHomeLink(); 626 return false; 627 } ); 628 }, 614 629 615 630 attachTabsPanelListeners : function() { 616 631 $('#menu-settings-column').bind('click', function(e) { -
wp-admin/nav-menus.php
561 561 <?php endif; ?> 562 562 <br class="clear" /> 563 563 <div class="publishing-action"> 564 <?php 565 566 // Add Home Link 567 if ( ! empty( $nav_menu_selected_id ) ) { 568 $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; 569 if ( ! empty( $front_page ) ) { 570 $front_page_obj = get_post( $front_page ); 571 $home_link_label = sprintf( _x('Home: %s', 'nav menu front page title'), $front_page_obj->post_title ); 572 $home_link_url = get_permalink( $front_page ); 573 } else { 574 $home_link_label = _x('Home', 'nav menu home label'); 575 $home_link_url = home_url('/'); 576 } 577 578 ?> 579 <input type="hidden" id="home-link-label" name="home_link_label" value="<?php echo $home_link_label; ?>" /> 580 <input type="hidden" id="home-link-url" name="home_link_url" value="<?php echo $home_link_url; ?>" /> 581 <?php 582 583 submit_button( __( 'Add Home Link' ), 'button-secondary', 'add_home_link', false, array( 'id' => 'add-home-link' ) ); 584 } 585 586 ?> 564 587 <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?> 565 588 </div><!-- END .publishing-action --> 566 589