Widget block: Add widget_block_content filter

Adds a new 'widget_block_content' filter to the widget block and hooks
`run_shortcode`, `autoembed`, `do_blocks`, and `do_shortcode` into it by
default. This is simlar to `widget_text_content.`

Fixes #51566.
Props talldanwp.


git-svn-id: https://develop.svn.wordpress.org/trunk@51058 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Robert Anderson
2021-06-02 01:17:37 +00:00
parent 9991a80cca
commit cf60c451b0
3 changed files with 20 additions and 14 deletions

View File

@@ -31,6 +31,7 @@ class WP_Embed {
// Hack to get the [embed] shortcode to run before wpautop().
add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 );
add_filter( 'widget_text_content', array( $this, 'run_shortcode' ), 8 );
add_filter( 'widget_block_content', array( $this, 'run_shortcode' ), 8 );
// Shortcode placeholder for strip_shortcodes().
add_shortcode( 'embed', '__return_false' );
@@ -38,6 +39,7 @@ class WP_Embed {
// Attempts to embed all URLs in a post.
add_filter( 'the_content', array( $this, 'autoembed' ), 8 );
add_filter( 'widget_text_content', array( $this, 'autoembed' ), 8 );
add_filter( 'widget_block_content', array( $this, 'autoembed' ), 8 );
// After a post is saved, cache oEmbed items via Ajax.
add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) );