[wp-trac] [WordPress Trac] #51064: Consider adding "local" as environment on WP_ENVIRONMENT_TYPE

WordPress Trac noreply at wordpress.org
Sat Aug 22 12:37:26 UTC 2020


#51064: Consider adding "local" as environment on WP_ENVIRONMENT_TYPE
----------------------------+---------------------
 Reporter:  claytoncollie   |       Owner:  (none)
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  5.5.1
Component:  Bootstrap/Load  |     Version:  5.5
 Severity:  normal          |  Resolution:
 Keywords:  2nd-opinion     |     Focuses:
----------------------------+---------------------

Comment (by claytoncollie):

 @khag7  @knutsp

 If we add `local`, plugin and theme developers could potentially use the
 following:

 {{{
 switch( wp_get_environment_type() ) {
     case 'local':
         // do something on local.
         break;
     case 'development':
         // do something on development.
         break;
     case 'staging':
         // do something on staging.
         break;
     case 'production':
         // do something on production.
         break;
     default:
         // do something when not defined, typically the same as
 production.
 }
 }}}

 And if we do not add `local` but instead rely on `WP_LOCAL_DEV`, an
 alternative could be

 {{{
 $environment_type = wp_get_environment_type();

 if ( defined( 'WP_LOCAL_DEV' ) && WP_LOCAL_DEV ) {
     // do something on local.
 } elseif ( 'development' === $environment_type ) {
     // do something on development.
 } elseif ( 'staging' === $environment_type ) {
     // do something on staging.
 } elseif ( 'production' === $environment_type ) {
     // do something on production.
 } else {
     // do something when not defined, typically the same as production.
 }
 }}}

 Does that sound about right?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51064#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list