-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Site Editor: Prevent classic theme from accessing global style menu #58345
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
Conversation
|
Size Change: +3 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
aaronrobertshaw
left a comment
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.
Thanks for the fix @t-hamano 👍
My understanding is that whether it supports the Global Styles or not is completely consistent with whether it's a block theme, so I updated it to only check if it's a block theme instead of supportsTemplatePartsMode.
Assuming I understood the original intent of #42729, I'd agree. In that light the changes here make sense to me.
✅ Changes LGTM
✅ Could replicate original issue
✅ Confirmed this PR resolves the issue
| Before | After |
|---|---|
![]() |
![]() |
|
@aaronrobertshaw Thanks for the review! |
carolinan
left a comment
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 tested this with a Twenty Twenty-One and Astra, a classic theme with theme.json.
With the PR I can no longer open the Styles sidebar.
|
@carolinan Thanks for the review! It seems that React Native E2E Tests are also failing on trunk, so I would like to update and merge this PR after that issue is resolved. |


What?
This PR fixes an issue where classic themes could unintentionally access global styles when they get access to the Patterns page in the site editor in the future.
Why?
As indicated in this comment, the goal is for all Classic themes to have access to the Site Editor's Patterns page in the future.
As of WP6.5, access to this Pattern page is allowed internally, but I discovered that when I open the pattern editor canvas I can access the Global Styles menu.
My understanding is that the Global Styles is not expected to support the classic theme in the future, so this menu should not appear.
How?
Support for global styles currently relies on
supportsTemplatePartsModebeingfalse. This variable is determined by whether the theme is not classic and supports template parts:https://github.com/WordPress/wordpress-develop/blob/5c4b4887bf088b91df4f5e467b8982fa3b5441ec/src/wp-admin/site-editor.php#L64
The fact that
supportsTemplatePartsModeisfalsemeans that the following conditions are met:If the classic theme does not have template parts opted in, this condition is
false, which meanssupportsGlobalStylesistrue.My understanding is that whether it supports the Global Styles or not is completely consistent with whether it's a block theme, so I updated it to only check if it's a block theme instead of
supportsTemplatePartsMode.Testing Instructions
wp-admin/site-editor.phpto temporarily allow access:http://localhost:8888/wp-admin/site-editor.php?path=%2Fpatternsand create a pattern.