Make WordPress Core


Ignore:
Timestamp:
08/27/2020 09:44:10 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Bootstrap/Load: Remove the ability to alter the list of environment types in wp_get_environment_type().

The intention of wp_get_environment_type() is to provide a consistent means of identifying the environment type, not of identifying a specific environment.

Actual environments should fit within one of the existing types: local, development, staging, or production. That should cover the types that plugins and themes might be concerned about when toggling functionality.

Props johnbillion, joostdevalk, TimothyBlynJacobs, jeremyfelt, batmoo, claytoncollie, Clorith, markjaquith, garrett-eclipse, GaryJ, elrae.
Merges [48894] and [48895] to the 5.5 branch.
Fixes #50992.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/load.php

    r48857 r48896  
    139139 *
    140140 * @since 5.5.0
    141  * @since 5.5.1 The 'local' type was added.
     141 * @since 5.5.1 Added the 'local' type.
     142 * @since 5.5.1 Removed the ability to alter the list of types.
    142143 *
    143144 * @return string The current environment type.
     
    157158    );
    158159
    159     // Check if the environment variable has been set, if `getenv` is available on the system.
    160     if ( function_exists( 'getenv' ) ) {
    161         $has_env = getenv( 'WP_ENVIRONMENT_TYPES' );
    162         if ( false !== $has_env ) {
    163             $wp_environments = explode( ',', $has_env );
    164         }
    165     }
    166 
    167     // Fetch the environment types from a constant, this overrides the global system variable.
    168     if ( defined( 'WP_ENVIRONMENT_TYPES' ) ) {
    169         $wp_environments = WP_ENVIRONMENT_TYPES;
     160    // Add a note about the deprecated WP_ENVIRONMENT_TYPES constant.
     161    if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) {
     162        if ( function_exists( '__' ) ) {
     163            /* translators: %s: WP_ENVIRONMENT_TYPES */
     164            $message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' );
     165        } else {
     166            $message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' );
     167        }
     168
     169        _deprecated_argument(
     170            'define()',
     171            '5.5.1',
     172            $message
     173        );
    170174    }
    171175
Note: See TracChangeset for help on using the changeset viewer.