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.

git-svn-id: https://develop.svn.wordpress.org/trunk@40031 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2017-01-30 19:31:25 +00:00
parent 99a101ff27
commit 3e6e1a12f6
1 changed files with 2 additions and 1 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();
}