Changeset 8125 for trunk/bp-activity/bp-activity-classes.php
- Timestamp:
- 03/13/2014 06:34:06 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r8075 r8125 161 161 $this->mptt_right = $row->mptt_right; 162 162 $this->is_spam = $row->is_spam; 163 } 164 165 // Generate dynamic 'action' when possible 166 $action = bp_activity_generate_action_string( $this ); 167 if ( false !== $action ) { 168 $this->action = $action; 169 170 // If no callback is available, use the literal string from 171 // the database row 172 } else if ( ! empty( $row->action ) ) { 173 $this->action = $row->action; 174 175 // Provide a fallback to avoid PHP notices 176 } else { 177 $this->action = ''; 163 178 } 164 179 } … … 443 458 $activities = BP_Activity_Activity::append_comments( $activities, $spam ); 444 459 460 // Pre-fetch data associated with activity users and other objects 461 BP_Activity_Activity::prefetch_object_data( $activities ); 462 463 // Generate action strings 464 $activities = BP_Activity_Activity::generate_action_strings( $activities ); 465 445 466 // If $max is set, only return up to the max results 446 467 if ( !empty( $max ) ) { … … 540 561 } 541 562 } 563 } 564 565 return $activities; 566 } 567 568 /** 569 * Pre-fetch data for objects associated with activity items. 570 * 571 * Activity items are associated with users, and often with other 572 * BuddyPress data objects. Here, we pre-fetch data about these 573 * associated objects, so that inline lookups - done primarily when 574 * building action strings - do not result in excess database queries. 575 * 576 * The only object data required for activity component activity types 577 * (activity_update and activity_comment) is related to users, and that 578 * info is fetched separately in BP_Activity_Activity::get_activity_data(). 579 * So this method contains nothing but a filter that allows other 580 * components, such as bp-friends and bp-groups, to hook in and prime 581 * their own caches at the beginning of an activity loop. 582 * 583 * @since BuddyPress (2.0.0) 584 * 585 * @param array $activities Array of activities. 586 */ 587 protected static function prefetch_object_data( $activities ) { 588 return apply_filters( 'bp_activity_prefetch_object_data', $activities ); 589 } 590 591 /** 592 * Generate action strings for the activities located in BP_Activity_Activity::get(). 593 * 594 * If no string can be dynamically generated for a given item 595 * (typically because the activity type has not been properly 596 * registered), the static 'action' value pulled from the database will 597 * be left in place. 598 * 599 * @since BuddyPress (2.0.0) 600 * 601 * @param array $activities Array of activities. 602 * @return array 603 */ 604 protected static function generate_action_strings( $activities ) { 605 foreach ( $activities as $key => $activity ) { 606 $generated_action = bp_activity_generate_action_string( $activity ); 607 if ( false !== $generated_action ) { 608 $activity->action = $generated_action; 609 } 610 611 $activities[ $key ] = $activity; 542 612 } 543 613
Note: See TracChangeset
for help on using the changeset viewer.