Query: collapse several of the `is_*` methods using `__call()`. Add `@method` annotations.

Fixes #37830.

Built from https://develop.svn.wordpress.org/trunk@38356


git-svn-id: http://core.svn.wordpress.org/trunk@38297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2016-08-25 19:42:43 +00:00
parent 9ce58d9d86
commit faccc617fb
2 changed files with 21 additions and 157 deletions

View File

@ -14,6 +14,21 @@
*
* @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 {
@ -3381,20 +3396,12 @@ class WP_Query {
if ( in_array( $name, $this->compat_methods ) ) {
return call_user_func_array( array( $this, $name ), $arguments );
}
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;
if ( 'is_' === substr( $name, 0, 3 ) && property_exists( $this, $name ) ) {
return (bool) $this->{$name};
}
return false;
}
/**
@ -3604,28 +3611,6 @@ 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?
*
@ -3643,17 +3628,6 @@ 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?
*
@ -3700,17 +3674,6 @@ 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?
*
@ -3758,50 +3721,6 @@ 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?
*
@ -3873,61 +3792,6 @@ 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?
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38355';
$wp_version = '4.7-alpha-38356';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.