clean_object_term_cache

The timeline below displays how wordpress function clean_object_term_cache has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

//
// Cache.
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @see get_object_taxonomies() for more on $object_type.
 *
 * @param int|array    $object_ids  Single or list of term object ID(s).
 * @param array|string $object_type The taxonomy 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_set_terms_last_changed();
    /**
     * 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);
}

WordPress Version: 6.1

//
// Cache.
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @see get_object_taxonomies() for more on $object_type.
 *
 * @param int|array    $object_ids  Single or list of term object ID(s).
 * @param array|string $object_type The taxonomy 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);
}

WordPress Version: 5.4

//
// Cache.
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @see get_object_taxonomies() for more on $object_type.
 *
 * @param int|array    $object_ids  Single or list of term object ID(s).
 * @param array|string $object_type The taxonomy 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 ($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);
}

WordPress Version: 4.8

//
// Cache
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @see get_object_taxonomies() for more on $object_type.
 *
 * @param int|array    $object_ids  Single or list of term object ID(s).
 * @param array|string $object_type The taxonomy 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 ($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);
}

WordPress Version: 4.5

//
// Cache
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @see get_object_taxonomies() for more on $object_type.
 *
 * @param int|array    $object_ids  Single or list of term object ID(s).
 * @param array|string $object_type The taxonomy 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 ($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 $objet_type Object type.
     */
    do_action('clean_object_term_cache', $object_ids, $object_type);
}

WordPress Version: 4.3

//
// Cache
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @see get_object_taxonomies() for more on $object_type.
 *
 * @param int|array    $object_ids  Single or list of term object ID(s).
 * @param array|string $object_type The taxonomy object type.
 */
function clean_object_term_cache($object_ids, $object_type)
{
    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 $objet_type Object type.
     */
    do_action('clean_object_term_cache', $object_ids, $object_type);
}

WordPress Version: 3.9

//
// Cache
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @since 2.3.0
 *
 * @see get_object_taxonomies() for more on $object_type
 *
 * @param int|array $object_ids Single or list of term object ID(s)
 * @param array|string $object_type The taxonomy object type
 */
function clean_object_term_cache($object_ids, $object_type)
{
    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 $objet_type Object type.
     */
    do_action('clean_object_term_cache', $object_ids, $object_type);
}

WordPress Version: 3.7

//
// Cache
//
/**
 * Removes the taxonomy relationship to terms from the cache.
 *
 * 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.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @see get_object_taxonomies() for more on $object_type
 * @uses do_action() Will call action hook named, 'clean_object_term_cache' after completion.
 *	Passes, function params in same order.
 *
 * @param int|array $object_ids Single or list of term object ID(s)
 * @param array|string $object_type The taxonomy object type
 */
function clean_object_term_cache($object_ids, $object_type)
{
    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");
        }
    }
    do_action('clean_object_term_cache', $object_ids, $object_type);
}