WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp kses data

Description

Sanitize content with allowed HTML Kses rules.

Usage

<?php wp_kses_data$data ); ?>

Parameters

$data
(string) (required) Content to filter, expected to not be escaped
Default: None

Return Values

(string) 
Filtered content

Examples

Below example sanitizes input HTML string by removing non allowed tag <div> and <script>.

<?php
$s = '<div id="1st"><strong><i>Foo</i></strong><script>alert("Bar");</script></div>';
$x = wp_kses_data($s);
// Now, $x is <strong><i>Foo</i></strong>alert("Bar");
?>

Change Log

Since: 2.9

Source File

wp_kses_data() is located in wp-includes/kses.php