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

Don't use the custom 'Template Parts' page with WP 6.1 and above #45158

Merged
merged 1 commit into from
Oct 21, 2022

Conversation

Mamaduka
Copy link
Member

What?

PR adds a check not to register the custom 'Template Parts' page for WP 6.1 and above. This also prevents displaying two menu items with 'Template Parts' under the Appearance.

Why?

The custom page is only needed for older WP versions, where required restrictions are missing from site-editor.php.

Testing Instructions

  1. Install and activate a classic theme that enables block template parts - https://github.com/Mamaduka/block-fragments.
  2. On WP 6.0, confirm that the "Template Parts" menu uses a custom page.
  3. Upgrade to WP 6.1 RC.
  4. Confirm that the "Template Parts" page uses the site-editor.php path.

Screenshots or screencast

Before After
CleanShot 2022-10-20 at 16 21 44 CleanShot 2022-10-20 at 16 21 20

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts labels Oct 20, 2022
@Mamaduka Mamaduka self-assigned this Oct 20, 2022
@Mamaduka Mamaduka requested review from fabiankaegy and removed request for spacedmonkey October 20, 2022 12:30
@Mamaduka Mamaduka force-pushed the add/check-for-template-parts-screen branch from 5b27479 to 229cb23 Compare October 21, 2022 05:14

$needs_custom_page = true;
foreach ( $submenu['themes.php'] as $menu_item ) {
if ( str_contains( $menu_item[2], 'site-editor.php?postType=wp_template_part' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure whether there is any other way to query this, but just from my gut feeling this feels rather fragile. But I will still approve the PR since we can follow up with a more robust solution and this does fix the bug that is currently present.

@Mamaduka Mamaduka merged commit 902dd72 into trunk Oct 21, 2022
@Mamaduka Mamaduka deleted the add/check-for-template-parts-screen branch October 21, 2022 08:31
@Mamaduka Mamaduka added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Oct 21, 2022
@github-actions github-actions bot added this to the Gutenberg 14.5 milestone Oct 21, 2022
@Mamaduka
Copy link
Member Author

@priethor, @juanmaguitar, can we backport this into 14.4?

It would be great to land the fix in the plugin before WP 6.1 is released

@priethor priethor removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Oct 24, 2022
@priethor
Copy link
Contributor

Cherry-picked to the 14.4 branch in 55180ae

@Mamaduka
Copy link
Member Author

Thank you, @priethor!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants