render_block_context
Filters the default context provided to a rendered block.
Использование
add_filter( 'render_block_context', 'wp_kama_render_block_context_filter', 10, 3 ); /** * Function for `render_block_context` filter-hook. * * @param array $context Default context. * @param array $parsed_block An associative array of the block being rendered. 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_context_filter( $context, $parsed_block, $parent_block ){ // filter... return $context; }
- $context(массив)
- Default context.
- $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.
-
- $parent_block(WP_Block|null)
- If this is a nested block, a reference to the parent block.
Список изменений
С версии 5.5.0 | Введена. |
С версии 5.9.0 | The $parent_block parameter was added. |
Где вызывается хук
render_block_context
wp-includes/blocks.php 2186
$context = apply_filters( 'render_block_context', $context, $parsed_block, $parent_block );
wp-includes/class-wp-block.php 515
$inner_block->context = apply_filters( 'render_block_context', $inner_block->context, $inner_block->parsed_block, $parent_block );
Где используется хук в WordPress
wp-includes/blocks/block.php 87
add_filter( 'render_block_context', $filter_block_context, 1 );
wp-includes/blocks/block.php 94
remove_filter( 'render_block_context', $filter_block_context, 1 );
wp-includes/blocks/comment-template.php 44
add_filter( 'render_block_context', $filter_block_context, 1 );
wp-includes/blocks/comment-template.php 52
remove_filter( 'render_block_context', $filter_block_context, 1 );
wp-includes/blocks/post-template.php 120
add_filter( 'render_block_context', $filter_block_context, 1 );
wp-includes/blocks/post-template.php 124
remove_filter( 'render_block_context', $filter_block_context, 1 );
wp-includes/default-filters.php 720
add_filter( 'render_block_context', '_block_template_render_without_post_block_context' );