Title: wp_filter_kses
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_filter_kses( string $data ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#wp--skip-link--target)

Sanitize content with allowed HTML KSES rules.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#description)󠁿

This function expects slashed data.

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

 `$data`stringrequired

Content to filter, expected to be escaped with slashes.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_filter_kses/?output_format=md#return)󠁿

 string Filtered content.

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

`wp_filter_kses` should generally be preferred over `wp_kses_data` because `wp_magic_quotes`
escapes `$_GET`, `$_POST`, `$_COOKIE`, `$_SERVER`, and `$_REQUEST` fairly early 
in the hook system, shortly after ‘plugins_loaded’ but earlier then ‘init’ or ‘wp_loaded’.

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

    ```php
    function wp_filter_kses( $data ) {
    	return addslashes( wp_kses( stripslashes( $data ), current_filter() ) );
    }
    ```

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

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

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

Filters text content and strips out disallowed HTML.

  | 
| [current_filter()](https://developer.wordpress.org/reference/functions/current_filter/)`wp-includes/plugin.php` |

Retrieves the name of the current filter hook.

  |

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

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

## User Contributed Notes

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