Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/21/2014 02:49:28 PM (12 years ago)
Author:
boonebgorges
Message:

Add 'offset' parameter to bp_has_activities() function stack

This param allows plugins and themes to filter results to only those activity
items whose IDs are greater than the 'offset' parameter. See eg the "load
new items" integration with the Heartbeat API.

See #5328

Props imath, boonebgorges

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/class.BP_Activity_Activity.php

    r7922 r7951  
    258258
    259259    /**
     260     * @group get
     261     */
     262    public function test_get_with_offset() {
     263        $now = time();
     264        $a1 = $this->factory->activity->create( array(
     265            'content' => 'Life Rules',
     266            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     267        ) );
     268        $a2 = $this->factory->activity->create( array(
     269            'content' => 'Life Drools',
     270            'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
     271        ) );
     272        $a3 = $this->factory->activity->create( array(
     273            'content' => 'Life Drools',
     274            'recorded_time' => date( 'Y-m-d H:i:s', $now - 10 ),
     275        ) );
     276
     277        $activity = BP_Activity_Activity::get( array(
     278            'filter' => array(
     279                'offset' => $a2,
     280            ),
     281        ) );
     282        $ids = wp_list_pluck( $activity['activities'], 'id' );
     283        $this->assertEquals( array( $a3, $a2 ), $ids );
     284    }
     285    /**
    260286     * @group get_id
    261287     */
Note: See TracChangeset for help on using the changeset viewer.