update_site_cache() WordPress Function

This function updates the site's cache.

update_site_cache( array $sites, bool $update_meta_cache = true ) #

Updates sites in cache.


Parameters

$sites

(array)(Required)Array of site objects.

$update_meta_cache

(bool)(Optional)Whether to update site meta cache.

Default value: true


Top ↑

Source

File: wp-includes/ms-site.php

function update_site_cache( $sites, $update_meta_cache = true ) {
	if ( ! $sites ) {
		return;
	}
	$site_ids          = array();
	$site_data         = array();
	$blog_details_data = array();
	foreach ( $sites as $site ) {
		$site_ids[]                                    = $site->blog_id;
		$site_data[ $site->blog_id ]                   = $site;
		$blog_details_data[ $site->blog_id . 'short' ] = $site;

	}
	wp_cache_add_multiple( $site_data, 'sites' );
	wp_cache_add_multiple( $blog_details_data, 'blog-details' );

	if ( $update_meta_cache ) {
		update_sitemeta_cache( $site_ids );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0Introduced the $update_meta_cache parameter.
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.