clean_blog_cache

Clean the blog cache.

Description

clean_blog_cache( (WP_Site) $blog ); 

Parameters (1)

0. $blog (WP_Site)
The site object to be cleared from cache.

Usage

  1. if ( !function_exists( 'clean_blog_cache' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-blogs.php'; 
  3.  
  4. // The site object to be cleared from cache. 
  5. $blog = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = clean_blog_cache($blog); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-blogs.php  
  1. function clean_blog_cache( $blog ) { 
  2. $blog_id = $blog->blog_id; 
  3. $domain_path_key = md5( $blog->domain . $blog->path ); 
  4.  
  5. wp_cache_delete( $blog_id, 'sites' ); 
  6. wp_cache_delete( $blog_id, 'site-details' ); 
  7. wp_cache_delete( $blog_id , 'blog-details' ); 
  8. wp_cache_delete( $blog_id . 'short' , 'blog-details' ); 
  9. wp_cache_delete( $domain_path_key, 'blog-lookup' ); 
  10. wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' ); 
  11. wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' ); 
  12. wp_cache_delete( $domain_path_key, 'blog-id-cache' ); 
  13.  
  14. /** 
  15. * Fires immediately after a site has been removed from the object cache. 
  16. * @since 4.6.0 
  17. * @param int $id Blog ID. 
  18. * @param WP_Site $blog Site object. 
  19. * @param string $domain_path_key md5 hash of domain and path. 
  20. */ 
  21. do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key ); 
  22.  
  23. wp_cache_set( 'last_changed', microtime(), 'sites' );