Drag and Drop Multiple File Upload – Contact Form 7 - Version 1.2.5

Version Description

  • Fixed - Improved ( Disable button while upload is on progress )
  • Fixes - Validate file size limit before uploading the file ( https://wordpress.org/support/topic/file-uploading-is-working-incorrect/ )
Download this release

Release Info

Developer glenwpcoder
Plugin Icon 128x128 Drag and Drop Multiple File Upload – Contact Form 7
Version 1.2.5
Comparing to
See all releases

Code changes from version 1.2.4 to 1.2.5

assets/js/codedropz-uploader-min.js CHANGED
@@ -1,11 +1,21 @@
1
  /**
2
- * CodeDropz Uploader v1.1
3
  * Copyright 2018 Glen Mongaya
4
  * CodeDrop Drag&Drop Uploader
5
- * @version 1.1
6
  * @author CodeDropz, Glen Don L. Mongaya
7
  * @license The MIT License (MIT)
8
  */
9
 
10
- // CodeDropz Drag and Drop Plugin
11
- !function(e){e.fn.CodeDropz_Uploader=function(a){var d=e.extend({handler:this,color:"#000",background:"",server_max_error:"Uploaded file exceeds the maximum upload size of your server.",max_file:10,text:"Drag & Drop Files Here",separator:"or",button_text:"Browse Files",max_upload_size:"5242880",supported_type:"jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv",on_success:""},a),r=1,o='<div class="codedropz-upload-handler"><div class="codedropz-upload-container"><div class="codedropz-upload-inner"><h3>'+d.text+"</h3><span>"+d.separator+'</span><div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+d.button_text+"</a></div></div></div></div>";d.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>');var n=d.handler.parents("form"),s=d.handler.parents(".codedropz-upload-wrapper");d.handler.after(o),e(".codedropz-upload-handler",s).on("drag dragstart dragend dragover dragenter dragleave drop",function(e){e.preventDefault(),e.stopPropagation()}),e(".codedropz-upload-handler",s).on("dragover dragenter",function(a){e(this).addClass("codedropz-dragover")}),e(".codedropz-upload-handler",s).on("dragleave dragend drop",function(a){e(this).removeClass("codedropz-dragover")}),e("a.cd-upload-btn",s).on("click",function(e){e.preventDefault(),d.handler.click()}),e(".codedropz-upload-handler",s).on("drop",function(e){t(e.originalEvent.dataTransfer.files,"drop")}),d.handler.on("change",function(a){var d;t(this.files,"click"),btnOBJ=e('input[type="submit"]',n),(d=btnOBJ).length>0&&d.addClass("disable").prop("disabled",!0)});var t=function(a,o){if(!(!a.length>1)){console.log(a.length);var t=new FormData;e.each(a,function(a,i){if(r>d.max_file)return!1;r++;var l=function(a){var d=e(".codedropz-upload-handler",s),r="dnd-file-"+Math.random().toString(36).substr(2,9),o='<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div><div class="dnd-upload-details"><span class="name">'+a.name+" <em>("+(n=a.size,0===n?"0":(kBytes=n/1024,fileSize=kBytes>=1024?(kBytes/1024).toFixed(2)+"MB":kBytes.toFixed(2)+"KB",fileSize))+')</em></span><a href="javascript:void(0)" title="Remove" class="remove-file"><span class="dnd-icon-remove"></span></a><span class="dnd-progress-bar"><span></span></span></div>';var n;return d.after('<div id="'+r+'" class="dnd-upload-status">'+o+"</div>"),r}(i);t.append("upload-file",i),t.append("supported_type",d.supported_type),t.append("size_limit",d.max_upload_size),t.append("action","dnd_codedropz_upload"),t.append("type",o);e.ajax({url:d.ajax_url,type:n.attr("method"),data:t,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);p(l,d)}},!1),e},complete:function(){p(l,100)},success:function(a){a.success?e.isFunction(d.on_success)&&d.on_success.call(this,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"]',n).removeClass("disabled").prop("disabled",!1))},error:function(a,r,o){e(".dnd-progress-bar",e("#"+l)).remove(),e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+d.server_max_error+"</span>"),e('input[type="submit"]',n).removeClass("disabled").prop("disabled",!1)}})})}};function p(a,d){var r=e(".dnd-progress-bar",e("#"+a));return r.length>0&&(progress_width=d*r.width()/100,e("span",r).animate({width:progress_width},10).text(d+"% "),100==d&&e("span",r).addClass("complete")),!1}e(document).on("click",".dnd-icon-remove",function(){e(this).parents(".dnd-upload-status").remove(),r-=1})}}(jQuery);
 
 
 
 
 
 
 
 
 
 
1
  /**
2
+ * CodeDropz Uploader v1.0
3
  * Copyright 2018 Glen Mongaya
4
  * CodeDrop Drag&Drop Uploader
5
+ * @version 1.0
6
  * @author CodeDropz, Glen Don L. Mongaya
7
  * @license The MIT License (MIT)
8
  */
9
 
10
+ // CodeDropz Drag and Drop Plugin
11
+ (function($){$.fn.CodeDropz_Uploader=function(settings){var options=$.extend({handler:this,color:"#000",background:'',server_max_error:'Uploaded file exceeds the maximum upload size of your server.',max_file:10,text:'Drag & Drop Files Here',separator:'or',button_text:'Browse Files',max_upload_size:'5242880',supported_type:'jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv',on_success:''},settings);var count_files=1;var cdropz_template='<div class="codedropz-upload-handler">'+'<div class="codedropz-upload-container">'+'<div class="codedropz-upload-inner">'+'<h3>'+options.text+'</h3>'+'<span>'+options.separator+'</span>'+'<div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+options.button_text+'</a></div>'+'</div>'+'</div>'+'</div>';options.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>');var form_handler=options.handler.parents('form'),options_handler=options.handler.parents('.codedropz-upload-wrapper'),btnOBJ=$('input[type="submit"]',form_handler);options.handler.after(cdropz_template);$('.codedropz-upload-handler',options_handler).on('drag dragstart dragend dragover dragenter dragleave drop',function(e){e.preventDefault();e.stopPropagation()})
12
+ $('.codedropz-upload-handler',options_handler).on('dragover dragenter',function(e){$(this).addClass('codedropz-dragover')});$('.codedropz-upload-handler',options_handler).on('dragleave dragend drop',function(e){$(this).removeClass('codedropz-dragover')});$('a.cd-upload-btn',options_handler).on("click",function(e){e.preventDefault();options.handler.click()});$('.codedropz-upload-handler',options_handler).on('drop',function(event){DND_Setup_Uploader(event.originalEvent.dataTransfer.files,'drop')});options.handler.on("change",function(e){DND_Setup_Uploader(this.files,'click')});var DND_Setup_Uploader=function(files,action){if(!files.length>1){return}
13
+ var formData=new FormData(),object_files=[];$.each(files,function(i,file){if(count_files>options.max_file){return!1}
14
+ var progressBarID=createProgressBar(file),has_error=!1;if(file.size>options.max_upload_size){has_error=!0;$('.dnd-upload-details',$('#'+progressBarID)).append('<span class="has-error">'+dnd_cf7_uploader.drag_n_drop_upload.large_file+'</span>')}
15
+ count_files++;if(has_error===!1){formData.append('upload-file',file);formData.append('supported_type',options.supported_type);formData.append('size_limit',options.max_upload_size);formData.append('action','dnd_codedropz_upload');formData.append('type',action);var dnd_ajax_upload=$.ajax({url:options.ajax_url,type:form_handler.attr('method'),data:formData,dataType:'json',cache:!1,contentType:!1,processData:!1,xhr:function(){var _xhr=new window.XMLHttpRequest();_xhr.upload.addEventListener("progress",function(event){if(event.lengthComputable){var percentComplete=(event.loaded/event.total);var percentage=parseInt(percentComplete*100);setProgressBar(progressBarID,percentage)}},!1);return _xhr},complete:function(){setProgressBar(progressBarID,100)},success:function(response){if(response.success){if($.isFunction(options.on_success)){options.on_success.call(this,progressBarID,response)}}else{$('.dnd-progress-bar',$('#'+progressBarID)).remove();$('.dnd-upload-details',$('#'+progressBarID)).append('<span class="has-error">'+response.data+'</span>');$('input[type="submit"]',form_handler).removeClass('disabled').prop("disabled",!1)}},error:function(xhr,ajax,thrownError){$('.dnd-progress-bar',$('#'+progressBarID)).remove();$('.dnd-upload-details',$('#'+progressBarID)).append('<span class="has-error">'+options.server_max_error+'</span>');$('input[type="submit"]',form_handler).removeClass('disabled').prop("disabled",!1)}})}})}
16
+ $(document).on("click",'.dnd-icon-remove',function(){$(this).parents('.dnd-upload-status').remove();count_files=(count_files-1)});function createProgressBar(file){var upload_handler=$('.codedropz-upload-handler',options_handler),generated_ID='dnd-file-'+Math.random().toString(36).substr(2,9);var fileDetails='<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div>'+'<div class="dnd-upload-details">'+'<span class="name">'+file.name+' <em>('+bytesToSize(file.size)+')</em></span>'+'<a href="javascript:void(0)" title="Remove" class="remove-file"><span class="dnd-icon-remove"></span></a>'+'<span class="dnd-progress-bar"><span></span></span>'+'</div>';upload_handler.after('<div id="'+generated_ID+'" class="dnd-upload-status">'+fileDetails+'</div>');return generated_ID}
17
+ function setProgressBar(statusbar,percent){var statusBar=$('.dnd-progress-bar',$('#'+statusbar));if(statusBar.length>0){disableBtn(btnOBJ);progress_width=(percent*statusBar.width()/100);$('span',statusBar).addClass('in-progress').animate({width:progress_width},10).text(percent+'% ');if(percent==100){$('span',statusBar).removeClass('in-progress')}}
18
+ return!1}
19
+ function bytesToSize(bytes){if(bytes===0)
20
+ return'0';kBytes=(bytes/1024);fileSize=(kBytes>=1024?(kBytes/1024).toFixed(2)+'MB':kBytes.toFixed(2)+'KB');return fileSize}
21
+ function disableBtn(BtnOJB){if(BtnOJB.length>0){BtnOJB.addClass('disable').prop("disabled",!0)}}}}(jQuery))
assets/js/dnd-upload-cf7.js CHANGED
@@ -20,9 +20,9 @@ jQuery(document).ready(function($){
20
  // Progressbar Object
21
  var progressDetails = $('#' + progressBar, dnd_input_file.parents('.codedropz-upload-wrapper') );
22
 
23
- // If it's complete remove disabled attribute in button
24
- if( $('span.complete', $('#' + progressBar)).hasClass('complete') ) {
25
- $('input[type="submit"]', dnd_input_file.parents('form') ).removeClass('disabled').prop( "disabled", false );
26
  }
27
 
28
  // Append hidden input field
20
  // Progressbar Object
21
  var progressDetails = $('#' + progressBar, dnd_input_file.parents('.codedropz-upload-wrapper') );
22
 
23
+ // If it's complete remove disabled attribute in button
24
+ if( $('.in-progress', dnd_input_file.parents('form') ).length === 0 ) {
25
+ setTimeout(function(){ $('input[type="submit"]', dnd_input_file.parents('form')).removeAttr('disabled'); }, 1);
26
  }
27
 
28
  // Append hidden input field
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.2.4
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.2.4' );
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.2.5.0
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.2.5.0' );
25
 
26
  /** Define constant Plugin Directories */
27
  define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
inc/dnd-upload-cf7.php CHANGED
@@ -28,6 +28,9 @@
28
  add_action('wpcf7_before_send_mail','dnd_cf7_before_send_mail', 30, 1);
29
  add_action('wpcf7_mail_components','dnd_cf7_mail_components', 50, 2);
30
 
 
 
 
31
  // Add Submenu - Settings
32
  add_action('admin_menu', 'dnd_admin_settings');
33
 
@@ -42,6 +45,13 @@
42
  add_action('admin_init','dnd_upload_register_settings');
43
  }
44
 
 
 
 
 
 
 
 
45
  // Default Error Message
46
  function dnd_cf7_error_msg( $error_key ) {
47
 
@@ -193,6 +203,7 @@
193
  'or_separator' => ( get_option('drag_n_drop_separator') ? get_option('drag_n_drop_separator') : __('or','dnd-upload-cf7') ),
194
  'browse' => ( get_option('drag_n_drop_browse_text') ? get_option('drag_n_drop_browse_text') : __('Browse Files','dnd-upload-cf7') ),
195
  'server_max_error' => ( get_option('drag_n_drop_error_server_limit') ? get_option('drag_n_drop_error_server_limit') : dnd_cf7_error_msg('server_limit') ),
 
196
  )
197
  )
198
  );
28
  add_action('wpcf7_before_send_mail','dnd_cf7_before_send_mail', 30, 1);
29
  add_action('wpcf7_mail_components','dnd_cf7_mail_components', 50, 2);
30
 
31
+ // Add custom mime-type
32
+ add_filter('upload_mimes', 'dnd_extra_mime_types', 1, 1);
33
+
34
  // Add Submenu - Settings
35
  add_action('admin_menu', 'dnd_admin_settings');
36
 
45
  add_action('admin_init','dnd_upload_register_settings');
46
  }
47
 
48
+ // Add custom mime-types
49
+ function dnd_extra_mime_types( $mime_types ){
50
+ $mime_types['xls'] = 'application/excel, application/vnd.ms-excel, application/x-excel, application/x-msexcel';
51
+ $mime_types['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
52
+ return $mime_types;
53
+ }
54
+
55
  // Default Error Message
56
  function dnd_cf7_error_msg( $error_key ) {
57
 
203
  'or_separator' => ( get_option('drag_n_drop_separator') ? get_option('drag_n_drop_separator') : __('or','dnd-upload-cf7') ),
204
  'browse' => ( get_option('drag_n_drop_browse_text') ? get_option('drag_n_drop_browse_text') : __('Browse Files','dnd-upload-cf7') ),
205
  'server_max_error' => ( get_option('drag_n_drop_error_server_limit') ? get_option('drag_n_drop_error_server_limit') : dnd_cf7_error_msg('server_limit') ),
206
+ 'large_file' => ( get_option('drag_n_drop_error_files_too_large') ? get_option('drag_n_drop_error_files_too_large') : dnd_cf7_error_msg('large_file') ),
207
  )
208
  )
209
  );
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.2
6
- Stable tag: 1.2.4
7
  Requires PHP: 5.2.4
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -85,6 +85,13 @@ To install this plugin see below:
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
88
  = 1.2.4 =
89
  * Added - Support WPML using .po and .mo files
90
  * Added - Added to support multilingual ( using Poedit )
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.2
6
+ Stable tag: 1.2.5.0
7
  Requires PHP: 5.2.4
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
85
 
86
  == Changelog ==
87
 
88
+ = 1.2.5.0 =
89
+ * Fixed - Please Update to 1.2.5.0 to fixed disable button issue.
90
+
91
+ = 1.2.5 =
92
+ * Fixed - Improved ( Disable button while upload is on progress )
93
+ * Fixes - Validate file size limit before uploading the file ( https://wordpress.org/support/topic/file-uploading-is-working-incorrect/ )
94
+
95
  = 1.2.4 =
96
  * Added - Support WPML using .po and .mo files
97
  * Added - Added to support multilingual ( using Poedit )