render_block хук-фильтрWP 5.0.0

Filters the content of a single block.

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

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

/**
 * Function for `render_block` filter-hook.
 * 
 * @param string   $block_content The block content.
 * @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(строка)
The block content.
$block(массив)
The full block, including name and attributes.
$instance(WP_Block)
The block instance.

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

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

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

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

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

wp-includes/block-supports/duotone.php 597
add_filter( 'render_block', 'wp_render_duotone_support', 10, 2 );
wp-includes/block-supports/elements.php 126
add_filter( 'render_block', 'wp_render_elements_support', 10, 2 );
wp-includes/block-supports/layout.php 445
add_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
wp-includes/default-filters.php 691
add_filter( 'render_block', 'wp_render_typography_support', 10, 2 );
wp-includes/script-loader.php 3140
add_filter( 'render_block', $callback_separate, 10, 2 );