BBP_Skip_Children::skip_related_posts( int $post_id )
Skip cache invalidation of related posts if the post ID being invalidated is not the one that was just updated.
Description
Parameters
- $post_id
-
(Required) The post ID of the cache being invalidated
Return
(If) invalid post data
Source
File: bp-forums/core/cache.php
public function skip_related_posts( $post_id = 0 ) {
// Bail if this post is not the current Forums post
if ( empty( $post_id ) || ( $this->updating_post !== $post_id ) )
return;
// Stash the current cache invalidation value in a variable, so we can
// restore back to it nicely in the future.
global $_wp_suspend_cache_invalidation;
$this->original_cache_invalidation = $_wp_suspend_cache_invalidation;
// Turn off cache invalidation
wp_suspend_cache_invalidation( true );
// Restore cache invalidation
add_action( 'wp_insert_post', array( $this, 'restore_cache_invalidation' ) );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r4011) | 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.