BBP_Skip_Children::pre_post_update( int $post_id )
Only clean post caches for main Forums posts.
Description
Check that the post being updated is a Forums post type, saves the post ID to be used later, and adds an action to ‘clean_post_cache’ that prevents child post caches from being cleared.
Parameters
- $post_id
-
(Required) The post ID being updated
Return
(If) invalid post data
Source
File: bp-forums/core/cache.php
public function pre_post_update( $post_id = 0 ) {
// Bail if post ID is not a Forums post type
if ( empty( $post_id ) || ! bbp_is_custom_post_type( $post_id ) )
return;
// Store the $post_id
$this->updating_post = $post_id;
// Skip related post cache invalidation. This prevents invalidating the
// caches of the child posts when there is no reason to do so.
add_action( 'clean_post_cache', array( $this, 'skip_related_posts' ) );
}
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.