WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32115 closed enhancement (invalid)

Extend functionality of WP_Date_Query beyond core tables

Reported by: transom 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)

date_query_known_columns.diff (637 bytes) - added by transom 4 years ago.
Add filter to known_columns in wp-includes/date.php WP_Date_Query/validate_column
date_query_known_columns.2.diff (1.1 KB) - added by transom 4 years ago.
Duh - Add the phpdoc

Download all attachments as: .zip

Change History (6)

@transom
4 years ago

Add filter to known_columns in wp-includes/date.php WP_Date_Query/validate_column

@transom
4 years ago

Duh - Add the phpdoc

#1 @boonebgorges
4 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,
    ),
) );

#2 @transom
4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

OK - I will now accept my dunce cap for the day - I just re-read the code.

To callback to an old SNL skit - Never mind!

#3 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted

#4 @boonebgorges
4 years ago

OK - I will now accept my dunce cap for the day - I just re-read the code.

Let me know when you're done with that dunce cap - I'm usually the one who wears it.

Note: See TracTickets for help on using tickets.