wppaste
WordPress

apply_filters( 'pre_render_block', string|null $pre_render, array $parsed_block, WP_Block|null $parent_block )

Since
5.1.0, 5.9.0
Allows render_block() to be short-circuited, by returning a non-null value.

Compatibility

WordPress
since 5.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$pre_renderstring|null
The pre-rendered content. Default null.
$parsed_blockarray
{ An associative array of the block being rendered. See WP_Block_Parser_Block.
@type string|null $blockName Name of block.
@type array $attrs Attributes from block comment delimiters.
@type array[] $innerBlocks List of inner blocks. An array of arrays that have the same structure as this one.
@type string $innerHTML HTML from inside block comment delimiters.
@type array $innerContent List of string fragments and null markers where inner blocks were found.
}
  • $blockNamestring|null

    Name of block.
  • $attrsarray

    Attributes from block comment delimiters.
  • $innerBlocksarray[]

    List of inner blocks. An array of arrays that have the same structure as this one.
  • $innerHTMLstring

    HTML from inside block comment delimiters.
  • $innerContentarray

    List 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.

Where this hook fires · 2

  • wp-includes/blocks.php:2436render_block()
  • wp-includes/class-wp-block.php:605WP_Block::render()

Source code

	 *     @type string      $innerHTML    HTML from inside block comment delimiters.	 *     @type array       $innerContent List of string fragments and null markers where	 *                                     inner blocks were found.	 * }	 * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.	 */	$pre_render = apply_filters( 'pre_render_block', null, $parsed_block, $parent_block );	if ( ! is_null( $pre_render ) ) {		return $pre_render;	} 	$source_block = $parsed_block;

Changelog

Introduced in 5.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.9.0
The $parent_block parameter was added.from the docblock
5.1.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.