-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Only list the custom block templates in the list of available templates per post type #2020
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
Closed
youknowriad
wants to merge
1
commit into
WordPress:trunk
from
youknowriad:backport/get-block-templates
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, Riad. While an update will fix the issue, I'm a little worried about the
WP_Querycalls this change will produce.Since only custom templates (is_custom = true) are allowed to be page/post templates, maybe we use that property and conditionally add templates to the list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand? Are you worried about the number of requests? Is there a way maybe to solve this by adding a new
is_customto the query object?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm worried about the number of requests.
We'll still need the
post_typeto check if the template is supported for this specific post type.I think this has to be done slightly differently than we do in a plugin. I can create PR for my idea of PoC later today/tomorrow if we're not limited in the timeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rough example:
We have to use properties directly in the loop instead of passing post type as query argument because we don't have access to the current post type in the
get_post_templatesmethod.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need that to determine whether a template is
is_custom?--
I think we can probably commit the PR as is and consider improvements in follow-up to buy us time WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I can do a follow-up PR for beta 3.
We don't need to know the post type for
is_custom.