diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index 58ee129d2a..10ba863c62 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -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; + } } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index d27d3f1c36..eb7b2bf517 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.