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

Fix flash when clicking on template name when a plugin registered template matches a default WP theme template #7676

Open
wants to merge 12 commits into
base: trunk
Choose a base branch
from
Open
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 ) )
Aljullu marked this conversation as resolved.
Show resolved Hide resolved
) {
$query_result[] = _build_block_template_result_from_file( $template_file, $template_type );
}
}

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