Skip to content

Instantly share code, notes, and snippets.

@manishsongirkar
Last active June 10, 2024 18:50
Show Gist options
  • Save manishsongirkar/47f5c1e8f1eb430cf5ac5a717e8af33f to your computer and use it in GitHub Desktop.
Save manishsongirkar/47f5c1e8f1eb430cf5ac5a717e8af33f to your computer and use it in GitHub Desktop.
Gutenberg Block List
// All block lists.
wp.blocks.getBlockTypes();
// All Core blocks only.
wp.blocks.getBlockTypes().filter((block) => { return block.name.indexOf('core') !== -1});
// All block list name only.
wp.blocks.getBlockTypes().filter((block) => { console.log( block.name ) });
// All block list name only EXCLUDING child block.
wp.blocks.getBlockTypes().filter(
( block ) => {
if ( block.name.indexOf( 'core' ) !== -1 && undefined === block.parent ) {
return block.name;
}
}
);
// Get selected block details.
wp.data.select( 'core/block-editor' ).getSelectedBlock();
// Get selected block attributes in console.
wp.data.select( 'core/block-editor' ).getSelectedBlock().attributes;
// Get selected block innerBlocks and its attributes.
wp.data.select( 'core/block-editor' ).getSelectedBlock().innerBlocks
// List all Patterns.
wp.apiFetch( { path: '/wp/v2/block-patterns/patterns' } ).then( console.log );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment