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

Filters the block being rendered in render_block(), before it's processed.

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

add_filter( 'render_block_data', 'wp_kama_render_block_data_filter', 10, 3 );

/**
 * Function for `render_block_data` filter-hook.
 * 
 * @param array         $parsed_block An associative array of the block being rendered. See WP_Block_Parser_Block.
 * @param array         $source_block An un-modified copy of `$parsed_block`, as it appeared in the source content. See WP_Block_Parser_Block.
 * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
 *
 * @return array
 */
function wp_kama_render_block_data_filter( $parsed_block, $source_block, $parent_block ){

	// filter...
	return $parsed_block;
}
$parsed_block(массив)

An associative array of the block being rendered. See WP_Block_Parser_Block.

  • blockName(строка)
    Name of block.

  • attrs(массив)
    Attributes from block comment delimiters.

  • innerBlocks(array[])
    List of inner blocks. An array of arrays that have the same structure as this one.

  • innerHTML(строка)
    HTML from inside block comment delimiters.

  • innerContent(массив)
    List of string fragments and null markers where inner blocks were found.
$source_block(массив)

An un-modified copy of $parsed_block, as it appeared in the source content. See WP_Block_Parser_Block.

  • blockName(строка)
    Name of block.

  • attrs(массив)
    Attributes from block comment delimiters.

  • innerBlocks(array[])
    List of inner blocks. An array of arrays that have the same structure as this one.

  • innerHTML(строка)
    HTML from inside block comment delimiters.

  • innerContent(массив)
    List of string fragments and null markers where inner blocks were found.
$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()
render_block_data
WP_Block::render()
render_block_data
wp-includes/blocks.php 2318
$parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block, $parent_block );
wp-includes/class-wp-block.php 551
$inner_block->parsed_block = apply_filters( 'render_block_data', $inner_block->parsed_block, $source_block, $parent_block );

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

wp-includes/block-supports/block-style-variations.php 253
add_filter( 'render_block_data', 'wp_render_block_style_variation_support_styles', 10, 2 );
wp-includes/block-supports/elements.php 264
add_filter( 'render_block_data', 'wp_render_elements_support_styles', 10, 1 );
wp-includes/block-supports/layout.php 980
add_filter( 'render_block_data', 'wp_add_parent_layout_to_parsed_block', 10, 3 );
wp-includes/blocks/gallery.php 35
add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
wp-includes/blocks/latest-posts.php 270
add_filter( 'render_block_data', 'block_core_latest_posts_migrate_categories' );
wp-includes/blocks/navigation.php 1209
add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_backcompatibility' );
wp-includes/blocks/query.php 152
add_filter( 'render_block_data', 'block_core_query_disable_enhanced_pagination', 10, 1 );