-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Template activation: allow duplicates of 'custom' plugin templates to be activated #72713
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
|
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 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: -37 B (0%) Total Size: 2.37 MB
ℹ️ View Unchanged
|
1d6e4bb to
4b16298
Compare
| return <Badge intent="error">{ item.theme }</Badge>; | ||
| }, | ||
| }; | ||
| return useMemo( |
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.
Just added useMemo here.
|
Flaky tests detected in 14c45b4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18867527805
|
0d678b9 to
8ce160b
Compare
kmanijak
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 @ellatrix for the PR and followup fixes based on my testing! 🚀
I tested the PR from WooCoommerce perspective and:
- template edits from before activation are preserved
- templates can be edited, saved and user is prompt to activate the template
- custom templates show up in the editor
Looking good, let's merge!
… be activated (#72713) Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: kmanijak <karolmanijak@git.wordpress.org>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 551c3a0 |
| if ( item.theme === activeTheme.stylesheet ) { | ||
| return <Badge intent="success">{ item.theme }</Badge>; | ||
| } | ||
| return <Badge intent="error">{ item.theme }</Badge>; |
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.
Nit: we're creating 2 separate <Badge /> components, when we could have made just the intent prop have a conditional value.
|
|
||
| const activeLabel = item._isCustom | ||
| ? __( 'Active when used' ) | ||
| : __( 'Active' ); |
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.
These might need context or a translator's comment. For example, in some languages, these words will have a gender, and it might depend on the context.
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.
-> #72928
What?
See #72475. See #72580.
All registered templates were editable before: so you need to be able to duplicate and activate.
Example: the
Page No Titleis a custom template, which is in a sort of grey area in terms of "Active" status. I've opted for "Active when used" for custom templates, because they may be used for certain pages, and plugins may render templates their own way.Users can duplicate these templates (previously edit), which means this duplicate can now be activated and receive the "Active when used" status, while the original theme/plugin (registered) template will become "Inactive".
This PR essentially removes custom behavior for custom (ugh) templates: they can be activated, we just label the status differently.
Note
Plugins can opt-out of showing the special custom template status by adding the slug to
default_template_types. When added to this filter, these templates will now receive the regular "Active" status like theme templates types.Note
When plugins register templates that fit in the template hierarchy, they should not be marked as custom templates. This is currently a pre-6.9 limit where only a narrow set of template slugs are considered default templates. This is incorrect: any slug that matches the hierarchy should be considered a default template. When we fix this in the future, these templates will automatically no longer be marked as custom.
Why?
Backwards compatibility: All registered templates were editable before: so you need to be able to duplicate and activate.
It also simplifies things and makes things easy to reason about: all templates can be activated.
How?
Testing Instructions
When testing the 2025 theme:
When testing Woo:
TODO: add some e2e tests for these custom template flows.
Testing Instructions for Keyboard
Screenshots or screencast