_sanitize_text_fields

函数


_sanitize_text_fields ( $str, $keep_newlines = false )
Access
Private
参数
  • (string)
    $str
    String to sanitize.
    Required:
  • (bool)
    $keep_newlines
    Optional. Whether to keep newlines. Default: false.
    Required:
    Default: false
返回值
  • (string) Sanitized string.
定义位置
  • wp-includes/formatting.php
    , line 5475
引入
4.7.0
弃用

Internal helper function to sanitize a string from user input or from the database.

function _sanitize_text_fields( $str, $keep_newlines = false ) {
	if ( is_object( $str ) || is_array( $str ) ) {
		return '';
	}

	$str = (string) $str;

	$filtered = wp_check_invalid_utf8( $str );

	if ( strpos( $filtered, '