Introduced `dayofweek_iso` time param for `WP_Date_Query`.
The initial `dayofweek` param sets day 1 to Sunday. This is out of step with ISO standards, which calls Monday day 1. To maintain backward compatibility with the existing parameter, we introduce the new `dayofweek_iso` for the new, more compliant param. Props mboynes. Fixes #28063. Built from https://develop.svn.wordpress.org/trunk@30142 git-svn-id: http://core.svn.wordpress.org/trunk@30142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
96b42c2fdc
commit
92536aae65
|
@ -60,13 +60,14 @@ class WP_Date_Query {
|
||||||
* @access public
|
* @access public
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'hour', 'minute', 'second' );
|
public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
* @param array $date_query {
|
* @param array $date_query {
|
||||||
|
@ -116,7 +117,9 @@ class WP_Date_Query {
|
||||||
* @type int $week Optional. The week number of the year. Default empty. Accepts numbers 0-53.
|
* @type int $week Optional. The week number of the year. Default empty. Accepts numbers 0-53.
|
||||||
* @type int $dayofyear Optional. The day number of the year. Default empty. Accepts numbers 1-366.
|
* @type int $dayofyear Optional. The day number of the year. Default empty. Accepts numbers 1-366.
|
||||||
* @type int $day Optional. The day of the month. Default empty. Accepts numbers 1-31.
|
* @type int $day Optional. The day of the month. Default empty. Accepts numbers 1-31.
|
||||||
* @type int $dayofweek Optional. The day number of the week. Default empty. Accepts numbers 1-7.
|
* @type int $dayofweek Optional. The day number of the week. Default empty. Accepts numbers 1-7 (1 is Sunday).
|
||||||
|
* @type int $dayofweek_iso Optional. The day number of the week (ISO). Default empty.
|
||||||
|
* Accepts numbers 1-7 (1 is Monday).
|
||||||
* @type int $hour Optional. The hour of the day. Default empty. Accepts numbers 0-23.
|
* @type int $hour Optional. The hour of the day. Default empty. Accepts numbers 0-23.
|
||||||
* @type int $minute Optional. The minute of the hour. Default empty. Accepts numbers 0-60.
|
* @type int $minute Optional. The minute of the hour. Default empty. Accepts numbers 0-60.
|
||||||
* @type int $second Optional. The second of the minute. Default empty. Accepts numbers 0-60.
|
* @type int $second Optional. The second of the minute. Default empty. Accepts numbers 0-60.
|
||||||
|
@ -313,6 +316,12 @@ class WP_Date_Query {
|
||||||
'max' => 7
|
'max' => 7
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Days per week.
|
||||||
|
$min_max_checks['dayofweek_iso'] = array(
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 7
|
||||||
|
);
|
||||||
|
|
||||||
// Months per year.
|
// Months per year.
|
||||||
$min_max_checks['month'] = array(
|
$min_max_checks['month'] = array(
|
||||||
'min' => 1,
|
'min' => 1,
|
||||||
|
@ -727,6 +736,9 @@ class WP_Date_Query {
|
||||||
if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) )
|
if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) )
|
||||||
$where_parts[] = "DAYOFWEEK( $column ) $compare $value";
|
$where_parts[] = "DAYOFWEEK( $column ) $compare $value";
|
||||||
|
|
||||||
|
if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) )
|
||||||
|
$where_parts[] = "WEEKDAY( $column ) + 1 $compare $value";
|
||||||
|
|
||||||
if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) {
|
if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) {
|
||||||
// Avoid notices.
|
// Avoid notices.
|
||||||
foreach ( array( 'hour', 'minute', 'second' ) as $unit ) {
|
foreach ( array( 'hour', 'minute', 'second' ) as $unit ) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.1-alpha-30141';
|
$wp_version = '4.1-alpha-30142';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue