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:
@@ -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 ];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user