]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/post-formats.php
WordPress 3.8
[autoinstalls/wordpress.git] / wp-includes / post-formats.php
index a13de3eaa6dcae552c16cfd83863df4a4b8da90b..cdb9da5d735a7c9f86f5c9c792a92fae85ca2844 100644 (file)
@@ -32,23 +32,23 @@ function get_post_format( $post = null ) {
 }
 
 /**
- * Check if a post has a particular format
+ * Check if a post has any of the given formats, or any format.
  *
  * @since 3.1.0
  *
  * @uses has_term()
  *
- * @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.
+ * @param string|array $format Optional. The format or formats to check.
+ * @param object|int $post Optional. The post to check. If not supplied, defaults to the current post if used in the loop.
+ * @return bool True if the post has any of the given formats (or any format, if no format specified), false otherwise.
  */
-function has_post_format( $format, $post = null ) {
-       if ( ! is_array( $format ) )
-               $format = array( $format );
-
+function has_post_format( $format = array(), $post = null ) {
        $prefixed = array();
-       foreach( $format as $single ) {
-               $prefixed[] = 'post-format-' . sanitize_key( $single );
+
+       if ( $format ) {
+               foreach ( (array) $format as $single ) {
+                       $prefixed[] = 'post-format-' . sanitize_key( $single );
+               }
        }
 
        return has_term( $prefixed, 'post_format', $post );