-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register the block attributes server-side for blocks with support flags #24400
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Thanks for following up to add these for colors and typography.
'type' => 'string', | ||
'enum' => array( 'left', 'center', 'right', 'wide', 'full', '' ), | ||
); | ||
if ( ! array_key_exists( 'align', $block_type->attributes ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes! Good addition we missed in the last one. This makes sense to not define if it is already defined.
$block_type->attributes = array(); | ||
} | ||
|
||
if ( $has_text_colors_support && ! array_key_exists( 'style', $block_type->attributes ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be more readable if we use $color_support
instead of $has_text_colors_support
(or a comment), since the style attribute needs to be initialized for custom values of all the different items that can have color support.
At first glance reading it I thought "why are we only defining the style object for text colors?", but then realized that none of the others can be supported without text color support anyways. So it still looks correct from a functionality standpoint!
Size Change: 0 B Total Size: 1.16 MB ℹ️ View Unchanged
|
This PR continues on top of #24351 to register the missing attributes for the colors and typography support flags.
This doesn't have any impact on Core blocks because Core blocks with these flags don't use
ServerSideRender
. Nonetheless, it is important to register those attributes for third-party blocks and for consistency.