The Play Editor is a single static file WYPIWYG (What You Play Is What You Get) WordPress Playground blueprints editor.
The .html file spins a Playground instance that generates a blueprint on the fly
if you perform some changes in wp-admin. It accepts the same fragment
(#{...}, #cmVhbGx5Pw==) and blueprint-url=... API accepted by
playground.wordpress.net.
Important
The Play Editor is a work of proof and tested only with the most popular plugins and themes. Please do not use it in production environments.
There is a live demo available. If you want to
play with this on localhost, download and open that index.html file.
Once Playground has started, do whatever you want on WordPress, such as changing
options, installing plugins and themes, creating posts, etc. After this, select
the "Play Editor" menu. Inside that page, you will find the generated blueprint
.json file. In that page, you can open it on Playground, download it or copy
it on the clipboard.
The Play Editor can also be used as a standard plugin.
The Play Editor is composed of two things:
- The
play-editor.php(mu-)plugin. - The main
index.htmlfile that spins Playground.
The plugin intercepts various changes made by the user and generates a .json
file. It also sends the results back to the parent window using
post_message_to_js.
The index.html instead:
- Decode a blueprint from URL parameters, if there is one.
- Add three steps to the blueprint.
- It generates the
mu-pluginsfolder. - Write the Play Editor plugin there.
- Save the original
blueprint.jsonfile.
- It generates the
- It listens to Playground messages to save on the clipboard, download or open the JSON file.
The index.html editor file is an amalgamation of more than one file. To
generate it, you must run npm run compile, or simply npm i. You can find the
source in the source.html file and the play-editor folder.
Why not?
To specify that it is just a prototype and should only be used to play with a bit.
Because Playground is run inside an <iframe> and opening new tabs is
impossible.