Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/12/2021 02:09:02 PM (4 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-blogs/bp-blogs-template.php

    r13147 r13184  
    112112 * Based on the $args passed, bp_has_blogs() populates the $blogs_template
    113113 * global, enabling the use of BuddyPress templates and template functions to
    114  * display a list of activity items.
     114 * display a list of blogs.
     115 *
     116 * @since 1.0.0
     117 * @since 1.2.0 Added $type, $page, $search_terms parameters
     118 * @since 1.6.0 Added $page_arg parameter
     119 * @since 2.0.0 Added $include_blog_ids, $update_meta_cache parameters
     120 * @since 10.0.0 Added $date_query parameter
    115121 *
    116122 * @global BP_Blogs_Template $blogs_template {@link BP_Blogs_Template}
     
    122128 *     and because bp_has_blogs() determines some default arguments in a
    123129 *     dynamic fashion, we list all accepted arguments here as well.
    124  *
    125  *     Arguments can be passed as an associative array, or as a URL query
    126  *     string (eg, 'user_id=4&per_page=3').
    127130 *
    128131 *     @type int      $page             Which page of results to fetch. Using page=1 without
     
    141144 *                                      When viewing a user profile page, 'user_id' defaults to the
    142145 *                                      ID of the displayed user. Otherwise the default is false.
     146 *     @type array    $date_query       Filter results by site last activity date. See first parameter of
     147 *                                      {@link WP_Date_Query::__construct()} for syntax. Only applicable if
     148 *                                      $type is either 'newest' or 'active'.
    143149 * }
    144150 * @return bool Returns true when blogs are found, otherwise false.
     
    168174            'include_blog_ids'  => false,
    169175            'search_terms'      => $search_terms_default,
     176            'date_query'        => false,
    170177            'update_meta_cache' => true,
    171178        ),
     
    179186
    180187    // Get the blogs.
    181     $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] );
     188    $blogs_template = new BP_Blogs_Template( $r );
    182189
    183190    /**
Note: See TracChangeset for help on using the changeset viewer.