Skip to content

Commit

Permalink
Formatting: Pass the block instance as a parameter to the `render_blo…
Browse files Browse the repository at this point in the history
…ck` filters.

This allows filters to access properties and methods on the block instance.

Fixes #53596


git-svn-id: https://develop.svn.wordpress.org/trunk@51841 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
johnbillion committed Sep 21, 2021
1 parent d7b91f9 commit 9269cbd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/wp-includes/class-wp-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,13 @@ public function render( $options = array() ) {
* Filters the content of a single block.
*
* @since 5.0.0
* @since 5.9.0 The `$instance` parameter was added.
*
* @param string $block_content The block content about to be appended.
* @param array $block The full block, including name and attributes.
* @param string $block_content The block content about to be appended.
* @param array $block The full block, including name and attributes.
* @param WP_Block $instance The block instance.
*/
$block_content = apply_filters( 'render_block', $block_content, $this->parsed_block );
$block_content = apply_filters( 'render_block', $block_content, $this->parsed_block, $this );

/**
* Filters the content of a single block.
Expand All @@ -254,11 +256,13 @@ public function render( $options = array() ) {
* the block name, e.g. "core/paragraph".
*
* @since 5.7.0
* @since 5.9.0 The `$instance` parameter was added.
*
* @param string $block_content The block content about to be appended.
* @param array $block The full block, including name and attributes.
* @param string $block_content The block content about to be appended.
* @param array $block The full block, including name and attributes.
* @param WP_Block $instance The block instance.
*/
$block_content = apply_filters( "render_block_{$this->name}", $block_content, $this->parsed_block );
$block_content = apply_filters( "render_block_{$this->name}", $block_content, $this->parsed_block, $this );

return $block_content;
}
Expand Down

0 comments on commit 9269cbd

Please sign in to comment.