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-activity/classes/class-bp-activity-activity.php

    r13150 r13184  
    10331033     * We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
    10341034     * of parsing the date_query array and creating the necessary SQL clauses.
    1035      * However, since BP_Activity_Activity::get() builds its SQL differently than
    1036      * WP_Query, we have to alter the return value (stripping the leading AND
    1037      * keyword from the query).
    10381035     *
    10391036     * @since 2.1.0
     
    10441041     */
    10451042    public static function get_date_query_sql( $date_query = array() ) {
    1046         $sql = '';
    1047 
    1048         // Date query.
    1049         if ( ! empty( $date_query ) && is_array( $date_query ) ) {
    1050             $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
    1051             $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
    1052         }
    1053 
    1054         return $sql;
     1043        return BP_Date_Query::get_where_sql( $date_query, 'a.date_recorded' );
    10551044    }
    10561045
Note: See TracChangeset for help on using the changeset viewer.