[wp-trac] [WordPress Trac] #60781: Expand or modify wp_get_environment_type function to allow more environment types

WordPress Trac noreply at wordpress.org
Fri Mar 15 09:49:27 UTC 2024


#60781: Expand or modify wp_get_environment_type function to allow more environment
types
----------------------------+--------------------------------------
 Reporter:  dingo_d         |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Bootstrap/Load  |    Version:
 Severity:  normal          |   Keywords:  2nd-opinion dev-feedback
  Focuses:                  |
----------------------------+--------------------------------------
 Currently the
 [https://developer.wordpress.org/reference/functions/wp_get_environment_type/
 wp_get_environment_type()] function only allows 4 environment types:

 {{{#!php
 $wp_environments = array(
         'local',
         'development',
         'staging',
         'production',
 );
 }}}

 But there are projects that have multiple environment types (CI, CD, pre-
 production, UAT, etc.).

 So if you define the `WP_ENVIRONMENT_TYPE` to anything outside of these 4
 environments, you'll end up with serving the `production` environment.

 A trivial example would be where you'd like to change the color of your
 admin UI based on environments. I mean, sure you can use something like
 {{{defined('WP_ENVIRONMENT_TYPE') ? WP_ENVIRONMENT_TYPE : 'production'}}},
 but what's the point of the `wp_get_environment_type` function then?

 One alternative is to expand the `$wp_environments` variable with some of
 the industry most-used terms. Or just remove this check, and just return
 the value of `defined('WP_ENVIRONMENT_TYPE') ? WP_ENVIRONMENT_TYPE :
 'production'` check.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60781>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list