Skip to content

Expose the Site Editor Patterns page for all classic themes#6480

Closed
t-hamano wants to merge 1 commit into
WordPress:trunkfrom
t-hamano:61109
Closed

Expose the Site Editor Patterns page for all classic themes#6480
t-hamano wants to merge 1 commit into
WordPress:trunkfrom
t-hamano:61109

Conversation

@t-hamano

@t-hamano t-hamano commented May 2, 2024

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented May 2, 2024

Copy link
Copy Markdown

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

github-actions Bot commented May 2, 2024

Copy link
Copy Markdown

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.

@ironprogrammer ironprogrammer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, @t-hamano. It'll be great to resolve the awkward links between Patterns and Template Parts into the site editor's Patterns menu 👍🏻

I'd like to recommend this for commit.

@azaozz

azaozz commented May 22, 2024

Copy link
Copy Markdown
Contributor

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?

@t-hamano

Copy link
Copy Markdown
Contributor Author

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 WordPress/gutenberg#61446 for details.

@azaozz

azaozz commented May 24, 2024

Copy link
Copy Markdown
Contributor

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

@t-hamano

Copy link
Copy Markdown
Contributor Author

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

@azaozz

azaozz commented May 24, 2024

Copy link
Copy Markdown
Contributor

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

@youknowriad

Copy link
Copy Markdown
Contributor

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.

@t-hamano

Copy link
Copy Markdown
Contributor Author

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

@youknowriad

Copy link
Copy Markdown
Contributor

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

@ironprogrammer

Copy link
Copy Markdown
Member

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.

@audrasjb

audrasjb commented Jun 2, 2024

Copy link
Copy Markdown
Contributor

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

@audrasjb audrasjb closed this Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants