Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 10 additions & 6 deletions packages/edit-site/src/components/add-new-template/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ export function usePostTypeArchiveMenuItems() {
// `icon` is the `menu_icon` property of a post type. We
// only handle `dashicons` for now, even if the `menu_icon`
// also supports urls and svg as values.
icon: postType.icon?.startsWith( 'dashicons-' )
? postType.icon.slice( 10 )
: archive,
icon:
typeof postType.icon === 'string' &&
postType.icon.startsWith( 'dashicons-' )
? postType.icon.slice( 10 )
: archive,
templatePrefix: 'archive',
};
} ) || [],
Expand Down Expand Up @@ -272,9 +274,11 @@ export const usePostTypeMenuItems = ( onClickMenuItem ) => {
// `icon` is the `menu_icon` property of a post type. We
// only handle `dashicons` for now, even if the `menu_icon`
// also supports urls and svg as values.
icon: icon?.startsWith( 'dashicons-' )
? icon.slice( 10 )
: post,
icon:
typeof icon === 'string' &&
icon.startsWith( 'dashicons-' )
? icon.slice( 10 )
: post,
templatePrefix: templatePrefixes[ slug ],
};
const hasEntities = postTypesInfo?.[ slug ]?.hasEntities;
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ export const getPostIcon = createRegistrySelector(
// `icon` is the `menu_icon` property of a post type. We
// only handle `dashicons` for now, even if the `menu_icon`
// also supports urls and svg as values.
if ( postTypeEntity?.icon?.startsWith( 'dashicons-' ) ) {
if (
typeof postTypeEntity?.icon === 'string' &&
postTypeEntity.icon.startsWith( 'dashicons-' )
) {
return postTypeEntity.icon.slice( 10 );
}
return pageIcon;
Expand Down