Skip to content

Commit

Permalink
Fix flash when clicking on template name when a plugin registered tem…
Browse files Browse the repository at this point in the history
…plate matches a default WP theme template
  • Loading branch information
Aljullu committed Oct 29, 2024
1 parent 8d58139 commit 657b0a8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1167,10 +1167,16 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' )
* If the query has found some user templates, those have priority
* over the theme-provided ones, so we skip querying and building them.
*/
$query['slug__not_in'] = wp_list_pluck( $query_result, 'slug' );
$template_files = _get_block_templates_files( $template_type, $query );
$template_files_query = $query;
unset( $template_files_query['post_type'] );
$template_files = _get_block_templates_files( $template_type, $template_files_query );
foreach ( $template_files as $template_file ) {
$query_result[] = _build_block_template_result_from_file( $template_file, $template_type );
if (
! isset( $query['post_type'] ) ||
( isset( $query['post_type'] ) && isset( $template_file['postTypes'] ) && in_array( $query['post_type'], $template_file['postTypes'], true ) )
) {
$query_result[] = _build_block_template_result_from_file( $template_file, $template_type );
}
}

if ( 'wp_template' === $template_type ) {
Expand Down

0 comments on commit 657b0a8

Please sign in to comment.