Changeset 14521 for trunk/wp-includes/post.php
- Timestamp:
- 05/08/2010 10:10:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r14507 r14521 667 667 * @see get_post_type_object 668 668 * 669 * @param string|int|object $post Post type name, post id, or a post object. 670 * @return bool true if post type is hierarchical, else false. 671 */ 672 function is_post_type_hierarchical( $post = false ) { 673 if ( is_string($post) && $is_post_type = get_post_type_object($post) ) 674 return $is_post_type->hierarchical; 675 676 $ptype = get_post( $post ); 677 if ( $ptype && $is_post_type = get_post_type_object($ptype->post_type) ) 678 return $is_post_type->hierarchical; 679 680 return false; 681 } 682 683 /** 684 * Checks if a post type is registered. Can also check if the current or specified post is of a post type. 669 * @param string $post Post type name 670 * @return bool Whether post type is hierarchical. 671 */ 672 function is_post_type_hierarchical( $post_type ) { 673 if ( ! is_post_type( $post_type ) ) 674 return false; 675 676 $post_type = get_post_type_object( $post_type ); 677 return $post_type->hierarchical; 678 } 679 680 /** 681 * Checks if a post type is registered. 685 682 * 686 683 * @since 3.0.0 687 684 * @uses get_post_type() 688 685 * 689 * @param string|array $types Type or types to check. Defaults to all post types. 690 * @param int $id Post ID. Defaults to current ID. 691 * @return bool 692 */ 693 function is_post_type( $types = false, $id = false ) { 694 if ( $id ) { 695 $types = ( $types === false ) ? get_post_types() : (array) $types; 696 697 return in_array( get_post_type( $id ), $types ); 698 } 699 700 return (bool) get_post_type_object($types); 686 * @param string Post type name 687 * @return bool Whether post type is registered. 688 */ 689 function is_post_type( $post_type ) { 690 return (bool) get_post_type_object( $post_type ); 701 691 } 702 692
Note: See TracChangeset
for help on using the changeset viewer.