wpcf7_special_mail_tag()CF7 1.0

Returns output string of a special mail-tag.

Хуков нет.

Возвращает

Строку. Output of the given special mail-tag.

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

wpcf7_special_mail_tag( $output, $name, $html, $mail_tag );
$output(строка) (обязательный)
The string to be output.
$name(строка) (обязательный)
The tag name of the special mail-tag.
$html(true|false) (обязательный)
Whether the mail-tag is used in an HTML content.
$mail_tag(WPCF7_MailTag)
An object representation of the mail-tag.
По умолчанию: null

Код wpcf7_special_mail_tag() CF7 5.9.3

function wpcf7_special_mail_tag( $output, $name, $html, $mail_tag = null ) {
	if ( ! $mail_tag instanceof WPCF7_MailTag ) {
		wpcf7_doing_it_wrong(
			sprintf( '%s()', __FUNCTION__ ),
			__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
			'5.2.2'
		);
	}

	$name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat

	$submission = WPCF7_Submission::get_instance();

	if ( ! $submission ) {
		return $output;
	}

	if ( '_remote_ip' === $name ) {
		if ( $remote_ip = $submission->get_meta( 'remote_ip' ) ) {
			return $remote_ip;
		} else {
			return '';
		}
	}

	if ( '_user_agent' === $name ) {
		if ( $user_agent = $submission->get_meta( 'user_agent' ) ) {
			return $html ? esc_html( $user_agent ) : $user_agent;
		} else {
			return '';
		}
	}

	if ( '_url' === $name ) {
		if ( $url = $submission->get_meta( 'url' ) ) {
			return $url;
		} else {
			return '';
		}
	}

	if ( '_date' === $name or '_time' === $name ) {
		if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
			if ( '_date' === $name ) {
				return wp_date( get_option( 'date_format' ), $timestamp );
			}

			if ( '_time' === $name ) {
				return wp_date( get_option( 'time_format' ), $timestamp );
			}
		}

		return '';
	}

	if ( '_invalid_fields' === $name ) {
		return count( $submission->get_invalid_fields() );
	}

	return $output;
}