WordPress Playground began as an experiment to see what a self-hosted WordPress experience might look like without the requirement of having to actually install WordPress. A year later, the experiment has evolved into a full-fledged project that not only abstracts installation but opens up WordPress to a slew of new opportunities. Ganesh Dahal demonstrates how WordPress Playground works and gets deep into how it might be used.
Many things have changed in WordPress over the years, but installation has largely remained the same: download Wo
This is an overly simplistic example that demonstrates how the JavaScript API is embedded in a page in an iframe
.
The Playground docs provide a better example of how PHP is used within
JavaScript to do things, like execute a file pointed at a specific path:
Adam Zieliński and Thomas Nattestad offer a nicely commented example with multiple tasks in the article they published over at web.dev:
Once again, the scope and breadth of using the JavaScript API for advanced configurations is yet another topic that might warrant its own article.
Wrapping Up #
WordPress Playground is an excellent new platform that’s an ideal testing environment for WordPress themes, plugins… or even WordPress itself. Despite the fact that it is still in its early days, Playground is already capable of some pretty incredible stuff that makes WordPress more portable than ever.
We looked at lots of ways that Playground accomplishes this. Just want to check out a new theme? Use the playground.wordpress.net
URL configured with parameters supported by the Query API, or grab the
Chrome extension. Need to do a quick test of your theme in a different
PHP environment? Use the wp-now
package to spin up a test site locally. Want to let others demo a plugin you made? Embed Playground in an iframe
on your site.
WordPress Playground is an evolving space, so keep your eye on it. You can participate in the discussion and request a feature through a pull request or report an issue that you encounter in your testing. In the meantime, you may want to be aware of what the WordPress Playground team has identified as known limitations of the service:
- No access to plugins and theme directories in the browser.
The theme and plugin directories are not accessible due to the fact that Playgrounds are not connected to the internet, but are virtual environments. - Instances are destroyed on a browser refresh.
Because WordPress Playground uses a browser-based temporary database, all changes and uploads are lost after a browser refresh. If you want to preserve your changes, though, use the export feature to download a zipped archive of the instance. Meanwhile, this is something the team is working on. - iFrame issues with anchor links.
Clicking a link in a Playground instance that is embedded on a page in aniframe
may trigger the main page to refresh, causing the instance to reset. - iFrame rendering issues.
There are reports where setting theiframe
’ssrc
attribute to a blobbed URL instead of an HTTP URL breaks links to assets, including CSS and images.
How will you use WordPress Playground? WordPress Playground creator Adam Zieliński recently shipped a service that uses Playground to preview pull requests in GitHub. We all know that WordPress has never put a strong emphasis on developer experience (DX) the same way other technical stacks do, like static site generators and headless configurations. But this is exactly the sort of way that I imagine Playground improving DX to make developing for WordPress easier and, yes, fun.
References & Resources #
- “InstaWP Review: Create WordPress Sandbox Sites the Easy Way,” Colin Newcomer (WP Mayor)
- “TasteWP Review: Free WordPress Hosting to Test Plugins & Themes,” Xaif (WebVerge)
- WordPress Playground Resources (WordPress Developer Resources)
- WordPress Playground for VS Code (Visual Studio Marketplace)
- “Exploring the Future of Web Development with WebAssembly and PHP,” Angel M De Miguel (WordPress Developer Blog)
- “Build In-browser WordPress Experiences with WordPress Playground and WebAssembly,” Adam Zieliński and Thomas Nattestad (web.dev)
- “WordPress Playground Lets You Run WordPress Entirely in Your Browser,” Romain Dillet (TechCrunch)
- “An Introduction to WordPress Playground,” Tom Rankin (WPShout)
- “Preview WordPress Core Pull Requests with Playground,” Sarah Gooding (WP Tavern)
No comments:
Post a Comment