ACF_Taxonomy::flush_post_cachepublicACF 6.1

Flush rewrite rules whenever anything changes about a taxonomy.

Method of the class: ACF_Taxonomy{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

Changelog

Since 6.1 Introduced.

ACF_Taxonomy::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 taxonomy.
	if ( ! isset( $post['taxonomy'] ) ) {
		return;
	}

	// Temporarily unregister the taxonomy so that we can re-register with the latest args below.
	if ( empty( $post['active'] ) || taxonomy_exists( $post['taxonomy'] ) ) {
		unregister_taxonomy( $post['taxonomy'] );
	}

	// When this is being called, the post type may not have been registered yet, so we do it now.
	if ( ! empty( $post['active'] ) ) {
		$post['object_type'] = isset( $post['object_type'] ) ? (array) $post['object_type'] : array();
		register_taxonomy( $post['taxonomy'], $post['object_type'], $this->get_taxonomy_args( $post ) );
	}

	parent::flush_post_cache( $post );
	flush_rewrite_rules();
}