/* File: separator-remover.js (da posizionare nella stessa cartella del plugin) */
(function (wp) {
const { registerPlugin } = wp.plugins;
const { PluginPostStatusInfo } = wp.editPost;
const { CheckboxControl } = wp.components;
const { withSelect, withDispatch } = wp.data;
const { compose } = wp.compose;
const SeparatorToggle = ({ meta, setMeta }) =>
wp.element.createElement(
PluginPostStatusInfo,
null,
wp.element.createElement(CheckboxControl, {
label: 'Keep separators',
checked: !!meta._separator_remover_keep,
onChange: (value) => setMeta({ _separator_remover_keep: value }),
})
);
const SeparatorTogglePanel = compose(
withSelect((select) => ({
meta: select('core/editor').getEditedPostAttribute('meta'),
})),
withDispatch((dispatch) => ({
setMeta(meta) {
dispatch('core/editor').editPost({ meta });
},
}))
)(SeparatorToggle);
registerPlugin('separator-remover-plugin', {
render: SeparatorTogglePanel,
});
})(window.wp);