From 1c05c2f6e2e50e0d04b356a0db04dc4ee66d0154 Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 7 May 2010 04:57:23 +0000 Subject: [PATCH] Fix to is_post_type. props scribu, fixes #12588. git-svn-id: http://svn.automattic.com/wordpress/trunk@14498 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 3c7a025c8..d49dd54e1 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -681,7 +681,7 @@ function is_post_type_hierarchical( $post = false ) { } /** - * Checks if a post type is registered, can also check if the current or specified post is of a post type. + * Checks if a post type is registered. Can also check if the current or specified post is of a post type. * * @since 3.0.0 * @uses get_post_type() @@ -691,8 +691,13 @@ function is_post_type_hierarchical( $post = false ) { * @return bool */ function is_post_type( $types = false, $id = false ) { - $types = ( $types === false ) ? get_post_types() : (array) $types; - return in_array( get_post_type( $id ), $types ); + if ( $id ) { + $types = ( $types === false ) ? get_post_types() : (array) $types; + + return in_array( get_post_type( $id ), $types ); + } + + return (bool) get_post_type_object($types); } /**