UNPKG

@wordpress/editor

Version:
27 lines (23 loc) 709 B
import { useSelect } from '@wordpress/data'; import { store as editorStore } from '../../store'; /** * Wrapper component that renders its children only if post has a publish action. * * @param {Object} props Props. * @param {React.ReactNode} props.children Children to be rendered. * * @return {React.ReactNode} - The component to be rendered or null if there is no publish action. */ export default function PostScheduleCheck( { children } ) { const hasPublishAction = useSelect( ( select ) => { return ( select( editorStore ).getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false ); }, [] ); if ( ! hasPublishAction ) { return null; } return children; }