-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Added missing custom class in the latest posts & categories block #6311
Conversation
8013786
to
8d736e0
Compare
Thank you for reminding me I missed to commit the changes to the category block. They were added. |
@@ -48,6 +48,10 @@ function render_block_core_categories( $attributes ) { | |||
|
|||
$class = "wp-block-categories wp-block-categories-{$type} align{$align}"; | |||
|
|||
if ( isset( $attributes['className'] ) ) { |
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.
Out of curiosity, how does it work without attributes
specified on the server? :D
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.
Hi @gziolo, I was also curious about this logic while doing the changes. This works because prepare_attributes_for_render, just returns the attributes parsed from the comment demarcations if the attributes are not "registered" on the server.
gutenberg/lib/class-wp-block-type.php
Lines 128 to 130 in eee9278
if ( ! isset( $this->attributes ) ) { | |
return $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.
Good to know, it needs to be fixed soon (another PR) :)
|
8d736e0
to
c0e1a9d
Compare
Hi @gziolo, I'm sorry, my editor because of some reason did not display the error, the problem was corrected. |
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.
LGTM 👍
Thank you for the review @gziolo! |
@@ -74,6 +78,9 @@ function register_block_core_latest_posts() { | |||
'categories' => array( | |||
'type' => 'string', | |||
), | |||
'className' => array( |
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.
The introduction of this attribute should have been complemented by an update to fixtures, which auto-generates from server attributes. Running npm run fixtures:regenerate
on master introduces an unexpected change.
Description
This PR adds a custom class in the front end in the latest post and categories block.
Fixes: #5644
How has this been tested?
Add a latest posts block, set a custom class, save the post verify the custom class appears in the front end (in master it does not appear).
Repeat the same steps for the categories block.