UNPKG

@wordpress/block-library

Version:
24 lines (23 loc) 725 B
import { store as coreStore } from "@wordpress/core-data"; import { useSelect } from "@wordpress/data"; function usePostTypeLabel(contextPostType) { const currentPostType = useSelect((select) => { const { getCurrentPostType } = select("core/editor"); return getCurrentPostType(); }, []); return useSelect( (select) => { const { getPostType } = select(coreStore); const postTypeSlug = contextPostType || currentPostType; const postType = getPostType(postTypeSlug); return { postTypeLabel: postType ? postType.labels.singular_name : "" }; }, [contextPostType, currentPostType] ); } export { usePostTypeLabel }; //# sourceMappingURL=use-post-type-label.js.map