Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the site editor loading in multi-site installs #49861

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import { store as editSiteStore } from '../../store';
export default function useInitEditedEntityFromURL() {
const { params: { postId, postType } = {} } = useLocation();
const { isRequestingSite, homepageId, url } = useSelect( ( select ) => {
const { getSite } = select( coreDataStore );
const { getSite, getUnstableBase } = select( coreDataStore );
const siteData = getSite();
const base = getUnstableBase();

return {
isRequestingSite: ! siteData,
isRequestingSite: ! base,
homepageId:
siteData?.show_on_front === 'page'
? siteData.page_on_front
: null,
url: siteData?.url,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise, this is in line with the other two places I've seen this in use: home-link and header-edit-mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems the proper way to query this data based on usage, but I'm curious about the story of the unstableBase. I see it defined as an entity and the data comes from / in the network tab. However, I don't find this endpoint documented here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oandregal, the index endpoint data is defined here - https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/class-wp-rest-server.php#L1255-L1266.

The change correctly uses home instead of the url.

url: base?.home,
};
}, [] );

Expand Down