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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Adds support for reading
.asset.phpfiles for stylesheets defined inblock.jsonviafile:paths inregister_block_style_handle(), mirroring the existing behavior ofregister_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