sanitize_text_field( string $str )
Sanitizes a string from user input or from the database.
Description
- Checks for invalid UTF-8,
- Converts single
<
characters to entities - Strips all tags
- Removes line breaks, tabs, and extra whitespace
- Strips percent-encoded characters
See also
Parameters
- $str
-
(Required) String to sanitize.
Return
(string) Sanitized string.
Source
File: wp-includes/formatting.php
function sanitize_text_field( $str ) {
$filtered = _sanitize_text_fields( $str, false );
/**
* Filters a sanitized text field string.
*
* @since WP-2.9.0
*
* @param string $filtered The sanitized string.
* @param string $str The string prior to being sanitized.
*/
return apply_filters( 'sanitize_text_field', $filtered, $str );
}
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |