Make WordPress Core


Ignore:
Timestamp:
10/21/2025 07:11:53 AM (12 months ago)
Author:
ellatrix
Message:

Editor: update packages.

Updates the packages to match Gutenberg version 21.9.0 RC2.

Also updates the sync script to work with the new package-lock.json format.
Some reusable block tests were adjusted to work with more render arguments.
Added core-data to the ignore list for verify:source-maps because Yjs has been bundled by accident. To be removed in a follow-up. See https://core.trac.wordpress.org/ticket/64120. See ​https://github.com/WordPress/gutenberg/pull/72503.

See: ​https://github.com/WordPress/wordpress-develop/pull/10355.
See: https://core.trac.wordpress.org/ticket/64117.

Props ellatrix, dmsnell.
Fixes #64117.

File:
1 edited

Legend:

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

    r59906 r61009  
    1 <?php
     1<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName // Needed for WP_Block_Cloner helper class.
    22/**
    33 * Server-side rendering of the `core/block` block.
    … …  
    1717 * @return string Rendered HTML of the referenced block.
    1818 */
    19 function render_block_core_block( $attributes ) {
     19function render_block_core_block( $attributes, $content, $block_instance ) {
    2020        static $seen_refs = array();
    2121
    … …  
    7474        }
    7575
    76         /**
    77          * We set the `pattern/overrides` context through the `render_block_context`
    78          * filter so that it is available when a pattern's inner blocks are
    79          * rendering via do_blocks given it only receives the inner content.
    80          */
    81         $has_pattern_overrides = isset( $attributes['content'] ) && null !== get_block_bindings_source( 'core/pattern-overrides' );
    82         if ( $has_pattern_overrides ) {
    83                 $filter_block_context = static function ( $context ) use ( $attributes ) {
    84                         $context['pattern/overrides'] = $attributes['content'];
    85                         return $context;
    86                 };
    87                 add_filter( 'render_block_context', $filter_block_context, 1 );
    88         }
    89 
    9076        // Apply Block Hooks.
    9177        $content = apply_block_hooks_to_content_from_post_object( $content, $reusable_block );
    9278
    93         $content = do_blocks( $content );
     79        /**
     80         * We attach the blocks from $content as inner blocks to the Synced Pattern block instance.
     81         * This ensures that block context available to the Synced Pattern block instance is provided to
     82         * those blocks.
     83         */
     84        $block_instance->parsed_block['innerBlocks']  = parse_blocks( $content );
     85        $block_instance->parsed_block['innerContent'] = array_fill( 0, count( $block_instance->parsed_block['innerBlocks'] ), null );
     86        if ( method_exists( $block_instance, 'refresh_context_dependents' ) ) {
     87                // WP_Block::refresh_context_dependents() was introduced in WordPress 6.8.
     88                $block_instance->refresh_context_dependents();
     89        } else {
     90                // This branch can be removed once Gutenberg requires WordPress 6.8 or later.
     91                if ( ! class_exists( 'WP_Block_Cloner' ) ) {
     92                        // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
     93                        class WP_Block_Cloner extends WP_Block {
     94                                /**
     95                                 * Static methods of subclasses have access to protected properties
     96                                 * of instances of the parent class.
     97                                 * In this case, this gives us access to `available_context` and `registry`.
     98                                 */
     99                                // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
     100                                public static function clone_instance( $instance ) {
     101                                        return new WP_Block(
     102                                                $instance->parsed_block,
     103                                                $instance->available_context,
     104                                                $instance->registry
     105                                        );
     106                                }
     107                        }
     108                }
     109                $block_instance = WP_Block_Cloner::clone_instance( $block_instance );
     110        }
     111
     112        $content = $block_instance->render( array( 'dynamic' => false ) );
    94113        unset( $seen_refs[ $attributes['ref'] ] );
    95 
    96         if ( $has_pattern_overrides ) {
    97                 remove_filter( 'render_block_context', $filter_block_context, 1 );
    98         }
    99114
    100115        return $content;
Note: See TracChangeset for help on using the changeset viewer.