Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/22/2014 09:46:50 PM (12 years ago)
Author:
r-a-y
Message:

Activity: Support multiple scopes in bp_has_activities().

This commit:

  • Allows the 'scope' parameter to support multiple scopes. For example, scope=friends,mentions. This can be a comma-delimited string or an array.
  • Makes the 'scope' parameter available across the bp_has_activities() stack. Previously, 'scope' was only available for use in the bp_has_activities() loop.
  • Parses scopes using the BP_Activity_Query class to handle complex conditions.
  • Allows components to declare their own custom activity scopes. Components can also override existing activity arguments by setting the 'override' key in their scope callback. For an example, see how the friends component declares the 'friends' scope in bp_friends_filter_activity_scope(). Previously, it was not possible for components or third-party plugins to declare their own scopes without doing a fair bit of workarounds.

See #4988.

File:
1 edited

Legend:

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

    r9256 r9257  
    14241424                'update_meta_cache' => true,
    14251425                'count_total'       => false,
     1426                'scope'             => false,
    14261427
    14271428                /**
     
    14391440
    14401441        // Attempt to return a cached copy of the first page of sitewide activity.
    1441         if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
     1442        if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
    14421443
    14431444                $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
     
    14541455                                'filter_query'      => $r['filter_query'],
    14551456                                'filter'            => $r['filter'],
     1457                                'scope'             => $r['scope'],
    14561458                                'display_comments'  => $r['display_comments'],
    14571459                                'show_hidden'       => $r['show_hidden'],
     
    14751477                        'filter_query'     => $r['filter_query'],
    14761478                        'filter'           => $r['filter'],
     1479                        'scope'            => $r['scope'],
    14771480                        'display_comments' => $r['display_comments'],
    14781481                        'show_hidden'      => $r['show_hidden'],
Note: See TracChangeset for help on using the changeset viewer.