WordPress.org

Make WordPress Core

Ticket #12588: is_post_type.diff

File is_post_type.diff, 891 bytes (added by scribu, 4 years ago)
  • wp-includes/post.php

     
    667667} 
    668668 
    669669/** 
    670  * Checks if a post type is registered, can also check if the current or specified post is of a post type. 
     670 * Checks if a post type is registered. Can also check if the current or specified post is of a post type. 
    671671 * 
    672672 * @since 3.0.0 
    673673 * @uses get_post_type() 
     
    677677 * @return bool 
    678678 */ 
    679679function is_post_type( $types = false, $id = false ) { 
    680         $types = ( $types === false ) ? get_post_types() : (array) $types; 
    681         return in_array( get_post_type( $id ), $types ); 
     680        if ( $id ) { 
     681                $types = ( $types === false ) ? get_post_types() : (array) $types; 
     682 
     683                return in_array( get_post_type( $id ), $types ); 
     684        } 
     685 
     686        return (bool) get_post_type_object($types); 
    682687} 
    683688 
    684689/**