Sanitizes a string from user input or from the database.
< characters to entities$strstringrequired
Basic Usage
<?php sanitize_text_field( $str ) ?> 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 );
}
Filters a sanitized text field string.
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/sanitize_text_field