Editor: Fix block template files query for a post-type.

See https://github.com/WordPress/gutenberg/pull/61244.
See https://github.com/WordPress/wordpress-develop/pull/6468.

Fixes #61110.

Props mamaduka, mukesh27, grantmkin, vcanales, ellatrix, oandregal.


Built from https://develop.svn.wordpress.org/trunk@58323


git-svn-id: http://core.svn.wordpress.org/trunk@57780 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ellatrix 2024-06-04 08:14:18 +00:00
parent 6635e1b9f3
commit 4e28fde39a
2 changed files with 13 additions and 1 deletions

View File

@ -362,6 +362,11 @@ function _get_block_templates_files( $template_type, $query = array() ) {
return null;
}
$default_template_types = array();
if ( 'wp_template' === $template_type ) {
$default_template_types = get_default_block_template_types();
}
// Prepare metadata from $query.
$slugs_to_include = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
$slugs_to_skip = isset( $query['slug__not_in'] ) ? $query['slug__not_in'] : array();
@ -425,12 +430,19 @@ function _get_block_templates_files( $template_type, $query = array() ) {
if ( 'wp_template' === $template_type ) {
$candidate = _add_block_template_info( $new_template_item );
$is_custom = ! isset( $default_template_types[ $candidate['slug'] ] );
if (
! $post_type ||
( $post_type && isset( $candidate['postTypes'] ) && in_array( $post_type, $candidate['postTypes'], true ) )
) {
$template_files[ $template_slug ] = $candidate;
}
// The custom templates with no associated post types are available for all post types.
if ( $post_type && ! isset( $candidate['postTypes'] ) && $is_custom ) {
$template_files[ $template_slug ] = $candidate;
}
}
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-58322';
$wp_version = '6.6-alpha-58323';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.