How to use get_option() in Gutenberg block editor to retrieve global settings?

If your option is enabled in the REST API, e.g. by using register_setting() with ‘show_in_rest’ => true, you can use wp.data.select( ‘core’ ).getSite() to retrieve the value of your option, and to update the option, you can use wp.data.dispatch( ‘core’ ).saveSite(). So for example in your case: To get the option value: wp.data.select( ‘core’ ).getSite()?.autoupdate … Read more

Detect whether a block has server-side render

In PHP, it’s certainly possible to check if a block type is dynamic or whether the block uses server-side rendering. For example for already registered block types, just get the block type object and call its is_dynamic method. $block_registry = WP_Block_Type_Registry::get_instance(); $block_name=”core/latest-posts”; $block_type_object = $block_registry->get_registered( $block_name ); if ( $block_type_object ) { // Note: render_callback … Read more

Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?

Yes, but you have to do it Redux- way. Subscribe to post saving action (there are separate actions for save and auto-save) and dispatch a message using dispatch function. Edit: Inside blocks, there are better hooks to use, like useSelect. But, outside the block, in general block editor environmentm you have to use subscribe. In … Read more

Custom Gutenberg block with nested InnerBlocks renderAppender not displaying add button

In gc-slider2/index.js, I removed the templateLock=”all” from the InnerBlocks, and it is now displaying the plus sign for the gc-slider-items block. <InnerBlocks template={SLIDER_TEMPLATE} allowedBlocks={ [ ] } /> Which leaves me with a different problem of two add block plus signs. See Gutenberg Innerblocks notallowedblocks on parent but allowedblock on child

Why is my drop down empty

I’d guess you may have figured this out by now. Here’s my answer anyway. You say the API returns an array whose object items have label and value properties but if I try that same request I get an array whose object items have name and id properties (as you would expect when you specify … Read more

useBlockProps() nests wrapper with class name inside block wrapper in the editor

I was bitten by this as well, and it caused me much frustration. I had exactly the same nested block duplication problem that you described above. I was able to solve this issue by specifying an apiVersion for my custom block. E.g.: registerBlockType(“custom-cafe-theme/custom-column”,{ apiVersion: 2, // or 3 title: “Custom Column”, attributes: { imgID: { … Read more