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

Global Styles: Skip registration of variation styles when unsupported #62529

Merged

Conversation

aaronrobertshaw
Copy link
Contributor

What?

Prevents going through all the work of searching for theme.json partials, parsing them and the core theme.json etc when the theme doesn't have its own theme.json.

Why?

Performance and simplicity.

How?

Make a check to wp_theme_has_theme_json() and return early if applicable.

Testing Instructions

  1. Add a block style variation to a theme via any source e.g. through its theme.json and the snippet below:
                       "variations": {
                               "FromTheme": {
                                       "blockTypes": [
                                               "core/group",
                                               "core/columns"
                                       ],
                                       "color": {
                                               "background": "blue"
                                       }
                               }
                       },
  1. Confirm this variation still shows and works appropriately
  2. Switch theme to a classic theme and confirm no variations are shown
  3. Update a hybrid theme to have a block style variation within its theme.json via snippet below.
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 2,
	"styles": {
		"blocks": {
			"variations": {
				"FromTheme": {
					"blockTypes": [ "core/group", "core/columns" ],
					"color": {
						"background": "blue"
					}
				}
			}
		}
	}
}
  1. Confirm the variation shows

@aaronrobertshaw aaronrobertshaw added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 13, 2024
@aaronrobertshaw aaronrobertshaw self-assigned this Jun 13, 2024
Copy link

github-actions bot commented Jun 13, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

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/block-supports/block-style-variations.php

@aaronrobertshaw
Copy link
Contributor Author

I'm holding off on merging this one for the moment.

The solution would work nicely for block themes but also impacts hybrid themes. I'll take another run at this tomorrow.

@aaronrobertshaw aaronrobertshaw force-pushed the update/skip-variation-registration-when-not-supported branch from 450576e to 045c15a Compare June 17, 2024 03:16
@aaronrobertshaw aaronrobertshaw added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 17, 2024
@aaronrobertshaw aaronrobertshaw force-pushed the update/skip-variation-registration-when-not-supported branch from f282c1f to 303e91f Compare June 17, 2024 04:47
Copy link

Flaky tests detected in 34f4768.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9542559209
📝 Reported issues:

@oandregal oandregal merged commit e3e5775 into trunk Jun 17, 2024
64 checks passed
@oandregal oandregal deleted the update/skip-variation-registration-when-not-supported branch June 17, 2024 09:46
@github-actions github-actions bot added this to the Gutenberg 18.7 milestone Jun 17, 2024
huubl pushed a commit to huubl/gutenberg that referenced this pull request Jun 17, 2024
…WordPress#62529)

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…#62529)

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…#62529)

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
@ellatrix
Copy link
Member

I just cherry-picked this PR to the wp/6.6-beta-3 branch to get it included in the next release: f0327a0

@ellatrix ellatrix added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 18, 2024
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…#62529)

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants