bp_blogs_setup_activity_loop_globals

Utility function to set up some variables for use in the activity loop.

Description

bp_blogs_setup_activity_loop_globals( (object) $activity ); 

Grabs the blog's comment depth and the post's open comment status options for later use in the activity and activity comment loops.

This is to prevent having to requery these items later on.

Parameters (1)

0. $activity (object)
The BP_Activity_Activity object.

Usage

  1. if ( !function_exists( 'bp_blogs_setup_activity_loop_globals' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-activity.php'; 
  3.  
  4. // The BP_Activity_Activity object. 
  5. $activity = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_blogs_setup_activity_loop_globals($activity); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-blogs/bp-blogs-activity.php  
  1. function bp_blogs_setup_activity_loop_globals( $activity ) { 
  2. if ( ! is_object( $activity ) ) { 
  3. return; 
  4.  
  5. // The activity type does not support comments or replies ? stop now! 
  6. if ( ! bp_activity_type_supports( $activity->type, 'post-type-comment-reply' ) ) { 
  7. return; 
  8.  
  9. if ( empty( $activity->id ) ) { 
  10. return; 
  11.  
  12. // If we've already done this before, stop now! 
  13. if ( isset(buddypress)->blogs->allow_comments[ $activity->id ] ) ) { 
  14. return; 
  15.  
  16. $allow_comments = bp_blogs_comments_open( $activity ); 
  17. $thread_depth = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' ); 
  18.  
  19. // Initialize a local object so we won't have to query this again in the 
  20. // comment loop. 
  21. if ( empty(buddypress)->blogs->allow_comments ) ) { 
  22. buddypress)->blogs->allow_comments = array(); 
  23. if ( empty(buddypress)->blogs->thread_depth ) ) { 
  24. buddypress)->blogs->thread_depth = array(); 
  25.  
  26. // Cache comment settings in thebuddypress) singleton to reference later in 
  27. // the activity comment loop 
  28. // @see bp_blogs_disable_activity_replies() 
  29. // 
  30. // thread_depth is keyed by activity ID instead of blog ID because when we're 
  31. // in a comment loop, we don't have access to the blog ID... 
  32. // should probably object cache these values instead... 
  33. buddypress)->blogs->allow_comments[ $activity->id ] = $allow_comments; 
  34. buddypress)->blogs->thread_depth[ $activity->id ] = $thread_depth;