从缓存中删除与术语的分类关系。

原型

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

描述

将删除包含术语$ object_id的整个分类关系。术语ID必须存在于分类法$ object_type中才能进行删除。

参考:

  • get_object_taxonomies()

参数

$object_ids (int|array) (Required) 单个或列表的术语对象ID。

$object_type (array|string) (Required) 分类对象类型。

源文件

路径:wp-includes/taxonomy.php

<?php
...
function clean_object_term_cache($object_ids, $object_type) {
	global $_wp_suspend_cache_invalidation;
	if ( ! empty( $_wp_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 ) {
			wp_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 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/clean_object_term_cache/