I would like to generate a Gutenberg block in PHP.
I'm currently developing a WordPress plugin that import videos from YouTube and create a post for each video. I can insert the YouTube video inside the post_content but when i edit the post with the Gutenberg editor it doesn't display as a block.
I read most of the "Block Editor Handbook" here https://developer.wordpress.org/block-editor/ But i can't find anything except how to create custom block. I searched on google also, but everything I found was also about creating custom block. Yet I found that Gutenberg blocks are stored inside post_content as a html comment, but the comment seems to be generated with js via Gutenberg WYSIWYG editor.
I know that I could create a post with the blocks and copy the post_content from my database then use it as a "template" but I don't think it's a proper way.
Is there any documentation about using the blocks that come with WordPress (i.e.: embed, paragraph) and generate the html comment which is saved within post_content with PHP? Is it even possible?
parse_blocks()
which will convert the HTML-comments content to actual PHP arrays representing the blocks, andrender_block()
which will turn the arrays back into the content as it is saved to the DB. Here's a fine article about these functions billerickson.net/access-gutenberg-block-data – Industrial