-
Notifications
You must be signed in to change notification settings - Fork 798
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
Gutenblocks: add new utility to get all classes for a given block #13302
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: September 3, 2019. |
@jeffersonrabb I added you as a reviewer here because I remember you were particularly interested to see this happen unless I remember wrong. but no pressure/feel free to ignore. ;-) |
&& in_array( $attr['align'], array( 'left', 'center', 'right', 'wide', 'full' ), true ) | ||
) { | ||
array_push( $classes, 'align' . $attr['align'] ); | ||
} |
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.
Do we even have to take care of alignment? I thought we could pretty much rely on Gutenberg's supports
feature for alignment... 🤔 I'll try to dig up a PR I vaguely recall where I was doing something like that...
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.
I think some of our blocks are little old in that we handled it manually. Gutenberg's support might be purely frontend side and backend side has to be handled manually like this?
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.
For reference, this is the commit I was thinking of: Automattic/wp-calypso@d675ab0
I'll see if that kind of change can be applied here...
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, nevermind, that doesn't really apply to dynamic blocks/the server side/PHP.
jeherve, Your synced wpcom patch D31844-code has been updated. |
It's already specified earlier anyway. See https://github.com/Automattic/jetpack/pull/13302/files#r316986528 Co-Authored-By: Bernie Reiter <ockham@raz.or.at>
jeherve, Your synced wpcom patch D31844-code has been updated. |
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.
Tested gif, recurring payments, repeat visitor, and Mailchimp blocks. Tested with gif's align options and with custom CSS classes for each.
Super happy to see maintenance like this. Well done!
empty does check if it is set anyway. See #13302 (comment)
jeherve, Your synced wpcom patch D31844-code has been updated. |
'wp-block-button__link', | ||
'components-button', | ||
'is-primary', | ||
'is-button', |
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.
Not entirely sure classes like this belong into a top-level block element, that's pre-existing. (It might raise the question if the new util is really needed, or more of a symptom of suboptimal architectural choices, but oh well.)
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 👍
It's almost curious that core doesn't provide a helper like this for dynamic blocks (and might be a worthwhile addition).
|
||
// Basic block name class. | ||
$classes = array( | ||
'wp-block-jetpack-' . $slug, |
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.
Just noting that (I think) setting className:false
in block's supports
attributes would normally disable the primary class name as well but this always enforces it.
I don't think we'll ever have any such blocks in Jetpack so it doesn't really matter, but wanted to note in case anyone looks up this PR later on for inspiration to implement this also in core Gutenberg.
Bringing Design for a second opinion here about the default alignment for blocks. See #13257 for a point of view on this, and p1566567543002100-slack-jetpack-plugin for another. |
For reference here's how we're doing the same in Newspack, although this PR has a bit of sophistication we'll want to add to Newspack's: https://github.com/Automattic/newspack-blocks/blob/master/newspack-blocks.php#L147-L164 |
I think it's ok to address separate since this PR doesn't really change that behavior, right? |
It does, for the Mailchimp and the Gif blocks. See #13257 for the previous behaviour. |
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. The center
alignment in GIF and Mailchimp was just a reasonable default, I don't think we'll miss it.
* 7.7 changelog: initial set of changes * Changelog: add #13154 * Changelog: add #13134 * Changelog: add #12699 and many others * Changelog: add #13127 * Changelog: add #13167 * Changelog: add #13225 * Changelog: add #13179 * Changelog: add #13173 * Changelog: add #13232 * Changelog: add #13137 * Changelog: add #13172 * Changelog: add #13182 * Changelog: add #13200 * Changelog: add #13244 * Changelog: add #13267 * Changelog: add #13204 * changelog: add #13205 * Changelog: add #13183 * Changelog: add #13278 * Changelog: add #13162 * Changelog: add #13268 * Changelog: add #13286 * Changelog: add #13273 * Changelog: add #12474 * Changelog: add #13085 * Changelog: add #13266 * Changelog: add #13306 * Changelog: add #13311 * Changelog: add #13302 * Changelog: add #13196 * Changelog: add #12733 * Changelog: add #13261 * Changelog: add #13322 * Changelog: add #13333 * Changelog: add #13335
Fixes #13257
Changes proposed in this Pull Request:
Testing instructions:
wp-block-jetpack-blockname
.aligncenter
class name by default.Proposed changelog entry for your changes: