wpcf7_flamingo_serial_number()CF7 1.0

Returns output string of a special mail-tag.

Хуков нет.

Возвращает

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

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

wpcf7_flamingo_serial_number( $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_flamingo_serial_number() CF7 5.9.3

function wpcf7_flamingo_serial_number( $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'
		);
	}

	if ( '_serial_number' != $name ) {
		return $output;
	}

	if ( ! class_exists( 'Flamingo_Inbound_Message' )
	or ! method_exists( 'Flamingo_Inbound_Message', 'count' ) ) {
		return $output;
	}

	if ( ! $contact_form = WPCF7_ContactForm::get_current() ) {
		return $output;
	}

	$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );

	$channel_id = isset( $post_meta['channel'] )
		? (int) $post_meta['channel']
		: wpcf7_flamingo_add_channel(
				$contact_form->name(), $contact_form->title()
			);

	if ( $channel_id ) {
		return 1 + (int) Flamingo_Inbound_Message::count(
			array( 'channel_id' => $channel_id )
		);
	}

	return 0;
}