# wp_kses_allowed_html()

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

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

## Сигнатура

```php
wp_kses_allowed_html( string|array $context = '' ): array
```

## Описание

Возвращает массив допустимых HTML-тегов и атрибутов для заданного контекста.

## Параметры

- `$context` `string|array` — необязательный, по умолчанию `''`. Контекст, для которого нужно получить теги. Допустимые значения: 'post', 'strip', 'data', 'entities', имя фильтра поля (например, 'pre_user_description') либо массив допустимых HTML-элементов и атрибутов.

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

`array`

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

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

```php
function wp_kses_allowed_html( $context = '' ) {
	global $allowedposttags, $allowedtags, $allowedentitynames;

	if ( is_array( $context ) ) {
		// When `$context` is an array it's actually an array of allowed HTML elements and attributes.
		$html    = $context;
		$context = 'explicit';

		/**
		 * Filters the HTML tags that are allowed for a given context.
		 *
		 * HTML tags and attribute names are case-insensitive in HTML but must be
		 * added to the KSES allow list in lowercase. An item added to the allow list
		 * in upper or mixed case will not recognized as permitted by KSES.
		 *
		 * @since 3.5.0
		 *
		 * @param array[] $html    Allowed HTML tags.
		 * @param string  $context Context name.
		 */
		return apply_filters( 'wp_kses_allowed_html', $html, $context );
	}

	switch ( $context ) {
		case 'post':
			/** This filter is documented in wp-includes/kses.php */
			$tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );

			// 5.0.1 removed the `<form>` tag, allow it if a filter is allowing it's sub-elements `<input>` or `<select>`.
			if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
				$tags = $allowedposttags;

				$tags['form'] = array(
					'action'         => true,
					'accept'         => true,
					'accept-charset' => true,
					'enctype'        => true,
					'method'         => true,
					'name'           => true,
					'target'         => true,
				);

				/** This filter is documented in wp-includes/kses.php */
				$tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
			}

			return $tags;

		case 'user_description':
		case 'pre_term_description':
		case 'pre_user_description':
			$tags                = $allowedtags;
			$tags['a']['rel']    = true;
			$tags['a']['target'] = true;
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $tags, $context );

		case 'strip':
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', array(), $context );

		case 'entities':
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context );

		case 'data':
		default:
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context );
	}
}
```

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

- 5.0.1 — form removed as allowable HTML tag.
- 3.5.0 — Introduced.

## Связанные

Использует: [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`filter_block_core_template_part_attributes`](https://chugunov.pro/api-wordpress/functions/filter_block_core_template_part_attributes/), [`wp_get_code_editor_settings`](https://chugunov.pro/api-wordpress/functions/wp_get_code_editor_settings/), `WP_Widget_Custom_HTML::render_control_template_scripts`, [`wp_kses_one_attr`](https://chugunov.pro/api-wordpress/functions/wp_kses_one_attr/), [`wp_kses_attr`](https://chugunov.pro/api-wordpress/functions/wp_kses_attr/), [`gallery_shortcode`](https://chugunov.pro/api-wordpress/functions/gallery_shortcode/).

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