Expose the Site Editor Patterns page for all classic themes
Trac ticket: https://core.trac.wordpress.org/ticket/61109
Summary
This PR makes the following changes in the classic theme.
- Link Appearance > Patterns submenu to the Site Editor Patterns page (
wp-admin/site-editor.php?path=/patterns) - Remove Template Parts submenu
About Menu Structure
It's a little confusing what the index of the submenu that $submenu['themes.php'] has, but for the submenu that this PR relates to, it should be as follows.
Block Theme
[5] => Themes
[6] => Editor
[7] => (Customize)
Classic Theme
[5] => Themes
[6] => Patterns
[7] => Customize
[8] => (Widgets)
Screenshots
Block Theme (Twenty Twenty-Four)
It's no different than before.
Classic Theme (Twenty Twenty-One)
The menu structure remains the same, but the Patterns submenu now links to the Site Editor's Patterns page.
Classic theme with block-template-parts support
The Template Part submenu has been removed and the Patterns submenu now links to the Site Editor's Patterns page.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
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.
Core Committers: Use this line as a base for the props when committing in SVN:
Props wildworks, ironprogrammer, azaozz, youknowriad, audrasjb.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.
Test using WordPress Playground
The changes in this pull request can previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.
Some things to be aware of
- The Plugin and Theme Directories cannot be accessed within Playground.
- All changes will be lost when closing a tab with a Playground instance.
- All changes will be lost when refreshing the page.
- A fresh instance is created each time the link below is clicked.
- Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance, it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.
Agree with @ironprogrammer, code looks good. The only thing I'm a bit unsure about is the part of site-editor.php that deals with template parts and non-block themes: https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-admin/site-editor.php#L22-L35.
If the template parts menu item is removed, does that code need updating too?
Thanks for the review!
The only thing I'm a bit unsure about is the part of site-editor.php that deals with template parts and non-block themes: https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-admin/site-editor.php#L22-L35.
If the template parts menu item is removed, does that code need updating too?
The code here, i.e. $is_template_part_editor, should be maintained for backward compatibility. This is because the path (wp-admin/site-editor.php?path=/wp_template_part/all ) may have been hard-coded by the developer or added to the browser's bookmarks by the user.
On the site editor side, when this old path is accessed, it redirects to the pattern page. See https://github.com/WordPress/gutenberg/pull/61446 for details.
should be maintained for backward compatibility. ...may have been hard-coded by the developer or added to the browser's bookmarks by the user.
Right, that's why I asked :)
On the site editor side, when this old path is accessed, it redirects to the pattern page.
Yep, this is how it should be. However it doesn't seem to redirect in WP core when testing this PR (unless I'm not testing it right?). It goes to a "Manage template parts" screen which of course doesn't work right. Thinking it would be good to have that redirect in PHP too.
Here's a screenshot with this PR applied and testing the old URL:
However it doesn't seem to redirect in WP core when testing this PR
I think it's because the latest Gutenberg hasn't been merged into core yet, although JS redirection is implemented here.
I feel that if we implement PHP redirection in the core, JS redirection in Gutenberg might be unnecessary.
cc @youknowriad @jsnajdr
I feel that if we implement PHP redirection in the core, JS redirection in Gutenberg might be unnecessary.
Yes, thinking so too. Generally PHP redirects are preferable as they run faster (the browser stops loading the current page and redirects as soon as it receives the header of the response).
I think JS redirection is probably necessary here because the site editor is an SPA and folks (third-parties) can navigate to URLs without actually reaching the server.
With changeset 58187, The JS side redirect is now reflected in the core. Do we also need a PHP redirect just in case?
I don't think it's needed personally. This PR seems ready to ship for me.
Checking WP Directory for use of \/wp_template_part\/all, of the [only] two hard-coded links in those results, they redirect to site-editor.php?path=/patterns as expected. I agree this is good to go.
Committed in https://core.trac.wordpress.org/changeset/58278