| 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( { supportsCustomFieldsAction, children } ) { |
| 9 |
if ( ! supportsCustomFieldsAction ) { |
| 10 |
return null; |
| 11 |
} |
| 12 |
|
| 13 |
return children; |
| 14 |
} |
| 15 |
|
| 16 |
export default compose( [ |
| 17 |
withSelect( ( select ) => { |
| 18 |
const { getCurrentPostType } = select( 'core/editor' ); |
| 19 |
const postType = getCurrentPostType(); |
| 20 |
|
| 21 |
return { |
| 22 |
supportsCustomFieldsAction: |
| 23 |
!! select( coreStore ).getPostType( postType )?.supports?.['custom-fields'], |
| 24 |
}; |
| 25 |
} ), |
| 26 |
] )( BlockAttributesCheck ); |
| 27 |
|