From 6871c84f1f80e06b22fe32f44877625fb3adad5f Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Fri, 19 Feb 2021 16:31:15 +0800 Subject: [PATCH 1/4] Fix php error in the widget screen --- lib/class-wp-widget-block.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/class-wp-widget-block.php b/lib/class-wp-widget-block.php index b5fbe90c2162ef..a365ac48b4868b 100644 --- a/lib/class-wp-widget-block.php +++ b/lib/class-wp-widget-block.php @@ -54,7 +54,8 @@ public function __construct() { */ public function widget( $args, $instance ) { echo sprintf( $args['before_widget'], $this->get_dynamic_classname( $instance ) ); - echo do_blocks( $instance['content'] ); + $content = do_blocks( $instance['content'] ); + echo $content; // Handle embeds for block widgets. // From 951cb49f4f1b5a3b96d98319d7cfdf5d61d67c27 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Fri, 19 Feb 2021 18:05:14 +0800 Subject: [PATCH 2/4] Remove duplicated echo --- lib/class-wp-widget-block.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/class-wp-widget-block.php b/lib/class-wp-widget-block.php index a365ac48b4868b..013a57ba0c8224 100644 --- a/lib/class-wp-widget-block.php +++ b/lib/class-wp-widget-block.php @@ -55,7 +55,6 @@ public function __construct() { public function widget( $args, $instance ) { echo sprintf( $args['before_widget'], $this->get_dynamic_classname( $instance ) ); $content = do_blocks( $instance['content'] ); - echo $content; // Handle embeds for block widgets. // From 810f2afe02b9b8930235e1886dd4d58349a4723c Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Fri, 19 Feb 2021 10:17:28 +0000 Subject: [PATCH 3/4] adding embed and shortcode expansion to the content rendered in legacy widgets --- lib/class-wp-widget-block.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/class-wp-widget-block.php b/lib/class-wp-widget-block.php index 013a57ba0c8224..838c3f47ddf98f 100644 --- a/lib/class-wp-widget-block.php +++ b/lib/class-wp-widget-block.php @@ -54,8 +54,6 @@ public function __construct() { */ public function widget( $args, $instance ) { echo sprintf( $args['before_widget'], $this->get_dynamic_classname( $instance ) ); - $content = do_blocks( $instance['content'] ); - // Handle embeds for block widgets. // // When this feature is added to core it may need to be implemented @@ -63,7 +61,10 @@ public function widget( $args, $instance ) { // 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 ); + $content = $wp_embed->run_shortcode( $instance['content'] ); + $content = $wp_embed->autoembed( $content ); + + echo do_blocks( $content ); echo $args['after_widget']; } From ef00b020e98e07b2114c92dfa57d86e18b317375 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Fri, 19 Feb 2021 15:49:05 +0000 Subject: [PATCH 4/4] fix linting --- lib/class-wp-widget-block.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-widget-block.php b/lib/class-wp-widget-block.php index 838c3f47ddf98f..16f5e093260ebc 100644 --- a/lib/class-wp-widget-block.php +++ b/lib/class-wp-widget-block.php @@ -63,7 +63,7 @@ public function widget( $args, $instance ) { global $wp_embed; $content = $wp_embed->run_shortcode( $instance['content'] ); $content = $wp_embed->autoembed( $content ); - + echo do_blocks( $content ); echo $args['after_widget'];