Skip to content

Commit

Permalink
Update post/page related functions to return ID as number
Browse files Browse the repository at this point in the history
  • Loading branch information
louwie17 committed Dec 17, 2024
1 parent 9e4ceb6 commit ba6868a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function getRegisteredPostMeta( state: State, postType: string ) {
return state.registeredPostMeta?.[ postType ] ?? {};
}

function normalizePageId( value: number | string | undefined ): string | null {
function normalizePageId( value: number | string | undefined ): number | null {
if ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {
return null;
}
Expand All @@ -129,7 +129,11 @@ function normalizePageId( value: number | string | undefined ): string | null {
return null;
}

return value.toString();
if ( typeof value === 'string' ) {
return parseInt( value, 10 );
}

return value;
}

interface SiteData {
Expand Down
5 changes: 2 additions & 3 deletions packages/fields/src/fields/template/template-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ export const TemplateEdit = ( {
select( coreStore )
);

const isPostsPage = getPostsPageId() === postId.toString();
const isPostsPage = getPostsPageId() === postId;
const isFrontPage =
postType === 'page' &&
getHomePage()?.postId === postId.toString();
postType === 'page' && getHomePage()?.postId === postId;

return {
templates: allTemplates,
Expand Down

0 comments on commit ba6868a

Please sign in to comment.