Query: Prevent PHP notice when `get_post_type_object()` returns `null` in `is_post_type_archive()`.

This changeset avoids potential PHP notices caused by `get_post_type_object()` returning `null` when called inside `is_post_type_archive()`.

Props sean212, costdev.
Fixes #56287.

Built from https://develop.svn.wordpress.org/trunk@54464


git-svn-id: http://core.svn.wordpress.org/trunk@54023 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-10-10 23:03:14 +00:00
parent 8ad3828d20
commit 81e88ecaa5
2 changed files with 5 additions and 1 deletions

View File

@ -3935,6 +3935,10 @@ class WP_Query {
}
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object ) {
return false;
}
return in_array( $post_type_object->name, (array) $post_types, true );
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-beta3-54450';
$wp_version = '6.1-beta3-54464';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.