Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/11/2014 03:13:23 PM (10 years ago)
Author:
r-a-y
Message:

Add ability to query activity items by date.

This commit:

  • Introduces the BP_Date_Query class. This class extends WP_Date_Query, which will enable us to easily add support to query various BuddyPress items by date.
  • Adds a new 'date_query' parameter to BP_Activity_Activity::get(). This parameter utilizes the new BP_Date_Query class and is an example of how to use the class in BuddyPress. (Will add support for the Groups component in a later commit.)
  • Adds unit tests.

Due to the dependency on the WP_Date_Query class, this functionality is
only available in WordPress 3.7+.

Fixes #5803.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r8783 r8787  
    10201020        'search_terms'      => false,        // Pass search terms as a string
    10211021        'meta_query'        => false,        // Filter by activity meta. See WP_Meta_Query for format
     1022        'date_query'        => false,        // Filter by date. See first parameter of WP_Date_Query for format
    10221023        'show_hidden'       => false,        // Show activity items that are hidden site-wide?
    10231024        'exclude'           => false,        // Comma-separated list of activity IDs to exclude
     
    10411042
    10421043    // Attempt to return a cached copy of the first page of sitewide activity.
    1043     if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
     1044    if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
    10441045
    10451046        $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
     
    10531054                'search_terms'      => $r['search_terms'],
    10541055                'meta_query'        => $r['meta_query'],
     1056                'date_query'        => $r['date_query'],
    10551057                'filter'            => $r['filter'],
    10561058                'display_comments'  => $r['display_comments'],
     
    10721074            'search_terms'     => $r['search_terms'],
    10731075            'meta_query'       => $r['meta_query'],
     1076            'date_query'       => $r['date_query'],
    10741077            'filter'           => $r['filter'],
    10751078            'display_comments' => $r['display_comments'],
Note: See TracChangeset for help on using the changeset viewer.