WPCF7_FormTagsManager::replace_with_placeholders()publicCF7 1.0

Replace all form-tags in the given text with placeholders.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WPCF7_FormTagsManager = new WPCF7_FormTagsManager();
$WPCF7_FormTagsManager->replace_with_placeholders( $content );
$content (обязательный)
-

Код WPCF7_FormTagsManager::replace_with_placeholders() CF7 5.9.3

public function replace_with_placeholders( $content ) {
	if ( empty( $this->tag_types ) ) {
		return $content;
	}

	$this->placeholders = array();

	$callback = function ( $matches ) {
		// Allow [[foo]] syntax for escaping a tag.
		if ( '[' === $matches[1] and ']' === $matches[6] ) {
			return $matches[0];
		}

		$tag = $matches[0];
		$tag_type = $matches[2];

		$block_or_hidden = $this->tag_type_supports(
			$tag_type,
			array( 'display-block', 'display-hidden' )
		);

		if ( $block_or_hidden ) {
			$placeholder_tag_name = WPCF7_HTMLFormatter::placeholder_block;
		} else {
			$placeholder_tag_name = WPCF7_HTMLFormatter::placeholder_inline;
		}

		$placeholder = sprintf(
			'<%1$s id="%2$s" />',
			$placeholder_tag_name,
			sha1( $tag )
		);

		list( $placeholder ) =
			WPCF7_HTMLFormatter::normalize_start_tag( $placeholder );

		$this->placeholders[$placeholder] = $tag;

		return $placeholder;
	};

	return preg_replace_callback(
		'/' . $this->tag_regex() . '/s',
		$callback,
		$content
	);
}