Skip to content

Commit

Permalink
Make sure the custom templates with no associated post types are avai…
Browse files Browse the repository at this point in the history
…lable for all post types
  • Loading branch information
Aljullu committed Nov 3, 2024
1 parent 1d1af57 commit d32b25e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,16 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' )
) {
$query_result[] = _build_block_template_result_from_file( $template_file, $template_type );
}

// The custom templates with no associated post types are available for all post types.
if ( isset( $query['post_type'] ) && ! isset( $template_file['postTypes'] ) ) {
$candidate = _build_block_template_result_from_file( $template_file, $template_type );
$default_template_types = get_default_block_template_types();
$is_custom = ! isset( $default_template_types[ $candidate->slug ] );
if ( $is_custom ) {
$query_result[] = $candidate;
}
}
}

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

0 comments on commit d32b25e

Please sign in to comment.