/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/editor/src/components/page-attributes/check.js
30 строк
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'; /** * Wrapper component that renders its children only if the post type supports page attributes. * * @param {Object} props - The component props. * @param {React.ReactNode} props.children - The child components to render. * * @return {React.ReactNode} The rendered child components or null if page attributes are not supported. */ export function PageAttributesCheck( { children } ) { const supportsPageAttributes = useSelect( ( select ) => { const { getEditedPostAttribute } = select( editorStore ); const { getPostType } = select( coreStore ); const postType = getPostType( getEditedPostAttribute( 'type' ) ); return !! postType?.supports?.[ 'page-attributes' ]; }, [] ); // Only render fields if post type supports page attributes or available templates exist. if ( ! supportsPageAttributes ) { return null; } return children; } export default PageAttributesCheck;