The introduction of the Block Editor killed all plugins which provided publishing situations, reminiscent of minimal phrase counts, featured picture necessities and so forth.
However the Block Editor did introduce the pre-publish checks:
Lovely. How can we disable the Publish
button till a set quantity of situations have been fulfilled?
Examples of 4 (very) totally different situations:
- Minimal phrase rely (instance:
500
phrases) - Min/max tags (instance:
3-5
tags) - Min class (that is not
uncategorized
) - Featured picture is assigned
What we’ve thus far
As anticipated, the documentation is non-existent. However leads are scattered throughout the net.
In core/editor
, we will use .lockPostSaving() to disabled the Publish
button, and unlock it through .unlockPostSaving()
.
We will add a panel to the pre-publish display screen through PluginPrePublishPanel
. Instance (by MadMaardigan):
var PluginPrePublishPanel = wp.editPost.PluginPrePublishPanel;
var registerPlugin = wp.plugins.registerPlugin;
perform Element() {
// lock submit saving
wp.knowledge.dispatch('core/editor').lockPostSaving()
// unlock submit saving
// wp.knowledge.dispatch('core/editor').unlockPostSaving()
return wp.aspect.createElement(
PluginPrePublishPanel,
{
className: 'my-plugin-publish-panel',
title: 'Panel title',
initialOpen: true,
},
'Panel content material'
);
}
registerPlugin( 'my-plugin', {
render: Element,
});
It really works:
And we’ve nice discussions on GitHub: #7020, #7426, #13413, #15568, #10649…