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?
Share Improve this question asked Apr 11, 2019 at 12:29 ChristopherDBerryChristopherDBerry 1817 bronze badges 1- 1 I added an example on how to do this here -wordpress.stackexchange/questions/339138/… – Welcher Commented Jan 10, 2020 at 15:25
1 Answer
Reset to default 4This 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,
});