From 02b214cd856e5495459f02835b41fb05bccc9d7c Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 28 Jul 2013 20:48:09 +0000 Subject: [PATCH] Allow has_post_format() to accept an array of formats to check. props ericmann. fixes #17320. git-svn-id: http://core.svn.wordpress.org/trunk@24817 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-formats.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/post-formats.php b/wp-includes/post-formats.php index 7fc11575be..a13de3eaa6 100644 --- a/wp-includes/post-formats.php +++ b/wp-includes/post-formats.php @@ -38,12 +38,20 @@ function get_post_format( $post = null ) { * * @uses has_term() * - * @param string $format The format to check for. - * @param object|int $post The post to check. If not supplied, defaults to the current post if used in the loop. + * @param string|array $format The format or formats to check. + * @param object|int $post The post to check. If not supplied, defaults to the current post if used in the loop. * @return bool True if the post has the format, false otherwise. */ function has_post_format( $format, $post = null ) { - return has_term('post-format-' . sanitize_key($format), 'post_format', $post); + if ( ! is_array( $format ) ) + $format = array( $format ); + + $prefixed = array(); + foreach( $format as $single ) { + $prefixed[] = 'post-format-' . sanitize_key( $single ); + } + + return has_term( $prefixed, 'post_format', $post ); } /**