WordPress.org

Make WordPress Core

Ticket #12950: is_post_type_hierarchical.diff

File is_post_type_hierarchical.diff, 944 bytes (added by ptahdunbar, 9 years ago)
  • wp-includes/post.php

     
    661661}
    662662
    663663/**
     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_post_type = get_post_type_object($post) )
     676                return $is_post_type->hierarchical;
     677       
     678        $ptype = get_post( $post, OBJECT );
     679        if ( $is_post_type = get_post_type_object($ptype->post_type) )
     680                return $is_post_type->hierarchical;
     681               
     682        return false;
     683}
     684
     685/**
    664686 * Retrieve the post type of the current post or of a given post.
    665687 *
    666688 * @since 2.1.0