Introduce is_post_type_hierarchical(). Props ptahdunbar. See #12950
git-svn-id: http://svn.automattic.com/wordpress/trunk@14053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
71d7acc71d
commit
ab16d12c2c
|
@ -660,6 +660,28 @@ function get_post_stati( $args = array(), $output = 'names', $operator = 'or' )
|
|||
return $post_statuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the post type is hierarchical.
|
||||
*
|
||||
* A false return value might also mean that the post type does not exist.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
function is_post_type_hierarchical( $post = false ) {
|
||||
if ( is_string($post) && $is_post_type = get_post_type_object($post) )
|
||||
return $is_post_type->hierarchical;
|
||||
|
||||
$ptype = get_post( $post );
|
||||
if ( $ptype && $is_post_type = get_post_type_object($ptype->post_type) )
|
||||
return $is_post_type->hierarchical;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the post type of the current post or of a given post.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue