Changes between Initial Version and Version 4 of Ticket #63254
- Timestamp:
- 04/08/2025 11:28:06 PM (10 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #63254
- Property Keywords has-patch needs-testing added
-
Property
Component
changed from
GeneraltoEditor
-
Ticket #63254 – Description
initial v4 1 When a block script is defined in the `block.json` and registered automatically via `register_block_script_handle()` the version is pulled from [ the script asset php file if it exists](https://github.com/WordPress/wordpress-develop/blob/6511cc02f764a3d9c0dd105e5366fdfe63a564cc/src/wp-includes/blocks.php#L242). This ensures that the cache is always busted when the file is updated.1 When a block script is defined in the `block.json` and registered automatically via `register_block_script_handle()` the version is pulled from [https://github.com/WordPress/wordpress-develop/blob/6511cc02f764a3d9c0dd105e5366fdfe63a564cc/src/wp-includes/blocks.php#L242 the script asset PHP file if it exists]. This ensures that the cache is always busted when the file is updated. 2 2 3 3 Something similar should exist for `register_block_style_handle` as otherwise it's a total pain to develop editor styles. I just lost a few hours this morning wondering why my styles didn't update even though I am using the `@wordpress/scripts` package to recompile them on every change. … … 6 6 7 7 Replacing this: 8 ``` 8 {{{ 9 9 $version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false; 10 10 $result = wp_register_style( … … 14 14 $version 15 15 ); 16 ``` 16 }}} 17 17 18 18 with this: 19 ``` 19 {{{ 20 20 $block_version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false; 21 21 $version = SCRIPT_DEBUG ? filemtime( $style_path_norm ) : $block_version; … … 27 27 $version 28 28 ); 29 ``` 29 }}} 30 30 31 31 Should do the trick. The assets file is another option.