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. Built from https://develop.svn.wordpress.org/trunk@35382 git-svn-id: http://core.svn.wordpress.org/trunk@35346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1159,6 +1159,10 @@ function wp_ajax_add_menu_item() {
|
||||
$_object = get_post( $menu_item_data['menu-item-object-id'] );
|
||||
break;
|
||||
|
||||
case 'post_type_archive' :
|
||||
$_object = get_post_type_object( $menu_item_data['menu-item-object'] );
|
||||
break;
|
||||
|
||||
case 'taxonomy' :
|
||||
$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
|
||||
break;
|
||||
|
||||
@@ -78,6 +78,9 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
||||
} elseif ( 'post_type' == $item->type ) {
|
||||
$original_object = get_post( $item->object_id );
|
||||
$original_title = get_the_title( $original_object->ID );
|
||||
} elseif ( 'post_type_archive' == $item->type ) {
|
||||
$original_object = get_post_type_object( $item->object );
|
||||
$original_title = $original_object->labels->archives;
|
||||
}
|
||||
|
||||
$classes = array(
|
||||
|
||||
@@ -493,6 +493,23 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
||||
}
|
||||
}
|
||||
|
||||
$post_type = get_post_type_object( $post_type_name );
|
||||
$archive_link = get_post_type_archive_link( $post_type_name );
|
||||
if ( $post_type->has_archive ) {
|
||||
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
|
||||
array_unshift( $posts, (object) array(
|
||||
'ID' => 0,
|
||||
'object_id' => $_nav_menu_placeholder,
|
||||
'object' => $post_type_name,
|
||||
'post_content' => '',
|
||||
'post_excerpt' => '',
|
||||
'post_title' => $post_type->labels->archives,
|
||||
'post_type' => 'nav_menu_item',
|
||||
'type' => 'post_type_archive',
|
||||
'url' => get_post_type_archive_link( $post_type_name ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the posts displayed in the 'View All' tab of the current
|
||||
* post type's menu items meta box.
|
||||
|
||||
Reference in New Issue
Block a user