# wp_get_global_settings()

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

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

## Сигнатура

```php
wp_get_global_settings( array $path = array(), array $context = array() ): mixed
```

## Описание

Возвращает настройки, полученные в результате объединения данных ядра, темы и пользователя.

## Параметры

- `$path` `array` — необязательный, по умолчанию `array()`. Путь к конкретной настройке, которую нужно получить. Необязательный.
  
  Если пусто, будут возвращены все настройки.
- `$context` `array` — необязательный, по умолчанию `array()`. Метаданные о том, откуда извлекать $path. Необязательный.
  
  block_name string Из какого блока извлекать настройки.
  
  Если пусто, будут возвращены настройки для глобального контекста.
  
  origin string Из какого источника брать данные.
  
  Допустимые значения — 'all' (ядро, тема и пользователь) или 'base' (ядро и тема).
  
  Если пусто или значение неизвестно, используется 'all'.

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

`mixed`

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

Файл: `wp-includes/global-styles-and-settings.php:26`

```php
function wp_get_global_settings( $path = array(), $context = array() ) {
	if ( ! empty( $context['block_name'] ) ) {
		$new_path = array( 'blocks', $context['block_name'] );
		foreach ( $path as $subpath ) {
			$new_path[] = $subpath;
		}
		$path = $new_path;
	}

	/*
	 * This is the default value when no origin is provided or when it is 'all'.
	 *
	 * The $origin is used as part of the cache key. Changes here need to account
	 * for clearing the cache appropriately.
	 */
	$origin = 'custom';
	if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) {
		$origin = 'theme';
	}

	/*
	 * By using the 'theme_json' group, this data is marked to be non-persistent across requests.
	 * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php and other places.
	 *
	 * 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:
	 * 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_group = 'theme_json';
	$cache_key   = 'wp_get_global_settings_' . $origin;

	/*
	 * 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' );

	$settings = false;
	if ( $can_use_cached ) {
		$settings = wp_cache_get( $cache_key, $cache_group );
	}

	if ( false === $settings ) {
		$settings = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_settings();
		if ( $can_use_cached ) {
			wp_cache_set( $cache_key, $settings, $cache_group );
		}
	}

	return _wp_array_get( $settings, $path, $settings );
}
```

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

- 5.9.0 — Introduced.

## Связанные

Использует: [`wp_is_development_mode`](https://chugunov.pro/api-wordpress/functions/wp_is_development_mode/), `WP_Theme_JSON_Resolver::get_merged_data`, [`_wp_array_get`](https://chugunov.pro/api-wordpress/functions/_wp_array_get/), [`wp_cache_set`](https://chugunov.pro/api-wordpress/functions/wp_cache_set/), [`wp_cache_get`](https://chugunov.pro/api-wordpress/functions/wp_cache_get/).
Используется в: `WP_Font_Face_Resolver::get_fonts_from_theme_json`, `WP_Duotone::get_all_global_styles_presets`, [`get_block_editor_settings`](https://chugunov.pro/api-wordpress/functions/get_block_editor_settings/).

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