From cb7d0efb451e14d828cd825829d4df0743a9c49b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 1 Feb 2021 18:06:03 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-block.php | 17 ++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-block.php b/wp-includes/class-wp-block.php index 10c7d92dcd..6926abf3f4 100644 --- a/wp-includes/class-wp-block.php +++ b/wp-includes/class-wp-block.php @@ -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; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 4c28de102a..301d072b9b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-50122'; +$wp_version = '5.7-alpha-50123'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.