Make WordPress Core

Changeset 14498


Ignore:
Timestamp:
05/07/2010 04:57:23 AM (13 years ago)
Author:
nacin
Message:

Fix to is_post_type. props scribu, fixes #12588.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r14487 r14498  
    682682
    683683/**
    684  * Checks if a post type is registered, can also check if the current or specified post is of a post type.
     684 * Checks if a post type is registered. Can also check if the current or specified post is of a post type.
    685685 *
    686686 * @since 3.0.0
     
    692692 */
    693693function is_post_type( $types = false, $id = false ) {
    694     $types = ( $types === false ) ? get_post_types() : (array) $types;
    695     return in_array( get_post_type( $id ), $types );
     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);
    696701}
    697702
Note: See TracChangeset for help on using the changeset viewer.