-
-
Save anver/3971159ef78bc991d1a7a4a29d3315e9 to your computer and use it in GitHub Desktop.
get all available gutenberg block info for your site with javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Navigate to a wordpress edit page for any post and run one of the code sections below in a javascript console to get the names/info for all blocks available to gutenberg on your site. */ | |
/* log all block info to console */ | |
console.log(wp.data.select( "core/blocks" ).getBlockTypes()); | |
/* log all block names to console */ | |
wp.data.select( "core/blocks" ).getBlockTypes().forEach(function(element) { | |
console.log(element['name']); | |
}); | |
/* print all block names to a new window */ | |
var win = window.open("", "Title", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top="+(screen.height-400)+",left="+(screen.width-840)); | |
var tmpContent = 'Blocks<br><hr><br>'; | |
wp.data.select( "core/blocks" ).getBlockTypes().forEach(function(element) { | |
tmpContent = tmpContent + element['name'] + "<br>"; | |
}); | |
win.document.body.innerHTML = tmpContent; | |
/* same thing but formatted for a php array with commented descriptions */ | |
var win = window.open("", "Title", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top="+(screen.height-400)+",left="+(screen.width-840)); | |
var tmpContent = 'Block List<br><hr><br>array(<br>'; | |
wp.data.select( "core/blocks" ).getBlockTypes().forEach(function(element) { | |
tmpContent = tmpContent + "'" + element['name'] + "', //"+element['description']+"<br>"; | |
}); | |
tmpContent = tmpContent + ');'; | |
win.document.body.innerHTML = tmpContent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment