Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit Site: Fix template lookup (#22954)
## Description This PR fixes two issues with template lookup: ### 1. Templates with `index.html` block template fallback When using a theme that came with an `index.html` but not with a `front-page.html` block template, the site editor would show the following `Notice: Undefined index: front-page in /var/www/html/wp-content/plugins/gutenberg/lib/edit-site-page.php on line 162`. The reason is that I was setting the wrong key here: https://github.com/WordPress/gutenberg/blob/710373b254fbcd15d524afdeb31da0d93c4defd4/lib/edit-site-page.php#L158 This would use the name of the template that was _found_, not the name of the key that was looked for. So if we're looking up `front-page`, but don't find any template, and [thus fall](https://github.com/WordPress/gutenberg/blob/710373b254fbcd15d524afdeb31da0d93c4defd4/lib/template-loader.php#L226) back to `index`, the template will be stored under the `index` key, rather than the front-end one. The fix for this is to use the template we were looking for as key (rather than the name of the template we actually found). ### 2. Templates without `index.html` block template fallback When using a theme that doesn't come with any block templates at all, we need to provide a blank `index` template when the user first opens the site editor (see [discussion](#22893 (comment))). Co-authored-by: Enrique Piqueras <epiqueras@users.noreply.github.com>
- Loading branch information