sanitize_text_field() – Sanitizes a string from user input or from the database.
You appear to be a bot. Output may be restricted
Description
Sanitizes a string from user input or from the database.
- Checks for invalid UTF-8,
- Converts single
<
characters to entities - Strips all tags
- Removes line breaks, tabs, and extra whitespace
- Strips octets
Usage
$string = sanitize_text_field( $str );
Parameters
- $str
- ( string ) required – String to sanitize.
Returns
string Sanitized string.
Source
File name: wordpress/wp-includes/formatting.php
Lines:
1 to 13 of 13
function sanitize_text_field( $str ) { $filtered = _sanitize_text_fields( $str, false ); /** * Filters a sanitized text field string. * * @since 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 ); }