BP_Activity_Activity::get_date_query_sql( array $date_query = array() )

Get the SQL for the ‘date_query’ param in BP_Activity_Activity::get().

Description

We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting of parsing the date_query array and creating the necessary SQL clauses. However, since BP_Activity_Activity::get() builds its SQL differently than WP_Query, we have to alter the return value (stripping the leading AND keyword from the query).

Parameters

$date_query

(Optional) An array of date_query parameters. See the documentation for the first parameter of WP_Date_Query.

Default value: array()

Return

(string)

Source

File: bp-activity/classes/class-bp-activity-activity.php

1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
public static function get_date_query_sql( $date_query = array() ) {
    $sql = '';
 
    // Date query.
    if ( ! empty( $date_query ) && is_array( $date_query ) ) {
        $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
        $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
    }
 
    return $sql;
}

Changelog

Changelog
Version Description
BuddyPress 2.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.