Lists all blocks from block editor
wp.data.select( ‘core/block-editor’ ).getBlocks();
wp.data.select( ‘core/block-editor’).getBlockRootClientId( clientId )
Get Parent Block Client Id
Set attributes
wp.data.dispatch(“core/block-editor”).updateBlockAttributes(“block_client_id”, {attr});
Get root block client id: (e.g when you are extending the query-loop)
wp.data.select(“core/block-editor”).getBlockRootClientId( clientId_child_block );
Get featured image
$featuredImageId = wp.data.select(“core/editor”).getEditedPostAttribute(“featured_media”);
Get current post type
wp.data.select(“core/editor”).getCurrentPostType();
Execute on DOM ready
wp.domReady(function () {} );
Lock publish/update save button
wp.data.dispatch(“core/editor”).lockPostSaving(“requiredValueLock”);
Show message on block editor
wp.data.dispatch(“core/notices”).createNotice(“error”, data.requiredMessage, { isDismissible: true });
Unlock publish/update button
wp.data.dispatch(“core/editor”).unlockPostSaving(“requiredValueLock”);
Create block by code
wp.blocks.createBlock(“block_name”, {attrs}, [child_blocks]);
Get ACF metas or title, content, etc…
wp.coreData.useEntityProp(“postType”, postType, “acf”, postId);
it also works with title, content, excerpt and featured_image
