Title: pre_kses
Published: April 25, 2014
Last modified: August 20, 2026

---

# apply_filters( ‘pre_kses’, string $content, array[]|string $allowed_html, string[] $allowed_protocols )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#changelog)

Filters content to be run through KSES.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#parameters)󠁿

 `$content`string

Content to filter through KSES.

`$allowed_html`array[]|string

An array of allowed HTML elements and attributes, or a context name such as `'post'`.
See [wp_kses_allowed_html()](https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/)
for the list of accepted context names.

`$allowed_protocols`string[]

Array of allowed URL protocols.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#more-information)󠁿

KSES is a recursive acronym which stands for “KSES Strips Evil Scripts”.

The filter is used to change the types of HTML elements/attributes or context names
are allowed in WordPress content, then strips any HTML elements/attributes that 
are registered as not allowed.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#source)󠁿

    ```php
    return apply_filters( 'pre_kses', $content, $allowed_html, $allowed_protocols );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/kses.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/kses.php#L1245)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/kses.php#L1245-L1245)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_kses_hook()](https://developer.wordpress.org/reference/functions/wp_kses_hook/)`wp-includes/kses.php` |

You add any KSES hooks here.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/pre_kses/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.3.0](https://developer.wordpress.org/reference/since/2.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpre_kses%2F)
before being able to contribute a note or feedback.