BP_Activity_Activity::append_comments( array $activities, string $spam = 'ham_only' )

Append activity comments to their associated activity items.


Description Description


Parameters Parameters

$activities

(Required) Activities to fetch comments for.

$spam

(Optional) 'ham_only' (default), 'spam_only' or 'all'.

Default value: 'ham_only'


Top ↑

Return Return

(array) The updated activities with nested comments.


Top ↑

Source Source

File: bp-activity/classes/class-bp-activity-activity.php

	public static function append_comments( $activities, $spam = 'ham_only' ) {
		$activity_comments = array();

		// Now fetch the activity comments and parse them into the correct position in the activities array.
		foreach ( (array) $activities as $activity ) {
			$top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
			$activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
		}

		// Merge the comments with the activity items.
		foreach ( (array) $activities as $key => $activity ) {
			if ( isset( $activity_comments[$activity->id] ) ) {
				$activities[$key]->children = $activity_comments[$activity->id];
			}
		}

		return $activities;
	}

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.