-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Block Styles: Ensure unique classname generation for variations #7200
Block Styles: Ensure unique classname generation for variations #7200
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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.
Unit tests going failed. That needs to fix.
1) Tests_Block_Supports_WpCreateBlockStyleVariationInstanceName::test_block_style_variation_instance_name_generation
Unexpected deprecation notice for wp_create_block_style_variation_instance_name.
Function wp_create_block_style_variation_instance_name is deprecated since version 6.7.0! Use wp_unique_id instead.
Failed asserting that an array is empty.
/var/www/tests/phpunit/includes/abstract-testcase.php:643
/var/www/tests/phpunit/includes/abstract-testcase.php:655
/var/www/vendor/yoast/phpunit-polyfills/src/TestCases/TestCasePHPUnitGte8.php:82
phpvfscomposer:///var/www/vendor/phpunit/phpunit/phpunit:97
/var/www/vendor/bin/phpunit:118
59afe95
to
b851a6b
Compare
Thanks for flagging that @mukeshpanchal27 👍 I wasn't too sure on whether the test should be removed or just flagged as expecting the deprecation. I went with flagging the expected deprecation so it can be removed once the deprecated function is. |
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.
Relocation sale and a question.
tests/phpunit/tests/block-supports/wpCreateBlockStyleVariationInstanceName.php
Show resolved
Hide resolved
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
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.
✅ Unique ids appear for style variations inside multiple patterns on the frontend
✅ Unique style variations rules are being generated for global styles on the frontend, e.g., :root :where(.wp-block-group.is-style-section-a--17)
Trac ticket: https://core.trac.wordpress.org/ticket/61877
This PR backports the PHP changes from WordPress/gutenberg#64511.
What?
Simplifies block style variation class name generation to ensure unique class.
Why?
Avoids potential for non-unique class names and conflicting styles when exact copies of a block are inserted via a repeated pattern.
Further background and context can be found over on WordPress/gutenberg#64511.
How?
Replace the hashing of block attributes in the block style variation classnames with a call to
wp_unique_id
.Testing Instructions
Confirm unique classnames on frontend
is-style-outline-
. You should find CSS with three styles matching that pattern however they should now all be unique.Ensure no regressions for block style variations on the frontend
Example block style variation theme.json partial (place under `/styles`)
Screenshots or screencast
Simple unique classnames for exact copies of blocks
Block Style Variations still working
Screen.Recording.2024-08-14.at.9.24.28.PM.mp4
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.