bp_blogs_prefetch_activity_object_data( array $activities )

Fetch data related to blogs at the beginning of an activity loop.


Description Description

This reduces database overhead during the activity loop.


Top ↑

Parameters Parameters

$activities

(array) (Required) Array of activity items.


Top ↑

Return Return

(array)


Source Source

File: bp-blogs/bp-blogs-activity.php

function bp_blogs_prefetch_activity_object_data( $activities ) {
	if ( empty( $activities ) ) {
		return $activities;
	}

	$blog_ids = array();

	foreach ( $activities as $activity ) {
		if ( buddypress()->blogs->id !== $activity->component ) {
			continue;
		}

		$blog_ids[] = $activity->item_id;
	}

	if ( ! empty( $blog_ids ) ) {
		bp_blogs_update_meta_cache( $blog_ids );
	}

	return $activities;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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