From f145f085dd12364beaa5971105382f6b68717347 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Tue, 30 Jan 2024 15:19:45 +0000 Subject: [PATCH] Home Link: Render Home text if there is no attribute label present (#58387) Co-authored-by: Bernie Reiter <96308+ockham@users.noreply.github.com> --- packages/block-library/src/home-link/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/home-link/index.php b/packages/block-library/src/home-link/index.php index 8fb5ed109019d3..9ec0c185872c0f 100644 --- a/packages/block-library/src/home-link/index.php +++ b/packages/block-library/src/home-link/index.php @@ -129,7 +129,10 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) { */ function render_block_core_home_link( $attributes, $content, $block ) { if ( empty( $attributes['label'] ) ) { - return ''; + // Using a fallback for the label attribute allows rendering the block even if no attributes have been set, + // e.g. when using the block as a hooked block. + // Note that the fallback value needs to be kept in sync with the one set in `edit.js` (upon first loading the block in the editor). + $attributes['label'] = __( 'Home' ); } $aria_current = '';