WordPress.org

Make WordPress Core

Ticket #12588: 12588.simple.diff

File 12588.simple.diff, 1.8 KB (added by nacin, 8 years ago)

Aligns is_post_type and is_post_type_hierarchical with the taxonomy counterparts.

  • wp-includes/post.php

     
    666666 * @since 3.0.0
    667667 * @see get_post_type_object
    668668 *
    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.
     669 * @param string $post Post type name
     670 * @return bool Whether post type is hierarchical.
    671671 */
    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;
     672function is_post_type_hierarchical( $post_type ) {
     673        if ( ! is_post_type( $post_type ) )
     674                return false;
    675675
    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;
     676        $post_type = get_post_type_object( $post_type );
     677        return $is_post_type->hierarchical;
    681678}
    682679
    683680/**
    684  * Checks if a post type is registered. Can also check if the current or specified post is of a post type.
     681 * Checks if a post type is registered.
    685682 *
    686683 * @since 3.0.0
    687684 * @uses get_post_type()
    688685 *
    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
     686 * @param string Post type name
     687 * @return bool Whether post type is registered.
    692688 */
    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);
     689function is_post_type( $post_type ) {
     690        return (bool) get_post_type_object( $post_type );
    701691}
    702692
    703693/**