From e836e47a8a352d6fe1a681f4dc4b99f69dfd6d35 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 30 Jan 2017 19:32:42 +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. Built from https://develop.svn.wordpress.org/trunk@40031 git-svn-id: http://core.svn.wordpress.org/trunk@39968 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template.php | 3 ++- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/template.php b/wp-includes/template.php index 01f9c8a715..cc15eedb48 100644 --- a/wp-includes/template.php +++ b/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(); } diff --git a/wp-includes/version.php b/wp-includes/version.php index b99db66045..770f018f15 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.