Avoid PHP notices in get_post_type_archive_template().

The function should fail more gracefully when called in the context
where `get_query_var( 'post_type' )` doesn't represent an actual post
type.

Props technopolitica, dlh.
Fixes #38374.
Built from https://develop.svn.wordpress.org/trunk@40031


git-svn-id: http://core.svn.wordpress.org/trunk@39968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2017-01-30 19:32:42 +00:00
parent c957e3acb0
commit e836e47a8a
2 changed files with 3 additions and 2 deletions

View File

@ -135,8 +135,9 @@ function get_post_type_archive_template() {
$post_type = reset( $post_type );
$obj = get_post_type_object( $post_type );
if ( ! $obj->has_archive )
if ( ! ( $obj instanceof WP_Post_Type ) || ! $obj->has_archive ) {
return '';
}
return get_archive_template();
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40030';
$wp_version = '4.8-alpha-40031';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.