Changeset 58323
- Timestamp:
- 06/04/2024 08:13:01 AM (6 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template-utils.php
r58291 r58323 361 361 if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) { 362 362 return null; 363 } 364 365 $default_template_types = array(); 366 if ( 'wp_template' === $template_type ) { 367 $default_template_types = get_default_block_template_types(); 363 368 } 364 369 … … 426 431 if ( 'wp_template' === $template_type ) { 427 432 $candidate = _add_block_template_info( $new_template_item ); 433 $is_custom = ! isset( $default_template_types[ $candidate['slug'] ] ); 434 428 435 if ( 429 436 ! $post_type || 430 437 ( $post_type && isset( $candidate['postTypes'] ) && in_array( $post_type, $candidate['postTypes'], true ) ) 431 438 ) { 439 $template_files[ $template_slug ] = $candidate; 440 } 441 442 // The custom templates with no associated post types are available for all post types. 443 if ( $post_type && ! isset( $candidate['postTypes'] ) && $is_custom ) { 432 444 $template_files[ $template_slug ] = $candidate; 433 445 } -
trunk/tests/phpunit/tests/block-template.php
r57215 r58323 400 400 $templates = array( 401 401 'parts/small-header.html', 402 'templates/custom-hero-template.html', 402 403 'templates/custom-single-post-template.html', 403 404 'templates/index.html', -
trunk/tests/phpunit/tests/blocks/getBlockTemplates.php
r56971 r58323 189 189 * @dataProvider data_get_block_templates_should_respect_posttypes_property 190 190 * @ticket 55881 191 * @ticket 61110 191 192 * 192 193 * @param string $post_type Post type for query. … … 204 205 /** 205 206 * Data provider. 207 * 208 * The `custom-hero-template` is intentionally omitted from the theme.json's `customTemplates`. 209 * See: https://core.trac.wordpress.org/ticket/61110. 206 210 * 207 211 * @return array … … 212 216 'post_type' => 'post', 213 217 'expected' => array( 218 'block-theme//custom-hero-template', 214 219 'block-theme//custom-single-post-template', 215 220 ), … … 218 223 'post_type' => 'page', 219 224 'expected' => array( 225 'block-theme//custom-hero-template', 220 226 'block-theme//page-home', 221 227 ),
Note: See TracChangeset
for help on using the changeset viewer.