bp_activity_recurse_comment_count( object $comment, int $count )

Return the total number of comments to the current comment.


Description Description

This function recursively adds the total number of comments each activity child has, and returns them.


Parameters Parameters

$comment

(Required) Activity comment object.

$count

(Required) The current iteration count.


Top ↑

Return Return

(int) $count The activity comment count.


Top ↑

Source 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 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 );
		}

Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.