clean_object_term_cache()

最后更新于:2021-11-25 20:33:46

clean_object_term_cache( int|array$object_ids, array|string$object_type)

Removes the taxonomy relationship to terms from the cache.

参数

$object_ids

(int|array) (Required) Single or list of term object ID(s).

$object_type

(array|string) (Required) The taxonomy object type.

源文件

文件: gc-includes/taxonomy.php

function clean_object_term_cache( $object_ids, $object_type ) {
	global $_gc_suspend_cache_invalidation;

	if ( ! empty( $_gc_suspend_cache_invalidation ) ) {
		return;
	}

	if ( ! is_array( $object_ids ) ) {
		$object_ids = array( $object_ids );
	}

	$taxonomies = get_object_taxonomies( $object_type );

	foreach ( $object_ids as $id ) {
		foreach ( $taxonomies as $taxonomy ) {
			gc_cache_delete( $id, "{$taxonomy}_relationships" );
		}
	}

	/**
	 * Fires after the object term cache has been cleaned.
	 *
	 * @since 2.5.0
	 *
	 * @param array  $object_ids An array of object IDs.
	 * @param string $object_type Object type.
	 */
	do_action( 'clean_object_term_cache', $object_ids, $object_type );
}