/**
* Class for generating SQL clauses that filter a primary query according to date.
*
- * `WP_Date_Query` is a helper that allows primary query classes, such as {@see WP_Query},
- * to filter their results by date columns, by generating `WHERE` subclauses to be attached
- * to the primary SQL query string.
+ * WP_Date_Query is a helper that allows primary query classes, such as WP_Query, to filter
+ * their results by date columns, by generating `WHERE` subclauses to be attached to the
+ * primary SQL query string.
*
* Attempting to filter by an invalid date value (eg month=13) will generate SQL that will
* return no results. In these cases, a _doing_it_wrong() error notice is also thrown.
- * See {@link WP_Date_Query::validate_date_values()}.
+ * See WP_Date_Query::validate_date_values().
*
* @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page.
*
/**
* Array of date queries.
*
- * See {@see WP_Date_Query::__construct()} for information on date query arguments.
+ * See WP_Date_Query::__construct() for information on date query arguments.
*
* @since 3.7.0
* @access public
* 'comment_date', 'comment_date_gmt'.
*/
public function __construct( $date_query, $default_column = 'post_date' ) {
-
if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
$this->relation = 'OR';
} else {
$valid_columns = array(
'post_date', 'post_date_gmt', 'post_modified',
'post_modified_gmt', 'comment_date', 'comment_date_gmt',
- 'user_registered',
+ 'user_registered', 'registered', 'last_updated',
);
// Attempt to detect a table prefix.
if ( false === strpos( $column, '.' ) ) {
/**
- * Filter the list of valid date query columns.
+ * Filters the list of valid date query columns.
*
* @since 3.7.0
* @since 4.1.0 Added 'user_registered' to the default recognized columns.
$wpdb->users => array(
'user_registered',
),
+ $wpdb->blogs => array(
+ 'registered',
+ 'last_updated',
+ ),
);
// If it's a known column name, add the appropriate table prefix.
$where = $sql['where'];
/**
- * Filter the date query WHERE clause.
+ * Filters the date query WHERE clause.
*
* @since 3.7.0
*
/**
* Generate SQL clauses to be appended to a main query.
*
- * Called by the public {@see WP_Date_Query::get_sql()}, this method
- * is abstracted out to maintain parity with the other Query classes.
+ * Called by the public WP_Date_Query::get_sql(), this method is abstracted
+ * out to maintain parity with the other Query classes.
*
* @since 4.1.0
* @access protected
}
// Range queries.
- if ( ! empty( $query['after'] ) )
+ if ( ! empty( $query['after'] ) ) {
$where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );
-
- if ( ! empty( $query['before'] ) )
+ }
+ if ( ! empty( $query['before'] ) ) {
$where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );
-
+ }
// Specific value queries.
if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) )