Update: I’ve added this feature request as a WordPress Meta Trac ticket. You can follow along here: https://meta.trac.wordpress.org/ticket/7307
I know what you’re thinking: “we just went through this whole thing. It didn’t end well.” To which I might argue that it was a failed experiment on the way to something really interesting.
The problem was not in the idea, but in the execution.
Here’s how I would do it…
Opt In vs Opt Out (aka, having a choice)
The idea of having a live preview of developers’ plugins using the WordPress Playground was spot on. The problem was that it wasn’t completely thought through. Many plugins in the WordPress.org repository rely on various things that WordPress Playground doesn’t have:
- Dependencies on other plugins, like WooCommerce or a page builder
- Connectivity to external APIs
- Specific and detailed settings
- Database rows to import/export
In fact, one of the two plugins that I’ve developed requires Elementor, which itself doesn’t even work on the Playground.
But what about the ones that do work perfectly on WordPress Playground? Isn’t that a great, zero-lift way for folks to try out those plugins? Absolutely! But it needs to be something developers can opt into!
Some folks have offered that this could be in the plugin’s README file, but because of the way that README files are parsed anyway, I’d recommend we build this into the plugin headers themselves. You know, the place in the main plugin PHP file where we set the plugin name, description, version, text domain, etc. Maybe it could look something like this:
/* Plugin Name: Demo Plugin Plugin URI: https://mburnette.com/demo-plugin Description: Not a real plugin Version: 1.0 Author: Marcus Burnette Author URI: https://mburnette.com License: GPL2 Playground: true */
It’s that last line –
Playground: true – that’s the magic sauce. There’s already a precedence for a field like this with the Network field, which should be set to “true” if desired, and omitted when not needed. The same would apply here!
With this Playground field set to “true”, the Live Preview button (as it was launched) would be present for that plugin. This allows the author to have control over its existence.
An External Option
What if we take that a step further and give developers the ability to provide an external demo site URL? I know lots of folks use InstaWP (highly recommend!) to set up demo site templates for folks to try out. What if developers could share that link the same way?
/* Plugin Name: Demo Plugin Plugin URI: https://mburnette.com/demo-plugin Description: Not a real plugin Version: 1.0 Author: Marcus Burnette Author URI: https://mburnette.com License: GPL2 Demo URI: https://app.instawp.io/launch?t=classroom-library-plugin-demo&d=v2 */
Ideally, this would add a button to the plugin page that says something like “Launch Demo” instead of “Live Preview”, giving folks context for what will happen when they click the button.
There’s always the chance, of course, that a developer employs both – intentionally or unintentionally. In this case, I think the external demo takes priority and the “Live Preview” button is not shown.
What do you think? Is this a good idea or not?