# wp_kses()

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

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

## Сигнатура

```php
wp_kses( string $content, array[]|string $allowed_html, string[] $allowed_protocols = array() ): string
```

## Описание

Гарантирует, что в переданной строке останутся только допустимые имена HTML-элементов, имена атрибутов, значения атрибутов и HTML-сущности.
Ожидает данные без экранирующих слэшей.
См. alsowp_kses_post(): для фильтрации именно содержимого и полей записи.

wp_allowed_protocols(): для протоколов, разрешённых по умолчанию в URL-адресах ссылок.

## Параметры

- `$content` `string` — обязательный. Текстовое содержимое для фильтрации.
- `$allowed_html` `array[]|string` — обязательный. Массив допустимых HTML-элементов и атрибутов либо имя контекста, например 'post'. Список допустимых имён контекстов см. в wp_kses_allowed_html().
- `$allowed_protocols` `string[]` — необязательный, по умолчанию `array()`. Массив разрешённых URL-протоколов.
  
  По умолчанию — результат работы wp_allowed_protocols().

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

`string`

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

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

```php
function wp_kses( $content, $allowed_html, $allowed_protocols = array() ) {
	if ( empty( $allowed_protocols ) ) {
		$allowed_protocols = wp_allowed_protocols();
	}

	$content = wp_kses_no_null( $content, array( 'slash_zero' => 'keep' ) );
	$content = wp_kses_normalize_entities( $content );
	$content = wp_kses_hook( $content, $allowed_html, $allowed_protocols );

	return wp_kses_split( $content, $allowed_html, $allowed_protocols );
}
```

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

- 1.0.0 — Introduced.

## Связанные

Использует: [`wp_kses_no_null`](https://chugunov.pro/api-wordpress/functions/wp_kses_no_null/), [`wp_kses_normalize_entities`](https://chugunov.pro/api-wordpress/functions/wp_kses_normalize_entities/), [`wp_kses_hook`](https://chugunov.pro/api-wordpress/functions/wp_kses_hook/), [`wp_kses_split`](https://chugunov.pro/api-wordpress/functions/wp_kses_split/), [`wp_allowed_protocols`](https://chugunov.pro/api-wordpress/functions/wp_allowed_protocols/).
Используется в: `WP_Icons_Registry::sanitize_icon_content`, `WP_Debug_Data::get_wp_active_theme`, `WP_Debug_Data::get_wp_parent_theme`, `WP_Debug_Data::get_wp_themes_inactive`, [`wp_trigger_error`](https://chugunov.pro/api-wordpress/functions/wp_trigger_error/), `WP_Site_Health::get_test_persistent_object_cache`, `Walker_Comment::filter_comment_text`, [`filter_block_kses_value`](https://chugunov.pro/api-wordpress/functions/filter_block_kses_value/), `WP_Site_Health::get_test_sql_server`, [`wp_privacy_generate_personal_data_export_group_html`](https://chugunov.pro/api-wordpress/functions/wp_privacy_generate_personal_data_export_group_html/), `WP_Customize_Manager::handle_load_themes_request`, [`wp_filter_oembed_result`](https://chugunov.pro/api-wordpress/functions/wp_filter_oembed_result/), `Automatic_Upgrader_Skin::feedback`, `WP_Theme_Install_List_Table::install_theme_info`, `WP_Theme_Install_List_Table::single_row`, [`wp_plugin_update_row`](https://chugunov.pro/api-wordpress/functions/wp_plugin_update_row/), [`install_plugin_information`](https://chugunov.pro/api-wordpress/functions/install_plugin_information/), [`_get_plugin_data_markup_translate`](https://chugunov.pro/api-wordpress/functions/_get_plugin_data_markup_translate/), `WP_Plugin_Install_List_Table::display_rows`, [`wp_ajax_query_themes`](https://chugunov.pro/api-wordpress/functions/wp_ajax_query_themes/), [`themes_api`](https://chugunov.pro/api-wordpress/functions/themes_api/), [`wp_kses_data`](https://chugunov.pro/api-wordpress/functions/wp_kses_data/), [`wp_filter_post_kses`](https://chugunov.pro/api-wordpress/functions/wp_filter_post_kses/), [`wp_kses_post`](https://chugunov.pro/api-wordpress/functions/wp_kses_post/), [`wp_filter_nohtml_kses`](https://chugunov.pro/api-wordpress/functions/wp_filter_nohtml_kses/), [`wp_filter_kses`](https://chugunov.pro/api-wordpress/functions/wp_filter_kses/), `WP_Theme::sanitize_header`, [`img_caption_shortcode`](https://chugunov.pro/api-wordpress/functions/img_caption_shortcode/), [`wp_sidebar_description`](https://chugunov.pro/api-wordpress/functions/wp_sidebar_description/).

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