wpcf7_turnstile_prepend_widget()CF7 1.0

Prepends a Turnstile widget to the form content if the form template does not include a Turnstile form-tag.

Хуков нет.

Возвращает

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

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

wpcf7_turnstile_prepend_widget( $content );
$content(обязательный)
.

Код wpcf7_turnstile_prepend_widget() CF7 6.1.6

function wpcf7_turnstile_prepend_widget( $content ) {
	$service = WPCF7_Turnstile::get_instance();

	if ( ! $service->is_active() ) {
		return $content;
	}

	$contact_form = WPCF7_ContactForm::get_current();
	$manager = WPCF7_FormTagsManager::get_instance();

	$tags = $contact_form->scan_form_tags( array(
		'type' => 'turnstile',
	) );

	if ( empty( $tags ) ) {
		$content = $manager->replace_all( '[turnstile]' ) . "\n\n" . $content;
	}

	return $content;
}