bordoni / fakerpress

A WordPress plugin that implements an easy way to create fake data inside WordPress.
http://fakerpress.com
Other
338 stars 54 forks source link

Option for generating block editor-aware content #151

Open cbirdsong opened 3 years ago

cbirdsong commented 3 years ago

Fakerpress currently generates blocks of basic HTML, which show up in the block editor as "Classic Editor" blocks. It would be great if the content it generated was native to the block editor and used stock blocks and block options (align, color, drop cap, etc).

cr0ybot commented 1 week ago

I was hoping for this functionality too, but I also happen to know how difficult this would be to pull off. The PHP side of WordPress does not include any way to easily "render" blocks to the HTML format that is stored in the database. There are ways to get it to sort-of work using render_block(), but if you aren't feeding the results from parse_blocks() to it the output will often not work correctly. You can't just feed the function some expected block attributes and expect it to actually render the HTML. Currently the client-side JavaScript in the block editor is responsible for creating the commented HTML that is stored in the database. I'm not sure what the solution to this problem would be but it would future-proof this plugin tremendously.