wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

Expose the Site Editor Patterns page for all classic themes

Open t-hamano opened this issue 1 year ago • 2 comments

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.

image

Classic Theme (Twenty Twenty-One)

The menu structure remains the same, but the Patterns submenu now links to the Site Editor's Patterns page.

image

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.

image


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.

t-hamano avatar May 02 '24 03:05 t-hamano

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.

github-actions[bot] avatar May 02 '24 03:05 github-actions[bot]

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.

Test this pull request with WordPress Playground.

github-actions[bot] avatar May 02 '24 03:05 github-actions[bot]

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?

azaozz avatar May 22 '24 23:05 azaozz

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.

t-hamano avatar May 23 '24 12:05 t-hamano

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: old-template-parts-screen

azaozz avatar May 24 '24 01:05 azaozz

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

t-hamano avatar May 24 '24 01:05 t-hamano

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).

azaozz avatar May 24 '24 02:05 azaozz

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.

youknowriad avatar May 24 '24 07:05 youknowriad

With changeset 58187, The JS side redirect is now reflected in the core. Do we also need a PHP redirect just in case?

t-hamano avatar May 24 '24 11:05 t-hamano

I don't think it's needed personally. This PR seems ready to ship for me.

youknowriad avatar May 30 '24 09:05 youknowriad

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.

ironprogrammer avatar May 30 '24 18:05 ironprogrammer

Committed in https://core.trac.wordpress.org/changeset/58278

audrasjb avatar Jun 02 '24 08:06 audrasjb