Ticket #12588: is_post_of_type.diff
File is_post_of_type.diff, 1.2 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
681 681 } 682 682 683 683 /** 684 * Check s if a post type is registered. Can also check if the current or specified post is of a post type.684 * Check if a post type is registered. 685 685 * 686 686 * @since 3.0.0 687 * @uses get_post_type_object() 688 * 689 * @param string $types Type to check. 690 * @return bool 691 */ 692 function is_post_type( $type ) { 693 return (bool) get_post_type_object($type); 694 } 695 696 /** 697 * Check if the current or specified post is of a given post type. 698 * 699 * @since 3.0.0 687 700 * @uses get_post_type() 688 701 * 689 * @param string|array $types Type or types to check. Defaults to all post types.702 * @param string|array $types Type or types to check. 690 703 * @param int $id Post ID. Defaults to current ID. 691 704 * @return bool 692 705 */ 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); 706 function is_post_of_type( $types, $id = false ) { 707 return in_array( get_post_type( $id ), (array) $types ); 701 708 } 702 709 703 710 /**