bbp_clean_post_cache( int $post_id = null, WP_Post $post = null )

Will clean a post in the cache.


Description Description

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


Parameters Parameters

$post_id

(Optional) The post id.

Default value: null

$post

(Optional) The WP_Post object.

Default value: null


Top ↑

Source Source

File: includes/core/cache.php

function bbp_clean_post_cache( $post_id = null, $post = null ) {

	// Child query types to clean
	$post_types = array(
		bbp_get_forum_post_type(),
		bbp_get_topic_post_type(),
		bbp_get_reply_post_type()
	);

	// Bail if not a bbPress post type
	if ( ! in_array( $post->post_type, $post_types, true ) ) {
		return;
	}

	/**
	 * Fires immediately after the given post cache is cleaned.
	 *
	 * @since 2.1.0
	 *
	 * @param int     $post_id Post ID.
	 * @param WP_Post $post    Post object.
	 */
	do_action( 'bbp_clean_post_cache', $post->ID, $post );

	// Invalidate parent caches
	if ( ! empty( $post->post_parent ) ) {
		clean_post_cache( $post->post_parent );

	// Only bump `last_changed` when forum-root is reached
	} else {
		wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 bbPress (r6053) Introduced the $post_id parameter.
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.