Make WordPress Core

Ticket #12588: 12588.diff

File 12588.diff, 699 bytes (added by rmccue, 15 years ago)

nacin's patch, plus a workaround for get_post_type() bug

  • post.php

     
    661661}
    662662
    663663/**
     664 * Check if the current or specified post is a post type
     665 *
     666 * @since 3.0
     667 * @uses $post
     668 * @uses get_post_type()
     669 *
     670 * @param string|array $types Type or types to check.
     671 * @param int $id Post ID. Defaults to current ID.
     672 * @return bool
     673 */
     674function is_post_type( $types, $id = null ) {
     675        global $post;
     676
     677        $id = ( null === $id )  ? $post->ID : $id;
     678
     679        return in_array( get_post_type( $id ), (array) $types );
     680}
     681
     682/**
    664683 * Retrieve the post type of the current post or of a given post.
    665684 *
    666685 * @since 2.1.0