wp_kses_data()
Cleans text, leaving only allowed HTML tags and their attributes. Expects unslashed text.
Which tags are allowed is determined by the current filter that fired at the time of this function call: current_filter(). If no special allowed tags are specified for the current filter, then wp_kses( $string, 'default' ) will be used.
Use wp_filter_kses() when processing the $_POST request parameter (where the data is escaped).
All allowed tags by default are located in the global variable $allowedtags.
Uses: wp_kses()
1 time — 0.000276 sec (fast) | 50000 times — 0.59 sec (very fast) | PHP 7.0.2, WP 4.4.1
No Hooks.
Returns
String. The cleaned string
Usage
wp_kses_data( $data );
- $data(string) (required)
- Text from which unwanted HTML tags should be removed. Expected that the text is not escaped with backslashes (\).
Examples
#1 Demo
$str = '<div id="1st"><strong><i>Foo</i></strong><script>alert("passed");</script></div>'
echo wp_kses_data( $str );
// <strong><i>Foo</i></strong>alert("passed");
Changelog
| Since 2.9.0 | Introduced. |
wp_kses_data() wp kses data code WP 6.8.3
function wp_kses_data( $data ) {
return wp_kses( $data, current_filter() );
}