wp_get_speculative_loading_override()WP 7.1.0

Returns the value of a speculative loading override, as supplied by a constant or an environment variable.

The constant takes precedence over the environment variable, consistent with wp_get_environment_type().

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

string|null. The override value, or null if neither is set.

Использование

wp_get_speculative_loading_override( $name ): ?string;
$name(строка) (обязательный)
Name of the constant and environment variable to look up.

Список изменений

С версии 7.1.0 Введена.

Код wp_get_speculative_loading_override() WP 7.1.2

function wp_get_speculative_loading_override( string $name ): ?string {
	$value = null;

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

	// Fetch the value from a constant, which overrides the environment variable.
	if ( defined( $name ) ) {
		$has_constant = constant( $name );
		if ( is_string( $has_constant ) ) {
			$value = $has_constant;
		}
	}

	return $value;
}