Make WordPress Core

Ticket #23749: 23749.diff

File 23749.diff, 1.2 KB (added by helen, 11 years ago)
  • src/wp-includes/query.php

     
    292292}
    293293
    294294/**
     295 * Is the query for a post format archive page?
     296 *
     297 * If the $format parameter is specified, this function will check
     298 * if the query is for one of the formats.
     299 * specified.
     300 *
     301 * @since 3.9.0
     302 * @uses $wp_query
     303 *
     304 * @param mixed $format Optional. Format slug or array of format slugs, without the post-format prefix.
     305 * @return bool
     306 */
     307function is_post_format_archive( $format = '' ) {
     308        global $wp_query;
     309
     310        if ( ! isset( $wp_query ) ) {
     311                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     312                return false;
     313        }
     314
     315        if ( ! empty( $format ) ) {
     316                if ( is_array( $format ) ) {
     317                        foreach ( $format as &$value ) {
     318                                $value = 'post-format-' . $value;
     319                        }
     320                } else {
     321                        $format = 'post-format-' . $format;
     322                }
     323        }
     324
     325        return $wp_query->is_tax( 'post_format', $format );
     326}
     327
     328/**
    295329 * Whether the current URL is within the comments popup window.
    296330 *
    297331 * @see WP_Query::is_comments_popup()