Make WordPress Core


Ignore:
Timestamp:
10/17/2023 03:46:44 PM (11 months ago)
Author:
Bernhard Reiter
Message:

Patterns, Templates: Inject theme attr into Template Part blocks.

It was found that Template Part blocks were broken in the Site Editor, showing the Template part has been deleted or is unavailable message, due to a missing theme attribute.

This bug seems to have been introduced by [56896], whose goal was to only inject that attribute into the markup returned by the templates and patterns REST API endpoints but not on the frontend, in order to improve performance. It has been demonstrated locally that reverting that changeset fixes the bug.

Reverts [56896].
Props mmcalister, swisspidy, thelovelist, hellofromTonya, pbiron, Pauthake015, richtabor, nicolefurlan, huzaifaalmesbah, annezazu, kafleg, aegkr, sunitarai, shresthaaman, andraganescu, onemaggie, gziolo.
Fixes #59629.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-patterns-registry.php

    r56896 r56960  
    166166        $content = $pattern['content'];
    167167
    168         $before_block_visitor = ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ? '_inject_theme_attribute_in_template_part_block' : null;
     168        $before_block_visitor = '_inject_theme_attribute_in_template_part_block';
    169169        $after_block_visitor  = null;
    170170        if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
     
    172172            $after_block_visitor  = make_after_block_visitor( $hooked_blocks, $pattern );
    173173        }
    174         if ( null !== $before_block_visitor || null !== $after_block_visitor ) {
    175             $blocks  = parse_blocks( $content );
    176             $content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );
    177         }
     174        $blocks  = parse_blocks( $content );
     175        $content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );
    178176
    179177        return $content;
Note: See TracChangeset for help on using the changeset viewer.