ACF_Post_Type::flush_post_cachepublicACF 6.1

Flush rewrite rules whenever anything changes about a post type.

Method of the class: ACF_Post_Type{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ACF_Post_Type = new ACF_Post_Type();
$ACF_Post_Type->flush_post_cache( $post );
$post(array) (required)
The main post type array.

Changelog

Since 6.1 Introduced.

ACF_Post_Type::flush_post_cache() code ACF 6.8.8

public function flush_post_cache( $post ) {
	// Bail early if we won't be able to register/unregister the post type.
	if ( empty( $post['post_type'] ) ) {
		return;
	}

	// Temporarily unregister the post type so that we can potentially re-register with the latest args below.
	if ( empty( $post['active'] ) || post_type_exists( $post['post_type'] ) ) {
		unregister_post_type( $post['post_type'] );
	}

	// When this is being called, the post type may not have been registered yet, so we do it now.
	if ( ! empty( $post['active'] ) ) {
		register_post_type( $post['post_type'], $this->get_post_type_args( $post ) );
	}

	// Flush our internal cache and the WordPress rewrite rules.
	parent::flush_post_cache( $post );
	flush_rewrite_rules();
}