diff --git a/packages/editor/src/components/post-publish-panel/maybe-category-panel.js b/packages/editor/src/components/post-publish-panel/maybe-category-panel.js index 8fbf1c38fc36d..72df6e883fd2e 100644 --- a/packages/editor/src/components/post-publish-panel/maybe-category-panel.js +++ b/packages/editor/src/components/post-publish-panel/maybe-category-panel.js @@ -16,17 +16,14 @@ import { store as editorStore } from '../../store'; function MaybeCategoryPanel() { const hasNoCategory = useSelect( ( select ) => { const postType = select( editorStore ).getCurrentPostType(); - const categoriesTaxonomy = - select( coreStore ).getTaxonomy( 'category' ); - const defaultCategoryId = select( coreStore ).getEntityRecord( - 'root', - 'site' - )?.default_category; - const defaultCategory = select( coreStore ).getEntityRecord( - 'taxonomy', - 'category', - defaultCategoryId - ); + const { canUser, getEntityRecord, getTaxonomy } = select( coreStore ); + const categoriesTaxonomy = getTaxonomy( 'category' ); + const defaultCategoryId = canUser( 'read', 'settings' ) + ? getEntityRecord( 'root', 'site' )?.default_category + : undefined; + const defaultCategory = defaultCategoryId + ? getEntityRecord( 'taxonomy', 'category', defaultCategoryId ) + : undefined; const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some( ( type ) => type === postType ); @@ -45,7 +42,7 @@ function MaybeCategoryPanel() { postTypeSupportsCategories && ( categories?.length === 0 || ( categories?.length === 1 && - defaultCategory.id === categories[ 0 ] ) ) + defaultCategory?.id === categories[ 0 ] ) ) ); }, [] ); const [ shouldShowPanel, setShouldShowPanel ] = useState( false );