carbon-fields
carbon-fields copied to clipboard
Blocks do not work in 5.8 Wordpress widgets screen
Version
- Carbon Fields: 3.3.2
- WordPress: 5.8
- PHP: 7.3.21
Expected Behavior
I can edit and preview the block in the Widgets screen.
Actual Behavior
I recieve a "This block has encountered an error and cannot be previewed" error message.
Container definition
Block::make( 'hello', 'Hello' )
->add_fields( array(
Field::make( 'text', 'person', 'Person' )
->set_default_value( 'World' )
) )
->set_render_callback( function( $fields ) {
echo 'Hello ' . $fields[ 'person' ];
});
Steps to Reproduce the Problem
- Create a block
- Add it to a sidebar in Wordpress 5.8
Could this be because of the deprecated block_categories function? I see it is used here. I get this error when using the latest CarbonFields:
block_categories is <strong>deprecated</strong> since version 5.8.0! Use block_categories_all instead.
I tried switching out with block_categories_all as you did in your pull request ( #1024 ) but no luck.
I think it might be something to do with the new way block assets are enqueued. Still trying to figure it out for one of my own projects. Do you get this error when wp_debug is enabled?
PHP Notice: wp_enqueue_script() was called <strong>incorrectly</strong>. "wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets).
More info here: https://core.trac.wordpress.org/ticket/53664
Do you get this error when wp_debug is enabled?
I'm not getting any PHP notices or errors and wp_debug is enabled. Just "This block has encountered an error and cannot be previewed" when I add the block to a sidebar.
The block displays correctly on the frontend sidebar, albeit with the default fields values.
Any update on this one?
It's pretty sad for these awesome blocks to be broken :'(
Yep, faced the same problem :( Created a block with just one text field. And it's working as expected in the post's editor, but not working in the widgets' editor ("Appearance"->"Widget"). I also see only "This block has encountered an error and cannot be previewed." message and don't see the field. I have WordPress 6.0.
Still an problem with
- WordPress: 6.4.3
- Carbon Fields: 3.6.3
- PHP: 8.1
Any updates on this issue?
Is there any relation between this issue and this: https://github.com/Automattic/jetpack/issues/20357 ?