Skip to content
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

First step towards hybrid themes: Fallback to PHP templates #29026

Merged
merged 10 commits into from
Mar 22, 2021
Prev Previous commit
Next Next commit
CS fix
aristath committed Feb 26, 2021
commit 1fe8fcedb7030fcea925d3c7af40c3c4a8b54a76
6 changes: 3 additions & 3 deletions lib/full-site-editing/template-loader.php
Original file line number Diff line number Diff line change
@@ -68,12 +68,12 @@ function gutenberg_override_query_template( $template, $type, array $templates =
// Allow falling back to a PHP template if it has a higher priority than the block template.
$current_template_slug = basename( $template, '.php' );
$current_block_template_slug = is_object( $current_template ) ? $current_template->slug : false;
foreach ( $templates as $template_item) {
$template_item_slug = gutenberg_strip_php_suffix( $template_item);
foreach ( $templates as $template_item ) {
$template_item_slug = gutenberg_strip_php_suffix( $template_item );

// Don't override the template if we find a template matching the slug we look for
// and which does not match a block template slug
if ( $current_template_slug !== $current_block_template_slug && $current_template_slug === $template_item_slug) {
if ( $current_template_slug !== $current_block_template_slug && $current_template_slug === $template_item_slug ) {
return $template;
}
}