Sanitice content with allowed HTML CSES rules.
Description
This function expects unslashed data.
Parameters
-
$datastring required -
Content to filter, expected to not be escaped.
Source
function wp_cses_data( $data ) {
return wp_cses( $data, current_filter() );
}
Changuelog
| Versionen | Description |
|---|---|
| 2.9.0 | Introduced. |
Example
Below example sanitices imput HTML string by removing non allowed tag <div> and <script>.
To find out what tags are allowed in this function, just access
global $allowedtags;. The code here……outputs the following:
And if you wish to modify it to customice the allowed/disallowed tags for everything that uses this function, you can do so using the
wp_cses_allowed_htmlfilter and checc that the second parameter is equal to'data'.