Background
WordPress Playground is a tool that runs a full WordPress instance entirely within the browser, powered by WebAssembly—no server required. The official site, playground.wordpress.net, supports the ?plugin=xxx query parameter to directly load and preview plugins hosted on WordPress.org.
We self-host WordPress Playground at play.wenpai.net, and need to implement identical functionality—but with plugins sourced from our own repository instead of WordPress.org.
Core Concept: Blueprint
A Blueprint is WordPress Playground’s configuration file (in JSON format), defining the initial state of a Playground instance:
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/wp-admin/options-general.php?page=wpslug",
"preferredVersions": { "php": "8.3", "wp": "latest" },
"steps": [
{ "step": "setSiteLanguage", "language": "zh_CN" },
{ "step": "installPlugin", "pluginData": { "resource": "url", "url": "https://play.wenpai.net/plugins/wpslug-1.1.1.zip" } },
{ "step": "activatePlugin", "pluginPath": "wpslug/wpslug.php" },
{ "step": "login", "username": "admin", "password": "password" }
]
}
Playground natively supports the blueprint-url query parameter. Visiting /playground.html?blueprint-url=/path/to/blueprint.json loads the specified configuration.
Implementation Plan
1. nginx Redirect Rule
Add the following rule to the nginx configuration to rewrite ?plugin=xxx into ?blueprint-url=:
location = / {
if ($arg_plugin) {
return 302 /playground.html?blueprint-url=/play/blueprints/$arg_plugin.json;
}
try_files $uri $uri/ =404;
}
Effect:
https://play.wenpai.net/?plugin=wpslug→ 302 redirect →/playground.html?blueprint-url=/play/blueprints/wpslug.json
2. Declarative Plugin Configuration
Place a blueprint.json file in the root directory of each plugin repository, declaring Playground metadata:
{
"id": "wpslug",
"name": "Wenpai Slug",
"tag": "SEO",
"icon": "link",
"desc": "More user-friendly and aesthetically pleasing permalinks for posts, pages, and media.",
"landingPage": "/wp-admin/options-general.php?page=wpslug",
"pluginPath": "wpslug/wpslug.php",
"blogname": "Wenpai Slug Demo Site"
}
3. Automated Synchronization Script
The sync-plugins.sh script scans all repositories under our organization that contain a blueprint.json file and automatically:
- Downloads the latest release ZIP (falling back to GitHub archive URL if no release asset exists);
- Generates a valid Playground blueprint JSON file using metadata from
blueprint.json; - Updates the
plugins.jsonfile used to render the homepage plugin listing; - Runs weekly via CI, but can also be triggered manually.
4. Automated Deployment
A Forgejo Actions workflow monitors changes to the play/ directory and automatically deploys updates to the production server via rsync.
Full Workflow
To add a new plugin to Playground:
- Add
blueprint.jsonto the root of the plugin’s repository; - Publish a GitHub release (including a ZIP asset);
- Wait for automatic sync (or trigger it manually);
- Visit
https://play.wenpai.net/?plugin=<plugin-id>to preview the plugin instantly.