wp_filter_kses() WordPress Function

The wp_filter_kses() function is a WordPress function that strips unsafe or unwanted content from a string. This function is typically used to filter content before it is saved to the database, or displayed to the user.

wp_filter_kses( string $data ) #

Sanitize content with allowed HTML KSES rules.


Description

This function expects slashed data.


Top ↑

Parameters

$data

(string)(Required)Content to filter, expected to be escaped with slashes.


Top ↑

Return

(string) Filtered content.


Top ↑

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’.


Top ↑

Source

File: wp-includes/kses.php

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


Top ↑

Changelog

Changelog
VersionDescription
1.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.