pre_render_block хук-фильтрWP 5.1.0

Использование

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(строка|null)
The pre-rendered content.
По умолчанию: null
$parsed_block(массив)
The block being rendered.
$parent_block(WP_Block|null)
If this is a nested block, a reference to the parent block.

Список изменений

С версии 5.1.0 Введена.
С версии 5.9.0 The $parent_block parameter was added.

Где вызывается хук

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

Где используется хук в WordPress

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