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

Update the opt-in for the stylebook in classic themes #68940

Closed
wants to merge 2 commits into from

Conversation

carolinan
Copy link
Contributor

@carolinan carolinan commented Jan 29, 2025

What?

This PR changes how classic themes can opt-in to show the stylebook under the menu Appearance > Design.

Previously the stylebook was shown when the theme included add_theme_support( 'editor-styles' );
The PR replaces the check for editor-styles with current_theme_supports( 'editor', 'stylebook' )

What this does not do:
The PR does not offer a way to disable the style book for classic themes that add theme.json.
To do: Figure out what to do about the direct path to the stylebook
wp-admin/site-editor.php?p=%2Fstylebook

Partial for #68036

Why?

  • Theme developers may want to use editor-styles without the stylebook. A use case would be when the developer has created its own style guide.
  • Theme developers may be unaware that using the existing theme support enables new features.
  • By adding a new 'editor' theme support, theme developers can explicitly opt-in to the stylebook.
    The new editor theme support can be extended later, as an alias for existing theme support related to the Site Editor, and for new features.

How?

The PR replaces the check for editor-styles with current_theme_supports( 'editor', 'stylebook' )

Testing Instructions

There should be no change for block themes and hybrid themes:
classic themes with theme.json
classic themes with templatest/index.html

Activating a classic theme should not enable the Design menu unless the theme support is added.

To add the theme support, copy paste the following into the theme setup function, usually in functions.php:

		add_theme_support(
			'editor',
			array(
				'stylebook'
			)
		);

After it is added, the design menu item with the nested Patterns and Styles pages should be available.
The Pattern menu item should not be showing directly under Appearance.

@carolinan carolinan added [Type] Enhancement A suggestion for improvement. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Feature] Style Book Needs PHP backport Needs PHP backport to Core labels Jan 29, 2025
Copy link

Flaky tests detected in dc249b2.
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/13029645509
📝 Reported issues:

@carolinan
Copy link
Contributor Author

carolinan commented Jan 29, 2025

I added the needs backport label, but I see that the PR for the trac ticket from the previous PR is still a draft: WordPress/wordpress-develop#7865

And is conflicting with the new site editor paths: https://github.com/WordPress/wordpress-develop/pull/7903/files

@Mamaduka
Copy link
Member

@carolinan, what are the blockers for this PR?

@carolinan
Copy link
Contributor Author

#68959
and that the core patch has not been started on.

@carolinan carolinan marked this pull request as ready for review January 31, 2025 08:20
Copy link

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: carolinan <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

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

@Mamaduka
Copy link
Member

#68959 doesn't have to block this. It's a pre-existing bug here we're just changing the theme supports flag.

@carolinan
Copy link
Contributor Author

Changing the theme support here only changes the menu item, nothing else, and if that is what we want to do, no, a theme support is not needed at all because developers can already change the menu items.

@Mamaduka
Copy link
Member

Then I misunderstood the #68036. I thought the request was to use different theme support flags and make this feature opt-in for classic theme developers, which this PR does.

The new site redirection logic is a separate enhancement; related issues will be resolved separately.

a theme support is not needed at all because developers can already change the menu items.

Developers can do a lot, but frameworks still provide APIs to make certain things more manageable.

@carolinan
Copy link
Contributor Author

I don't understand. It does not opt-in to the style book to me. It opts in to the menu item.
But if I am the only blocker, go ahead.

@carolinan
Copy link
Contributor Author

carolinan commented Feb 5, 2025

What should have been obvious, is that there is also a Styles menu item in the Site Editor Sidebar, that can be found if you open the Patterns page and then go back to the start of the Site Editor. This menu item is not removed by changing the Admin menu 😆

If the decision is to opt-in to the stylebook, then the theme support needs to be registered so that it is available in the Site Editor. Then the entire Stylebook can be shown conditionally.

@carolinan
Copy link
Contributor Author

I am closing this in favour of #69043
69403 registers the theme support, which is closer to what we need to do in order to show or hide the Site Editor menu item and stylebook page.

@carolinan carolinan closed this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Style Book [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs PHP backport Needs PHP backport to Core [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants