Before publishing an unpublished article pre-publish checks are shown.
How can I extend this programmatically, and disable the publish button if the checks are not passed?
Before publishing an unpublished article pre-publish checks are shown.
How can I extend this programmatically, and disable the publish button if the checks are not passed?
This got me started.
Set up the block with create-guten-block
Gitub
Update block.js
to something like:
import './style.scss';
import './editor.scss';
var PluginPrePublishPanel = wp.editPost.PluginPrePublishPanel;
var registerPlugin = wp.plugins.registerPlugin;
function Component() {
wp.data.dispatch('core/editor').lockPostSaving()
//do stuff
//wp.data.dispatch('core/editor').unlockPostSaving()
return wp.element.createElement(
PluginPrePublishPanel,
{
className: 'my-plugin-publish-panel',
title: 'Panel title',
initialOpen: true,
},
'Panel content'
);
}
registerPlugin( 'my-plugin', {
render: Component,
});