UNPKG

@wordpress/editor

Version:
28 lines (24 loc) 696 B
import { useSelect } from '@wordpress/data'; import { VISIBILITY_OPTIONS } from './utils'; import { store as editorStore } from '../../store'; /** * Returns the label for the current post visibility setting. * * @return {string} Post visibility label. */ export default function PostVisibilityLabel() { return usePostVisibilityLabel(); } /** * Get the label for the current post visibility setting. * * @return {string} Post visibility label. */ export function usePostVisibilityLabel() { const visibility = useSelect( ( select ) => select( editorStore ).getEditedPostVisibility(), [] ); return VISIBILITY_OPTIONS.find( ( option ) => option.value === visibility ) ?.label; }