Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/12/2021 02:09:02 PM (3 years ago)
Author:
imath
Message:

Support date queries for Members, Groups and Sites

According to components, date queries can be restricted to a limited list of loop types:

  • For Members, the $type parameter in bp_has_members() needs to be either active, newest, random or online.
  • For Groups, the $type parameter in bp_has_groups() needs to be either active or newest.
  • For sites, the $type parameter in bp_has_blogs() needs to be either active or newest.

Props r-a-y

Fixes #8488

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/classes/class-bp-notifications-notification.php

    r13147 r13184  
    849849     * We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
    850850     * of parsing the date_query array and creating the necessary SQL clauses.
    851      * However, since BP_Notifications_Notification::get() builds its SQL
    852      * differently than WP_Query, we have to alter the return value (stripping
    853      * the leading AND keyword from the query).
    854851     *
    855852     * @since 2.3.0
     
    860857     */
    861858    public static function get_date_query_sql( $date_query = array() ) {
    862 
    863         // Bail if not a proper date query format.
    864         if ( empty( $date_query ) || ! is_array( $date_query ) ) {
    865             return '';
    866         }
    867 
    868         // Date query.
    869         $date_query = new BP_Date_Query( $date_query, 'date_notified' );
    870 
    871         // Strip the leading AND - it's handled in get().
    872         return preg_replace( '/^\sAND/', '', $date_query->get_sql() );
     859        return BP_Date_Query::get_where_sql( $date_query, 'n.date_notified' );
    873860    }
    874861
Note: See TracChangeset for help on using the changeset viewer.