-
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
Make it possible to opt-out of the classic theme Stylebook #69043
base: trunk
Are you sure you want to change the base?
Conversation
-Registers and enables a new theme support called stylebook. - Introduces a check for the theme support in the Site Editor sidebar and Stylebook preview. - The sidebar menu hides the Styles menu item if it is unsupported. - The stylebook preview displays a notice at the top of the page if it is unsupported. - Classic themes can opt.out by using remove_theme_support( 'stylebook' );
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @BowFarmer. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +201 B (+0.01%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in 14aff92. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13179898863
|
register_theme_feature( | ||
'stylebook', | ||
array( | ||
'description' => __( 'test' ), |
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.
of course, this isnt supposed to say test 😆 I will fix it when I get back to work next week.
What?
In this alternative for the stylebook in classic themes, all classic themes have a menu under Appearance called Design.
Design opens the preview of the homepage, and the sidebar has two menu items: Patterns and Styles.
Styles opens the Stylebook. This stylebook is not interactive: not yet. It is a preview of the color palette, blocks etc.
The Stylebook is available to all classic themes because this PR registers a new theme support called
stylebook
, and then enables it by default. Because, you can't remove a theme support that doesn't exist.Classic themes can then opt-out of the Stylebook by removing the theme support:
remove_theme_support( 'stylebook' );
To enable checking for the new theme support in the Site Editor, I needed to make it available in the themes REST API endpoint, which is why I am using https://developer.wordpress.org/reference/functions/register_theme_feature/ with
show_in_rest
set to true.The reason for not only removing the Design menu item from Appearance is that if you open the Patterns page, and then go back one step using the button with the arrow icon, you would see the Styles menu item and would be able to access the Stylebook from there.
Closes #68036
Testing Instructions
Activate any classic theme.
Go to Appearance > Design > Styles.
The Stylebook should display correctly.
Add
remove_theme_support( 'stylebook' );
to the theme, for example in the themes functions.php file, in the theme setup.Check that the Appearance menu now has Patterns instead of Design.
Open Patterns. Go back one step using the button in the sidebar.
Confirm that there is no Styles menu.
Go to: wp-admin/site-editor.php?p=%2Fstylebook
The Sidebar will still show the description, but the main content of the page is a notice saying that the Stylebook is not supported.
Screenshots or screencast
When the Stylebook is not supported, a notice is showing: