diff --git a/wp-includes/date.php b/wp-includes/date.php index 218fea26a0..5fade26fe6 100644 --- a/wp-includes/date.php +++ b/wp-includes/date.php @@ -60,13 +60,14 @@ class WP_Date_Query { * @access public * @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. * * @since 3.7.0 * @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 * * @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 $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 $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 $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. @@ -313,6 +316,12 @@ class WP_Date_Query { 'max' => 7 ); + // Days per week. + $min_max_checks['dayofweek_iso'] = array( + 'min' => 1, + 'max' => 7 + ); + // Months per year. $min_max_checks['month'] = array( 'min' => 1, @@ -727,6 +736,9 @@ class WP_Date_Query { if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) $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'] ) ) { // Avoid notices. foreach ( array( 'hour', 'minute', 'second' ) as $unit ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 82d6ca045f..514cdbe3ea 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.