gutenberg_locate_block_template slicing template slugs #37691
Labels
[Feature] Themes
Questions or issues with incorporating or styling blocks in a theme.
Needs Technical Feedback
Needs testing from a developer perspective.
[Type] Enhancement
A suggestion for improvement.
Description
TLDR
Check if specificity
$index
of the located php$template
is not false before clearing out the template candidates$templates
ingutenberg_locate_block_template
Function
gutenberg_locate_block_template
trims$templates
(template candidates) even when located php template doesn't match php candidates. This breaks template lookups for custom post types (product in my case) on lib/compat/wordpress-5.9/block-template.php:61.The comment line says,
for product post type
$template
is./wp-includes/template-canvas.php
, which doesn't seem specific to me at all.Possible Solution
Just check if the
$index
is not false before splicing the array.Step-by-step reproduction instructions
single-product.html
template.Screenshots, screen recording, code snippet
Environment info
Gutenberg Version 12.2.0
WordPress Version 5.8.2
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: