Version Description
- Fixed - (Flamingo) Removed uploaded files when item Inbound Messages "Permanently Deleted".
- Added - Counter of how many files are uploaded ( ie: 4 of 10 )
- New - Features allow to set Minimum File Upload.
- ie : minimum upload:2, max upload:10
Download this release
Release Info
Developer | glenwpcoder |
Plugin | Drag and Drop Multiple File Upload – Contact Form 7 |
Version | 1.3.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.3.3.2 to 1.3.4
- assets/css/dnd-upload-cf7.css +2 -0
- assets/js/codedropz-uploader-min.js +2 -2
- assets/js/dnd-upload-cf7.js +5 -0
- drag-n-drop-upload-cf7.php +2 -2
- inc/dnd-upload-cf7.php +88 -22
- readme.txt +11 -2
- uninstall.php +14 -0
assets/css/dnd-upload-cf7.css
CHANGED
@@ -120,12 +120,14 @@
|
|
120 |
line-height:14px;
|
121 |
}
|
122 |
.dnd-upload-status .dnd-upload-details .dnd-progress-bar span.complete { width:100%!important; padding-right:5px; }
|
|
|
123 |
|
124 |
/* CodeDropz Upload Plugin */
|
125 |
.codedropz-upload-handler {
|
126 |
border:2px dashed #c5c5c5;
|
127 |
border-radius:5px;
|
128 |
margin-bottom:10px;
|
|
|
129 |
}
|
130 |
.codedropz-upload-container {
|
131 |
padding:15px 20px;
|
120 |
line-height:14px;
|
121 |
}
|
122 |
.dnd-upload-status .dnd-upload-details .dnd-progress-bar span.complete { width:100%!important; padding-right:5px; }
|
123 |
+
.dnd-upload-counter { position:absolute; right:5px; bottom:3px; font-size:12px; }
|
124 |
|
125 |
/* CodeDropz Upload Plugin */
|
126 |
.codedropz-upload-handler {
|
127 |
border:2px dashed #c5c5c5;
|
128 |
border-radius:5px;
|
129 |
margin-bottom:10px;
|
130 |
+
position:relative;
|
131 |
}
|
132 |
.codedropz-upload-container {
|
133 |
padding:15px 20px;
|
assets/js/codedropz-uploader-min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* CodeDropz Uploader v1.3.
|
3 |
* Copyright 2018 Glen Mongaya
|
4 |
* CodeDrop Drag&Drop Uploader
|
5 |
* @version 1.0
|
@@ -8,4 +8,4 @@
|
|
8 |
*/
|
9 |
|
10 |
// CodeDropz Drag and Drop Plugin
|
11 |
-
!function(e){e.fn.CodeDropz_Uploader=function(a){this.each(function(){var d=e(this),r=e.extend({handler:d,color:"#000",background:"",server_max_error:"Uploaded file exceeds the maximum upload size of your server.",max_file:d.data("max")?d.data("max"):10,max_upload_size:d.data("limit")?d.data("limit"):"5242880",supported_type:d.data("type")?d.data("type"):"jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls",text:"Drag & Drop Files Here",separator:"or",button_text:"Browse Files",on_success:""},a),o=d.data("name")+"_count_files";localStorage.setItem(o,1);var
|
1 |
/**
|
2 |
+
* CodeDropz Uploader v1.3.4
|
3 |
* Copyright 2018 Glen Mongaya
|
4 |
* CodeDrop Drag&Drop Uploader
|
5 |
* @version 1.0
|
8 |
*/
|
9 |
|
10 |
// CodeDropz Drag and Drop Plugin
|
11 |
+
!function(e){e.fn.CodeDropz_Uploader=function(a){this.each(function(){var d=e(this),r=e.extend({handler:d,color:"#000",background:"",server_max_error:"Uploaded file exceeds the maximum upload size of your server.",max_file:d.data("max")?d.data("max"):10,max_upload_size:d.data("limit")?d.data("limit"):"5242880",supported_type:d.data("type")?d.data("type"):"jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls",text:"Drag & Drop Files Here",separator:"or",button_text:"Browse Files",on_success:""},a),o=d.data("name")+"_count_files";localStorage.setItem(o,1);var s='<div class="codedropz-upload-handler"><div class="codedropz-upload-container"><div class="codedropz-upload-inner"><h3>'+r.text+"</h3><span>"+r.separator+'</span><div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+r.button_text+'</a></div></div></div><span class="dnd-upload-counter"><span>0</span> of '+parseInt(r.max_file)+"</span></div>";r.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>'),r.supported_type=r.supported_type.replace(/[^a-zA-Z0-9| ]/g,"");var t=r.handler.parents("form"),n=r.handler.parents(".codedropz-upload-wrapper"),p=e('input[type="submit"]',t);r.handler.after(s),e(".codedropz-upload-handler",n).on("drag dragstart dragend dragover dragenter dragleave drop",function(e){e.preventDefault(),e.stopPropagation()}),e(".codedropz-upload-handler",n).on("dragover dragenter",function(a){e(this).addClass("codedropz-dragover")}),e(".codedropz-upload-handler",n).on("dragleave dragend drop",function(a){e(this).removeClass("codedropz-dragover")}),e("a.cd-upload-btn",n).on("click",function(e){e.preventDefault(),r.handler.val(null),r.handler.click()}),e(".codedropz-upload-handler",n).on("drop",function(e){l(e.originalEvent.dataTransfer.files,"drop")}),r.handler.on("change",function(e){l(this.files,"click")});var l=function(a,s){if(!(!a.length>1)){var p=new FormData;p.append("supported_type",r.supported_type),p.append("size_limit",r.max_upload_size),p.append("action","dnd_codedropz_upload"),p.append("type",s),p.append("security",dnd_cf7_uploader.ajax_nonce),e("span.has-error",r.handler).remove(),e.each(a,function(a,s){if(void 0!==p.delete&&p.delete("upload-file"),localStorage.getItem(o)>r.max_file)return!e("span.has-error-msg",n).length>0&&(err_msg=dnd_cf7_uploader.drag_n_drop_upload.max_file_limit,n.append('<span class="has-error-msg">'+err_msg.replace("%count%",r.max_file)+"</span>")),!1;var l=i.createProgressBar(s),c=!1;if(s.size>r.max_upload_size&&(e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+dnd_cf7_uploader.drag_n_drop_upload.large_file+"</span>"),c=!0),regex_type=new RegExp("(.*?).("+r.supported_type+")$"),!1!==c||regex_type.test(s.name.toLowerCase())||(e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+dnd_cf7_uploader.drag_n_drop_upload.inavalid_type+"</span>"),c=!0),localStorage.setItem(o,Number(localStorage.getItem(o))+1),!1===c){p.append("upload-file",s);e.ajax({url:r.ajax_url,type:t.attr("method"),data:p,dataType:"json",cache:!1,contentType:!1,processData:!1,xhr:function(){var e=new window.XMLHttpRequest;return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var a=e.loaded/e.total,d=parseInt(100*a);i.setProgressBar(l,d)}},!1),e},complete:function(){i.setProgressBar(l,100)},success:function(a){a.success?e.isFunction(r.on_success)&&r.on_success.call(this,d,l,a):(e(".dnd-progress-bar",e("#"+l)).remove(),e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+a.data+"</span>"),e('input[type="submit"]',t).removeClass("disabled").prop("disabled",!1))},error:function(a,d,o){e(".dnd-progress-bar",e("#"+l)).remove(),e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+r.server_max_error+"</span>"),e('input[type="submit"]',t).removeClass("disabled").prop("disabled",!1)}})}})}},i={createProgressBar:function(a){var d=e(".codedropz-upload-handler",n),r="dnd-file-"+Math.random().toString(36).substr(2,9),s='<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div><div class="dnd-upload-details"><span class="name"><span>'+a.name+"</span><em>("+i.bytesToSize(a.size)+')</em></span><a href="javascript:void(0)" title="'+dnd_cf7_uploader.drag_n_drop_upload.delete.title+'" class="remove-file" data-storage="'+o+'"><span class="dnd-icon-remove"></span></a><span class="dnd-progress-bar"><span></span></span></div>';return d.after('<div id="'+r+'" class="dnd-upload-status">'+s+"</div>"),r},setProgressBar:function(a,d){var r=e(".dnd-progress-bar",e("#"+a));return r.length>0&&(i.disableBtn(p),progress_width=d*r.width()/100,e("span",r).addClass("in-progress").animate({width:progress_width},10).text(d+"% "),100==d&&e("span",r).addClass("complete").removeClass("in-progress")),!1},bytesToSize:function(e){return 0===e?"0":(kBytes=e/1024,fileSize=kBytes>=1024?(kBytes/1024).toFixed(2)+"MB":kBytes.toFixed(2)+"KB",fileSize)},disableBtn:function(e){e.length>0&&e.addClass("disable").prop("disabled",!0)}}}),e(document).on("click",".dnd-icon-remove",function(d){var r=e(this),o=r.parents(".dnd-upload-status"),s=r.parents(".codedropz-upload-wrapper"),t=r.parent("a").attr("data-storage"),n=Number(localStorage.getItem(t));if(e("span.in-progress",o).length>0)return!1;if(e(".has-error",o).length>0)return o.remove(),localStorage.setItem(t,n-1),!1;r.addClass("deleting").text(dnd_cf7_uploader.drag_n_drop_upload.delete.text+"...");var p={path:o.find('input[type="hidden"]').val(),action:"dnd_codedropz_upload_delete",security:dnd_cf7_uploader.ajax_nonce};e.post(a.ajax_url,p,function(a){a.success&&(o.remove(),localStorage.setItem(t,n-1),e(".dnd-upload-status",s).length<=1&&e("span.has-error-msg",s).remove(),e(".dnd-upload-counter span",s).text(Number(localStorage.getItem(t))-1))})})}}(jQuery);
|
assets/js/dnd-upload-cf7.js
CHANGED
@@ -19,6 +19,7 @@ jQuery(document).ready(function($){
|
|
19 |
|
20 |
// Remove status / progress bar
|
21 |
$('.dnd-upload-status', inputFile.parents('form')).remove();
|
|
|
22 |
$('span.has-error-msg').remove();
|
23 |
|
24 |
}, false );
|
@@ -50,6 +51,10 @@ jQuery(document).ready(function($){
|
|
50 |
progressDetails
|
51 |
.find('.dnd-upload-details')
|
52 |
.append('<span><input type="hidden" name="'+ input.attr('data-name') +'[]" value="'+ response.data.path +'/'+ response.data.file +'"></span>');
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
});
|
55 |
|
19 |
|
20 |
// Remove status / progress bar
|
21 |
$('.dnd-upload-status', inputFile.parents('form')).remove();
|
22 |
+
$('.dnd-upload-counter span',inputFile.parents('form')).text('0');
|
23 |
$('span.has-error-msg').remove();
|
24 |
|
25 |
}, false );
|
51 |
progressDetails
|
52 |
.find('.dnd-upload-details')
|
53 |
.append('<span><input type="hidden" name="'+ input.attr('data-name') +'[]" value="'+ response.data.path +'/'+ response.data.file +'"></span>');
|
54 |
+
|
55 |
+
// Update counter
|
56 |
+
files_counter = ( Number( localStorage.getItem( input.data('name') + '_count_files' ) ) - 1 );
|
57 |
+
$('.dnd-upload-counter span', input.parents('.codedropz-upload-wrapper')).text( files_counter );
|
58 |
}
|
59 |
});
|
60 |
|
drag-n-drop-upload-cf7.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Description: This simple plugin create Drag & Drop or choose Multiple File upload in your Confact Form 7 Forms.
|
7 |
* Text Domain: dnd-upload-cf7
|
8 |
* Domain Path: /languages
|
9 |
-
* Version: 1.3.
|
10 |
* Author: Glen Don L. Mongaya
|
11 |
* Author URI: http://codedropz.com
|
12 |
* License: GPL2
|
@@ -21,7 +21,7 @@
|
|
21 |
define( 'dnd_upload_cf7', true );
|
22 |
|
23 |
/** Define plugin Version */
|
24 |
-
define( 'dnd_upload_cf7_version', '1.3.
|
25 |
|
26 |
/** Define constant Plugin Directories */
|
27 |
define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
|
6 |
* Description: This simple plugin create Drag & Drop or choose Multiple File upload in your Confact Form 7 Forms.
|
7 |
* Text Domain: dnd-upload-cf7
|
8 |
* Domain Path: /languages
|
9 |
+
* Version: 1.3.4
|
10 |
* Author: Glen Don L. Mongaya
|
11 |
* Author URI: http://codedropz.com
|
12 |
* License: GPL2
|
21 |
define( 'dnd_upload_cf7', true );
|
22 |
|
23 |
/** Define plugin Version */
|
24 |
+
define( 'dnd_upload_cf7_version', '1.3.4' );
|
25 |
|
26 |
/** Define constant Plugin Directories */
|
27 |
define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
|
inc/dnd-upload-cf7.php
CHANGED
@@ -17,8 +17,8 @@
|
|
17 |
add_action( 'wpcf7_init', 'dnd_cf7_upload_add_form_tag_file' );
|
18 |
add_action( 'wpcf7_enqueue_scripts', 'dnd_cf7_scripts' );
|
19 |
|
20 |
-
// Hook
|
21 |
-
add_action('plugins_loaded','
|
22 |
|
23 |
// Ajax Upload
|
24 |
add_action( 'wp_ajax_dnd_codedropz_upload', 'dnd_upload_cf7_upload' );
|
@@ -48,9 +48,44 @@
|
|
48 |
// Add custom script in footer
|
49 |
add_action('wp_footer','dnd_custom_scripts');
|
50 |
|
|
|
|
|
|
|
51 |
// Load plugin text-domain
|
52 |
-
function
|
|
|
|
|
53 |
load_plugin_textdomain( 'dnd-upload-cf7', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
// Modify contact form posted_data
|
@@ -105,7 +140,8 @@
|
|
105 |
'large_file' => __('Uploaded file is too large','dnd-upload-cf7'),
|
106 |
'invalid_type' => __('Uploaded file is not allowed for file type','dnd-upload-cf7'),
|
107 |
'max_file_limit' => __('Note : Some of the files are not uploaded ( Only %count% files allowed )','dnd-upload-cf7'),
|
108 |
-
'required' => __('This field is required.', 'dnd-upload-cf7' )
|
|
|
109 |
);
|
110 |
|
111 |
// return error message based on $error_key request
|
@@ -265,34 +301,47 @@
|
|
265 |
return $components;
|
266 |
}
|
267 |
|
268 |
-
//
|
269 |
-
|
270 |
-
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
-
//
|
274 |
-
|
|
|
275 |
|
276 |
-
//
|
277 |
-
|
278 |
|
279 |
-
//
|
280 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
|
282 |
-
|
283 |
-
|
284 |
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
287 |
|
288 |
-
// Check if submitted and file exists then file is ready.
|
289 |
-
if ( $submission && file_exists( $new_file_name ) ) {
|
290 |
-
$components['attachments'][] = $new_file_name;
|
291 |
}
|
292 |
}
|
293 |
}
|
294 |
-
|
295 |
}
|
|
|
296 |
}
|
297 |
|
298 |
// Increment mail counter
|
@@ -413,7 +462,8 @@
|
|
413 |
function dnd_upload_cf7_validation_filter( $result, $tag ) {
|
414 |
$name = $tag->name;
|
415 |
$id = $tag->get_id_option();
|
416 |
-
$multiple_files = ( ( isset( $_POST[ $name ] ) && count( $_POST[ $name ] ) > 0 ) ?
|
|
|
417 |
|
418 |
// Cf7 Conditional Field
|
419 |
if( in_array('cf7-conditional-fields/contact-form-7-conditional-fields.php', get_option('active_plugins') ) ){
|
@@ -431,6 +481,13 @@
|
|
431 |
return $result;
|
432 |
}
|
433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
return $result;
|
435 |
}
|
436 |
|
@@ -482,6 +539,10 @@
|
|
482 |
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-filetypes' ); ?>"><?php echo esc_html( __( 'Acceptable file types', 'contact-form-7' ) ); ?></label></th>
|
483 |
<td><input type="text" name="filetypes" class="filetype oneline option" placeholder="jpeg|png|jpg|gif" id="<?php echo esc_attr( $args['content'] . '-filetypes' ); ?>" /></td>
|
484 |
</tr>
|
|
|
|
|
|
|
|
|
485 |
<tr>
|
486 |
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-max-file' ); ?>"><?php echo esc_html( __( 'Max file upload', 'contact-form-7' ) ); ?></label></th>
|
487 |
<td><input type="text" name="max-file" class="filetype oneline option" placeholder="10" id="<?php echo esc_attr( $args['content'] . '-max-file' ); ?>" /></td>
|
@@ -744,6 +805,10 @@
|
|
744 |
<th scope="row"><?php _e('Max File Limit','dnd-upload-cf7'); ?></th>
|
745 |
<td><input type="text" name="drag_n_drop_error_max_file" class="regular-text" value="<?php echo esc_attr( get_option('drag_n_drop_error_max_file') ); ?>" placeholder="" /><p class="description">Example: `Note : Some of the files are not uploaded ( Only %count% files allowed )`</p></td>
|
746 |
</tr>
|
|
|
|
|
|
|
|
|
747 |
</table>
|
748 |
|
749 |
<?php submit_button(); ?>
|
@@ -808,4 +873,5 @@
|
|
808 |
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_files_too_large','sanitize_text_field' );
|
809 |
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_invalid_file','sanitize_text_field' );
|
810 |
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_max_file','sanitize_text_field' );
|
|
|
811 |
}
|
17 |
add_action( 'wpcf7_init', 'dnd_cf7_upload_add_form_tag_file' );
|
18 |
add_action( 'wpcf7_enqueue_scripts', 'dnd_cf7_scripts' );
|
19 |
|
20 |
+
// Hook on plugins loaded
|
21 |
+
add_action('plugins_loaded','dnd_cf7_upload_plugins_loaded');
|
22 |
|
23 |
// Ajax Upload
|
24 |
add_action( 'wp_ajax_dnd_codedropz_upload', 'dnd_upload_cf7_upload' );
|
48 |
// Add custom script in footer
|
49 |
add_action('wp_footer','dnd_custom_scripts');
|
50 |
|
51 |
+
// Flamingo Hooks
|
52 |
+
add_action('before_delete_post', 'dnd_remove_uploaded_files');
|
53 |
+
|
54 |
// Load plugin text-domain
|
55 |
+
function dnd_cf7_upload_plugins_loaded() {
|
56 |
+
|
57 |
+
// Load language domain
|
58 |
load_plugin_textdomain( 'dnd-upload-cf7', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages' );
|
59 |
+
|
60 |
+
// Create dir
|
61 |
+
$dir = dnd_get_upload_dir();
|
62 |
+
if( is_dir( $dir['upload_dir'] ) ) {
|
63 |
+
// Generate .htaccess file`
|
64 |
+
$htaccess_file = path_join( dirname( $dir['upload_dir'] ), '.htaccess' );
|
65 |
+
if ( ! file_exists( $htaccess_file ) ) {
|
66 |
+
if ( $handle = fopen( $htaccess_file, 'w' ) ) {
|
67 |
+
fwrite( $handle, "Options -Indexes \n <Files *.php> \n deny from all \n </Files>" );
|
68 |
+
fclose( $handle );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
// Remove uploaded files when item is deleted permanently.
|
75 |
+
function dnd_remove_uploaded_files( $post_id ) {
|
76 |
+
$post_type = get_post_type( $post_id );
|
77 |
+
$page = get_post( $post_id );
|
78 |
+
if( $post_type == 'flamingo_inbound' ) {
|
79 |
+
preg_match_all( '/(.*?)(\/'.wpcf7_dnd_dir.'\/wpcf7-files\/.*$)/m', $page->post_content, $matches );
|
80 |
+
if( $matches[0] && count( $matches[0] ) > 0 ) {
|
81 |
+
foreach( $matches[0] as $files ) {
|
82 |
+
$new_file = str_replace( site_url().'/', wp_normalize_path( ABSPATH ), $files );
|
83 |
+
if( file_exists( $new_file ) ) {
|
84 |
+
wp_delete_file( $new_file );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
}
|
90 |
|
91 |
// Modify contact form posted_data
|
140 |
'large_file' => __('Uploaded file is too large','dnd-upload-cf7'),
|
141 |
'invalid_type' => __('Uploaded file is not allowed for file type','dnd-upload-cf7'),
|
142 |
'max_file_limit' => __('Note : Some of the files are not uploaded ( Only %count% files allowed )','dnd-upload-cf7'),
|
143 |
+
'required' => __('This field is required.', 'dnd-upload-cf7' ),
|
144 |
+
'min_file' => __('Minimum file upload at least','dnd-upload-cf7'),
|
145 |
);
|
146 |
|
147 |
// return error message based on $error_key request
|
301 |
return $components;
|
302 |
}
|
303 |
|
304 |
+
// Get mail,mail_2 attachment [tags]
|
305 |
+
$mail = array('mail','mail_2');
|
306 |
+
$props_mail = array();
|
307 |
+
|
308 |
+
foreach( $mail as $single_mail ) {
|
309 |
+
$props_mail[] = $form->prop( $single_mail );
|
310 |
}
|
311 |
|
312 |
+
// Get email attachments (mail, mail_2)
|
313 |
+
$mail = $props_mail[ $_mail ];
|
314 |
+
if( $mail['active'] && $mail['attachments'] ) {
|
315 |
|
316 |
+
// Loop fields get mfile only.
|
317 |
+
foreach( $fields as $field ) {
|
318 |
|
319 |
+
// If field type equal to mfile which our default field.
|
320 |
+
if( $field->basetype == 'mfile') {
|
321 |
+
|
322 |
+
// Make sure we have files to attach
|
323 |
+
if( isset( $_POST[ $field->name ] ) && count( $_POST[ $field->name ] ) > 0 ) {
|
324 |
+
|
325 |
+
// Check and make sure [upload-file-xxx] exists in attachments - fields
|
326 |
+
if ( false !== strpos( $mail['attachments'], "[{$field->name}]" ) ) {
|
327 |
+
|
328 |
+
// Loop all the files and attach to cf7 components
|
329 |
+
foreach( $_POST[ $field->name ] as $_file ) {
|
330 |
|
331 |
+
// Join dir and a new file name ( get from <input type="hidden" name="upload-file-333"> )
|
332 |
+
$new_file_name = trailingslashit( $uploads_dir['upload_dir'] ) . wp_basename( $_file );
|
333 |
|
334 |
+
// Check if submitted and file exists then file is ready.
|
335 |
+
if ( $submission && file_exists( $new_file_name ) ) {
|
336 |
+
$components['attachments'][] = $new_file_name;
|
337 |
+
}
|
338 |
+
}
|
339 |
|
|
|
|
|
|
|
340 |
}
|
341 |
}
|
342 |
}
|
|
|
343 |
}
|
344 |
+
|
345 |
}
|
346 |
|
347 |
// Increment mail counter
|
462 |
function dnd_upload_cf7_validation_filter( $result, $tag ) {
|
463 |
$name = $tag->name;
|
464 |
$id = $tag->get_id_option();
|
465 |
+
$multiple_files = ( ( isset( $_POST[ $name ] ) && count( $_POST[ $name ] ) > 0 ) ? $_POST[ $name ] : null );
|
466 |
+
$min_file = $tag->get_option( 'min-file','', true);
|
467 |
|
468 |
// Cf7 Conditional Field
|
469 |
if( in_array('cf7-conditional-fields/contact-form-7-conditional-fields.php', get_option('active_plugins') ) ){
|
481 |
return $result;
|
482 |
}
|
483 |
|
484 |
+
// Check minimum upload
|
485 |
+
if( $multiple_files && count( $multiple_files ) < (int) $min_file ) {
|
486 |
+
$min_file_error = ( get_option('drag_n_drop_error_min_file') ? get_option('drag_n_drop_error_min_file') : dnd_cf7_error_msg('min_file') );
|
487 |
+
$result->invalidate( $tag, $min_file_error .' '. (int)$min_file );
|
488 |
+
return $result;
|
489 |
+
}
|
490 |
+
|
491 |
return $result;
|
492 |
}
|
493 |
|
539 |
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-filetypes' ); ?>"><?php echo esc_html( __( 'Acceptable file types', 'contact-form-7' ) ); ?></label></th>
|
540 |
<td><input type="text" name="filetypes" class="filetype oneline option" placeholder="jpeg|png|jpg|gif" id="<?php echo esc_attr( $args['content'] . '-filetypes' ); ?>" /></td>
|
541 |
</tr>
|
542 |
+
<tr>
|
543 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-min-file' ); ?>"><?php echo esc_html( __( 'Mininum file upload', 'contact-form-7' ) ); ?></label></th>
|
544 |
+
<td><input type="text" name="min-file" class="filetype oneline option" placeholder="5" id="<?php echo esc_attr( $args['content'] . '-min-file' ); ?>" /></td>
|
545 |
+
</tr>
|
546 |
<tr>
|
547 |
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-max-file' ); ?>"><?php echo esc_html( __( 'Max file upload', 'contact-form-7' ) ); ?></label></th>
|
548 |
<td><input type="text" name="max-file" class="filetype oneline option" placeholder="10" id="<?php echo esc_attr( $args['content'] . '-max-file' ); ?>" /></td>
|
805 |
<th scope="row"><?php _e('Max File Limit','dnd-upload-cf7'); ?></th>
|
806 |
<td><input type="text" name="drag_n_drop_error_max_file" class="regular-text" value="<?php echo esc_attr( get_option('drag_n_drop_error_max_file') ); ?>" placeholder="" /><p class="description">Example: `Note : Some of the files are not uploaded ( Only %count% files allowed )`</p></td>
|
807 |
</tr>
|
808 |
+
<tr valign="top">
|
809 |
+
<th scope="row"><?php _e('Mininimum File','dnd-upload-cf7'); ?></th>
|
810 |
+
<td><input type="text" name="drag_n_drop_error_min_file" placeholder="" class="regular-text" value="<?php echo esc_attr( get_option('drag_n_drop_error_min_file') ); ?>" placeholder="" /></td>
|
811 |
+
</tr>
|
812 |
</table>
|
813 |
|
814 |
<?php submit_button(); ?>
|
873 |
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_files_too_large','sanitize_text_field' );
|
874 |
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_invalid_file','sanitize_text_field' );
|
875 |
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_max_file','sanitize_text_field' );
|
876 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_min_file','sanitize_text_field' );
|
877 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Donate link : http://codedropz.com/donation
|
|
3 |
Tags: drag and drop, contact form 7, ajax uploader, multiple file, upload, contact form 7 uploader
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 5.4.1
|
6 |
-
Stable tag: 1.3.
|
7 |
Requires PHP: 5.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -50,7 +50,7 @@ Checkout available features on **PRO version**.
|
|
50 |
* Chunks Upload *( Break large files into smaller Chunks )*
|
51 |
* Max Total Size *( of all Uploaded Files )*
|
52 |
* Parallel/Sequential Upload *( Number of files to simultaneously upload )*
|
53 |
-
* Change Filename Pattern ({filename}, {ip_address}, {random}, {post_id}, {post_slug}
|
54 |
* Automatically Optimize Images
|
55 |
* Able to Resize/Crop image (ie: 800x800)
|
56 |
* Improved Security
|
@@ -124,6 +124,15 @@ To install this plugin see below:
|
|
124 |
|
125 |
== Changelog ==
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
= 1.3.3.3.2 =
|
128 |
* Bugs - Fixed unable to submit form ( 500 Internal Server Error in response )
|
129 |
|
3 |
Tags: drag and drop, contact form 7, ajax uploader, multiple file, upload, contact form 7 uploader
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 5.4.1
|
6 |
+
Stable tag: 1.3.4
|
7 |
Requires PHP: 5.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
50 |
* Chunks Upload *( Break large files into smaller Chunks )*
|
51 |
* Max Total Size *( of all Uploaded Files )*
|
52 |
* Parallel/Sequential Upload *( Number of files to simultaneously upload )*
|
53 |
+
* Change Filename Pattern ({filename}, {ip_address}, {random}, {post_id}, {post_slug} & CF7 Fields
|
54 |
* Automatically Optimize Images
|
55 |
* Able to Resize/Crop image (ie: 800x800)
|
56 |
* Improved Security
|
124 |
|
125 |
== Changelog ==
|
126 |
|
127 |
+
= 1.3.4 =
|
128 |
+
* Fixed - (Flamingo) Removed uploaded files when item Inbound Messages "Permanently Deleted".
|
129 |
+
* Added - Counter of how many files are uploaded ( ie: 4 of 10 )
|
130 |
+
* New - Features allow to set Minimum File Upload.
|
131 |
+
- ie : minimum upload:2, max upload:10 = [mfile* upload-file-669 min-file:2 max-file:10]
|
132 |
+
* New - Added .htaccess file inside "wp_dndcf7_uploads" upload directory. ( prevent from direct access )
|
133 |
+
- Options: -Indexes \n <Files *.php> \n deny from all \n </Files>
|
134 |
+
* Fixed - File Attachments bug ( Issues on additional mail when (file attachment) is removed still send the file )
|
135 |
+
|
136 |
= 1.3.3.3.2 =
|
137 |
* Bugs - Fixed unable to submit form ( 500 Internal Server Error in response )
|
138 |
|
uninstall.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// if uninstall.php is not called by WordPress, die
|
4 |
+
if (!defined('WP_UNINSTALL_PLUGIN')) {
|
5 |
+
die;
|
6 |
+
}
|
7 |
+
|
8 |
+
// Lists of all options
|
9 |
+
$options = array('drag_n_drop_mail_attachment','drag_n_drop_text','drag_n_drop_separator','drag_n_drop_browse_text','drag_n_drop_error_server_limit','drag_n_drop_error_failed_to_upload','drag_n_drop_error_files_too_large','drag_n_drop_error_invalid_file','drag_n_drop_error_max_file','drag_n_drop_error_min_file');
|
10 |
+
|
11 |
+
// Loop and delete options
|
12 |
+
foreach( $options as $option ) {
|
13 |
+
delete_option( $option );
|
14 |
+
}
|