bp_activity_recurse_comment_count( object $comment, int $count )
Return the total number of comments to the current comment.
Description
This function recursively adds the total number of comments each activity child has, and returns them.
Parameters
- $comment
-
(Required) Activity comment object.
- $count
-
(Required) The current iteration count.
Return
(int) $count The activity comment count.
Source
File: bp-activity/bp-activity-template.php
function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
// Copy the count.
$new_count = $count;
// Loop through children and recursively count comments.
if ( ! empty( $comment->children ) ) {
foreach ( (array) $comment->children as $comment ) {
$new_count++;
$new_count = bp_activity_recurse_comment_count( $comment, $new_count );
}
}
/**
* Filters the total number of comments for the current comment.
*
* @since BuddyPress 2.1.0
*
* @param int $new_count New total count for the current comment.
* @param object $comment Activity comment object.
* @param int $count Current iteration count for the current comment.
*/
return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.