From 3e6e1a12f6cff5cf6ed9ec73975a7f86e41f5989 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 30 Jan 2017 19:31:25 +0000 Subject: [PATCH] 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 --- src/wp-includes/template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 01f9c8a715..cc15eedb48 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -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(); }