wp_filter_kses( string $data ): string

Sanitize content with allowed HTML KSES rules.

Description

This function expects slashed data.

Parameters

$datastringrequired
Content to filter, expected to be escaped with slashes.

Return

string Filtered content.

More Information

wp_filter_kses should generally be preferred over wp_kses_data because wp_magic_quotes escapes $_GET, $_POST, $_COOKIE, $_SERVER, and $_REQUEST fairly early in the hook system, shortly after ‘plugins_loaded’ but earlier then ‘init’ or ‘wp_loaded’.

Source

function wp_filter_kses( $data ) {
	return addslashes( wp_kses( stripslashes( $data ), current_filter() ) );
}

Changelog

VersionDescription
1.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.