-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Plugin Block Template editor inconsistency #65584
Comments
Thanks for reporting this issue. However, I'm not certain that it is a bug, or merely how the API is designed? With the example code above it seems you would be trying to overwrite the If we look at this check: https://github.com/WordPress/wordpress-develop/blob/292769dde95d7fec3b4f335af5b1c5cf04054db4/src/wp-includes/class-wp-block-templates-registry.php#L89 It is doing a lookup for If my understanding is correct then maybe we could look to introduce some additional error boundary for checking against I may be misunderstanding @widoz use case, and please forgive me if so. 😃 |
I meant to also tag @getdave and @kevin940726 for insight please. |
Hi @colorful-tones, They do not if the template exists in the theme but it is allowed if the theme does not provide one of them. |
@Aljullu since you have worked on the template registration API, would you be able to provide any insight here? |
Since RC1 is occurring later today and there is no active PR, I think we should punt this to 6.8 or 6.7.1. Thoughts @colorful-tones @getdave @kevin940726? |
Agree 👍 |
Thanks for opening this issue, @widoz. I'm not able to reproduce and I'm not 100% sure to understand what's going on here. A couple of questions:
Also wondering if you can reproduce the issue by hardcoding the add_action( 'init', static function() {
wp_register_block_template(
'templates//page',
[
'title' => 'My Single Page',
'description' => 'This is my single template',
'content' => '<!-- wp:paragraph --><p>This is a plugin-registered template.</p><!-- /wp:paragraph -->',
'post_types' => [ 'page' ],
]
);
} );
In fact, the goal of the API is to allow registering any template, even default WP ones. However, as @widoz mentions, theme templates take priority over plugin-registered templates. So if the theme includes a |
I wondered about this too. Good call out for simplifying the recreation steps. 👍 |
@widoz do you mind clarifying these items please:
|
Hi everyone, sorry about the late reply, I'll try to answer as best as I can @Aljullu
Yes
Unfortunately, I cannot replicate the problem anymore, at least not the way I was able to replicate it the first time (see first video). Now as you can see from the video below, the Template name appears for less than a second. It's not persistent anymore. No differences in using a Screencast.from.2024-10-18.23-31-44.webmUnfortunately I had problems with my local setup, and I had to destroy everything and I've also updated to the latest changes in the plugin, therefore my current installation is no longer the same of the one I had when I was experiencing the issue. |
Thanks for the additional info @widoz. I was finally able to replicate this. As you mentioned, the issue is no longer persistent, but I was able to capture the flash in the video below. custom-template-bug.mp4Steps to replicate:
cc @Aljullu |
The fact that "Swap template" takes a second to load in is not an issue. It happens with or without a registered template. The issue is that the name of the registered template "My Single Page" displays briefly. Here's a screenshot from the video above. My understanding is that if you register a template that is already part of the theme, the theme template takes precedence. At least that's what's noted in the PR. In the case of the example, the If this is just a visual bug, I don't think it's high priority. However, I do want to ensure it is just a visual bug and not something more. |
Thanks for your reporting the issue and your investigation trying to reproduce this, I was able to reproduce too.
Yes, this is my perception as well. There are two requests to the I will investigate it a bit more this week and hopefully come up with a fix, but I agree that this seems to be only a visual bug, it doesn't seem to affect the functionality of the editor or the frontend. |
Fantastic, thanks for the confirmation @Aljullu 🙏
Given this, I recommend we punt to 6.7.1 or 6.8. Thoughts @getdave @colorful-tones? |
I have been investigating this a bit more, the issue seems to be that In any case, I created a PR to fix this in Gutenberg: #66359. @ndiego I would appreciate it if you can take a look or ping somebody to take a look. I can then create the PR in WordPress core, but I want to make sure this is the correct approach, as I'm not very familiar with this logic. |
Description
I've noticed that registering a block template with a slug matching exactly
page
even if not applied (so the meta _wp_page_template does not exist) will be applied if and only if I click on the Template within the editor.The template is applied only to the Editor.
Below is the code I've used
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Screencast.from.2024-09-23.23-41-27.webm
Environment info
WordPress Version: 6.7-alpha-59076
Gutenberg Version: 19.3.0-rc.1
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: