Make WordPress Core

Changeset 24817


Ignore:
Timestamp:
07/28/2013 08:48:09 PM (10 years ago)
Author:
nacin
Message:

Allow has_post_format() to accept an array of formats to check. props ericmann. fixes #17320.

File:
1 edited

Legend:

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

    r24693 r24817  
    3939 * @uses has_term()
    4040 *
    41  * @param string $format The format to check for.
    42  * @param object|int $post The post to check. If not supplied, defaults to the current post if used in the loop.
     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.
    4343 * @return bool True if the post has the format, false otherwise.
    4444 */
    4545function has_post_format( $format, $post = null ) {
    46     return has_term('post-format-' . sanitize_key($format), 'post_format', $post);
     46    if ( ! is_array( $format ) )
     47        $format = array( $format );
     48
     49    $prefixed = array();
     50    foreach( $format as $single ) {
     51        $prefixed[] = 'post-format-' . sanitize_key( $single );
     52    }
     53
     54    return has_term( $prefixed, 'post_format', $post );
    4755}
    4856
Note: See TracChangeset for help on using the changeset viewer.