WordPress at a glance

wp_filter_nohtml_kses() WP 2.1.0

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.

Works based on: 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 );

/*

	 Текст с кавычками \"
	Еще текст

*/

Code of wp filter nohtml kses: wp-includes/kses.php WP 5.2.2

<?php
function wp_filter_nohtml_kses( $data ) {
	return addslashes( wp_kses( stripslashes( $data ), 'strip' ) );
}

Related Functions

From tag: kses (html cleanup sanitize)

More from category: Sanitizing, Escaping

No comments
    Hello, !     Log In . Register