Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#66264 new enhancement

Blocks: Add asset file (.asset.php) support for styles in register_block_style_handle()

Reported by: therssoftware Owned by:
Priority: normal Milestone: Awaiting Review
Component: Editor Version: trunk
Severity: normal Keywords:
Cc: Focuses:

Description

In block.json, block metadata fields like style, editorStyle, and viewStyle accept file paths via the file: prefix (e.g. "style": "file:./style.css"). Build tools such as @wordpress/scripts and Webpack generate adjacent .asset.php files containing automated cache-busting hashes/versions and dependencies.

While register_block_script_handle() and register_block_script_module_id() detect and load adjacent .asset.php files to extract custom handle names, dependencies, and versions, register_block_style_handle() previously did not look for an .asset.php file, hardcoding dependencies to array() and ignoring asset versions or custom handles.

Follows up on Gutenberg issue ​#56838 (matching the work done for scripts in #60485).

A PR has been prepared with full unit test coverage:
​https://github.com/WordPress/wordpress-develop/pull/14065

Change History (1)

#1 @therssoftware
4 weeks ago

Adds support for reading .asset.php files for stylesheets defined in block.json via file: paths in register_block_style_handle(), mirroring the existing behavior of register_block_script_handle().

This enables custom style handle names, dependency arrays, and versioning for block styles. Follows up on Gutenberg issue ​#56838.

All existing and newly added PHPUnit tests and PHPCS pass.

PR: ​https://github.com/WordPress/wordpress-develop/pull/14065

Note: See TracTickets for help on using tickets.