WordPress at a glance

sanitize_textarea_field() WP 1.0

Sanitizes a multiline string from user input or from the database.

The function is like sanitize_text_field(), but preserves new lines (\n) and other whitespace, which are legitimate input in textarea elements.

Works based on: _sanitize_text_fields()
1 time — 0.000098 sec (very fast) | 50000 times — 1.17 sec (fast) | PHP 7.1.2, WP 4.7.3
Hooks from the function

String. Sanitized string.


sanitize_textarea_field( $str );
$str(string) (required)
String to sanitize.


  • See: sanitize_text_field()


Since 4.7.0 Introduced.

Code of sanitize_textarea_field() WP 5.7.1

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 );

From tag: sanitize_

More from category: Sanitizing, Escaping

No comments
    Log In