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) || !is_readable($dir) || !wp_is_writable($dir)) { return false; } if ($handle = @opendir($dir)) { while (false !== ($file = readdir($handle))) { if (!preg_match('/^[0-9]+\\.(php|txt|png|gif|jpeg)$/', $file)) { continue; } $stat = @stat($dir . $file); if ($stat['mtime'] + 3600 < time()) { // 3600 secs == 1 hour @unlink($dir . $file); } } closedir($handle); } }
function wpcf7_remove_captcha($prefix) { global $wpcf7_captcha; if (!wpcf7_init_captcha()) { return false; } $captcha =& $wpcf7_captcha; $captcha->remove($prefix); }