Clarify inline documentation for `WP_Date_Query` to better explain the relationship between an individual clause's 'compare' argument and various integer-based date arguments.

If the 'compare' argument equals 'IN' or 'NOT IN', arrays of any number of specific, valid values are accepted and simply considered based on the value of 'operator' (OR or AND). If the 'compare' argument is a range such as 'BETWEEN' or 'NOT BETWEEN', arrays of only two valid values are accepted.
 
Props boonebgorges.
Fixes #31036.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2015-02-05 06:17:21 +00:00
parent 27aa3e92d7
commit 10eb2173c0
2 changed files with 55 additions and 43 deletions

View File

@ -65,6 +65,11 @@ class WP_Date_Query {
/** /**
* Constructor. * Constructor.
* *
* Time-related parameters that normally require integer values ('year', 'month', 'week', 'dayofyear', 'day',
* 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second') accept arrays of integers for some values of
* 'compare'. When 'compare' is 'IN' or 'NOT IN', arrays are accepted; when 'compare' is 'BETWEEN' or 'NOT
* BETWEEN', arrays of two valid values are required. See individual argument descriptions for accepted values.
*
* @since 3.7.0 * @since 3.7.0
* @since 4.0.0 The $inclusive logic was updated to include all times within the date range. * @since 4.0.0 The $inclusive logic was updated to include all times within the date range.
* @since 4.1.0 Introduced 'dayofweek_iso' time type parameter. * @since 4.1.0 Introduced 'dayofweek_iso' time type parameter.
@ -75,18 +80,19 @@ class WP_Date_Query {
* *
* @type array { * @type array {
* @type string $column Optional. The column to query against. If undefined, inherits the value of * @type string $column Optional. The column to query against. If undefined, inherits the value of
* the $default_column parameter. Default 'post_date'. Accepts 'post_date', * the `$default_column` parameter. Accepts 'post_date', 'post_date_gmt',
* 'post_date_gmt', 'post_modified','post_modified_gmt', 'comment_date', * 'post_modified','post_modified_gmt', 'comment_date', 'comment_date_gmt'.
* 'comment_date_gmt'. * Default 'post_date'.
* @type string $compare Optional. The comparison operator. Default '='. * @type string $compare Optional. The comparison operator. Accepts '=', '!=', '>', '>=', '<', '<=',
* Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. * 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default '='.
* @type string $relation Optional. The boolean relationship between the date queries. Default 'OR'. * @type string $relation Optional. The boolean relationship between the date queries. Accepts 'OR' or 'AND'.
* Accepts 'OR', 'AND'. * Default 'OR'.
* @type array { * @type array {
* Optional. An array of first-order clause parameters, or another fully-formed date query. * Optional. An array of first-order clause parameters, or another fully-formed date query.
* *
* @type string|array $before Optional. Date to retrieve posts before. Accepts strtotime()-compatible * @type string|array $before {
* string, or array of 'year', 'month', 'day' values. { * Optional. Date to retrieve posts before. Accepts `strtotime()`-compatible string,
* or array of 'year', 'month', 'day' values.
* *
* @type string $year The four-digit year. Default empty. Accepts any four-digit year. * @type string $year The four-digit year. Default empty. Accepts any four-digit year.
* @type string $month Optional when passing array.The month of the year. * @type string $month Optional when passing array.The month of the year.
@ -94,43 +100,49 @@ class WP_Date_Query {
* @type string $day Optional when passing array.The day of the month. * @type string $day Optional when passing array.The day of the month.
* Default (string:empty)|(array:1). Accepts numbers 1-31. * Default (string:empty)|(array:1). Accepts numbers 1-31.
* } * }
* @type string|array $after Optional. Date to retrieve posts after. Accepts strtotime()-compatible * @type string|array $after {
* string, or array of 'year', 'month', 'day' values. { * Optional. Date to retrieve posts after. Accepts `strtotime()`-compatible string,
* or array of 'year', 'month', 'day' values.
* *
* @type string $year The four-digit year. Default empty. Accepts any four-digit year. * @type string $year The four-digit year. Accepts any four-digit year. Default empty.
* @type string $month Optional when passing array.The month of the year. * @type string $month Optional when passing array. The month of the year. Accepts numbers 1-12.
* Default (string:empty)|(array:12). Accepts numbers 1-12. * Default (string:empty)|(array:12).
* @type string $day Optional when passing array.The day of the month. * @type string $day Optional when passing array.The day of the month. Accepts numbers 1-31.
* Default (string:empty)|(array:last day of month). Accepts numbers 1-31. * Default (string:empty)|(array:last day of month).
* } * }
* @type string $column Optional. Used to add a clause comparing a column other than the column * @type string $column Optional. Used to add a clause comparing a column other than the
* specified in the top-level $column parameter. Default is the value * column specified in the top-level `$column` parameter. Accepts
* of top-level $column. Accepts 'post_date', 'post_date_gmt', * 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt',
* 'post_modified', 'post_modified_gmt', 'comment_date', 'comment_date_gmt'. * 'comment_date', 'comment_date_gmt'. Default is the value of
* @type string $compare Optional. The comparison operator. Default '='. * top-level `$column`.
* Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', * @type string $compare Optional. The comparison operator. Accepts '=', '!=', '>', '>=',
* 'BETWEEN', 'NOT BETWEEN'. * '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. 'IN',
* 'NOT IN', 'BETWEEN', and 'NOT BETWEEN'. Comparisons support
* arrays in some time-related parameters. Default '='.
* @type bool $inclusive Optional. Include results from dates specified in 'before' or * @type bool $inclusive Optional. Include results from dates specified in 'before' or
* 'after'. Default false. * 'after'. Default false.
* @type int $year Optional. The four-digit year number. Default empty. Accepts * @type int|array $year Optional. The four-digit year number. Accepts any four-digit year
* any four-digit year. * or an array of years if `$compare` supports it. Default empty.
* @type int $month Optional. The two-digit month number. Default empty. * @type int|array $month Optional. The two-digit month number. Accepts numbers 1-12 or an
* Accepts numbers 1-12. * array of valid numbers if `$compare` supports it. Default empty.
* @type int $week Optional. The week number of the year. Default empty. * @type int|array $week Optional. The week number of the year. Accepts numbers 0-53 or an
* Accepts numbers 0-53. * array of valid numbers if `$compare` supports it. Default empty.
* @type int $dayofyear Optional. The day number of the year. Default empty. * @type int|array $dayofyear Optional. The day number of the year. Accepts numbers 1-366 or an
* Accepts numbers 1-366. * array of valid numbers if `$compare` supports it.
* @type int $day Optional. The day of the month. Default empty. * @type int|array $day Optional. The day of the month. Accepts numbers 1-31 or an array
* Accepts numbers 1-31. * of valid numbers if `$compare` supports it. Default empty.
* @type int $dayofweek Optional. The day number of the week. Default empty. * @type int|array $dayofweek Optional. The day number of the week. Accepts numbers 1-7 (1 is
* Accepts numbers 1-7 (1 is Sunday). * Sunday) or an array of valid numbers if `$compare` supports it.
* @type int $dayofweek_iso Optional. The day number of the week (ISO). Accepts numbers 1-7 * Default empty.
* (1 is Monday). Default empty. * @type int|array $dayofweek_iso Optional. The day number of the week (ISO). Accepts numbers 1-7
* @type int $hour Optional. The hour of the day. Default empty. Accepts numbers 0-23. * (1 is Monday) or an array of valid numbers if `$compare` supports it.
* @type int $minute Optional. The minute of the hour. Default empty. Accepts * Default empty.
* numbers 0-60. * @type int|array $hour Optional. The hour of the day. Accepts numbers 0-23 or an array
* @type int $second Optional. The second of the minute. Default empty. * of valid numbers if `$compare` supports it. Default empty.
* Accepts numbers 0-60. * @type int|array $minute Optional. The minute of the hour. Accepts numbers 0-60 or an array
* of valid numbers if `$compare` supports it. Default empty.
* @type int|array $second Optional. The second of the minute. Accepts numbers 0-60 or an
* array of valid numbers if `$compare` supports it. Default empty.
* } * }
* } * }
* } * }

View File

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