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

    r13129 r13184  
    10201020     * @since 2.8.0 Changed `$search_terms` parameter handling and added `$search_columns` parameter.
    10211021     * @since 2.9.0 Added `$slug` parameter.
     1022     * @since 10.0.0 Added `$date_query` parameter.
    10221023     *
    10231024     * @param array $args {
     
    10541055     *     @type array        $meta_query         Optional. An array of meta_query conditions.
    10551056     *                                            See {@link WP_Meta_Query::queries} for description.
     1057     *     @type array        $date_query         Optional. Filter results by group last activity date. See first
     1058     *                                            paramter of {@link WP_Date_Query::__construct()} for syntax. Only
     1059     *                                            applicable if $type is either 'newest' or 'active'.
    10561060     *     @type array|string $value              Optional. Array or comma-separated list of group IDs. Results
    10571061     *                                            will be limited to groups within the list. Default: false.
     
    11261130            'group_type__not_in' => '',
    11271131            'meta_query'         => false,
     1132            'date_query'         => false,
    11281133            'include'            => false,
    11291134            'parent_id'          => null,
     
    13141319        }
    13151320
     1321        // Process date query for 'date_created' and 'last_activity' sort.
     1322        if ( 'date_created' === $orderby || 'last_activity' === $orderby ) {
     1323            $date_query_sql = BP_Date_Query::get_where_sql( $r['date_query'], self::convert_orderby_to_order_by_term( $orderby ) );
     1324
     1325            if ( ! empty( $date_query_sql ) ) {
     1326                $where_conditions['date'] = $date_query_sql;
     1327            }
     1328        }
     1329
    13161330        // Sanitize 'order'.
    13171331        $order = bp_esc_sql_order( $order );
     
    14391453
    14401454    /**
    1441      * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get()
     1455     * Get the SQL for the 'meta_query' param in BP_Groups_Group::get()
    14421456     *
    14431457     * We use WP_Meta_Query to do the heavy lifting of parsing the
Note: See TracChangeset for help on using the changeset viewer.