bp_blogs_prefetch_activity_object_data( array $activities )

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

Description

This reduces database overhead during the activity loop.

Parameters

$activities

(Required) Array of activity items.

Return

(array)

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

Changelog

Changelog
Version Description
BuddyPress 2.0.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.