| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { compose } from '@wordpress/compose'; |
| 5 |
import { withSelect } from '@wordpress/data'; |
| 6 |
import { store as coreStore } from '@wordpress/core-data'; |
| 7 |
|
| 8 |
export function BlockAttributesCheck( { |
| 9 |
supportsCustomFieldsAction, |
| 10 |
children, |
| 11 |
} ) { |
| 12 |
if ( ! supportsCustomFieldsAction ) { |
| 13 |
return null; |
| 14 |
} |
| 15 |
|
| 16 |
return children; |
| 17 |
} |
| 18 |
|
| 19 |
export default compose( [ |
| 20 |
withSelect( ( select ) => { |
| 21 |
const { getCurrentPostType } = select( 'core/editor' ); |
| 22 |
const postType = getCurrentPostType(); |
| 23 |
|
| 24 |
return { |
| 25 |
supportsCustomFieldsAction: |
| 26 |
!! select( coreStore ).getPostType( postType )?.supports?.[ |
| 27 |
'custom-fields' |
| 28 |
], |
| 29 |
}; |
| 30 |
} ), |
| 31 |
] )( BlockAttributesCheck ); |
| 32 |
|