+
+ /**
+ * Is the query for an archive page?
+ *
+ * Month, Year, Category, Author, Post Type archive...
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_archive() {
+ return (bool) $this->is_archive;
+ }
+
+ /**
+ * Is the query for a post type archive page?
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $post_types Optional. Post type or array of posts types to check against.
+ * @return bool
+ */
+ function is_post_type_archive( $post_types = '' ) {
+ if ( empty( $post_types ) || !$this->is_post_type_archive )
+ return (bool) $this->is_post_type_archive;
+
+ $post_type_object = $this->get_queried_object();
+
+ return in_array( $post_type_object->name, (array) $post_types );
+ }
+
+ /**
+ * Is the query for an attachment page?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_attachment() {
+ return (bool) $this->is_attachment;
+ }
+
+ /**
+ * Is the query for an author archive page?
+ *
+ * If the $author parameter is specified, this function will additionally
+ * check if the query is for one of the authors specified.
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
+ * @return bool
+ */
+ function is_author( $author = '' ) {
+ if ( !$this->is_author )
+ return false;
+
+ if ( empty($author) )
+ return true;
+
+ $author_obj = $this->get_queried_object();
+
+ $author = (array) $author;
+
+ if ( in_array( $author_obj->ID, $author ) )
+ return true;
+ elseif ( in_array( $author_obj->nickname, $author ) )
+ return true;
+ elseif ( in_array( $author_obj->user_nicename, $author ) )
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Is the query for a category archive page?
+ *
+ * If the $category parameter is specified, this function will additionally
+ * check if the query is for one of the categories specified.
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
+ * @return bool
+ */
+ function is_category( $category = '' ) {
+ if ( !$this->is_category )
+ return false;
+
+ if ( empty($category) )
+ return true;
+
+ $cat_obj = $this->get_queried_object();
+
+ $category = (array) $category;
+
+ if ( in_array( $cat_obj->term_id, $category ) )
+ return true;
+ elseif ( in_array( $cat_obj->name, $category ) )
+ return true;
+ elseif ( in_array( $cat_obj->slug, $category ) )
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Is the query for a tag archive page?
+ *
+ * If the $tag parameter is specified, this function will additionally
+ * check if the query is for one of the tags specified.
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $slug Optional. Tag slug or array of slugs.
+ * @return bool
+ */
+ function is_tag( $slug = '' ) {
+ if ( !$this->is_tag )
+ return false;
+
+ if ( empty( $slug ) )
+ return true;
+
+ $tag_obj = $this->get_queried_object();
+
+ $slug = (array) $slug;
+
+ if ( in_array( $tag_obj->slug, $slug ) )
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Is the query for a taxonomy archive page?
+ *
+ * If the $taxonomy parameter is specified, this function will additionally
+ * check if the query is for that specific $taxonomy.
+ *
+ * If the $term parameter is specified in addition to the $taxonomy parameter,
+ * this function will additionally check if the query is for one of the terms
+ * specified.
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $taxonomy Optional. Taxonomy slug or slugs.
+ * @param mixed $term. Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
+ * @return bool
+ */
+ function is_tax( $taxonomy = '', $term = '' ) {
+ global $wp_taxonomies;
+
+ if ( !$this->is_tax )
+ return false;
+
+ if ( empty( $taxonomy ) )
+ return true;
+
+ $queried_object = $this->get_queried_object();
+ $tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy );
+ $term_array = (array) $term;
+
+ if ( empty( $term ) ) // Only a Taxonomy provided
+ return isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array );
+
+ return isset( $queried_object->term_id ) &&
+ count( array_intersect(
+ array( $queried_object->term_id, $queried_object->name, $queried_object->slug ),
+ $term_array
+ ) );
+ }
+
+ /**
+ * Whether the current URL is within the comments popup window.
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_comments_popup() {
+ return (bool) $this->is_comments_popup;
+ }
+
+ /**
+ * Is the query for a date archive?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_date() {
+ return (bool) $this->is_date;
+ }
+
+ /**
+ * Is the query for a day archive?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_day() {
+ return (bool) $this->is_day;
+ }
+
+ /**
+ * Is the query for a feed?
+ *
+ * @since 3.1.0
+ *
+ * @param string|array $feeds Optional feed types to check.
+ * @return bool
+ */
+ function is_feed( $feeds = '' ) {
+ if ( empty( $feeds ) || ! $this->is_feed )
+ return (bool) $this->is_feed;
+ $qv = $this->get( 'feed' );
+ if ( 'feed' == $qv )
+ $qv = get_default_feed();
+ return in_array( $qv, (array) $feeds );
+ }
+
+ /**
+ * Is the query for a comments feed?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_comment_feed() {
+ return (bool) $this->is_comment_feed;
+ }
+
+ /**
+ * Is the query for the front page of the site?
+ *
+ * This is for what is displayed at your site's main URL.
+ *
+ * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'.
+ *
+ * If you set a static page for the front page of your site, this function will return
+ * true when viewing that page.
+ *
+ * Otherwise the same as @see WP_Query::is_home()
+ *
+ * @since 3.1.0
+ * @uses is_home()
+ * @uses get_option()
+ *
+ * @return bool True, if front of site.
+ */
+ function is_front_page() {
+ // most likely case
+ if ( 'posts' == get_option( 'show_on_front') && $this->is_home() )
+ return true;
+ elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * Is the query for the blog homepage?
+ *
+ * This is the page which shows the time based blog content of your site.
+ *
+ * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'.
+ *
+ * If you set a static page for the front page of your site, this function will return
+ * true only on the page you set as the "Posts page".
+ *
+ * @see WP_Query::is_front_page()
+ *
+ * @since 3.1.0
+ *
+ * @return bool True if blog view homepage.
+ */
+ function is_home() {
+ return (bool) $this->is_home;
+ }
+
+ /**
+ * Is the query for a month archive?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_month() {
+ return (bool) $this->is_month;
+ }
+
+ /**
+ * Is the query for a single page?
+ *
+ * If the $page parameter is specified, this function will additionally
+ * check if the query is for one of the pages specified.
+ *
+ * @see WP_Query::is_single()
+ * @see WP_Query::is_singular()
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $page Page ID, title, slug, or array of such.
+ * @return bool
+ */
+ function is_page( $page = '' ) {
+ if ( !$this->is_page )
+ return false;
+
+ if ( empty( $page ) )
+ return true;
+
+ $page_obj = $this->get_queried_object();
+
+ $page = (array) $page;
+
+ if ( in_array( $page_obj->ID, $page ) )
+ return true;
+ elseif ( in_array( $page_obj->post_title, $page ) )
+ return true;
+ else if ( in_array( $page_obj->post_name, $page ) )
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Is the query for paged result and not for the first page?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_paged() {
+ return (bool) $this->is_paged;
+ }
+
+ /**
+ * Is the query for a post or page preview?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_preview() {
+ return (bool) $this->is_preview;
+ }
+
+ /**
+ * Is the query for the robots file?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_robots() {
+ return (bool) $this->is_robots;
+ }
+
+ /**
+ * Is the query for a search?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_search() {
+ return (bool) $this->is_search;
+ }
+
+ /**
+ * Is the query for a single post?
+ *
+ * Works for any post type, except attachments and pages
+ *
+ * If the $post parameter is specified, this function will additionally
+ * check if the query is for one of the Posts specified.
+ *
+ * @see WP_Query::is_page()
+ * @see WP_Query::is_singular()
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $post Post ID, title, slug, or array of such.
+ * @return bool
+ */
+ function is_single( $post = '' ) {
+ if ( !$this->is_single )
+ return false;
+
+ if ( empty($post) )
+ return true;
+
+ $post_obj = $this->get_queried_object();
+
+ $post = (array) $post;
+
+ if ( in_array( $post_obj->ID, $post ) )
+ return true;
+ elseif ( in_array( $post_obj->post_title, $post ) )
+ return true;
+ elseif ( in_array( $post_obj->post_name, $post ) )
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Is the query for a single post of any post type (post, attachment, page, ... )?
+ *
+ * If the $post_types parameter is specified, this function will additionally
+ * check if the query is for one of the Posts Types specified.
+ *
+ * @see WP_Query::is_page()
+ * @see WP_Query::is_single()
+ *
+ * @since 3.1.0
+ *
+ * @param mixed $post_types Optional. Post Type or array of Post Types
+ * @return bool
+ */
+ function is_singular( $post_types = '' ) {
+ if ( empty( $post_types ) || !$this->is_singular )
+ return (bool) $this->is_singular;
+
+ $post_obj = $this->get_queried_object();
+
+ return in_array( $post_obj->post_type, (array) $post_types );
+ }
+
+ /**
+ * Is the query for a specific time?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_time() {
+ return (bool) $this->is_time;
+ }
+
+ /**
+ * Is the query for a trackback endpoint call?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_trackback() {
+ return (bool) $this->is_trackback;
+ }
+
+ /**
+ * Is the query for a specific year?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_year() {
+ return (bool) $this->is_year;
+ }
+
+ /**
+ * Is the query a 404 (returns no results)?
+ *
+ * @since 3.1.0
+ *
+ * @return bool
+ */
+ function is_404() {
+ return (bool) $this->is_404;
+ }
+
+ /**
+ * Is the query the main query?
+ *
+ * @since 3.3.0
+ *
+ * @return bool
+ */
+ function is_main_query() {
+ global $wp_the_query;
+ return $wp_the_query === $this;
+ }