Automattic\WooCommerce\Internal\Caches
ProductTermCacheInvalidator{}
Invalidates cached product terms when taxonomy caches are cleaned.
Хуков нет.
Использование
$ProductTermCacheInvalidator = new ProductTermCacheInvalidator(); // use class methods
Методы
- public handle_clean_taxonomy_cache( $taxonomy )
- public init()
Список изменений
| С версии 11.2.0 | Введена. |
Код ProductTermCacheInvalidator{} ProductTermCacheInvalidator{} WC 11.2.2
class ProductTermCacheInvalidator {
/**
* Register cache invalidation hooks.
*
* @since 11.2.0
*
* @internal
*/
final public function init(): void {
add_action( 'clean_taxonomy_cache', array( $this, 'handle_clean_taxonomy_cache' ) );
}
/**
* Invalidate cached product terms after a taxonomy cache is cleaned.
*
* @since 11.2.0
*
* @internal
*
* @param mixed $taxonomy Taxonomy name.
*/
public function handle_clean_taxonomy_cache( $taxonomy ): void {
if ( ! is_string( $taxonomy ) || ! is_object_in_taxonomy( 'product', $taxonomy ) ) {
return;
}
WC_Cache_Helper::invalidate_cache_group( 'product_terms_' . $taxonomy );
}
}