diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index de7c7b9da1..0ca0572b9d 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -14,21 +14,6 @@ * * @since 1.5.0 * @since 4.5.0 Removed the `$comments_popup` property. - * - * @method bool is_archive() Is the query for an existing archive page? Month, Year, Category, Author, Post Type archive... - * @method bool is_date() Is the query for an existing date archive? - * @method bool is_day() Is the query for an existing day archive? - * @method bool is_comment_feed() Is the query for a comments feed? - * @method bool is_month() Is the query for an existing month archive? - * @method bool is_paged() Is the query for paged result and not for the first page? - * @method bool is_preview() Is the query for a post or page preview? - * @method bool is_robots() Is the query for the robots file? - * @method bool is_search() Is the query for a search? - * @method bool is_time() Is the query for a specific time? - * @method bool is_trackback() Is the query for a trackback endpoint call? - * @method bool is_year() Is the query for an existing year archive? - * @method bool is_404() Is the query a 404 (returns no results)? - * @method bool is_embed() Is the query for an embedded post? */ class WP_Query { @@ -3396,14 +3381,22 @@ class WP_Query { if ( in_array( $name, $this->compat_methods ) ) { return call_user_func_array( array( $this, $name ), $arguments ); } - - if ( 'is_' === substr( $name, 0, 3 ) && property_exists( $this, $name ) ) { - return (bool) $this->{$name}; - } - return false; } + /** + * Is the query for an existing archive page? + * + * Month, Year, Category, Author, Post Type archive... + * + * @since 3.1.0 + * + * @return bool + */ + public function is_archive() { + return (bool) $this->is_archive; + } + /** * Is the query for an existing post type archive page? * @@ -3611,6 +3604,28 @@ class WP_Query { return false; } + /** + * Is the query for an existing date archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_date() { + return (bool) $this->is_date; + } + + /** + * Is the query for an existing day archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_day() { + return (bool) $this->is_day; + } + /** * Is the query for a feed? * @@ -3628,6 +3643,17 @@ class WP_Query { return in_array( $qv, (array) $feeds ); } + /** + * Is the query for a comments feed? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_comment_feed() { + return (bool) $this->is_comment_feed; + } + /** * Is the query for the front page of the site? * @@ -3674,6 +3700,17 @@ class WP_Query { return (bool) $this->is_home; } + /** + * Is the query for an existing month archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_month() { + return (bool) $this->is_month; + } + /** * Is the query for an existing single page? * @@ -3721,6 +3758,50 @@ class WP_Query { return false; } + /** + * Is the query for paged result and not for the first page? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_paged() { + return (bool) $this->is_paged; + } + + /** + * Is the query for a post or page preview? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_preview() { + return (bool) $this->is_preview; + } + + /** + * Is the query for the robots file? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_robots() { + return (bool) $this->is_robots; + } + + /** + * Is the query for a search? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_search() { + return (bool) $this->is_search; + } + /** * Is the query for an existing single post? * @@ -3792,6 +3873,61 @@ class WP_Query { return in_array( $post_obj->post_type, (array) $post_types ); } + /** + * Is the query for a specific time? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_time() { + return (bool) $this->is_time; + } + + /** + * Is the query for a trackback endpoint call? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_trackback() { + return (bool) $this->is_trackback; + } + + /** + * Is the query for an existing year archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_year() { + return (bool) $this->is_year; + } + + /** + * Is the query a 404 (returns no results)? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_404() { + return (bool) $this->is_404; + } + + /** + * Is the query for an embedded post? + * + * @since 4.4.0 + * + * @return bool + */ + public function is_embed() { + return (bool) $this->is_embed; + } + /** * Is the query the main query? *