bbp_clean_post_cache

Will clean a post in the cache.

Description

bbp_clean_post_cache( (string) $_post = '' ); 

Will call to clean the term object cache associated with the post ID.

Parameters (1)

0. $post (string)
The post object or ID to remove from the cache

Usage

  1. if ( !function_exists( 'bbp_clean_post_cache' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/cache.php'; 
  3.  
  4. // The post object or ID to remove from the cache 
  5. $post = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_clean_post_cache($post); 
  9.  

Defined (1)

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

/includes/core/cache.php  
  1. function bbp_clean_post_cache( $_post = '' ) { 
  2.  
  3. // Bail if no post 
  4. $_post = get_post( $_post ); 
  5. if ( empty( $_post ) ) 
  6. return; 
  7.  
  8. wp_cache_delete( $_post->ID, 'posts' ); 
  9. wp_cache_delete( $_post->ID, 'post_meta' ); 
  10.  
  11. clean_object_term_cache( $_post->ID, $_post->post_type ); 
  12.  
  13. do_action( 'bbp_clean_post_cache', $_post->ID, $_post ); 
  14.  
  15. // Child query types to clean 
  16. $post_types = array( 
  17. ); 
  18.  
  19. // Loop through query types and clean caches 
  20. foreach ( $post_types as $post_type ) { 
  21. wp_cache_delete( 'bbp_get_forum_' . $_post->ID . '_reply_id', 'bbpress_posts' ); 
  22. wp_cache_delete( 'bbp_parent_' . $_post->ID . '_type_' . $post_type . '_child_last_id', 'bbpress_posts' ); 
  23. wp_cache_delete( 'bbp_parent_' . $_post->ID . '_type_' . $post_type . '_child_count', 'bbpress_posts' ); 
  24. wp_cache_delete( 'bbp_parent_public_' . $_post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); 
  25. wp_cache_delete( 'bbp_parent_all_' . $_post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); 
  26.  
  27. // Invalidate parent caches 
  28. if ( ! empty( $_post->post_parent ) ) { 
  29. bbp_clean_post_cache( $_post->post_parent );