pre_render_block filter-hookWP 5.1.0

Usage

add_filter( 'pre_render_block', 'wp_kama_pre_render_block_filter', 10, 3 );

/**
 * Function for `pre_render_block` filter-hook.
 * 
 * @param string|null   $pre_render   The pre-rendered content.
 * @param array         $parsed_block The block being rendered.
 * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
 *
 * @return string|null
 */
function wp_kama_pre_render_block_filter( $pre_render, $parsed_block, $parent_block ){

	// filter...
	return $pre_render;
}
$pre_render(string|null)
The pre-rendered content.
Default: null
$parsed_block(array)
The block being rendered.
$parent_block(WP_Block|null)
If this is a nested block, a reference to the parent block.

Changelog

Since 5.1.0 Introduced.
Since 5.9.0 The $parent_block parameter was added.

Where the hook is called

render_block()
pre_render_block
WP_Block::render()
pre_render_block
wp-includes/blocks.php 854
$pre_render = apply_filters( 'pre_render_block', null, $parsed_block, $parent_block );
wp-includes/class-wp-block.php 228
$pre_render = apply_filters( 'pre_render_block', null, $inner_block->parsed_block, $parent_block );

Where the hook is used in WordPress

wp-includes/block-supports/elements.php 139
add_filter( 'pre_render_block', 'wp_render_elements_support_styles', 10, 2 );