Nav Menus: show custom post type Archive item at the top of the View All tab for the post type on the legacy Nav Menu screen.

Props aaroncampbell, DrewAPicture, seanchayes, hlashbrooke, paulwilde, ericlewis, raulillana
See #16075.


git-svn-id: https://develop.svn.wordpress.org/trunk@35382 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-10-24 17:45:11 +00:00
parent a97bf5b2ca
commit a18feed6bd
6 changed files with 51 additions and 0 deletions

View File

@@ -403,6 +403,9 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
$original_object = get_post( $args['menu-item-object-id'] );
$original_parent = (int) $original_object->post_parent;
$original_title = $original_object->post_title;
} elseif ( 'post_type_archive' == $args['menu-item-type'] ) {
$original_object = get_post_type_object( $args['menu-item-object'] );
$original_title = $original_object->labels->archives;
}
if ( $args['menu-item-title'] == $original_title )
@@ -731,6 +734,17 @@ function wp_setup_nav_menu_item( $menu_item ) {
$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
} elseif ( 'post_type_archive' == $menu_item->type ) {
$object = get_post_type_object( $menu_item->object );
if ( $object ) {
$menu_item->title = '' == $menu_item->post_title ? $object->labels->archives : $menu_item->post_title;
} else {
$menu_item->_invalid = true;
}
$menu_item->type_label = __( 'Post Type Archive' );
$menu_item->description = '';
$menu_item->url = get_post_type_archive_link( $menu_item->object );
} elseif ( 'taxonomy' == $menu_item->type ) {
$object = get_taxonomy( $menu_item->object );
if ( $object ) {