Admin Notification after save_post, when ajax saving in gutenberg

Presenting Notices Gutenberg provides a mechanism for displaying notices in the form of the Notices Data package. In Gutenberg’s editors, the package’s selectors and action creators are exposed on the core/notices store, and can be accessed by any standard means therein, e.g.: useDispatch( ‘core/notices’ ) hook in functional components (including the edit() function of a … Read more

Managing two editable fields in gutenberg

Editable has been replaced with RichText in 2.2. Here’s a example of two RichText components being edit/saved together: const { __ } = wp.i18n; const { registerBlockType, RichText, } = wp.blocks; registerBlockType( ‘wtv/wtv’, { title: __( ‘wtv’, ‘wtv’ ), icon: ‘id’, category: ‘widgets’, keywords: [ __( ‘wtv’ ), __( ‘wtv’ ), __( ‘wtv’ ) ], … Read more

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