mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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:
@@ -66,20 +66,21 @@ class WP_Widget_Block extends WP_Widget {
|
||||
$args['before_widget']
|
||||
);
|
||||
|
||||
// Handle embeds for block widgets.
|
||||
//
|
||||
// When this feature is added to core it may need to be implemented
|
||||
// differently. WP_Widget_Text is a good reference, that applies a
|
||||
// filter for its content, which WP_Embed uses in its constructor.
|
||||
// See https://core.trac.wordpress.org/ticket/51566.
|
||||
global $wp_embed;
|
||||
$content = $wp_embed->run_shortcode( $instance['content'] );
|
||||
$content = $wp_embed->autoembed( $content );
|
||||
|
||||
$content = do_blocks( $content );
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
echo $content;
|
||||
/**
|
||||
* Filters the content of the Block widget before output.
|
||||
*
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @param string $content The widget content.
|
||||
* @param array $instance Array of settings for the current widget.
|
||||
* @param WP_Widget_Text $widget Current Block widget instance.
|
||||
*/
|
||||
echo apply_filters(
|
||||
'widget_block_content',
|
||||
$instance['content'],
|
||||
$instance,
|
||||
$this
|
||||
);
|
||||
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user