Skip to content

Commit

Permalink
Fix: Page list: Pages without a title has no link text (WordPress#64297)
Browse files Browse the repository at this point in the history
Add placeholder title to the page list block, that shows when the page is missing a title.

Co-authored-by: carolinan <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
4 people authored Aug 27, 2024
1 parent 9a6b2cc commit 0f19243
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ export default function PageListEdit( {
page.title?.rendered?.trim() !== ''
? page.title?.rendered
: __( '(no title)' ),
title: page.title?.rendered,
title:
// translators: displayed when a page has an empty title.
page.title?.rendered?.trim() !== ''
? page.title?.rendered
: __( '(no title)' ),
link: page.url,
hasChildren,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/page-list/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
$css_class .= ' menu-item-home';
}

$title = wp_kses_post( $page['title'] );
$title = wp_kses_post( $page['title'] );
$title = $title ? $title : __( '(no title)' );

$aria_label = sprintf(
/* translators: Accessibility text. %s: Parent page title. */
__( '%s submenu' ),
Expand Down

0 comments on commit 0f19243

Please sign in to comment.