wpcf7_cleanup_captcha_files()CF7 1.0

Хуков нет.

Возвращает

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

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

wpcf7_cleanup_captcha_files();

Код wpcf7_cleanup_captcha_files() CF7 5.9.3

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;
	}

	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() ) {
				@unlink( path_join( $dir, $file ) );
			}
		}

		closedir( $handle );
	}
}