_prime_term_caches

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

WordPress Version: 6.3

/**
 * Adds any terms from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @since 6.1.0 This function is no longer marked as "private".
 * @since 6.3.0 Use wp_lazyload_term_meta() for lazy-loading of term meta.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $term_ids          Array of term IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_term_caches($term_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
    if (!empty($non_cached_ids)) {
        $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode(',', array_map('intval', $non_cached_ids))));
        update_term_cache($fresh_terms);
    }
    if ($update_meta_cache) {
        wp_lazyload_term_meta($term_ids);
    }
}

WordPress Version: 6.1

/**
 * Adds any terms from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @since 6.1.0 This function is no longer marked as "private".
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $term_ids          Array of term IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_term_caches($term_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
    if (!empty($non_cached_ids)) {
        $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode(',', array_map('intval', $non_cached_ids))));
        update_term_cache($fresh_terms);
        if ($update_meta_cache) {
            update_termmeta_cache($non_cached_ids);
        }
    }
}

WordPress Version: 5.6

/**
 * Adds any terms from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @access private
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $term_ids          Array of term IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_term_caches($term_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
    if (!empty($non_cached_ids)) {
        $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode(',', array_map('intval', $non_cached_ids))));
        update_term_cache($fresh_terms, $update_meta_cache);
        if ($update_meta_cache) {
            update_termmeta_cache($non_cached_ids);
        }
    }
}

WordPress Version: 5.1

/**
 * Adds any terms from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @access private
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $term_ids          Array of term IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_term_caches($term_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
    if (!empty($non_cached_ids)) {
        $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join(',', array_map('intval', $non_cached_ids))));
        update_term_cache($fresh_terms, $update_meta_cache);
        if ($update_meta_cache) {
            update_termmeta_cache($non_cached_ids);
        }
    }
}

WordPress Version: 4.6

/**
 * Adds any terms from the given IDs to the cache that do not already exist in cache.
 *
 * @since 4.6.0
 * @access private
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $term_ids          Array of term IDs.
 * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
 */
function _prime_term_caches($term_ids, $update_meta_cache = true)
{
    global $wpdb;
    $non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
    if (!empty($non_cached_ids)) {
        $fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
        update_term_cache($fresh_terms, $update_meta_cache);
        if ($update_meta_cache) {
            update_termmeta_cache($non_cached_ids);
        }
    }
}