_wc_get_cached_product_terms( int $product_id, string $taxonomy, array $args = array() )
Cached version of wp_get_post_terms().
Description Description
This is a private function (internal use ONLY).
Parameters Parameters
- $product_id
-
(Required) Product ID.
- $taxonomy
-
(Required) Taxonomy slug.
- $args
-
(Optional) Query arguments.
Default value: array()
Return Return
(array)
Source Source
File: includes/wc-term-functions.php
function _wc_get_cached_product_terms( $product_id, $taxonomy, $args = array() ) {
$cache_key = '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;
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |