WPCF7_MailTaggedText::replace_tags_callback()privateCF7 1.0

Callback function for replacement.

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

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->replace_tags_callback( $matches, $html );
$matches (обязательный)
-
$html **
-
По умолчанию: false

Код WPCF7_MailTaggedText::replace_tags_callback() CF7 5.9.3

private function replace_tags_callback( $matches, $html = false ) {
	// allow [[foo]] syntax for escaping a tag
	if ( $matches[1] == '['
	and $matches[4] == ']' ) {
		return substr( $matches[0], 1, -1 );
	}

	$tag = $matches[0];
	$tagname = $matches[2];
	$values = $matches[3];

	$mail_tag = new WPCF7_MailTag( $tag, $tagname, $values );
	$field_name = $mail_tag->field_name();

	$submission = WPCF7_Submission::get_instance();
	$submitted = $submission
		? $submission->get_posted_data( $field_name )
		: null;

	if ( $mail_tag->get_option( 'do_not_heat' ) ) {
		$submitted = wp_unslash( $_POST[$field_name] ?? '' );
	}

	$replaced = $submitted;

	if ( null !== $replaced ) {
		if ( $format = $mail_tag->get_option( 'format' ) ) {
			$replaced = $this->format( $replaced, $format );
		}

		$separator = ( 'body' === WPCF7_Mail::get_current_component_name() )
			? wp_get_list_item_separator()
			: ', ';

		$replaced = wpcf7_flat_join( $replaced, array(
			'separator' => $separator,
		) );

		if ( $html ) {
			$replaced = esc_html( $replaced );
			$replaced = wptexturize( $replaced );
		}
	}

	if ( $form_tag = $mail_tag->corresponding_form_tag() ) {
		$type = $form_tag->type;

		$replaced = apply_filters(
			"wpcf7_mail_tag_replaced_{$type}", $replaced,
			$submitted, $html, $mail_tag
		);
	}

	$replaced = apply_filters(
		'wpcf7_mail_tag_replaced', $replaced,
		$submitted, $html, $mail_tag
	);

	if ( null !== $replaced ) {
		$replaced = trim( $replaced );

		$this->replaced_tags[$tag] = $replaced;
		return $replaced;
	}

	$special = apply_filters( 'wpcf7_special_mail_tags', null,
		$mail_tag->tag_name(), $html, $mail_tag
	);

	if ( null !== $special ) {
		$this->replaced_tags[$tag] = $special;
		return $special;
	}

	return $tag;
}