wpcf7_init_captcha()
CAPTCHA functions
Хуков нет.
Возвращает
null. Ничего (null).
Использование
wpcf7_init_captcha();
Код wpcf7_init_captcha() wpcf7 init captcha CF7 6.1.7
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;
}
}
$filesystem = WPCF7_Filesystem::get_instance();
$htaccess_body = '
# Apache 2.4+
<IfModule authz_core_module>
Require all denied
<FilesMatch "^\w+\.(jpe?g|gif|png)$">
Require all granted
</FilesMatch>
</IfModule>
# Apache 2.2
<IfModule !authz_core_module>
Order deny,allow
Deny from all
<FilesMatch "^\w+\.(jpe?g|gif|png)$">
Allow from all
</FilesMatch>
</IfModule>
';
$filesystem->put_contents( $htaccess_file, ltrim( $htaccess_body ) );
return $captcha;
}