Make WordPress Core

Changes between Initial Version and Version 4 of Ticket #63254


Ignore:
Timestamp:
04/08/2025 11:28:06 PM (10 months ago)
Author:
sabernhardt
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #63254

    • Property Keywords has-patch needs-testing added
    • Property Component changed from General to Editor
  • 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.
     1When 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.
    22
    33Something 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.
     
    66
    77Replacing this:
    8 ```
     8{{{
    99$version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
    1010$result  = wp_register_style(
     
    1414        $version
    1515);
    16 ```
     16}}}
    1717
    1818with this:
    19 ```
     19{{{
    2020$block_version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
    2121$version = SCRIPT_DEBUG ? filemtime( $style_path_norm ) : $block_version;
     
    2727        $version
    2828);
    29 ```
     29}}}
    3030
    3131Should do the trick. The assets file is another option.