将给定ID中的任何术语添加到缓存中尚不存在的缓存中。
原型
_prime_term_caches( array $term_ids, bool $update_meta_cache = true )
参数
$term_ids
(array)
(Required)
术语ID数组。
$update_meta_cache
(bool)
(Optional)
是否更新元缓存。
源文件
路径:wp-includes/taxonomy.php
<?php
...
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 );
}
}
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/_prime_term_caches/