Filters the block being rendered in render_block() , before it’s processed.
Parameters
$parsed_blockarray- An associative array of the block being rendered. See WP_Block_Parser_Block.
blockNamestring|nullName of block.attrsarrayAttributes from block comment delimiters.innerBlocksarray[]List of inner blocks. An array of arrays that have the same structure as this one.innerHTMLstringHTML from inside block comment delimiters.innerContentarrayList of string fragments and null markers where inner blocks were found.
$source_blockarray- An un-modified copy of
$parsed_block, as it appeared in the source content.
See WP_Block_Parser_Block.
blockNamestring|nullName of block.attrsarrayAttributes from block comment delimiters.innerBlocksarray[]List of inner blocks. An array of arrays that have the same structure as this one.innerHTMLstringHTML from inside block comment delimiters.innerContentarrayList of string fragments and null markers where inner blocks were found.
$parent_blockWP_Block|null- If this is a nested block, a reference to the parent block.
Source
$parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block, $parent_block );
Filter post content block and add custom classes for every post content block wrapper dynamically before render on template.
Here is the structure of the $parsed_block
Filter the Image core block to disable the “Enlarge on click” (lightbox) feature on the RSS feeds. This will remove the lightbox markup from the feed, including the Enlarge button, as it won’t work on the readers.
// Disable lightbox ("Enlarge on click") markup for images on the feeds
function wpdocs_disable_images_lightbox_on_feeds( $parsed_block ) {
if ( ! is_feed() ) {
return $parsed_block;
}
if ( 'core/image' === $parsed_block['blockName'] ) {
$parsed_block['attrs']['lightbox'] = false;
}
return $parsed_block;
}
add_filter( 'render_block_data', 'wpdocs_disable_images_lightbox_on_feeds' );