/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/editor/src/components/post-url/check.js
39 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; import { store as editorStore } from '../../store'; /** * Check if the post URL is valid and visible. * * @param {Object} props The component props. * @param {React.ReactNode} props.children The child components. * * @return {React.ReactNode} The child components if the post URL is valid and visible, otherwise null. */ export default function PostURLCheck( { children } ) { const isVisible = useSelect( ( select ) => { const postTypeSlug = select( editorStore ).getCurrentPostType(); const postType = select( coreStore ).getPostType( postTypeSlug ); if ( ! postType?.viewable ) { return false; } const post = select( editorStore ).getCurrentPost(); if ( ! post.link ) { return false; } const permalinkParts = select( editorStore ).getPermalinkParts(); if ( ! permalinkParts ) { return false; } return true; }, [] ); if ( ! isVisible ) { return null; } return children; }