PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/scripts/block-library/block.php +26 -2 23.6.2 → 22.7.0 View file →
@@ -1,5 +1,5 @@
1 -<?php
1 +<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName // Needed for WP_Block_Cloner helper class.
2 2 /**
3 3 * Server-side rendering of the `core/block` block.
4 4 *
5 5 * @package WordPress
@@ -82,9 +82,33 @@
82 82 * those blocks.
83 83 */
84 84 $block_instance->parsed_block['innerBlocks'] = parse_blocks( $content );
85 85 $block_instance->parsed_block['innerContent'] = array_fill( 0, count( $block_instance->parsed_block['innerBlocks'] ), null );
86 - $block_instance->refresh_context_dependents();
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 + }
87 111
88 112 $content = $block_instance->render( array( 'dynamic' => false ) );
89 113 unset( $seen_refs[ $attributes['ref'] ] );
90 114