I’ve somewhat intentionally given this little story about a new WordPress 5.5 feature a silly title. But as this story from Sarah Gooding over at the Tavern illustrates, people are already putting the new WordPress function
wp_get_environment_type function to good use. And this story was doubly-interesting to me because I for one had no earthly idea that this new function existed. 😳
The core idea of the
wp_get_environment_type function is pretty simple: let developers of plugins and themes disable dangerous features (say, sending notification emails) when they know that they’re on the “staging,” “development” version of a site. More than once in my life I’ve been pretty confused by why things were happening I didn’t expect, only to later it was because the staging or dev site was doing those weird things.
As you might guess, WordPress has to be told what your environment is. As you might also guess, you do that via a constant definition—
wp-config.php. More details of that whole setup are in the make.wordpress.org announcement post for the feature.
What Sarah’s story covers is how that value is used in a new plugin by Roy Tanck to give you a little useful banner in the top-right on your admin bar. More than once I’ve absolutely done something on the Production site thinking it was a local development site. And this plugin would save me that heart-ache with a big blaring red “Production” label up there. If I were maintaining a “stock WordPress install” with all my favorite plugins, I’d surely add this one to the list.