-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Is your feature request related to a problem? Please describe.
A developer may want to add extra classes to existing blocks,
without using the additional CSS class field.
For example if you are using a design system and need to make the blocks more compatible with a theme or plugins current CSS.
The downside with the CSS class input field is that, a developer can populate it, but the user can also remove that class.
Or, the developer wants a list of all CSS classes that are used for a block.
I ran into this when I tried to document the class names used as part of a block reference.
There is a solution for JS:
https://developer.wordpress.org/block-editor/developers/filters/block-filters/#blocks-getblockdefaultclassname
But not for PHP/server side. (-If there is, I was not able to find it and documentation needs to be improved)
For PHP, we can use https://developer.wordpress.org/reference/functions/render_block/
By using render_block we can get block attributes and block content,
but the CSS classes names are then only available as part of the content, and getting them is possible but "hacky".
Describe the solution you'd like
I want the class names, including the wp-block-block-name and CSS classes added by attributes and supports and the additional CSS field, to be available inside an array, be it separate or as part of the attributes.