diff --git a/packages/block-library/src/home-link/edit.js b/packages/block-library/src/home-link/edit.js index ec9ae2864e3d50..fa6b27a3e2128b 100644 --- a/packages/block-library/src/home-link/edit.js +++ b/packages/block-library/src/home-link/edit.js @@ -19,13 +19,10 @@ import { useEffect } from '@wordpress/element'; const preventDefault = ( event ) => event.preventDefault(); export default function HomeEdit( { attributes, setAttributes, context } ) { - const { homeUrl } = useSelect( ( select ) => { - const { - getUnstableBase, // Site index. - } = select( coreStore ); - return { - homeUrl: getUnstableBase()?.home, - }; + const homeUrl = useSelect( ( select ) => { + // Site index. + return select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) + ?.home; }, [] ); const { __unstableMarkNextChangeAsNotPersistent } = useDispatch( blockEditorStore ); diff --git a/packages/edit-post/src/store/private-selectors.js b/packages/edit-post/src/store/private-selectors.js index 0c0ac3c518024d..246b2754d895ab 100644 --- a/packages/edit-post/src/store/private-selectors.js +++ b/packages/edit-post/src/store/private-selectors.js @@ -12,12 +12,13 @@ export const getEditedPostTemplateId = createRegistrySelector( type: postType, slug, } = select( editorStore ).getCurrentPost(); - const { getSite, getEntityRecords, canUser } = select( coreStore ); + const { getEntityRecord, getEntityRecords, canUser } = + select( coreStore ); const siteSettings = canUser( 'read', { kind: 'root', name: 'site', } ) - ? getSite() + ? getEntityRecord( 'root', 'site' ) : undefined; // First check if the current page is set as the posts page. const isPostsPage = +postId === siteSettings?.page_for_posts; diff --git a/packages/edit-site/src/components/add-new-template/index.js b/packages/edit-site/src/components/add-new-template/index.js index 8a900ecc958009..933ea6df1198bb 100644 --- a/packages/edit-site/src/components/add-new-template/index.js +++ b/packages/edit-site/src/components/add-new-template/index.js @@ -166,14 +166,10 @@ function NewTemplateModal( { onClose } ) { const isMobile = useViewportMatch( 'medium', '<' ); - const { homeUrl } = useSelect( ( select ) => { - const { - getUnstableBase, // Site index. - } = select( coreStore ); - - return { - homeUrl: getUnstableBase()?.home, - }; + const homeUrl = useSelect( ( select ) => { + // Site index. + return select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) + ?.home; }, [] ); const TEMPLATE_SHORT_DESCRIPTIONS = { diff --git a/packages/edit-site/src/components/site-hub/index.js b/packages/edit-site/src/components/site-hub/index.js index 66439cd0712fab..7fe929d20a1db2 100644 --- a/packages/edit-site/src/components/site-hub/index.js +++ b/packages/edit-site/src/components/site-hub/index.js @@ -36,15 +36,12 @@ const SiteHub = memo( const { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => { const { getSettings } = unlock( select( editSiteStore ) ); - const { - getSite, - getUnstableBase, // Site index. - } = select( coreStore ); - const _site = getSite(); + const { getEntityRecord } = select( coreStore ); + const _site = getEntityRecord( 'root', 'site' ); return { dashboardLink: getSettings().__experimentalDashboardLink || 'index.php', - homeUrl: getUnstableBase()?.home, + homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home, siteTitle: ! _site?.title && !! _site?.url ? filterURLForDisplay( _site?.url ) @@ -128,13 +125,10 @@ export const SiteHubMobile = memo( const { navigate } = useContext( SidebarNavigationContext ); const { homeUrl, siteTitle } = useSelect( ( select ) => { - const { - getSite, - getUnstableBase, // Site index. - } = select( coreStore ); - const _site = getSite(); + const { getEntityRecord } = select( coreStore ); + const _site = getEntityRecord( 'root', 'site' ); return { - homeUrl: getUnstableBase()?.home, + homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home, siteTitle: ! _site?.title && !! _site?.url ? filterURLForDisplay( _site?.url ) diff --git a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js index a0707802846fcf..ab6ea92bac4413 100644 --- a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +++ b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js @@ -37,10 +37,9 @@ function useResolveEditedEntityAndContext( { postId, postType } ) { url, frontPageTemplateId, } = useSelect( ( select ) => { - const { getSite, getUnstableBase, getEntityRecords } = - select( coreDataStore ); - const siteData = getSite(); - const base = getUnstableBase(); + const { getEntityRecord, getEntityRecords } = select( coreDataStore ); + const siteData = getEntityRecord( 'root', 'site' ); + const base = getEntityRecord( 'root', '__unstableBase' ); const templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, { per_page: -1, } ); diff --git a/packages/edit-site/src/hooks/commands/use-common-commands.js b/packages/edit-site/src/hooks/commands/use-common-commands.js index 2b5d0d8614c954..ca6e2d1c6b45dd 100644 --- a/packages/edit-site/src/hooks/commands/use-common-commands.js +++ b/packages/edit-site/src/hooks/commands/use-common-commands.js @@ -287,11 +287,9 @@ function useGlobalStylesOpenRevisionsCommands() { export function useCommonCommands() { const homeUrl = useSelect( ( select ) => { - const { - getUnstableBase, // Site index. - } = select( coreStore ); - - return getUnstableBase()?.home; + // Site index. + return select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) + ?.home; }, [] ); useCommand( { diff --git a/packages/editor/src/components/page-attributes/parent.js b/packages/editor/src/components/page-attributes/parent.js index 1018834d1b9fca..0f19ffcdd5daa4 100644 --- a/packages/editor/src/components/page-attributes/parent.js +++ b/packages/editor/src/components/page-attributes/parent.js @@ -222,10 +222,11 @@ function PostParentToggle( { isOpen, onClick } ) { } export function ParentRow() { - const homeUrl = useSelect( - ( select ) => select( coreStore ).getUnstableBase()?.home, - [] - ); + const homeUrl = useSelect( ( select ) => { + // Site index. + return select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) + ?.home; + }, [] ); // Use internal state instead of a ref to make sure that the component // re-renders when the popover's anchor updates. const [ popoverAnchor, setPopoverAnchor ] = useState( null ); diff --git a/packages/editor/src/components/preview-dropdown/index.js b/packages/editor/src/components/preview-dropdown/index.js index ef41fc087f1d2e..ec30d55cf0f17b 100644 --- a/packages/editor/src/components/preview-dropdown/index.js +++ b/packages/editor/src/components/preview-dropdown/index.js @@ -39,14 +39,14 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { showIconLabels, } = useSelect( ( select ) => { const { getDeviceType, getCurrentPostType } = select( editorStore ); - const { getUnstableBase, getPostType } = select( coreStore ); + const { getEntityRecord, getPostType } = select( coreStore ); const { get } = select( preferencesStore ); const { __unstableGetEditorMode } = select( blockEditorStore ); const _currentPostType = getCurrentPostType(); return { deviceType: getDeviceType(), editorMode: __unstableGetEditorMode(), - homeUrl: getUnstableBase()?.home, + homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home, isTemplate: _currentPostType === 'wp_template', isViewable: getPostType( _currentPostType )?.viewable ?? false, showIconLabels: get( 'core', 'showIconLabels' ), diff --git a/packages/editor/src/store/private-actions.js b/packages/editor/src/store/private-actions.js index e22929011256d5..358d00af396bbb 100644 --- a/packages/editor/src/store/private-actions.js +++ b/packages/editor/src/store/private-actions.js @@ -137,7 +137,9 @@ export const saveDirtyEntities = { kind: 'postType', name: 'wp_navigation' }, ]; const saveNoticeId = 'site-editor-save-success'; - const homeUrl = registry.select( coreStore ).getUnstableBase()?.home; + const homeUrl = registry + .select( coreStore ) + .getEntityRecord( 'root', '__unstableBase' )?.home; registry.dispatch( noticesStore ).removeNotice( saveNoticeId ); const entitiesToSave = dirtyEntityRecords.filter( ( { kind, name, key, property } ) => {