render_block filter-hookWP 5.0.0

Filters the content of a single block.

Usage

add_filter( 'render_block', 'wp_kama_render_block_filter', 10, 3 );

/**
 * Function for `render_block` filter-hook.
 * 
 * @param string   $block_content The block content about to be appended.
 * @param array    $block         The full block, including name and attributes.
 * @param WP_Block $instance      The block instance.
 *
 * @return string
 */
function wp_kama_render_block_filter( $block_content, $block, $instance ){

	// filter...
	return $block_content;
}
$block_content(string)
The block content about to be appended.
$block(array)
The full block, including name and attributes.
$instance(WP_Block)
The block instance.

Changelog

Since 5.0.0 Introduced.
Since 5.9.0 The $instance parameter was added.

Where the hook is called

WP_Block::render()
render_block
wp-includes/class-wp-block.php 284
$block_content = apply_filters( 'render_block', $block_content, $this->parsed_block, $this );

Where the hook is used in WordPress

wp-includes/block-supports/duotone.php 586
add_filter( 'render_block', 'wp_render_duotone_support', 10, 2 );
wp-includes/block-supports/elements.php 138
add_filter( 'render_block', 'wp_render_elements_support', 10, 2 );
wp-includes/block-supports/layout.php 232
add_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
wp-includes/script-loader.php 3011
add_filter( 'render_block', $callback_separate, 10, 2 );