I would like to generate a gutenberg block in php.
I'm currently developping 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 (ie: embed, paragraphe) and generate the html comment wich 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 – Jules Colle