Skip to content

Commit

Permalink
Merge pull request #532 from takayukister/dev/5.5
Browse files Browse the repository at this point in the history
Update file.php
  • Loading branch information
takayukister authored Aug 29, 2021
2 parents 9313491 + bd7ea16 commit ed64bff
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions includes/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();

Expand All @@ -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();
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ed64bff

Please sign in to comment.