Editor: Introduce a dynamic filter for the content of a single block:
`render_block_{$this->name}`
This complements the existing `render_block` hook and allows for filtering the content of a specific block without having to use conditionals inside the filter callback.
Props manzoorwani.jk, noisysocks, birgire, johnbillion.
Fixes #46187.
Built from https://develop.svn.wordpress.org/trunk@50123
git-svn-id: http://core.svn.wordpress.org/trunk@49802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -241,7 +241,22 @@ class WP_Block {
|
||||
* @param string $block_content The block content about to be appended.
|
||||
* @param array $block The full block, including name and attributes.
|
||||
*/
|
||||
return apply_filters( 'render_block', $block_content, $this->parsed_block );
|
||||
$block_content = apply_filters( 'render_block', $block_content, $this->parsed_block );
|
||||
|
||||
/**
|
||||
* Filters the content of a single block.
|
||||
*
|
||||
* The dynamic portion of the hook name, `$name`, refers to
|
||||
* the block name, e.g. "core/paragraph".
|
||||
*
|
||||
* @since 5.7.0
|
||||
*
|
||||
* @param string $block_content The block content about to be appended.
|
||||
* @param array $block The full block, including name and attributes.
|
||||
*/
|
||||
$block_content = apply_filters( "render_block_{$this->name}", $block_content, $this->parsed_block );
|
||||
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user