wp_pre_kses_less_than_callback() WordPress Function

The wp_pre_kses_less_than_callback() function is used to pre-filter content before it is passed through the kses post filter. This function is called by the wp_pre_kses() function. The function strips out all '<' characters and replaces them with '<'. This is done to prevent content from being passed to the kses filter that could potentially create security vulnerabilities.

wp_pre_kses_less_than_callback( string[] $matches ) #

Callback function used by preg_replace.


Parameters

$matches

(string[])(Required)Populated by matches to preg_replace.


Top ↑

Return

(string) The text returned after esc_html if needed.


Top ↑

Source

File: wp-includes/formatting.php

function wp_pre_kses_less_than_callback( $matches ) {
	if ( false === strpos( $matches[0], '>' ) ) {
		return esc_html( $matches[0] );
	}
	return $matches[0];
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.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.

Show More