_wc_get_cached_product_terms()
Cached version of wp_get_post_terms(). This is a private function (internal use ONLY).
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
array.
Использование
_wc_get_cached_product_terms( $product_id, $taxonomy, $args );
- $product_id(int) (обязательный)
- Product ID.
- $taxonomy(строка) (обязательный)
- Taxonomy slug.
- $args(массив)
- Query arguments.
По умолчанию:array()
Список изменений
| С версии 3.0.0 | Введена. |
Код _wc_get_cached_product_terms() wc get cached product terms WC 11.2.2
function _wc_get_cached_product_terms( $product_id, $taxonomy, $args = array() ) {
$cache_key = WC_Cache_Helper::get_cache_prefix( 'product_terms_' . $taxonomy ) . 'wc_' . $taxonomy . md5( wp_json_encode( $args ) );
$cache_group = WC_Cache_Helper::get_cache_prefix( 'product_' . $product_id ) . $product_id;
$terms = wp_cache_get( $cache_key, $cache_group );
if ( false !== $terms ) {
return $terms;
}
$terms = wp_get_post_terms( $product_id, $taxonomy, $args );
wp_cache_add( $cache_key, $terms, $cache_group );
return $terms;
}