_prime_network_caches()
Adds any networks from the given IDs to the cache that do not already exist in cache.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
null. Nothing (null).
Usage
_prime_network_caches( $network_ids );
- $network_ids(array) (required)
- Array of network IDs.
Notes
- See: update_network_cache()
- Global. wpdb.
$wpdbWordPress database abstraction object.
Changelog
| Since 4.6.0 | Introduced. |
| Since 6.1.0 | This function is no longer marked as "private". |
_prime_network_caches() prime network caches code WP 6.9.1
function _prime_network_caches( $network_ids ) {
global $wpdb;
$non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
if ( ! empty( $non_cached_ids ) ) {
$fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
update_network_cache( $fresh_networks );
}
}