diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index 0818fe0b0446ef..f6f3b2c033bd92 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -29,7 +29,7 @@ import { ItemSubmenuIcon } from '../navigation-link/icons'; const MAX_PAGE_COUNT = 100; export default function PageListEdit( { context, clientId } ) { - const { pagesByParentId, totalPages } = usePagesByParentId(); + const { pagesByParentId, totalPages } = usePageData(); const isNavigationChild = 'showSubmenuIcon' in context; const allowConvertToLinks = @@ -94,7 +94,14 @@ export default function PageListEdit( { context, clientId } ) { ); } -function usePagesByParentId() { +function useFrontPageId() { + return useSelect( ( select ) => { + const site = select( coreStore ).getEntityRecord( 'root', 'site' ); + return site?.show_on_front === 'page' && site?.page_on_front; + }, [] ); +} + +function usePageData() { const { pages } = useSelect( ( select ) => { const { getEntityRecords } = select( coreStore ); @@ -137,6 +144,7 @@ const PageItems = memo( function PageItems( { depth = 0, } ) { const pages = pagesByParentId.get( parentId ); + const frontPageId = useFrontPageId(); if ( ! pages?.length ) { return []; @@ -155,6 +163,7 @@ const PageItems = memo( function PageItems( { 'open-on-hover-click': ! context.openSubmenusOnClick && context.showSubmenuIcon, + 'menu-item-home': page.id === frontPageId, } ) } > { hasChildren && context.openSubmenusOnClick ? ( diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index efec9ff583cb77..e410448dccdbba 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -173,6 +173,11 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, } } + $front_page_id = (int) get_option( 'page_on_front' ); + if ( (int) $page['page_id'] === $front_page_id ) { + $css_class .= ' menu-item-home'; + } + $title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) ); $aria_label = sprintf( /* translators: Accessibility text. %s: Parent page title. */