Is it possible to convert an existing WordPress widget to a block, without having to write a custom block (javascript)?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The short answer here is no.
Widgets are written in PHP and blocks are written in JavaScript. Beyond that there pretty fundamental differences between the two paradigms in the sense of where they are stored, markup output approaches etc.
You could take the approach of a dynamic block where the block is rendered on the front end with PHP, but you’d still need to register a custom block in JavaScript ( as well as enqueue the files ) to be able to insert it into the Block Editor.
There may be plugins available that solve this, but I am not aware of any.
Hope this helps!
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0