# wp_filter_global_styles_post()

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

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

## Сигнатура

```php
wp_filter_global_styles_post( string $data ): string
```

## Описание

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

## Параметры

- `$data` `string` — обязательный. Содержимое записи для фильтрации.

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

`string`

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

Файл: `wp-includes/kses.php:2380`

```php
function wp_filter_global_styles_post( $data ) {
	$decoded_data        = json_decode( wp_unslash( $data ), true );
	$json_decoding_error = json_last_error();
	if (
		JSON_ERROR_NONE === $json_decoding_error &&
		is_array( $decoded_data ) &&
		isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) &&
		$decoded_data['isGlobalStylesUserThemeJSON']
	) {
		unset( $decoded_data['isGlobalStylesUserThemeJSON'] );

		$data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data, 'custom' );

		$data_to_encode['isGlobalStylesUserThemeJSON'] = true;
		/**
		 * JSON encode the data stored in post content.
		 * Escape characters that are likely to be mangled by HTML filters: "<>&".
		 *
		 * This matches the escaping in WP_REST_Global_Styles_Controller::prepare_item_for_database().
		 */
		return wp_slash( wp_json_encode( $data_to_encode, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) );
	}
	return $data;
}
```

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

- 5.9.0 — Introduced.

## Связанные

Использует: `WP_Theme_JSON::remove_insecure_properties`, [`wp_json_encode`](https://chugunov.pro/api-wordpress/functions/wp_json_encode/), [`wp_unslash`](https://chugunov.pro/api-wordpress/functions/wp_unslash/), [`wp_slash`](https://chugunov.pro/api-wordpress/functions/wp_slash/).

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