bp_activity_recurse_comments

Loops through a level of activity comments and loads the template for each.

Description

(bool|string) bp_activity_recurse_comments( (object) $comment ); 

Note: The recursion itself used to happen entirely in this function. Now it is split between here and the comment.php template.

Returns (bool|string)

Parameters (1)

0. $comment (object)
The activity object currently being recursed.

Usage

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

Defined (1)

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

/bp-activity/bp-activity-template.php  
  1. function bp_activity_recurse_comments( $comment ) { 
  2. global $activities_template; 
  3.  
  4. if ( empty( $comment ) ) { 
  5. return false; 
  6.  
  7. if ( empty( $comment->children ) ) { 
  8. return false; 
  9.  
  10. /** 
  11. * Filters the opening tag for the template that lists activity comments. 
  12. * @since 1.6.0 
  13. * @param string $value Opening tag for the HTML markup to use. 
  14. */ 
  15. foreach ( (array) $comment->children as $comment_child ) { 
  16.  
  17. // Put the comment into the global so it's available to filters. 
  18. $activities_template->activity->current_comment = $comment_child; 
  19.  
  20. $template = bp_locate_template( 'activity/comment.php', false, false ); 
  21.  
  22. // Backward compatibility. In older versions of BP, the markup was 
  23. // generated in the PHP instead of a template. This ensures that 
  24. // older themes (which are not children of bp-default and won't 
  25. // have the new template) will still work. 
  26. if ( !$template ) { 
  27. $template =buddypress)->plugin_dir . '/bp-themes/bp-default/activity/comment.php'; 
  28.  
  29. load_template( $template, false ); 
  30.  
  31. unset( $activities_template->activity->current_comment ); 
  32.  
  33. /** 
  34. * Filters the closing tag for the template that list activity comments. 
  35. * @since 1.6.0 
  36. * @param string $value Closing tag for the HTML markup to use. 
  37. */