Changeset 58710 for trunk/src/wp-includes/global-styles-and-settings.php
- Timestamp:
- 07/12/2024 07:24:12 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/global-styles-and-settings.php
r58703 r58710 256 256 $tree = WP_Theme_JSON_Resolver::get_merged_data(); 257 257 $block_nodes = $tree->get_styles_block_nodes(); 258 259 $can_use_cached = ! wp_is_development_mode( 'theme' );260 if ( $can_use_cached ) {261 // Hash global settings and block nodes together to optimize performance of key generation.262 $hash = md5(263 wp_json_encode(264 array(265 'global_setting' => wp_get_global_settings(),266 'block_nodes' => $block_nodes,267 )268 )269 );270 271 $cache_key = "wp_styles_for_blocks:$hash";272 $cached = get_site_transient( $cache_key );273 if ( ! is_array( $cached ) ) {274 $cached = array();275 }276 }277 278 $update_cache = false;279 280 258 foreach ( $block_nodes as $metadata ) { 281 282 if ( $can_use_cached ) { 283 // Use the block name as the key for cached CSS data. Otherwise, use a hash of the metadata. 284 $cache_node_key = isset( $metadata['name'] ) ? $metadata['name'] : md5( wp_json_encode( $metadata ) ); 285 286 if ( isset( $cached[ $cache_node_key ] ) ) { 287 $block_css = $cached[ $cache_node_key ]; 288 } else { 289 $block_css = $tree->get_styles_for_block( $metadata ); 290 $cached[ $cache_node_key ] = $block_css; 291 $update_cache = true; 292 } 293 } else { 294 $block_css = $tree->get_styles_for_block( $metadata ); 295 } 259 $block_css = $tree->get_styles_for_block( $metadata ); 296 260 297 261 if ( ! wp_should_load_separate_core_block_assets() ) { … … 339 303 } 340 304 } 341 342 if ( $update_cache ) {343 set_site_transient( $cache_key, $cached, HOUR_IN_SECONDS );344 }345 305 } 346 306
Note: See TracChangeset
for help on using the changeset viewer.