clean_object_term_cache() WordPress Function

The clean_object_term_cache() function is used to clean the cache for a given object and its terms. This function is called automatically when an object is updated or deleted, so it is not necessary to call it directly.

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

Removes the taxonomy relationship to terms from the cache.


Description

Will remove the entire taxonomy relationship containing term $object_id. The term IDs have to exist within the taxonomy $object_type for the deletion to take place.

Top ↑

See also


Top ↑

Parameters

$object_ids

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

$object_type

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


Top ↑

Source

File: wp-includes/taxonomy.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 ( $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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More