UNPKG

@wordpress/edit-post

Version:
60 lines (52 loc) 1.9 kB
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import { createElement } from "@wordpress/element"; /** * External dependencies */ import { filter, map } from 'lodash'; /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { withSelect } from '@wordpress/data'; /** * Internal dependencies */ import Section from './section'; import { EnableCustomFieldsOption, EnablePanelOption } from './options'; export function MetaBoxesSection(_ref) { var areCustomFieldsRegistered = _ref.areCustomFieldsRegistered, metaBoxes = _ref.metaBoxes, sectionProps = _objectWithoutProperties(_ref, ["areCustomFieldsRegistered", "metaBoxes"]); // The 'Custom Fields' meta box is a special case that we handle separately. var thirdPartyMetaBoxes = filter(metaBoxes, function (_ref2) { var id = _ref2.id; return id !== 'postcustom'; }); if (!areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0) { return null; } return createElement(Section, sectionProps, areCustomFieldsRegistered && createElement(EnableCustomFieldsOption, { label: __('Custom Fields') }), map(thirdPartyMetaBoxes, function (_ref3) { var id = _ref3.id, title = _ref3.title; return createElement(EnablePanelOption, { key: id, label: title, panelName: "meta-box-".concat(id) }); })); } export default withSelect(function (select) { var _select = select('core/editor'), getEditorSettings = _select.getEditorSettings; var _select2 = select('core/edit-post'), getAllMetaBoxes = _select2.getAllMetaBoxes; return { // This setting should not live in the block editor's store. areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== undefined, metaBoxes: getAllMetaBoxes() }; })(MetaBoxesSection); //# sourceMappingURL=meta-boxes-section.js.map