import { __ } from '@wordpress/i18n'; import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; import { PluginDocumentSettingPanel } from '@wordpress/edit-post'; import { PanelRow, TextControl, DateTimePicker } from '@wordpress/components'; const MetaBox = ( { postType, metaFields, setMetaFields } ) => { if ( 'post' !== postType ) return null; return( setMetaFields( { _meta_fields_book_title: value } ) } /> setMetaFields( { _meta_fields_book_author: value } ) } /> setMetaFields( { _meta_fields_book_publisher: value } ) } /> setMetaFields( { _meta_fields_book_date: newDate } ) } __nextRemoveHelpButton __nextRemoveResetButton /> ); } const applyWithSelect = withSelect( ( select ) => { return { metaFields: select( 'core/editor' ).getEditedPostAttribute( 'meta' ), postType: select( 'core/editor' ).getCurrentPostType() }; } ); const applyWithDispatch = withDispatch( ( dispatch ) => { return { setMetaFields ( newValue ) { dispatch('core/editor').editPost( { meta: newValue } ) } } } ); export default compose([ applyWithSelect, applyWithDispatch ])(MetaBox);