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?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityBefore 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,
});
pluginPrePublishPanel
to be used, but locking/unlocking post saving directly inside of a function component definitely is not a good way to do it and will lead to bugs.
Mar 19, 2021 at 15:41