wpcf7_special_mail_tag()
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() wpcf7 special mail tag CF7 6.1.6
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 (string) count( $submission->get_invalid_fields() );
}
if ( '_contact_form_title' === $name ) {
$contact_form = $submission->get_contact_form();
return $html
? esc_html( $contact_form->title() )
: $contact_form->title();
}
return $output;
}