wpcf7_cleanup_captcha_files()
Хуков нет.
Возвращает
null. Ничего (null).
Использование
wpcf7_cleanup_captcha_files();
Код wpcf7_cleanup_captcha_files() wpcf7 cleanup captcha files CF7 6.1.6
function wpcf7_cleanup_captcha_files() {
if ( ! $captcha = wpcf7_init_captcha() ) {
return false;
}
if ( is_callable( array( $captcha, 'cleanup' ) ) ) {
return $captcha->cleanup();
}
$dir = trailingslashit( wpcf7_captcha_tmp_dir() );
if (
! is_dir( $dir ) or
! is_readable( $dir ) or
! wp_is_writable( $dir )
) {
return false;
}
$filesystem = WPCF7_Filesystem::get_instance();
if ( $handle = opendir( $dir ) ) {
while ( false !== ( $file = readdir( $handle ) ) ) {
if ( ! preg_match( '/^[0-9]+\.(php|txt|png|gif|jpeg)$/', $file ) ) {
continue;
}
$stat = stat( path_join( $dir, $file ) );
if ( $stat['mtime'] + HOUR_IN_SECONDS < time() ) {
$filesystem->delete( path_join( $dir, $file ) );
}
}
closedir( $handle );
}
}