Customize: Add support for post_type_archive nav menu items.

Props celloexpressions, westonruter.
Fixes #16075.

Built from https://develop.svn.wordpress.org/trunk@35500


git-svn-id: http://core.svn.wordpress.org/trunk@35464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2015-11-04 04:30:26 +00:00
parent e0cab8383c
commit 77e365efbf
3 changed files with 23 additions and 3 deletions

View File

@@ -109,6 +109,8 @@ final class WP_Customize_Nav_Menus {
if ( 'post_type' === $type ) {
if ( ! get_post_type_object( $object ) ) {
return new WP_Error( 'nav_menus_invalid_post_type' );
} else {
$post_type = get_post_type_object( $object );
}
if ( 0 === $page && 'page' === $object ) {
@@ -121,6 +123,16 @@ final class WP_Customize_Nav_Menus {
'object' => '',
'url' => home_url(),
);
} elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) {
// Add a post type archive link.
$items[] = array(
'id' => $object . '-archive',
'title' => $post_type->labels->archives,
'type' => 'post_type_archive',
'type_label' => __( 'Post Type Archive' ),
'object' => $object,
'url' => get_post_type_archive_link( $object ),
);
}
$posts = get_posts( array(