Also during clean_term_cache

This commit is contained in:
Mike Jolley 2018-02-28 18:35:58 +00:00
parent 4bce7b0223
commit 49c2f2b28e
1 changed files with 14 additions and 0 deletions

View File

@ -21,6 +21,7 @@ class WC_Cache_Helper {
add_action( 'delete_version_transients', array( __CLASS__, 'delete_version_transients' ) );
add_action( 'wp', array( __CLASS__, 'prevent_caching' ) );
add_action( 'clean_taxonomy_cache', array( __CLASS__, 'clean_taxonomy_cache' ) );
add_action( 'clean_term_cache', array( __CLASS__, 'clean_term_cache' ), 10, 2 );
}
/**
@ -216,6 +217,19 @@ class WC_Cache_Helper {
wp_cache_delete( 'product-category-hierarchy', 'product_cat' );
}
}
/**
* Clean term caches added by WooCommerce.
*
* @since 3.3.4
* @param array $ids Array of ids to clear cache for.
* @param string $taxonomy Taxonomy name.
*/
public static function clean_term_cache( $ids, $taxonomy ) {
if ( 'product_cat' === $taxonomy ) {
wp_cache_delete( 'product-category-hierarchy', 'product_cat' );
}
}
}
WC_Cache_Helper::init();