Changeset 48188
- Timestamp:
- 06/27/2020 10:34:02 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/load.php
r48168 r48188 135 135 * a constant of the same name, or the {@see 'wp_get_environment_type'} filter. 136 136 * 137 * Possible values include 'development', 'stag e', 'production'. If not set,137 * Possible values include 'development', 'staging', 'production'. If not set, 138 138 * the type defaults to 'production'. 139 139 * … … 143 143 */ 144 144 function wp_get_environment_type() { 145 $approved_environments = array( 145 static $current_env = ''; 146 147 if ( $current_env ) { 148 return $current_env; 149 } 150 151 $wp_environments = array( 146 152 'development', 147 'stag e',153 'staging', 148 154 'production', 149 155 ); 150 156 157 // Check if the environment variable has been set, if `getenv` is available on the system. 158 if ( function_exists( 'getenv' ) ) { 159 $has_env = getenv( 'WP_ENVIRONMENT_TYPES' ); 160 if ( false !== $has_env ) { 161 $wp_environments = explode( ',', $has_env ); 162 } 163 } 164 165 // Fetch the environment types from a constant, this overrides the global system variable. 166 if ( defined( 'WP_ENVIRONMENT_TYPES' ) ) { 167 $wp_environments = WP_ENVIRONMENT_TYPES; 168 } 169 151 170 /** 152 * Filters the list of approved environment types.171 * Filters the list of supported environment types. 153 172 * 154 173 * This filter runs before it can be used by plugins. It is designed for non-web runtimes. … … 156 175 * @since 5.5.0 157 176 * 158 * @param string $approved_environments The list of approvedenvironment types. Possible values159 * include 'development', 'stage', 'production'.177 * @param array $wp_environments The list of environment types. Possible values 178 * include 'development', 'staging', 'production'. 160 179 */ 161 $approved_environments = apply_filters( 'wp_approved_environment_types', $approved_environments ); 162 163 $current_env = ''; 164 165 // Check if a environment variable has been set for max flexibility, if `getenv` is available on the system. 180 $wp_environments = apply_filters( 'wp_environment_types', $wp_environments ); 181 182 // Check if the environment variable has been set, if `getenv` is available on the system. 166 183 if ( function_exists( 'getenv' ) ) { 167 184 $has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); … … 186 203 * 187 204 * @param string $current_env The current environment type. Possible values 188 * include 'development', 'stag e', 'production'.205 * include 'development', 'staging', 'production'. 189 206 */ 190 207 $current_env = apply_filters( 'wp_get_environment_type', $current_env ); 191 208 192 209 // Make sure the environment is an allowed one, and not accidentally set to an invalid value. 193 if ( ! in_array( $current_env, $ approved_environments, true ) ) {210 if ( ! in_array( $current_env, $wp_environments, true ) ) { 194 211 $current_env = 'production'; 195 212 } … … 268 285 require ABSPATH . '.maintenance'; 269 286 // If the $upgrading timestamp is older than 10 minutes, consider maintenance over. 270 if ( ( time() - $upgrading ) >= 600) {287 if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) { 271 288 return false; 272 289 }
Note: See TracChangeset
for help on using the changeset viewer.