#32115 closed enhancement (invalid)
Extend functionality of WP_Date_Query beyond core tables
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.3 |
| Component: | Date/Time | Keywords: | |
| Focuses: | Cc: |
Description
Class WP_Date_Query in wp-includes/date.php already allows filtering of the valid columns. But when constructing the query limits the output to the known data fields in the core tables. The attached patch adds a filter over the known_columns so that the entire class can be used to generate SQL clauses on tables beyond the core tables.
Yes, the class could be extended with the validate_column method overloaded but why??
Attachments (2)
Change History (6)
#1
@
11 years ago
Can you explain how 'date_query_valid_columns' doesn't already allow this?
function wp32115_add_valid_date_column( $cols ) {
$cols[] = 'foo';
return $cols;
}
add_filter( 'date_query_valid_columns', 'wp32115_add_valid_date_column' );
$date_query = new WP_Date_Query( array(
array(
'column' => 'foo',
'year' => 2015,
),
) );
Note: See
TracTickets for help on using
tickets.
Add filter to known_columns in wp-includes/date.php WP_Date_Query/validate_column