WordPress.org

Make WordPress Core

Changeset 14053


Ignore:
Timestamp:
04/10/10 11:42:45 (5 years ago)
Author:
dd32
Message:

Introduce is_post_type_hierarchical(). Props ptahdunbar. See #12950

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r14034 r14053  
    659659 
    660660    return $post_statuses; 
     661} 
     662 
     663/** 
     664 * Whether the post type is hierarchical. 
     665 * 
     666 * A false return value might also mean that the post type does not exist. 
     667 * 
     668 * @since 3.0.0 
     669 * @see get_post_type_object 
     670 * 
     671 * @param string|int|object $post Post type name, post id, or a post object. 
     672 * @return bool true if post type is hierarchical, else false. 
     673 */ 
     674function is_post_type_hierarchical( $post = false ) { 
     675    if ( is_string($post) && $is_post_type = get_post_type_object($post) ) 
     676        return $is_post_type->hierarchical; 
     677     
     678    $ptype = get_post( $post ); 
     679    if ( $ptype && $is_post_type = get_post_type_object($ptype->post_type) ) 
     680        return $is_post_type->hierarchical; 
     681         
     682    return false; 
    661683} 
    662684 
Note: See TracChangeset for help on using the changeset viewer.