Ticket #16075: 16075-hlashbrooke.diff
File 16075-hlashbrooke.diff, 5.1 KB (added by , 9 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
1088 1088 case 'taxonomy' : 1089 1089 $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); 1090 1090 break; 1091 1092 case 'archive' : 1093 $_object = get_post_type_object( $menu_item_data['menu-item-object'] ); 1094 $_object->is_archive = true; 1095 break; 1091 1096 } 1092 1097 1093 1098 $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); -
wp-admin/includes/nav-menu.php
69 69 } elseif ( 'post_type' == $item->type ) { 70 70 $original_object = get_post( $item->object_id ); 71 71 $original_title = get_the_title( $original_object->ID ); 72 } elseif ( 'archive' == $item->type ) { 73 $original_title = false; 72 74 } 73 75 74 76 $classes = array( … … 445 447 // Register meta boxes 446 448 wp_nav_menu_post_type_meta_boxes(); 447 449 add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); 450 add_meta_box( 'add-post-types', __( 'Post Type Archives' ), 'wp_nav_menu_post_type_archives_meta_box', 'nav-menus', 'side', 'default' ); 448 451 wp_nav_menu_taxonomy_meta_boxes(); 449 452 450 453 // Register advanced menu items (columns) … … 545 548 } 546 549 547 550 /** 551 * Creates metabox for all post type archives. 552 * 553 * @since 4.3.0 554 */ 555 function wp_nav_menu_post_type_archives_meta_box () { 556 global $nav_menu_selected_id; 557 558 $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); 559 560 if ( ! $post_types ) { 561 return; 562 } 563 564 $types = array(); 565 foreach ( $post_types as $post_type ) { 566 567 /** This filter is documented in wp-admin/includes/nav-menu.php */ 568 $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); 569 570 if ( $post_type ) { 571 $id = $post_type->name; 572 573 if( ! in_array( $id, array( 'post', 'page' ) ) && $post_type->has_archive ) { 574 $types[ $id ] = $post_type; 575 $types[ $id ]->is_archive = true; 576 } 577 } 578 579 } 580 581 if( empty( $types ) ) { 582 return; 583 } 584 585 ?> 586 <div id="post_type-archives"> 587 <div class="tabs-panel-active"> 588 <ul id="post-type-archive-checklist" class="categorychecklist form-no-clear"> 589 <?php 590 $args['walker'] = new Walker_Nav_Menu_Checklist(); 591 echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $types ), 0, (object) $args ); 592 ?> 593 </ul> 594 </div> 595 </div><!-- /.tabs-panel --> 596 597 <p class="button-controls"> 598 <span class="add-to-menu"> 599 <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-archive-menu-item" id="submit-post_type-archives" /> 600 <span class="spinner"></span> 601 </span> 602 </p> 603 <?php 604 } 605 606 /** 548 607 * Check whether to disable the Menu Locations meta box submit button 549 608 * 550 609 * @since 3.6.0 -
wp-content
-
wp-includes/nav-menu.php
Property changes on: wp-content ___________________________________________________________________ Added: svn:ignore ## -0,0 +1 ## +uploads
367 367 $original_object = get_post( $args['menu-item-object-id'] ); 368 368 $original_parent = (int) $original_object->post_parent; 369 369 $original_title = $original_object->post_title; 370 } elseif ( 'archive' == $args['menu-item-type'] ) { 371 $original_object = get_post_type_object( $args['menu-item-object'] ); 372 $original_title = sprintf( __( '%1$s Archive' ), $original_object->labels->name ); 373 $args['menu-item-url'] = get_post_type_archive_link( $original_object->name ); 370 374 } 371 375 372 376 if ( $args['menu-item-title'] == $original_title ) … … 765 769 $menu_item->classes = array(); 766 770 $menu_item->xfn = ''; 767 771 772 } elseif ( isset( $menu_item->is_archive ) ) { 773 $menu_item->ID = $menu_item->name; 774 $menu_item->db_id = 0; 775 $menu_item->menu_item_parent = 0; 776 $menu_item->object_id = $menu_item->name; 777 $menu_item->type = 'archive'; 778 $menu_item->object = $menu_item->name; 779 $menu_item->type_label = __( 'Post Type Archive' ); 780 $menu_item->title = $menu_item->labels->name; 781 $menu_item->url = get_post_type_archive_link( $menu_item->name ); 782 $menu_item->target = ''; 783 $menu_item->attr_title = ''; 784 $menu_item->description = ''; 785 $menu_item->classes = array(); 786 $menu_item->xfn = ''; 768 787 } 769 788 770 789 /** -
.