Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCTransactionalEmailPostsManager::invalidate_cache_for_template
Invalidates cache entries for a specific post ID or email type.
Method of the class: WCTransactionalEmailPostsManager{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->invalidate_cache_for_template( $value, $type );
- $value(int|string) (required)
- The value to invalidate cache for.
- $type(string)
- The type of value to invalidate cache for. Can be
'post_id'or'email_type'.
Default:'post_id'
WCTransactionalEmailPostsManager::invalidate_cache_for_template() WCTransactionalEmailPostsManager::invalidate cache for template code WC 10.8.1
private function invalidate_cache_for_template( $value, $type = 'post_id' ) {
$post_id_array = array();
if ( 'post_id' === $type ) {
$post_id_array[] = (int) $value;
} elseif ( 'email_type' === $type ) {
// Get all the post IDs that map to the email type.
$post_id_array = array_merge( $post_id_array, array_unique( array_keys( $this->post_id_to_email_type_cache, $value, true ) ) );
}
foreach ( $post_id_array as $post_id ) {
unset( $this->post_id_to_email_type_cache[ $post_id ] );
// Delete from WordPress object cache.
$cache_key = $this->get_cache_key_for_post_id( $post_id );
wp_cache_delete( $cache_key, self::CACHE_GROUP );
}
}