Skip to content

Commit d986d14

Browse files
authored
Fix reply block showing empty div when embed fails (#2571)
1 parent 6bb4790 commit d986d14

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Reply block now shows fallback link when oEmbed fails instead of empty div.

includes/class-blocks.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public static function render_reply_block( $attrs ) {
204204
$html = '<div ' . $wrapper_attrs . '>';
205205

206206
// Try to get and append the embed if requested.
207+
$embed = null;
207208
if ( $show_embed ) {
208209
$embed = wp_oembed_get( $attrs['url'] );
209210
if ( $embed ) {
@@ -212,8 +213,8 @@ public static function render_reply_block( $attrs ) {
212213
}
213214
}
214215

215-
// Only show the link if we're not showing the embed.
216-
if ( ! $show_embed ) {
216+
// Show the link if embed is not requested or if embed failed.
217+
if ( ! $show_embed || ! $embed ) {
217218
$html .= sprintf(
218219
'<p><a title="%2$s" aria-label="%2$s" href="%1$s" class="u-in-reply-to" target="_blank">%3$s</a></p>',
219220
esc_url( $attrs['url'] ),

0 commit comments

Comments
 (0)