wp_filter_nohtml_kses()
Strips all of the HTML tags in the given content. Receives a slashed string (content). Returns the cleared content.
$data parameter expects a slashed string (content). If you pass a non-slashed string, the function slash special characters and return back the slashed string! See. example.
This function expects slashed data.
Uses: wp_kses()
No Hooks.
Return
String
. Filtered content without any HTML.
Usage
wp_filter_nohtml_kses( $data );
- $data(string) (required)
- Content to strip all HTML from.
Examples
#1 Remove HTML from text
This example shows how to clear text and remove all HTML tags from it. Pay attention to the character slashing:
$data = ' <div> <h2> Текст с кавычками "</h2> <span>Еще текст</span> </div>'; echo wp_filter_nohtml_kses( $data ); // Выведет (переносы строк и табы сохранены): /* Текст с кавычками \" Еще текст */ $data = wp_slash( $data ); echo wp_filter_nohtml_kses( $data ); /* Текст с кавычками \" Еще текст */
Changelog
Since 2.1.0 | Introduced. |
wp_filter_nohtml_kses() wp filter nohtml kses code WP 6.7.1
function wp_filter_nohtml_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), 'strip' ) ); }