Skip to content

Commit

Permalink
Fix flash when clicking template name in the editor when a plugin reg…
Browse files Browse the repository at this point in the history
…istered template matches a default WP theme template (#66359)

* Fix _gutenberg_get_block_templates_files() so it returns the 'page' template from the theme when 'page' post type templates are queried

* Try different approach: don't use query to get the templates reference to use for filtering

* Only unset post_type from the query

* Add backport file
  • Loading branch information
Aljullu authored Nov 8, 2024
1 parent 36f0847 commit f1a4f1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backport-changelog/6.7/7676.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7676

* https://github.com/WordPress/gutenberg/pull/66359
8 changes: 7 additions & 1 deletion lib/compat/wordpress-6.7/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ function _gutenberg_add_block_templates_from_registry( $query_result, $query, $t
}

if ( ! isset( $query['wp_id'] ) ) {
$template_files = _gutenberg_get_block_templates_files( $template_type, $query );
// We need to unset the post_type query param because some templates
// would be excluded otherwise, like `page.html` when looking for
// `page` templates.
// See: https://github.com/WordPress/gutenberg/issues/65584
$template_files_query = $query;
unset( $template_files_query['post_type'] );
$template_files = _gutenberg_get_block_templates_files( $template_type, $template_files_query );

/*
* Add templates registered in the template registry. Filtering out the ones which have a theme file.
Expand Down

0 comments on commit f1a4f1c

Please sign in to comment.