On this page
sanitize_textarea_field( string $str ): string
Sanitizes a multiline string from user input or from the database.
Description
The function is like sanitize_text_field() , but preserves new lines (\n) and other whitespace, which are legitimate input in textarea elements.
See also
Parameters
$strstring Required-
String to sanitize.
Return
string Sanitized string.
Source
File: wp-includes/formatting.php. View all references
function sanitize_textarea_field( $str ) {
$filtered = _sanitize_text_fields( $str, true );
/**
* Filters a sanitized textarea field string.
*
* @since 4.7.0
*
* @param string $filtered The sanitized string.
* @param string $str The string prior to being sanitized.
*/
return apply_filters( 'sanitize_textarea_field', $filtered, $str );
}
Hooks
- apply_filters( 'sanitize_textarea_field',
string $filtered ,string $str ) -
Filters a sanitized textarea field string.
Related
Uses
| Uses | Description |
|---|---|
| _sanitize_text_fields() wp-includes/formatting.php | Internal helper function to sanitize a string from user input or from the database. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| rest_sanitize_value_from_schema() wp-includes/rest-api.php | Sanitize a value based on a schema. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/sanitize_textarea_field