Sets block pattern cache.
Parameters
$patterns
arrayrequired- Block patterns data to set in cache.
Source
private function set_pattern_cache( array $patterns ) {
$pattern_data = array(
'version' => $this->get( 'Version' ),
'patterns' => $patterns,
);
/**
* Filters the cache expiration time for theme files.
*
* @since 6.6.0
*
* @param int $cache_expiration Cache expiration time in seconds.
* @param string $cache_type Type of cache being set.
*/
$cache_expiration = (int) apply_filters( 'wp_theme_files_cache_ttl', self::$cache_expiration, 'theme_block_patterns' );
// We don't want to cache patterns infinitely.
if ( $cache_expiration <= 0 ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %1$s: The filter name.*/
__( 'The %1$s filter must return an integer value greater than 0.' ),
'<code>wp_theme_files_cache_ttl</code>'
),
'6.6.0'
);
$cache_expiration = self::$cache_expiration;
}
set_site_transient( 'wp_theme_files_patterns-' . $this->cache_hash, $pattern_data, $cache_expiration );
}
Hooks
- apply_filters( ‘wp_theme_files_cache_ttl’,
int $cache_expiration ,string $cache_type ) Filters the cache expiration time for theme files.
User Contributed Notes
You must log in before being able to contribute a note or feedback.