BBP_Skip_Children::pre_post_update( int $post_id )

Only clean post caches for main bbPress posts.


Description Description

Check that the post being updated is a bbPress 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 Parameters

$post_id

(Required) The post ID being updated


Top ↑

Return Return

(If) invalid post data


Top ↑

Source Source

File: includes/core/cache.php

	public function pre_post_update( $post_id = 0 ) {

		// Bail if post ID is not a bbPress 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' ) );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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