最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - Adding pre-publish checks with Gutenberg

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 4

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,
});
发布评论

评论列表(0)

  1. 暂无评论