wpcf7_tag_generator_captcha()CF7 1.0

Хуков нет.

Возвращает

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

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

if ( ! $has_tags );
! $has_tags (обязательный)
-

Код wpcf7_tag_generator_captcha() CF7 6.0.1

if ( ! $has_tags ) {
	return;
}

if ( ! class_exists( 'ReallySimpleCaptcha' ) ) {
	return;
}

$uploads_dir = wpcf7_captcha_tmp_dir();
wpcf7_init_captcha();

if ( ! is_dir( $uploads_dir ) or ! wp_is_writable( $uploads_dir ) ) {
	$message = sprintf( __( 'This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );

	wp_admin_notice( esc_html( $message ), 'type=warning' );
}

if (
	! function_exists( 'imagecreatetruecolor' ) or
	! function_exists( 'imagettftext' )
) {
	$message = __( "This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.", 'contact-form-7' );

	wp_admin_notice( esc_html( $message ), 'type=warning' );
}
}


/* CAPTCHA functions */

function wpcf7_init_captcha() {
static $captcha = null;

if ( $captcha ) {
	return $captcha;
}

if ( class_exists( 'ReallySimpleCaptcha' ) ) {
	$captcha = new ReallySimpleCaptcha();
} else {
	return false;
}

$dir = trailingslashit( wpcf7_captcha_tmp_dir() );

$captcha->tmp_dir = $dir;

if ( is_callable( array( $captcha, 'make_tmp_dir' ) ) ) {
	$result = $captcha->make_tmp_dir();

	if ( ! $result ) {
		return false;
	}

	return $captcha;
}

$result = wp_mkdir_p( $dir );

if ( ! $result ) {
	return false;
}

$htaccess_file = path_join( $dir, '.htaccess' );

if ( file_exists( $htaccess_file ) ) {
	list( $first_line_comment ) = (array) file(
		$htaccess_file,
		FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
	);

	if ( '# Apache 2.4+' === $first_line_comment ) {
		return $captcha;
	}
}

if ( $handle = @fopen( $htaccess_file, 'w' ) ) {
	fwrite( $handle, "# Apache 2.4+\n" );
	fwrite( $handle, "<IfModule authz_core_module>\n" );
	fwrite( $handle, "    Require all denied\n" );