diff options
Diffstat (limited to '')
-rw-r--r-- | wp-includes/blocks/pattern.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/wp-includes/blocks/pattern.php b/wp-includes/blocks/pattern.php index f05bb33..9a4d4c0 100644 --- a/wp-includes/blocks/pattern.php +++ b/wp-includes/blocks/pattern.php @@ -22,11 +22,15 @@ function register_block_core_pattern() { * * @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper. * + * @global WP_Embed $wp_embed Used to process embedded content within patterns + * * @param array $attributes Block attributes. * * @return string Returns the output of the pattern. */ function render_block_core_pattern( $attributes ) { + static $seen_refs = array(); + if ( empty( $attributes['slug'] ) ) { return ''; } @@ -38,6 +42,17 @@ function render_block_core_pattern( $attributes ) { return ''; } + if ( isset( $seen_refs[ $attributes['slug'] ] ) ) { + // WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent + // is set in `wp_debug_mode()`. + $is_debug = WP_DEBUG && WP_DEBUG_DISPLAY; + + return $is_debug ? + // translators: Visible only in the front end, this warning takes the place of a faulty block. %s represents a pattern's slug. + sprintf( __( '[block rendering halted for pattern "%s"]' ), $slug ) : + ''; + } + $pattern = $registry->get_registered( $slug ); $content = $pattern['content']; @@ -48,7 +63,15 @@ function render_block_core_pattern( $attributes ) { $content = gutenberg_serialize_blocks( $blocks ); } - return do_blocks( $content ); + $seen_refs[ $attributes['slug'] ] = true; + + $content = do_blocks( $content ); + + global $wp_embed; + $content = $wp_embed->autoembed( $content ); + + unset( $seen_refs[ $attributes['slug'] ] ); + return $content; } add_action( 'init', 'register_block_core_pattern' ); |