wp-rest-blocks icon indicating copy to clipboard operation
wp-rest-blocks copied to clipboard

WP 5.9.1 Gutenberg Error

Open erralb opened this issue 3 years ago • 6 comments

Following this issue : https://github.com/spacedmonkey/wp-rest-blocks/issues/31

Gutenberg is not working well when the plugin is activated, there is some JS errors and the blocks are not loading at all within Gutenberg. This post here have some blocks and content but they are not loading :

Screenshot 2022-02-28 at 18 56 15

The same post when deactivating the plugin :

Screenshot 2022-02-28 at 18 59 18

Can you help ?

erralb avatar Feb 28 '22 17:02 erralb

As a temporary workaround, I installed the "Free Soul Deactivate Plugins" plugin and I deactivated the WP Rest Blocks plugin when editing posts / using Gutenberg : https://wordpress.org/support/topic/deactivate-plugins-on-editor-gutenberg/

It's fixing the block editor, but I still have to check if the blocks are correctly queried through the API.

erralb avatar Mar 03 '22 10:03 erralb

I developed a similar solution as this and placed it among my other tools in k1sul1/k1kit. I also used blocks as the field name, because that made sense. Now, 3 years later after I wrote my code, WP update has broken it.

I replaced the field name with blockData if WP >= 5.9 and the issue is gone.

Running @ 5.9.1

The thing I don't get about this; why was my custom field is breaking the editor?! blocks doesn't EVEN EXIST in the REST API response:

image

Thankfully, this will be my last WP project ever. I don't have to deal with the BS anymore.

k1sul1 avatar Mar 08 '22 16:03 k1sul1

Very

I developed a similar solution as this and placed it among my other tools in k1sul1/k1kit. I also used blocks as the field name, because that made sense. Now, 3 years later after I wrote my code, WP update has broken it.

I replaced the field name with blockData if WP >= 5.9 and the issue is gone.

Running @ 5.9.1

The thing I don't get about this; why was my custom field is breaking the editor?! blocks doesn't EVEN EXIST in the REST API response:

image

Thankfully, this will be my last WP project ever. I don't have to deal with the BS anymore.

Great!!!! Your replace solves my issue. I coud'nt figure out how to restore the gutemberg blocks in my project.

alfredojry avatar Apr 22 '22 06:04 alfredojry

I believe I'm seeing something similar on WP 6.0.1. With the plugin activated, gallery blocks are not rendering for me.

Does this plugin somehow interact with the editor? I would have guessed that it simply interacts with the API responses that are made in a way that only appended data into those responses on the way out.

Steps to replicate:

  1. Activate plugin on a WP 6.0.1 instance
  2. Create a new post
  3. Add a gallery
  4. Add an image
  5. Publish
  6. Refresh page
  7. Notice gallery is gone

Disabling the plugin and coming back renders the gallery.

sahandnayebaziz avatar Jul 31 '22 18:07 sahandnayebaziz

As a temporary workaround, I installed the "Free Soul Deactivate Plugins" plugin and I deactivated the WP Rest Blocks plugin when editing posts / using Gutenberg : https://wordpress.org/support/topic/deactivate-plugins-on-editor-gutenberg/

It's fixing the block editor, but I still have to check if the blocks are correctly queried through the API.

This was very very helpful for me!

I'm currently on WordPress 6.0.1. When trying to edit a page, all blocks I had added (both core and custom blocks) disappeared. I followed the instructions to deactivate the plugin while in editing mode and the blocks reappeared. Not the ultimate solution but surely a nice trick!

GiovannaMonti avatar Aug 19 '22 15:08 GiovannaMonti

I've run into the same problem in 6.0.1. Like others, renaming the registered rest field fixed this.

This is obviously a breaking change for other installs.

For anyone this might be useful to though, the relevant code is in src/posts.php. Changing blocks -> blocksData in the register_rest_field exposes the data to the REST API and allows the blocks to be rendered in the editor.

doingandlearning avatar Aug 30 '22 10:08 doingandlearning

FreeSoul Deactivate Plugins did not work to deactivate plugin in editor --

however -- switching the name of blocks to blockData in the posts.php made everything better <3 thank you!!

hollyhilts avatar Nov 17 '22 00:11 hollyhilts

Sorry for my late reply this. Somehow managed miss it.

Those that are on this ticket, can you test #37 and see if that fixes your issue.

spacedmonkey avatar Jan 10 '23 20:01 spacedmonkey

For anyone else stumbling across this months later, the solution proposed by @doingandlearning above in fact, does fixes the problem for now (renaming the registry name from blocks to blocksData or something else on line 68 in src/posts.php.

I have no idea why something like this isn't offered in WP core. It's very useful. Thanks @spacedmonkey

gregoryspragginsjr avatar Mar 09 '23 04:03 gregoryspragginsjr