Modify the core/paragraph block

Very similar to your goal, I recently wanted to add a block-style to all existing blocks. I found that upon loading an editor page, I must wait for the WP editor JS data to populate before adding my styles, and AFAIK, there’s no callback hook for this. So I chose to add a not-so-elegant delay … Read more

gutenberg dynamic block is returning 404

The handle() method is being called by an add_action(‘enqueue_block_editor_assets, [$block, ‘handle’]) method along with all the other blocks. Here lies the problem. The register_block_type is being called too late. Try to call the function inside the init action hook. You can see an example in the shortcode block of the core.

How to get the ToggleControl Gutenberg component working for a PHP Block

The issue is that in ToggleControl you are using the wrong prop for the value. It should be checked instead of value. Also use the blockEditor package instead of editor for InspectorControls as it will be deprecated. el( ToggleControl, { label: ‘Toogle’, checked: props.attributes.toggle, // here onChange: ( value ) => { props.setAttributes( { toggle: … Read more

Hide gutenberg option blocks

Some of the panels related to the entire post (e.g. the featured image, excerpt) can be removed and https://github.com/WordPress/gutenberg/issues/17281 shows how. e.g. wp.data.dispatch( ‘core/edit-post’).removeEditorPanel( ‘featured-image’ ); wp.data.dispatch( ‘core/edit-post’).removeEditorPanel( ‘post-excerpt’ ); The sidebar is also used for additional block options and there’s currently no cohesive, consistent way to manage whether a block’s options are available to … Read more

All post types with getEntityRecords

It is not possible to query multiple post types simultaneously using the getEntityRecords() selector. This is because the WordPress REST API is not built around the same ideology as the core WordPress back-end. All data-types being “posts” in the traditional PHP APIs is the product of the somewhat controversial underlying database implementation, while the REST … Read more

serialize_blocks breaking html tags in content

This happens in serialize_block_attributes, the docblock explains why: /** … * The serialized result is a JSON-encoded string, with unicode escape sequence * substitution for characters which might otherwise interfere with embedding * the result in an HTML comment. … */ So this is done as an encoding measure to avoid attributes accidentally closing a … Read more