WPCF7_HTMLFormatter::pre_format()publicCF7 1.0

Normalizes content in each chunk. This may change the type and position of the chunk.

Метод класса: WPCF7_HTMLFormatter{}

Хуков нет.

Возвращает

iterable. Normalized chunks.

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

$WPCF7_HTMLFormatter = new WPCF7_HTMLFormatter();
$WPCF7_HTMLFormatter->pre_format( $chunks );
$chunks(iterable) (обязательный)
The original chunks.

Код WPCF7_HTMLFormatter::pre_format() CF7 5.7.3

public function pre_format( $chunks ) {
	$position = 0;

	foreach ( $chunks as $chunk ) {
		$chunk['position'] = $position;

		// Standardize newline characters to "\n".
		$chunk['content'] = str_replace(
			array( "\r\n", "\r" ), "\n", $chunk['content']
		);

		if ( $chunk['type'] === self::start_tag ) {
			list( $chunk['content'] ) =
				self::normalize_start_tag( $chunk['content'] );

			// Replace <br /> by a line break.
			if (
				$this->options['auto_br'] and
				preg_match( '/^<br\s*\/?>$/i', $chunk['content'] )
			) {
				$chunk['type'] = self::text;
				$chunk['content'] = "\n";
			}
		}

		yield $chunk;
		$position = self::calc_next_position( $chunk );
	}
}