Make WordPress Core

Ticket #17320: 17320.2.diff

File 17320.2.diff, 1.2 KB (added by obenland, 11 years ago)
  • wp-includes/post-formats.php

     
    3232}
    3333
    3434/**
    35  * Check if a post has a particular format
     35 * Check if a post has any of given formats or any format at all.
    3636 *
    3737 * @since 3.1.0
    3838 *
     
    4040 *
    4141 * @param string|array $format The format or formats to check.
    4242 * @param object|int   $post   The post to check. If not supplied, defaults to the current post if used in the loop.
    43  * @return bool True if the post has the format, false otherwise.
     43 * @return bool True if the post has any of the given formats (or any format, if no format specified), false otherwise.
    4444 */
    45 function has_post_format( $format, $post = null ) {
     45function has_post_format( $format = array(), $post = null ) {
    4646        if ( ! is_array( $format ) )
    4747                $format = array( $format );
    4848
    4949        $prefixed = array();
    50         foreach( $format as $single ) {
    51                 $prefixed[] = 'post-format-' . sanitize_key( $single );
     50        foreach ( $format as $single ) {
     51                if ( ! empty( $single ) )
     52                        $prefixed[] = 'post-format-' . sanitize_key( $single );
    5253        }
    5354
    5455        return has_term( $prefixed, 'post_format', $post );