Skip to content

Instantly share code, notes, and snippets.

@techlemur
Created February 11, 2019 21:10
Show Gist options
  • Save techlemur/ea1c921516ce67ae0bceec30b872fd6e to your computer and use it in GitHub Desktop.
Save techlemur/ea1c921516ce67ae0bceec30b872fd6e to your computer and use it in GitHub Desktop.
/* gets all available blocks and log them in console */
wp.data.select( "core/blocks" ).getBlockTypes().forEach(function(element) {
console.log(element['name']);
});
/* same thing but in a new window and formatted for php */
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