Check if the $post_type passed to get_post_type_object() is a scalar value. Non-scalars were producing PHP warnings.

Adds unit tests.

Props Kloon.
Fixes #30013.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor
2015-09-14 00:03:24 +00:00
parent fa1e1a8850
commit 5077d917a3
2 changed files with 4 additions and 3 deletions

View File

@@ -835,10 +835,11 @@ function get_post_type( $post = null ) {
function get_post_type_object( $post_type ) {
global $wp_post_types;
if ( empty($wp_post_types[$post_type]) )
if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) {
return null;
}
return $wp_post_types[$post_type];
return $wp_post_types[ $post_type ];
}
/**