Changeset 7951
- Timestamp:
- 02/21/2014 02:49:28 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
bp-activity/bp-activity-classes.php (modified) (1 diff)
-
bp-activity/bp-activity-template.php (modified) (4 diffs)
-
tests/testcases/activity/class.BP_Activity_Activity.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r7906 r7951 1146 1146 } 1147 1147 1148 if ( ! empty( $filter_array['offset'] ) ) { 1149 $sid_sql = absint( $filter_array['offset'] ); 1150 $filter_sql[] = "a.id >= {$sid_sql}"; 1151 } 1152 1148 1153 if ( empty( $filter_sql ) ) 1149 1154 return false; -
trunk/bp-activity/bp-activity-template.php
r7906 r7951 455 455 * between components/types. Accepts a single ID, or an array of 456 456 * multiple IDs. Defaults to false. 457 * @type int $offset Return only activity items with an ID greater than or 458 * equal to this one. Note that providing an offset will disable 459 * pagination. Default: false. 457 460 * @type string|bool $display_comments How to handle activity comments. 458 461 * Possible values: … … 544 547 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 545 548 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id 549 'offset' => false, // return only items >= this ID 546 550 547 551 'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format … … 560 564 if ( in_array( $display_comments, array( 0, '0', 'none', 'false' ), true ) ) { 561 565 $display_comments = false; 566 } 567 568 // Ignore pagination if an offset is passed 569 if ( ! empty( $offset ) ) { 570 $page = 0; 562 571 } 563 572 … … 633 642 if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) ) 634 643 $filter = array( 'object' => $_GET['afilter'] ); 635 else if ( ! empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id) )636 $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );644 else if ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $offset ) ) 645 $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset ); 637 646 else 638 647 $filter = false; -
trunk/tests/testcases/activity/class.BP_Activity_Activity.php
r7922 r7951 258 258 259 259 /** 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 /** 260 286 * @group get_id 261 287 */
Note: See TracChangeset
for help on using the changeset viewer.