Adding pre-publish checks with Gutenberg

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: … Read more

How to create gutenberg block using REST API independently or as headless way?

Block editor blocks are dynamically constructed by parsing the HTML of post_content. Blocks are delimited by HTML comments that looks like these: <!– wp:image –> <figure class=”wp-block-image”><img src=”https://wordpress.stackexchange.com/questions/359758/source.jpg” alt=”” /></figure> <!– /wp:image –> The way the actual data of blocks is stored depends entirely on the block. Blocks can either store their attributes inside the … Read more

How can I see a list of pages and post where my custom Gutenberg block is used?

General block name search One can e.g. use the general search in the /wp-admin backend to find some text within the post’s content that stores the blocks: We can search for a prefixed block name wp:my-plugin/my-block within the posts: example.com/wp-admin/edit.php ?s=wp:my-plugin%2Fmy-block%20&post_type=post where we have an extra space (url encoded as %20and / as %2F) after … Read more

Implement Panel Color Inspector Control in Gutenberg

Many wp.blocks.* controls have been moved to wp.editor.* (see release notes). Specifically wp.blocks.InspectorControls is now wp.editor.InspectorControls – you’ll need to change the first line of your code. Note: registerBlockType is still imported from wp.blocks.* iirc. As a side note, I’ve also found that the focus && trick no longer required as GB automatically displays the … Read more

What version of Gutenberg is included with WordPress?

You can find the versions in WordPress here with this recently created document: https://developer.wordpress.org/block-editor/principles/versions-in-wordpress/ You weren’t alone in wanting to have this information 🙂 As mentioned above, it can be tricky to directly line up versions but this is the closest approximation currently. When WordPress 5.5 is launched, this document will be updated.

How to disable Gutenberg editor?

Yes, you can disable it. You can do this with code If you want to disable it globally, you can use this code: if ( version_compare($GLOBALS[‘wp_version’], ‘5.0-beta’, ‘>’) ) { // WP > 5 beta add_filter( ‘use_block_editor_for_post_type’, ‘__return_false’, 100 ); } else { // WP < 5 beta add_filter( ‘gutenberg_can_edit_post_type’, ‘__return_false’ ); } And if … Read more