WPCF7_HTMLFormatter::concatenate_texts()publicCF7 1.0

Concatenates neighboring text chunks to create a single chunk.

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

Хуков нет.

Возвращает

iterable. Processed chunks.

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

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

Код WPCF7_HTMLFormatter::concatenate_texts() CF7 5.7.3

public function concatenate_texts( $chunks ) {
	$position = 0;
	$text_left = null;

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

		if ( $chunk['type'] === self::text ) {
			if ( isset( $text_left ) ) {
				$text_left['content'] .= $chunk['content'];
			} else {
				$text_left = $chunk;
			}

			continue;
		}

		if ( isset( $text_left ) ) {
			yield $text_left;
			$chunk['position'] = self::calc_next_position( $text_left );
			$text_left = null;
		}

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

	if ( isset( $text_left ) ) {
		yield $text_left;
	}
}