# wp_get_global_styles_custom_css()

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

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

> Устаревший элемент. Помечен устаревшим с версии 6.7.0.

## Сигнатура

```php
wp_get_global_styles_custom_css(): string
```

## Описание

Получает пользовательский CSS глобальных стилей из theme.json.

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

`string`

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

Файл: `wp-includes/deprecated.php:6318`

```php
function wp_get_global_styles_custom_css() {
	_deprecated_function( __FUNCTION__, '6.7.0', 'wp_get_global_stylesheet' );
	if ( ! wp_theme_has_theme_json() ) {
		return '';
	}
	/*
	 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
	 * developer's workflow.
	 */
	$can_use_cached = ! wp_is_development_mode( 'theme' );

	/*
	 * By using the 'theme_json' group, this data is marked to be non-persistent across requests.
	 * @see `wp_cache_add_non_persistent_groups()`.
	 *
	 * The rationale for this is to make sure derived data from theme.json
	 * is always fresh from the potential modifications done via hooks
	 * that can use dynamic data (modify the stylesheet depending on some option,
	 * settings depending on user permissions, etc.).
	 * See some of the existing hooks to modify theme.json behavior:
	 * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/
	 *
	 * A different alternative considered was to invalidate the cache upon certain
	 * events such as options add/update/delete, user meta, etc.
	 * It was judged not enough, hence this approach.
	 * @see https://github.com/WordPress/gutenberg/pull/45372
	 */
	$cache_key   = 'wp_get_global_styles_custom_css';
	$cache_group = 'theme_json';
	if ( $can_use_cached ) {
		$cached = wp_cache_get( $cache_key, $cache_group );
		if ( $cached ) {
			return $cached;
		}
	}

	$tree       = WP_Theme_JSON_Resolver::get_merged_data();
	$stylesheet = $tree->get_custom_css();

	if ( $can_use_cached ) {
		wp_cache_set( $cache_key, $stylesheet, $cache_group );
	}

	return $stylesheet;
}
```

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

- 6.7.0 — Deprecated. Use 'wp_get_global_stylesheet' instead for top-level custom CSS, or 'WP_Theme_JSON::get_styles_for_block' for block-level custom CSS.
- 6.2.0 — Introduced.

## Связанные

Использует: [`wp_is_development_mode`](https://chugunov.pro/api-wordpress/functions/wp_is_development_mode/), [`wp_theme_has_theme_json`](https://chugunov.pro/api-wordpress/functions/wp_theme_has_theme_json/), `WP_Theme_JSON_Resolver::get_merged_data`, [`wp_cache_set`](https://chugunov.pro/api-wordpress/functions/wp_cache_set/), [`wp_cache_get`](https://chugunov.pro/api-wordpress/functions/wp_cache_get/), [`_deprecated_function`](https://chugunov.pro/api-wordpress/functions/_deprecated_function/).
Используется в: [`wp_enqueue_global_styles_custom_css`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_global_styles_custom_css/).

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