WPCF7_HTMLFormatter::append_text()publicCF7 1.0

Appends a text node content to the output property.

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

Хуков нет.

Возвращает

null. Ничего.

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

$WPCF7_HTMLFormatter = new WPCF7_HTMLFormatter();
$WPCF7_HTMLFormatter->append_text( $content );
$content(строка) (обязательный)
Text node content.

Код WPCF7_HTMLFormatter::append_text() CF7 5.7.3

public function append_text( $content ) {
	if ( $this->is_inside( array( 'pre', 'template' ) ) ) {
		$this->output .= $content;
		return;
	}

	if (
		empty( $this->stacked_elements ) or
		$this->has_parent( 'p' ) or
		$this->has_parent( self::p_parent_elements )
	) {
		// Close <p> if the content starts with multiple line breaks.
		if ( preg_match( '/^\s*\n\s*\n\s*/', $content ) ) {
			$this->end_tag( 'p' );
		}

		// Split up the contents into paragraphs, separated by double line breaks.
		$paragraphs = preg_split( '/\s*\n\s*\n\s*/', $content );

		$paragraphs = array_filter( $paragraphs, function ( $paragraph ) {
			return '' !== trim( $paragraph );
		} );

		$paragraphs = array_values( $paragraphs );

		if ( $paragraphs ) {
			if ( $this->is_inside( 'p' ) ) {
				$paragraph = array_shift( $paragraphs );

				$paragraph = self::normalize_paragraph(
					$paragraph,
					$this->options['auto_br']
				);

				$this->output .= $paragraph;
			}

			foreach ( $paragraphs as $paragraph ) {
				$this->start_tag( 'p' );

				$paragraph = ltrim( $paragraph );

				$paragraph = self::normalize_paragraph(
					$paragraph,
					$this->options['auto_br']
				);

				$this->output .= $paragraph;
			}
		}

		// Close <p> if the content ends with multiple line breaks.
		if ( preg_match( '/\s*\n\s*\n\s*$/', $content ) ) {
			$this->end_tag( 'p' );
		}

		// Cases where the content is a single line break.
		if ( preg_match( '/^\s*\n\s*$/', $content ) ) {
			$auto_br = $this->options['auto_br'] && $this->is_inside( 'p' );

			$content = self::normalize_paragraph( $content, $auto_br );

			$this->output .= $content;
		}
	} else {
		$auto_br = $this->options['auto_br'] &&
			$this->has_parent( self::br_parent_elements );

		$content = self::normalize_paragraph( $content, $auto_br );

		$this->output .= $content;
	}
}