Make WordPress Core

Changeset 58323

Timestamp:
06/04/2024 08:13:01 AM (2 months ago)
Author:
ellatrix
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-template-utils.php

    r58291 r58323  
    361361    if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) {
    362362        return null;
     363
     364
     365
     366
     367
    363368    }
    364369
     
    426431            if ( 'wp_template' === $template_type ) {
    427432                $candidate = _add_block_template_info( $new_template_item );
     433
     434
    428435                if (
    429436                    ! $post_type ||
    430437                    ( $post_type && isset( $candidate['postTypes'] ) && in_array( $post_type, $candidate['postTypes'], true ) )
    431438                ) {
     439
     440
     441
     442
     443
    432444                    $template_files[ $template_slug ] = $candidate;
    433445                }
  • trunk/tests/phpunit/tests/block-template.php

    r57215 r58323  
    400400        $templates = array(
    401401            'parts/small-header.html',
     402
    402403            'templates/custom-single-post-template.html',
    403404            'templates/index.html',
  • trunk/tests/phpunit/tests/blocks/getBlockTemplates.php

    r56971 r58323  
    189189     * @dataProvider data_get_block_templates_should_respect_posttypes_property
    190190     * @ticket 55881
     191
    191192     *
    192193     * @param string $post_type Post type for query.
     
    204205    /**
    205206     * Data provider.
     207
     208
     209
    206210     *
    207211     * @return array
     
    212216                'post_type' => 'post',
    213217                'expected'  => array(
     218
    214219                    'block-theme//custom-single-post-template',
    215220                ),
     
    218223                'post_type' => 'page',
    219224                'expected'  => array(
     225
    220226                    'block-theme//page-home',
    221227                ),
Note: See TracChangeset for help on using the changeset viewer.