diff --git a/includes/file.php b/includes/file.php index 54d3dc63..19147e28 100644 --- a/includes/file.php +++ b/includes/file.php @@ -109,6 +109,10 @@ function wpcf7_unship_uploaded_file( $file, $args = '' ) { 10, 1 ); +/** + * A wpcf7_messages filter callback that adds messages for + * file-uploading fields. + */ function wpcf7_file_messages( $messages ) { return array_merge( $messages, array( 'upload_failed' => array( @@ -140,6 +144,10 @@ function wpcf7_file_messages( $messages ) { 10, 1 ); +/** + * A wpcf7_form_enctype filter callback that sets the enctype attribute + * to multipart/form-data if the form has file-uploading fields. + */ function wpcf7_file_form_enctype_filter( $enctype ) { $multipart = (bool) wpcf7_scan_form_tags( array( 'feature' => 'file-uploading', @@ -234,6 +242,9 @@ function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) { 10, 0 ); +/** + * Initializes the temporary directory for uploaded files. + */ function wpcf7_init_uploads() { $dir = wpcf7_upload_tmp_dir(); @@ -249,6 +260,12 @@ function wpcf7_init_uploads() { } +/** + * Creates a child directory with a randomly generated name. + * + * @param string $dir The parent directory path. + * @return string The child directory path if created, otherwise the parent. + */ function wpcf7_maybe_add_random_dir( $dir ) { do { $rand_max = mt_getrandmax(); @@ -291,6 +308,13 @@ function wpcf7_upload_tmp_dir() { 20, 0 ); +/** + * Cleans up files in the temporary directory for uploaded files. + * + * @param int $seconds Files older than this are removed. Default 60. + * @param int $max Maximum number of files to be removed in a function call. + * Default 100. + */ function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) { if ( is_admin() or 'GET' != $_SERVER['REQUEST_METHOD'] @@ -345,6 +369,9 @@ function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) { 10, 3 ); +/** + * Displays warning messages about file-uploading fields. + */ function wpcf7_file_display_warning_message( $page, $action, $object ) { if ( $object instanceof WPCF7_ContactForm ) { $contact_form = $object;