Make WordPress Core


Ignore:
Timestamp:
10/12/2023 04:39:27 PM (16 months ago)
Author:
Bernhard Reiter
Message:

Patterns: Don't inject theme attribute on frontend.

Having the patterns registry inject the theme attribute into all Template Part blocks inside every pattern was found to negatively impact performance. It turns out that it's only required for the editor (i.e. in the REST API) but not on the frontend; there, it's instead possible to fall back to the currently active theme.

The latter change was made to the Pattern and Template Part blocks in https://github.com/WordPress/gutenberg/pull/55217, which was sync'ed to Core in [56849]. Consequently, this changeset removes theme attribute insertion from the frontend.

Props flixos90, gziolo, dmsnell, hellofromtonya.
Fixes #59583.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r56845 r56896  
    780780     */
    781781    return function ( &$block, $parent_block = null, $prev = null ) use ( $hooked_blocks, $context ) {
    782         _inject_theme_attribute_in_template_part_block( $block );
     782        if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
     783            _inject_theme_attribute_in_template_part_block( $block );
     784        }
    783785
    784786        $markup = '';
Note: See TracChangeset for help on using the changeset viewer.