diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php index adccacd130..6f5944f59c 100644 --- a/wp-includes/class-wp-customize-nav-menus.php +++ b/wp-includes/class-wp-customize-nav-menus.php @@ -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( diff --git a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index f8aaec73ae..463da87afe 100644 --- a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php +++ b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -324,12 +324,20 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { } } + if ( ! isset( $this->value['title'] ) ) { + $this->value['title'] = ''; + } + if ( ! isset( $this->value['_invalid'] ) ) { - $this->value['_invalid'] = ( - ( 'post_type' === $this->value['type'] && ! post_type_exists( $this->value['object'] ) ) + $this->value['_invalid'] = false; + $is_known_invalid = ( + ( ( 'post_type' === $this->value['type'] || 'post_type_archive' === $this->value['type'] ) && ! post_type_exists( $this->value['object'] ) ) || ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) ) ); + if ( $is_known_invalid ) { + $this->value['_invalid'] = true; + } } // Remove remaining properties available on a setup nav_menu_item post object which aren't relevant to the setting value. diff --git a/wp-includes/version.php b/wp-includes/version.php index 7f9a93e662..09964c0c85 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta2-35499'; +$wp_version = '4.4-beta2-35500'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.