Ticket #24906: 24906.3.diff
File 24906.3.diff, 1.4 KB (added by , 12 years ago) |
---|
-
src/wp-includes/post-formats.php
32 32 } 33 33 34 34 /** 35 * Check if a post has a particular format35 * Check if a post has any of the given formats, or any format. 36 36 * 37 37 * @since 3.1.0 38 38 * 39 39 * @uses has_term() 40 40 * 41 * @param string|array $format The format or formats to check.42 * @param object|int $postThe 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. 44 44 */ 45 function has_post_format( $format, $post = null ) { 46 if ( ! is_array( $format ) ) 47 $format = array( $format ); 45 function has_post_format( $format = array(), $post = null ) { 46 $prefixed = array(); 48 47 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 } 52 52 } 53 53 54 54 return has_term( $prefixed, 'post_format', $post );