Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/26/2013 05:46:44 PM (9 years ago)
Author:
boonebgorges
Message:

Introduces meta_query paramater for bp_has_activities() stack

This will allow plugin and theme authors to filter the contents of the activity
stream based on information stored in the activitymeta table, using the
powerful meta_query syntax familiar from the 'meta_query' WP_Query param.

Also adds unit test for 'meta_query' in BP_Activity_Activity::get(), and
integration test for bp_has_activities(). These tests are primarily designed
to ensure that our param gets passed properly down the stack; we rely on WP
to get the meta_query logic right.

See #3521

Props ericlewis

File:
1 edited

Legend:

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

    r6925 r6948  
    882882
    883883        'search_terms'     => false,        // Pass search terms as a string
     884        'meta_query'       => false,        // Filter by activity meta. See WP_Meta_Query for format
    884885        'show_hidden'      => false,        // Show activity items that are hidden site-wide?
    885886        'exclude'          => false,        // Comma-separated list of activity IDs to exclude
     
    903904
    904905    // Attempt to return a cached copy of the first page of sitewide activity.
    905     if ( 1 == (int) $page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && empty( $exclude ) && empty( $in ) && 'DESC' == $sort && empty( $exclude ) && 'ham_only' == $spam ) {
     906    if ( 1 == (int) $page && empty( $max ) && empty( $search_terms ) && empty( $meta_query ) && empty( $filter ) && empty( $exclude ) && empty( $in ) && 'DESC' == $sort && empty( $exclude ) && 'ham_only' == $spam ) {
    906907        if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) {
    907908            $args = array(
     
    911912                'sort'             => $sort,
    912913                'search_terms'     => $search_terms,
     914                'meta_query'       => $meta_query,
    913915                'filter'           => $filter,
    914916                'display_comments' => $display_comments,
     
    927929            'sort'             => $sort,
    928930            'search_terms'     => $search_terms,
     931            'meta_query'       => $meta_query,
    929932            'filter'           => $filter,
    930933            'display_comments' => $display_comments,
Note: See TracChangeset for help on using the changeset viewer.