wordpresswordpress-gutenberg

Gutenberg block not showing in block library upon name change


I am trying to make a custom gutenberg block in WordPress and for that case I downloaded the an example of such custom gutenberg block plugin: https://github.com/WordPress/gutenberg-examples/tree/43f1a2e44ca92585e614d2fda7690af813eac746/blocks-non-jsx/01-basic. If I install the example, I see the custom block in the block library in gutenberg editor.

Now, I want to modify it to make it my own. One step is to edit the name of the block, for that I went to block.json and changed "name": "gutenberg-examples/example-01-basic", to "name": "gutenberg-examples/call-to-action", and then went to block.js and changed blocks.registerBlockType( 'gutenberg-examples/example-01-basic', { to blocks.registerBlockType( 'gutenberg-examples/call-to-action', {.

Though this makes the custom block disappear from the block library. I have tried de- and reactivated the plugin, changed the plugin identifier (folder name, to avoid possible cache), hard reloaded gutenberg editor in browser (to avoid possible cache), checked the browser console for any errors.

This doesn't make sense to me, the only change I did that made the custom gutenberg block disappear was changing all occurences of the name (2 locations).

How can I debug my gutenberg block? Why does the name change cause the gutenberg block to disappear? How can I change the name of a gutenberg block's name (and still have it working)?


Solution

  • I was unaware, that WordPress debug was turned off. Therefore, I never saw the error messages revealing the error causing my gutenberg blocks not to appear.

    Notice: WP_Block_Type_Registry::register was called incorrectly. Block type names must not contain uppercase characters.

    I believe the fact, that I had one block with incorrect block name caused the other blocks to not be registered either.