[wp-trac] [WordPress Trac] #55319: Add filter to get_block_wrapper_attributes function
WordPress Trac
noreply at wordpress.org
Fri Mar 4 10:34:30 UTC 2022
#55319: Add filter to get_block_wrapper_attributes function
-------------------------+-----------------------------
Reporter: fabiankaegy | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
**What problem does this address?**
It is currently possible to add custom classnames to static blocks using
the blocks.getSaveContent.extraProps filter in JS. This is super useful
when working with custom block supports. And even core uses this system in
js to add the classnames generated for for example the color classes.
In PHP however, for custom blocks this is all hardcoded in the
get_block_wrapper_attributes function. Specifically inside the
WP_Block_Supports Class here:
https://github.com/WordPress/WordPress/blob/92f0b0cb48a3de660655cc658fc739695a393096
/wp-includes/class-wp-block-supports.php#L93-L128
This approach makes it impossible for custom supports that plugins develop
to apply to custom blocks.
**What is your proposed solution?**
This could be solved by adding a new hook in PHP to the
get_block_wrapper_attributes function which should work the same as the
blocks.getSaveContent.extraProps hook in js.
This ticket was first created in GitHub on the Gutenberg repository in
[#38830](https://github.com/WordPress/gutenberg/issues/38830) but as the
code no longer exists in Gutenberg since it was moved to core in 5.8 it
was suggested that the change needs to happen in core directly.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55319>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list