Make WordPress Core

Ticket #24906: 24906.3.diff

File 24906.3.diff, 1.4 KB (added by nacin, 12 years ago)
  • src/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 the given formats, or any format.
    3636 *
    3737 * @since 3.1.0
    3838 *
    3939 * @uses has_term()
    4040 *
    41  * @param string|array $format The format or formats to check.
    42  * @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.
     41 * @param string|array $format Optional. The format or formats to check.
     42 * @param object|int $post Optional. 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 any of the given formats (or any format, if no format specified), false otherwise.
    4444 */
    45 function has_post_format( $format, $post = null ) {
    46         if ( ! is_array( $format ) )
    47                 $format = array( $format );
     45function has_post_format( $format = array(), $post = null ) {
     46        $prefixed = array();
    4847
    49         $prefixed = array();
    50         foreach( $format as $single ) {
    51                 $prefixed[] = 'post-format-' . sanitize_key( $single );
     48        if ( $format ) {
     49                foreach ( (array) $format as $single ) {
     50                        $prefixed[] = 'post-format-' . sanitize_key( $single );
     51                }
    5252        }
    5353
    5454        return has_term( $prefixed, 'post_format', $post );