clean_object_term_cache

函式
clean_object_term_cache ( $object_ids, $object_type )
引數
  • (int|array) $object_ids Single or list of term object ID(s).
    Required:
  • (array|string) $object_type The taxonomy object type.
    Required:
相關
  • get_object_taxonomies()
定義位置
相關方法
get_object_term_cacheclean_term_cacheupdate_object_term_cacheclean_category_cacheclean_user_cache
引入
2.3.0
棄用
-

clean_object_term_cache: 這個函式清除了物件術語的快取。物件術語是與文章、頁面或自定義文章型別相關的術語或類別: 當這個函式被呼叫時,它清除了所有物件術語資料的快取。

從快取中刪除術語的分類關係。

將刪除包含術語`$object_id`的整個分類關係。術語ID必須存在於分類法`$object_type`中,才能進行刪除。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 ( $taxonomies as $taxonomy ) {
wp_cache_delete_multiple( $object_ids, "{$taxonomy}_relationships" );
}
wp_cache_delete( 'last_changed', 'terms' );
/**
* 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 );
}
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 ( $taxonomies as $taxonomy ) { wp_cache_delete_multiple( $object_ids, "{$taxonomy}_relationships" ); } wp_cache_delete( 'last_changed', 'terms' ); /** * 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 ); }
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 ( $taxonomies as $taxonomy ) {
		wp_cache_delete_multiple( $object_ids, "{$taxonomy}_relationships" );
	}

	wp_cache_delete( 'last_changed', 'terms' );

	/**
	 * 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 );
}

常見問題

FAQs
檢視更多 >