By MadMaardigan


2019-04-11 12:29:44 8 Comments

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?

prepublish check

1 comments

@MadMaardigan 2019-04-18 07:46:48

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,
});

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Page template added via plugin not saved in Gutenberg

2 Answered Questions

[SOLVED] Changing text within the Block Editor

2 Answered Questions

Change the text of the publish button to Save

2 Answered Questions

[SOLVED] How to detect the usage of Gutenberg

  • 2018-11-30 10:01:01
  • KAGG Design
  • 2248 View
  • 8 Score
  • 2 Answer
  • Tags:   block-editor

1 Answered Questions

[SOLVED] How to replace WordPress sidebars (widget areas) with Gutenberg

0 Answered Questions

How to add button to post page WordPress 5.x

0 Answered Questions

Modifying the Gutenberg Button Block

  • 2018-12-02 14:26:13
  • Moshe
  • 255 View
  • 2 Score
  • 0 Answer
  • Tags:   block-editor

1 Answered Questions

2 Answered Questions

Sponsored Content