wpcf7_strip_whitespaces()CF7 1.0

Strips surrounding whitespaces.

Хуков нет.

Возвращает

Строку|Массив. Output text.

Использование

wpcf7_strip_whitespaces( $input, $side );
$input(строка|массив) (обязательный)
Input text.
$side(строка)
The side from which whitespaces are stripped. 'start', 'end', or 'both' (default).
По умолчанию: 'both'

Код wpcf7_strip_whitespaces() CF7 6.1.4

function wpcf7_strip_whitespaces( $input, $side = 'both' ) {
	if ( is_array( $input ) ) {
		return array_map(
			static function ( $i ) use ( $side ) {
				return wpcf7_strip_whitespaces( $i, $side );
			},
			$input
		);
	}

	// https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html
	$whitespaces = wpcf7_get_unicode_whitespaces() . '\x{FEFF}';

	if ( 'end' !== $side ) {
		// Strip leading whitespaces
		$input = preg_replace(
			sprintf( '/^[%s]+/u', $whitespaces ),
			'',
			$input
		);
	}

	if ( 'start' !== $side ) {
		// Strip trailing whitespaces
		$input = preg_replace(
			sprintf( '/[%s]+$/u', $whitespaces ),
			'',
			$input
		);
	}

	return $input;
}