# wp_get_environment_type()

URL: https://chugunov.pro/api-wordpress/functions/wp_get_environment_type/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 5.5.0.

## Сигнатура

```php
wp_get_environment_type(): string
```

## Описание

Тип можно задать через глобальную системную переменную WP_ENVIRONMENT_TYPE или одноимённую константу.
Возможные значения: ‘local’, ‘development’, ‘staging’ и ‘production’.
Если значение не задано, по умолчанию используется ‘production’.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/load.php:250`

```php
function wp_get_environment_type() {
	static $current_env = '';

	if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) {
		return $current_env;
	}

	$wp_environments = array(
		'local',
		'development',
		'staging',
		'production',
	);

	// Add a note about the deprecated WP_ENVIRONMENT_TYPES constant.
	if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) {
		if ( function_exists( '__' ) ) {
			/* translators: %s: WP_ENVIRONMENT_TYPES */
			$message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' );
		} else {
			$message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' );
		}

		_deprecated_argument(
			'define()',
			'5.5.1',
			$message
		);
	}

	// Check if the environment variable has been set, if `getenv` is available on the system.
	if ( function_exists( 'getenv' ) ) {
		$has_env = getenv( 'WP_ENVIRONMENT_TYPE' );
		if ( false !== $has_env ) {
			$current_env = $has_env;
		}
	}

	// Fetch the environment from a constant, this overrides the global system variable.
	if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
		$current_env = WP_ENVIRONMENT_TYPE;
	}

	// Make sure the environment is an allowed one, and not accidentally set to an invalid value.
	if ( ! in_array( $current_env, $wp_environments, true ) ) {
		$current_env = 'production';
	}

	return $current_env;
}
```

## История изменений

- 5.5.1 — Removed the ability to alter the list of types.
- 5.5.0 — Introduced.

## Связанные

Использует: [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_deprecated_argument`](https://chugunov.pro/api-wordpress/functions/_deprecated_argument/).
Используется в: `WP_Debug_Data::get_wp_core`, [`wp_register_core_abilities`](https://chugunov.pro/api-wordpress/functions/wp_register_core_abilities/), [`wp_is_authorize_application_redirect_url_valid`](https://chugunov.pro/api-wordpress/functions/wp_is_authorize_application_redirect_url_valid/), [`wp_is_application_passwords_supported`](https://chugunov.pro/api-wordpress/functions/wp_is_application_passwords_supported/), `WP_Site_Health::is_development_environment`, `WP_Site_Health::get_tests`, [`wp_initial_constants`](https://chugunov.pro/api-wordpress/functions/wp_initial_constants/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_get_environment_type/
