Skip to content

Commit f3e7d3a

Browse files
committed
Editor: Add cache-busting for block styles on development mode.
This changeset introduces a development mode for block editor styles. When SCRIPT_DEBUG is enabled, block editor styles now use the file modification time as their version, ensuring cache busting during development. This matches the behavior that already exists for block scripts. Previously, block editor styles only used the version from block.json, which doesn't change during development, causing styles to be cached even after changes. Merges [60355] to the 6.8 branch. Props helgatheviking, abcd95, gziolo, whaze, audrasjb, sandeepdahiya, rollybueno. Fixes #63254. git-svn-id: https://develop.svn.wordpress.org/branches/6.8@60434 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5a612a6 commit f3e7d3a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/wp-includes/blocks.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) {
328328
$style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) );
329329
$style_uri = get_block_asset_url( $style_path_norm );
330330

331-
$version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
332-
$result = wp_register_style(
331+
$block_version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
332+
$version = $style_path_norm && defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? filemtime( $style_path_norm ) : $block_version;
333+
$result = wp_register_style(
333334
$style_handle_name,
334335
$style_uri,
335336
array(),

0 commit comments

Comments
 (0)