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

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Apr 20, 2018

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.

@jorgefilipecosta jorgefilipecosta self-assigned this Apr 20, 2018
@gziolo
Copy link
Member

gziolo commented Apr 20, 2018

Can you provide the same fix for Categories block? :D

From @jvisick:

This is similar to #5486. It also seems to be an issue with the categories widget block.

@gziolo gziolo self-requested a review April 20, 2018 10:19
@jorgefilipecosta jorgefilipecosta force-pushed the fix/custom-class-in-latest-posts branch from 8013786 to 8d736e0 Compare April 20, 2018 10:29
@jorgefilipecosta
Copy link
Member Author

Thank you for reminding me I missed to commit the changes to the category block. They were added.

@jorgefilipecosta jorgefilipecosta changed the title Added missing custom class in the latest posts block. Added missing custom class in the latest posts & categories block Apr 20, 2018
@@ -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) :)

@gziolo
Copy link
Member

gziolo commented Apr 20, 2018

phpcs complains about:

Array double arrow not aligned correctly; expected 7
| | space(s) between "'className'" and double arrow, but
| | found 6.
| | (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned)

@jorgefilipecosta jorgefilipecosta force-pushed the fix/custom-class-in-latest-posts branch from 8d736e0 to c0e1a9d Compare April 20, 2018 17:26
@jorgefilipecosta
Copy link
Member Author

phpcs complains about:

Hi @gziolo, I'm sorry, my editor because of some reason did not display the error, the problem was corrected.

@gziolo gziolo added this to the 2.8 milestone Apr 23, 2018
@gziolo gziolo added [Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended labels Apr 23, 2018
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jorgefilipecosta jorgefilipecosta merged commit 167d447 into master Apr 23, 2018
@jorgefilipecosta jorgefilipecosta deleted the fix/custom-class-in-latest-posts branch April 23, 2018 09:33
@jorgefilipecosta
Copy link
Member Author

Thank you for the review @gziolo!

nuzzio pushed a commit to nuzzio/gutenberg that referenced this pull request Apr 25, 2018
@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants