Simplify is_post_type and is_post_type_hierarchical. Make them work like their taxonomy counterparts. see #12588.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-08 22:10:28 +00:00
parent 444f8cc6c4
commit 2eab801eec
1 changed files with 12 additions and 22 deletions

View File

@ -666,38 +666,28 @@ function get_post_stati( $args = array(), $output = 'names', $operator = 'and' )
* @since 3.0.0
* @see get_post_type_object
*
* @param string|int|object $post Post type name, post id, or a post object.
* @return bool true if post type is hierarchical, else false.
* @param string $post Post type name
* @return bool Whether post type is hierarchical.
*/
function is_post_type_hierarchical( $post = false ) {
if ( is_string($post) && $is_post_type = get_post_type_object($post) )
return $is_post_type->hierarchical;
function is_post_type_hierarchical( $post_type ) {
if ( ! is_post_type( $post_type ) )
return false;
$ptype = get_post( $post );
if ( $ptype && $is_post_type = get_post_type_object($ptype->post_type) )
return $is_post_type->hierarchical;
return false;
$post_type = get_post_type_object( $post_type );
return $post_type->hierarchical;
}
/**
* 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.
*
* @since 3.0.0
* @uses get_post_type()
*
* @param string|array $types Type or types to check. Defaults to all post types.
* @param int $id Post ID. Defaults to current ID.
* @return bool
* @param string Post type name
* @return bool Whether post type is registered.
*/
function is_post_type( $types = false, $id = false ) {
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);
function is_post_type( $post_type ) {
return (bool) get_post_type_object( $post_type );
}
/**