-
Notifications
You must be signed in to change notification settings - Fork 368
Description
Recently, there was an issue where the Create Block Theme plugin was throwing an error due to limited networking support in Playground.
Maybe we could disable Google fonts if the plugin is on a Playground instance for now.
If the Playground could define a PHP constant, like WORDPRESS_PLAYGROUND, then plugins/themes could detect it and modify their behavior accordingly.
Another possible use case: when running wp-now on the server, a locally installed wp-cli could detect and interact with it somehow.
we may just need to tell WP-CLI where to find the WordPress files, SQLite database, and project files. At the moment however, the knowledge of this only exists in the virtualized filesystem.
If wp-now could define a PHP constant, like WP_NOW, it could help wp-cli (and maybe other tools) to implement a deeper integration. How exactly the communication between them would work is a bigger question. 🙃
@adamziel's recommendation:
I recommend not detecting Playground because it will break your plugin in many contexts.
You could, however, explicitly create a constant via a Blueprint and then check for that:
This way your plugin will only load the demo data when that's expected.
I understand why blanket Playground detection is tempting for setting up demo content. Playground, however, is more than just the app on https://playground.wordpress.net/. Here's a few contexts where loading the demo content would be harmful instead of useful:
- The WordPress Playground plugin adds a "Preview now" button to the plugin directory. It imports the entire sites and installs the plugin on top of that.
- wp-now is a local development environment for WordPress. Your plugin may be installed there.
- Ditto for WordPress Playground for VS Code.
If installing the plugin does something unexpected to the site content in either of these tools, the user will likely be surprised and assume the plugin is broken.