-
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
Gutenberg Plugin: Add hook to allow writing-mode
as a safe CSS property
#54581
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/compat/wordpress-6.4/kses.php ❔ lib/load.php ❔ phpunit/style-engine/style-engine-test.php |
As far as I know, it was never supported in 6.3. I don't know if this was a decision made or if the backport just did not get done. |
Another question is if we want to add support for text-orientation at the same time or if this needs to wait until later: |
Sorry, this was my mistake. Indeed, writing mode seems to be supported starting with WordPress 6.4. https://core.trac.wordpress.org/ticket/59306
Personally, I think it would be better to merge this PR first, which has fewer files to add/update. That way, #52624 would only need to update the |
$styles = ''; | ||
if ( isset( $attributes['style']['typography']['writingMode'] ) ) { | ||
$styles = "writing-mode: {$attributes['style']['typography']['writingMode']};"; | ||
} | ||
$wrapper_attributes = get_block_wrapper_attributes( | ||
array( | ||
'class' => $classes, | ||
'style' => $styles, | ||
) | ||
); |
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.
Since this change will be bundled in with the packages update for core, would it be worth trying to land the change to core's safe_style_css
list before attempting to land this Gutenberg PR?
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 see, I think that's certainly true.
Would it be ideal to wait to merge this PR until a patch has been submitted to the core that adds writing-mode
to the safe_style_css
list and is committed in the core?
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 don't think it necessarily needs to be committed to core before merging this PR, but I'd recommend opening a trac ticket and corresponding PR for wordpress-develop
before merging if you have the time, that way the change will be ready to land in time.
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 is working nicely for me, thanks for adding it in!
✅ Writing-mode now outputs correctly for the footnotes block on the site frontend
✅ With this change the writing mode still outputs correctly for the post navigation link block
Just left a comment about backporting to core. If this PR lands for 6.4, it'd be good to ensure the backport for core lands as well so that the adjustment to the post navigation link block doesn't cause any regressions.
LGTM! ✨
Added a ticket and a patch to the core: https://core.trac.wordpress.org/ticket/59387 Also added to the backport tracking issue #54177. I think everything is ready now, so let's merge this PR 👍 |
@carolinan Could you rebase #52624 with the latest trunk and add |
Original PR from Gutenberg repository: * [WordPress/gutenberg#54581 #54581 Gutenberg Plugin: Add hook to allow `writing-mode` as a safe CSS property] Reference: [https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode MDN Web Docs: writing-mode]. Follow-up to [56605]. Props wildworks, mukesh27, poena, andrewserong. Fixes #59387. git-svn-id: https://develop.svn.wordpress.org/trunk@56617 602fd350-edb4-49c9-b593-d223f7449a82
Original PR from Gutenberg repository: * [WordPress/gutenberg#54581 #54581 Gutenberg Plugin: Add hook to allow `writing-mode` as a safe CSS property] Reference: [https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode MDN Web Docs: writing-mode]. Follow-up to [56605]. Props wildworks, mukesh27, poena, andrewserong. Fixes #59387. Built from https://develop.svn.wordpress.org/trunk@56617 git-svn-id: http://core.svn.wordpress.org/trunk@56129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Original PR from Gutenberg repository: * [WordPress/gutenberg#54581 #54581 Gutenberg Plugin: Add hook to allow `writing-mode` as a safe CSS property] Reference: [https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode MDN Web Docs: writing-mode]. Follow-up to [56605]. Props wildworks, mukesh27, poena, andrewserong. Fixes #59387. Built from https://develop.svn.wordpress.org/trunk@56617 git-svn-id: https://core.svn.wordpress.org/trunk@56129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Original PR from Gutenberg repository: * [WordPress/gutenberg#54581 #54581 Gutenberg Plugin: Add hook to allow `writing-mode` as a safe CSS property] Reference: [https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode MDN Web Docs: writing-mode]. Follow-up to [56605]. Props wildworks, mukesh27, poena, andrewserong. Fixes #59387. git-svn-id: https://develop.svn.wordpress.org/trunk@56617 602fd350-edb4-49c9-b593-d223f7449a82
Done |
Fixes #54344
Alternative to #54345
For more information, see this comment
What?
This PR includes the following three:
safe_style_css
filter to preventwiriting-mode
property from being removed bysafecss_filter_attr()
functionwriting-mode
style in render callback function of the Post Navigation Link block which is no longer neededWhy?
For dynamic blocks, as with other block support styles, there is no need to explicitly pass the style, as it should be automatically output by the
get_wrapper_attributes()
function.However, this property is not yet allowed in the core, so we need to allow it in the Gutenberg plugin first.
How?
writing-mode
(text orientation) is supported in WordPress 6.3. Therefore, this hook originally needed to be added in thelib/compat/wordpress-6.3
directory. However, this property will only be allowed in core WordPress 6.4 and above, so I added the hook to thelib/compat/wordpress-6.4
directory.Testing Instructions
To test this PR, enable Emptytheme and update theme.json as below:
Footnotes Block
Post Navigation Block