Skip to content
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

Merged
merged 1 commit into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions blocks/library/categories/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function render_block_core_categories( $attributes ) {

$class = "wp-block-categories wp-block-categories-{$type} align{$align}";

if ( isset( $attributes['className'] ) ) {
Copy link
Member

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

Copy link
Member Author

@jorgefilipecosta jorgefilipecosta Apr 20, 2018

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.

if ( ! isset( $this->attributes ) ) {
return $attributes;
}

Copy link
Member

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) :)

$class .= ' ' . $attributes['className'];
}

$block_content = sprintf(
$wrapper_markup,
esc_attr( $class ),
Expand Down
7 changes: 7 additions & 0 deletions blocks/library/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ function render_block_core_latest_posts( $attributes ) {
$class .= ' columns-' . $attributes['columns'];
}

if ( isset( $attributes['className'] ) ) {
$class .= ' ' . $attributes['className'];
}

$block_content = sprintf(
'<ul class="%1$s">%2$s</ul>',
esc_attr( $class ),
Expand All @@ -74,6 +78,9 @@ function register_block_core_latest_posts() {
'categories' => array(
'type' => 'string',
),
'className' => array(
Copy link
Member

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.

'type' => 'string',
),
'postsToShow' => array(
'type' => 'number',
'default' => 5,
Expand Down