From d44101218e57c6501954350d82fa19693439500b Mon Sep 17 00:00:00 2001 From: Nirav sherasiya Date: Mon, 2 Feb 2026 16:10:19 +0530 Subject: [PATCH] Add filter to short-circuit the block render --- src/wp-includes/blocks.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 2a9968608106a..2709066dca135 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -2375,6 +2375,20 @@ function render_block( $parsed_block ) { $block = new WP_Block( $parsed_block, $context ); + /** + * Allows render_block() to be short-circuited after context processing, by returning a non-null value. + * + * @since 7.0.0 + * + * @param string|null $pre_render_output The pre-rendered content. Default null. + * @param WP_Block $block The block instance with processed context. + * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. + */ + $pre_render_output = apply_filters( 'pre_render_block_output', null, $block, $parent_block ); + if ( ! is_null( $pre_render_output ) ) { + return $pre_render_output; + } + return $block->render(); }