FSE: Fix template loading order for child themes when no explicit template exists#31336
Merged
draganescu merged 2 commits intotrunkfrom May 4, 2021
Merged
Conversation
Contributor
Author
|
I'm not sure if I might be missing other important cases that I've not considered to test. |
|
Size Change: 0 B Total Size: 1.31 MB ℹ️ View Unchanged
|
jffng
approved these changes
Apr 29, 2021
Contributor
There was a problem hiding this comment.
This works as described. The use case I verified:
- Child theme has an index.php
- Parent theme has an index.html
- Visited
/category/some-tagand verified the child theme's index.php was loaded
Without this PR, the parent theme's index.html is loaded.
For sanity, I also checked if the parent theme has a higher matching template (e.g. archive.html / archive.php in my example), it loads this template correctly.
scruffian
approved these changes
Apr 29, 2021
Contributor
scruffian
left a comment
There was a problem hiding this comment.
This solves the issue, and the code looks good. I tested all the scenarios I could think of...
youknowriad
pushed a commit
that referenced
this pull request
May 5, 2021
…plate exists (#31336) * formatting and comments * fix how we control the block template file
ockham
added a commit
that referenced
this pull request
May 12, 2021
The block template resolution algorithm is quite complex, as it has to cover quite a lot of different possible cases resulting from various combinations of - WP's "old" template hierarchy (including custom page templates, and child themes) - block templates. Things become especially complex when there are e.g. "oldschool" PHP templates with higher specificity than the available block templates; or when a child theme has a PHP template with equal specificity as the parent theme's corresponding block template. For more discussion on this, see #31399. Examples of previous iterations that sought to refine the algorithms' behavior include #29026, #30599, #31123, and #31336. This PR's goal is to eventually cover all of those cases.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR covers a condition that was not being considered by #31123: When a child theme has no explicit template for a certain page (such as the home.php) but it does have a fallback template available (such as index.php), the template that was being loaded was the one from the parent if it was using a block based template (in this example: index.html). This change encapsulates the previous PR to only consider child themes and covers this specific case that was not being considered.
How has this been tested?
Using a child of BCB I tested the following cases:
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.jsfiles for terms that need renaming or removal).