Skip to content

Commit

Permalink
Add embed handling for block widgets in frontend (#26307)
Browse files Browse the repository at this point in the history
* Add embed handling for block widgets

* Add comment explaining feature and implementation in core

* Add ticket ref

* full-stop
  • Loading branch information
talldan committed Oct 29, 2020
1 parent 36d2e19 commit eaf00bd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/class-wp-widget-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ public function __construct() {
*/
public function widget( $args, $instance ) {
echo $args['before_widget'];
echo do_blocks( $instance['content'] );
$content = do_blocks( $instance['content'] );

// 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;
echo $wp_embed->autoembed( $content );

echo $args['after_widget'];
}

Expand Down

0 comments on commit eaf00bd

Please sign in to comment.