Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCTransactionalEmailPostsManager::invalidate_cache_for_template │ private │ WC 1.0

Invalidates cache entries for a specific post ID or email type.

Метод класса: WCTransactionalEmailPostsManager{}

Хуков нет.

Возвращает

void. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->invalidate_cache_for_template( $value, $type );
$value(int|строка) (обязательный)
The value to invalidate cache for.
$type(строка)
The type of value to invalidate cache for. Can be 'post_id' or 'email_type'.
По умолчанию: 'post_id'

Код WCTransactionalEmailPostsManager::invalidate_cache_for_template() WC 11.2.2

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 );
	}
}