Version Description
- Fixed - Sanitized Admin Option Fields - For Security Reason
- Added - Filter for
wpcf7_posted_data
from CF7 to get the full link of the file.
Download this release
Release Info
Developer | glenwpcoder |
Plugin | Drag and Drop Multiple File Upload – Contact Form 7 |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- assets/js/codedropz-uploader.js +321 -0
- drag-n-drop-upload-cf7.php +2 -2
- inc/dnd-upload-cf7.php +42 -12
- readme.txt +11 -3
assets/js/codedropz-uploader.js
ADDED
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* CodeDropz Uploader v1.3.3
|
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($){
|
12 |
+
$.fn.CodeDropz_Uploader = function( settings ){
|
13 |
+
|
14 |
+
// Support multiple elements
|
15 |
+
this.each( function() {
|
16 |
+
|
17 |
+
// Parent input file type
|
18 |
+
var input = $(this);
|
19 |
+
|
20 |
+
// Extends options
|
21 |
+
var options = $.extend({
|
22 |
+
handler : input,
|
23 |
+
color : "#000",
|
24 |
+
background : '',
|
25 |
+
server_max_error : 'Uploaded file exceeds the maximum upload size of your server.',
|
26 |
+
max_file : input.data('max') ? input.data('max') : 10, // default 10
|
27 |
+
max_upload_size : input.data('limit') ? input.data('limit') : '5242880', // should be a bytes it's (5MB)
|
28 |
+
supported_type : input.data('type') ? input.data('type') : 'jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls',
|
29 |
+
text : 'Drag & Drop Files Here',
|
30 |
+
separator : 'or',
|
31 |
+
button_text : 'Browse Files',
|
32 |
+
on_success : ''
|
33 |
+
}, settings);
|
34 |
+
|
35 |
+
// Get storage name
|
36 |
+
var dataStorageName = input.data('name') + '_count_files';
|
37 |
+
|
38 |
+
// File Counter
|
39 |
+
localStorage.setItem( dataStorageName, 1);
|
40 |
+
|
41 |
+
// Template Container
|
42 |
+
var cdropz_template = '<div class="codedropz-upload-handler">'
|
43 |
+
+ '<div class="codedropz-upload-container">'
|
44 |
+
+ '<div class="codedropz-upload-inner">'
|
45 |
+
+ '<h3>'+ options.text +'</h3>'
|
46 |
+
+ '<span>'+ options.separator +'</span>'
|
47 |
+
+'<div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+ options.button_text +'</a></div>'
|
48 |
+
+'</div>'
|
49 |
+
+ '</div>'
|
50 |
+
+ '</div>';
|
51 |
+
|
52 |
+
// Wrap input fields
|
53 |
+
options.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>');
|
54 |
+
|
55 |
+
// Element Handler
|
56 |
+
var form_handler = options.handler.parents('form'),
|
57 |
+
options_handler = options.handler.parents('.codedropz-upload-wrapper'),
|
58 |
+
btnOBJ = $('input[type="submit"]', form_handler );
|
59 |
+
|
60 |
+
// Append Format
|
61 |
+
options.handler.after( cdropz_template);
|
62 |
+
|
63 |
+
// preventing the unwanted behaviours
|
64 |
+
$('.codedropz-upload-handler', options_handler ).on( 'drag dragstart dragend dragover dragenter dragleave drop', function( e ){
|
65 |
+
e.preventDefault();
|
66 |
+
e.stopPropagation();
|
67 |
+
})
|
68 |
+
|
69 |
+
// dragover and dragenter - add class
|
70 |
+
$('.codedropz-upload-handler', options_handler ).on( 'dragover dragenter', function( e ){
|
71 |
+
$(this).addClass('codedropz-dragover');
|
72 |
+
});
|
73 |
+
|
74 |
+
// dragleave dragend drop - remove class
|
75 |
+
$('.codedropz-upload-handler', options_handler ).on( 'dragleave dragend drop', function( e ){
|
76 |
+
$(this).removeClass('codedropz-dragover');
|
77 |
+
});
|
78 |
+
|
79 |
+
// Browse button clicked
|
80 |
+
$( 'a.cd-upload-btn', options_handler ).on("click", function(e){
|
81 |
+
// stops the default action of an element from happening
|
82 |
+
e.preventDefault();
|
83 |
+
|
84 |
+
// Reset value
|
85 |
+
options.handler.val(null);
|
86 |
+
|
87 |
+
// Click input type[file] element
|
88 |
+
options.handler.click();
|
89 |
+
});
|
90 |
+
|
91 |
+
// when dropping files
|
92 |
+
$('.codedropz-upload-handler', options_handler ).on('drop', function(event){
|
93 |
+
// Run the uploader
|
94 |
+
DND_Setup_Uploader( event.originalEvent.dataTransfer.files, 'drop' );
|
95 |
+
});
|
96 |
+
|
97 |
+
// Trigger when input type[file] is click/changed
|
98 |
+
options.handler.on("change", function(e){
|
99 |
+
// Run the uploader
|
100 |
+
DND_Setup_Uploader( this.files, 'click' );
|
101 |
+
});
|
102 |
+
|
103 |
+
// Setup Uploader
|
104 |
+
var DND_Setup_Uploader = function( files, action ) {
|
105 |
+
|
106 |
+
// make sure we have files
|
107 |
+
if( ! files.length > 1 ) {
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
|
111 |
+
// gathering the form data
|
112 |
+
var formData = new FormData();
|
113 |
+
|
114 |
+
// Append file
|
115 |
+
formData.append('supported_type', options.supported_type );
|
116 |
+
formData.append('size_limit', options.max_upload_size );
|
117 |
+
formData.append('action', 'dnd_codedropz_upload' );
|
118 |
+
formData.append('type', action );
|
119 |
+
|
120 |
+
// remove has error
|
121 |
+
$('span.has-error', options.handler ).remove();
|
122 |
+
|
123 |
+
// Loop files
|
124 |
+
$.each( files,function( i, file ) {
|
125 |
+
|
126 |
+
// Reset upload file type
|
127 |
+
if( typeof formData.delete !== 'undefined' ) {
|
128 |
+
formData.delete('upload-file');
|
129 |
+
}
|
130 |
+
|
131 |
+
// Limit file upload
|
132 |
+
if( localStorage.getItem( dataStorageName ) > options.max_file ) {
|
133 |
+
if( ! $('span.has-error-msg', options_handler ).length > 0 ) {
|
134 |
+
err_msg = dnd_cf7_uploader.drag_n_drop_upload.max_file_limit;
|
135 |
+
options_handler.append('<span class="has-error-msg">'+ err_msg.replace('%count%', options.max_file ) +'</span>');
|
136 |
+
}
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
// Create progress bar
|
141 |
+
var progressBarID = CodeDropz_Object.createProgressBar( file ),
|
142 |
+
has_error = false;
|
143 |
+
|
144 |
+
// File size limit - validation
|
145 |
+
if( file.size > options.max_upload_size ) {
|
146 |
+
$('.dnd-upload-details', $('#' + progressBarID)).append('<span class="has-error">'+ dnd_cf7_uploader.drag_n_drop_upload.large_file +'</span>');
|
147 |
+
has_error = true;
|
148 |
+
}
|
149 |
+
|
150 |
+
// Validate file type
|
151 |
+
regex_type = new RegExp("(.*?)\.("+ options.supported_type +")$");
|
152 |
+
if ( has_error === false && !( regex_type.test( file.name.toLowerCase() ) ) ) {
|
153 |
+
$('.dnd-upload-details', $('#' + progressBarID)).append('<span class="has-error">'+ dnd_cf7_uploader.drag_n_drop_upload.inavalid_type +'</span>');
|
154 |
+
has_error = true;
|
155 |
+
}
|
156 |
+
|
157 |
+
// Increment count
|
158 |
+
localStorage.setItem( dataStorageName, ( Number( localStorage.getItem( dataStorageName ) ) + 1 ) );
|
159 |
+
|
160 |
+
// Make sure there's no error
|
161 |
+
if( has_error === false ) {
|
162 |
+
|
163 |
+
// Append file
|
164 |
+
formData.append('upload-file', file );
|
165 |
+
|
166 |
+
// Process ajax upload
|
167 |
+
var dnd_ajax_upload = $.ajax({
|
168 |
+
url : options.ajax_url,
|
169 |
+
type : form_handler.attr('method'),
|
170 |
+
data : formData,
|
171 |
+
dataType : 'json',
|
172 |
+
cache : false,
|
173 |
+
contentType : false,
|
174 |
+
processData : false,
|
175 |
+
xhr : function(){
|
176 |
+
//objects to interact with servers.
|
177 |
+
var _xhr = new window.XMLHttpRequest();
|
178 |
+
|
179 |
+
// reference : https://stackoverflow.com/questions/15410265/file-upload-progress-bar-with-jquery
|
180 |
+
_xhr.upload.addEventListener("progress", function(event){
|
181 |
+
if ( event.lengthComputable ) {
|
182 |
+
var percentComplete = ( event.loaded / event.total );
|
183 |
+
var percentage = parseInt( percentComplete * 100 );
|
184 |
+
|
185 |
+
// Progress Loading
|
186 |
+
CodeDropz_Object.setProgressBar( progressBarID, percentage );
|
187 |
+
|
188 |
+
}
|
189 |
+
}, false);
|
190 |
+
|
191 |
+
return _xhr;
|
192 |
+
},
|
193 |
+
complete : function() {
|
194 |
+
// Set progress bar to 100%
|
195 |
+
CodeDropz_Object.setProgressBar( progressBarID, 100 );
|
196 |
+
},
|
197 |
+
success: function(response) {
|
198 |
+
if( response.success ) {
|
199 |
+
|
200 |
+
// Callback on success
|
201 |
+
if ( $.isFunction( options.on_success ) ) {
|
202 |
+
options.on_success.call( this, input, progressBarID, response );
|
203 |
+
}
|
204 |
+
|
205 |
+
}else {
|
206 |
+
$('.dnd-progress-bar', $('#' + progressBarID)).remove();
|
207 |
+
$('.dnd-upload-details', $('#' + progressBarID)).append('<span class="has-error">'+ response.data +'</span>');
|
208 |
+
$('input[type="submit"]', form_handler ).removeClass('disabled').prop( "disabled", false );
|
209 |
+
}
|
210 |
+
},
|
211 |
+
error: function(xhr,ajax,thrownError ) {
|
212 |
+
$('.dnd-progress-bar', $('#' + progressBarID)).remove();
|
213 |
+
$('.dnd-upload-details', $('#' + progressBarID)).append('<span class="has-error">'+ options.server_max_error +'</span>');
|
214 |
+
$('input[type="submit"]', form_handler ).removeClass('disabled').prop( "disabled", false );
|
215 |
+
}
|
216 |
+
});
|
217 |
+
}
|
218 |
+
});
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
// CodeDropz object and functions
|
223 |
+
var CodeDropz_Object = {
|
224 |
+
|
225 |
+
// Create progress bar
|
226 |
+
createProgressBar : function( file ) {
|
227 |
+
|
228 |
+
// Setup progress bar variable
|
229 |
+
var upload_handler = $('.codedropz-upload-handler', options_handler ),
|
230 |
+
generated_ID = 'dnd-file-' + Math.random().toString(36).substr(2, 9);
|
231 |
+
|
232 |
+
// Setup progressbar elements
|
233 |
+
var fileDetails = '<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div>'
|
234 |
+
+ '<div class="dnd-upload-details">'
|
235 |
+
+ '<span class="name">'+ file.name +' <em>('+ CodeDropz_Object.bytesToSize( file.size ) +')</em></span>'
|
236 |
+
+ '<a href="javascript:void(0)" title="Remove" class="remove-file" data-storage="'+ dataStorageName +'"><span class="dnd-icon-remove"></span></a>'
|
237 |
+
+ '<span class="dnd-progress-bar"><span></span></span>'
|
238 |
+
+ '</div>';
|
239 |
+
|
240 |
+
// Append Status Bar
|
241 |
+
upload_handler.after('<div id="'+ generated_ID +'" class="dnd-upload-status">'+ fileDetails +'</div>');
|
242 |
+
|
243 |
+
return generated_ID;
|
244 |
+
},
|
245 |
+
|
246 |
+
// Process progressbar ( Animate progress )
|
247 |
+
setProgressBar : function( statusbar, percent ) {
|
248 |
+
var statusBar = $( '.dnd-progress-bar', $('#' + statusbar) );
|
249 |
+
if( statusBar.length > 0 ) {
|
250 |
+
// Disable submit button
|
251 |
+
CodeDropz_Object.disableBtn( btnOBJ );
|
252 |
+
|
253 |
+
// Compute Progress bar
|
254 |
+
progress_width = ( percent * statusBar.width() / 100);
|
255 |
+
|
256 |
+
$('span', statusBar ).addClass('in-progress').animate({ width: progress_width }, 10).text( percent + '% ');
|
257 |
+
if( percent == 100 ) {
|
258 |
+
$('span', statusBar ).addClass('complete').removeClass('in-progress');
|
259 |
+
}
|
260 |
+
}
|
261 |
+
return false;
|
262 |
+
},
|
263 |
+
|
264 |
+
// Size Conversion
|
265 |
+
bytesToSize : function( bytes ) {
|
266 |
+
|
267 |
+
if( bytes === 0 )
|
268 |
+
return '0';
|
269 |
+
|
270 |
+
kBytes = (bytes / 1024);
|
271 |
+
fileSize = ( kBytes >= 1024 ? ( kBytes / 1024 ).toFixed(2) + 'MB' : kBytes.toFixed(2) + 'KB' );
|
272 |
+
|
273 |
+
return fileSize;
|
274 |
+
},
|
275 |
+
|
276 |
+
// Disable button
|
277 |
+
disableBtn : function( BtnOJB ) {
|
278 |
+
if( BtnOJB.length > 0 ) {
|
279 |
+
BtnOJB.addClass('disable').prop( "disabled", true );
|
280 |
+
}
|
281 |
+
}
|
282 |
+
};
|
283 |
+
});// end each
|
284 |
+
|
285 |
+
// Remove File
|
286 |
+
$(document).on("click",'.dnd-icon-remove',function(e){
|
287 |
+
var _self = $(this), _dnd_status = _self.parents('.dnd-upload-status'), _parent_wrap = _self.parents('.codedropz-upload-wrapper');
|
288 |
+
var removeStorageData = _self.parent('a').attr('data-storage');
|
289 |
+
|
290 |
+
// If file upload is in progress don't delete
|
291 |
+
if( $('span.in-progress', _dnd_status ).length > 0 ) {
|
292 |
+
return false;
|
293 |
+
}
|
294 |
+
|
295 |
+
// Direct remove the file if there's any error.
|
296 |
+
if( $( '.has-error', _dnd_status ).length > 0 ) {
|
297 |
+
_dnd_status.remove(); localStorage.setItem( removeStorageData, ( Number( localStorage.getItem( removeStorageData ) ) - 1 ) );
|
298 |
+
return false;
|
299 |
+
}
|
300 |
+
|
301 |
+
// Change text Status
|
302 |
+
_self.addClass('deleting').text('deleting...');
|
303 |
+
|
304 |
+
// Request ajax image delete
|
305 |
+
$.post( settings.ajax_url, { path : _dnd_status.find('input[type="hidden"]').val(), 'action' : 'dnd_codedropz_upload_delete', security : dnd_cf7_uploader.ajax_nonce }, function(response) {
|
306 |
+
if( response.success ) {
|
307 |
+
|
308 |
+
// Reduce file count and status bar element.
|
309 |
+
_dnd_status.remove(); localStorage.setItem( removeStorageData, ( Number( localStorage.getItem( removeStorageData ) ) - 1 ) );
|
310 |
+
|
311 |
+
// Remove error msg
|
312 |
+
if( $('.dnd-upload-status', _parent_wrap ).length <= 1 ) {
|
313 |
+
$('span.has-error-msg', _parent_wrap ).remove();
|
314 |
+
}
|
315 |
+
}
|
316 |
+
});
|
317 |
+
});
|
318 |
+
|
319 |
+
}; // end fn.function
|
320 |
+
|
321 |
+
}( jQuery ));
|
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.2
|
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.2' );
|
25 |
|
26 |
/** Define constant Plugin Directories */
|
27 |
define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
|
inc/dnd-upload-cf7.php
CHANGED
@@ -29,6 +29,7 @@
|
|
29 |
add_action('wp_ajax_dnd_codedropz_upload_delete','dnd_codedropz_upload_delete');
|
30 |
|
31 |
// Hook mail cf7
|
|
|
32 |
add_action('wpcf7_before_send_mail','dnd_cf7_before_send_mail', 30, 1);
|
33 |
add_action('wpcf7_mail_components','dnd_cf7_mail_components', 50, 2);
|
34 |
|
@@ -49,6 +50,35 @@
|
|
49 |
load_plugin_textdomain( 'dnd-upload-cf7', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages' );
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
// Hooks for admin settings
|
53 |
function dnd_admin_settings() {
|
54 |
add_submenu_page( 'wpcf7', 'Drag & Drop Uploader - Settings', 'Drag & Drop Upload', 'manage_options', 'drag-n-drop-upload','dnd_upload_admin_settings');
|
@@ -192,10 +222,10 @@
|
|
192 |
foreach( $fields as $field ) {
|
193 |
if( $field->basetype == 'mfile') {
|
194 |
if( isset( $submitted['posted_data'][$field->name] ) && ! empty( $submitted['posted_data'][$field->name] ) ) {
|
195 |
-
$files = implode( "\n"
|
196 |
-
$mail['body'] = str_replace( "[$field->name]", "\n" . $
|
197 |
if( $mail_2['active'] ) {
|
198 |
-
$mail_2['body'] = str_replace( "[$field->name]", "\n" . $
|
199 |
}
|
200 |
}
|
201 |
}
|
@@ -655,13 +685,13 @@
|
|
655 |
|
656 |
// Save admin settings
|
657 |
function dnd_upload_register_settings() {
|
658 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_mail_attachment' );
|
659 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_text' );
|
660 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_separator' );
|
661 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_browse_text' );
|
662 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_server_limit' );
|
663 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_failed_to_upload' );
|
664 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_files_too_large' );
|
665 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_invalid_file' );
|
666 |
-
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_max_file' );
|
667 |
}
|
29 |
add_action('wp_ajax_dnd_codedropz_upload_delete','dnd_codedropz_upload_delete');
|
30 |
|
31 |
// Hook mail cf7
|
32 |
+
add_filter('wpcf7_posted_data', 'dnd_wpcf7_posted_data', 10, 1);
|
33 |
add_action('wpcf7_before_send_mail','dnd_cf7_before_send_mail', 30, 1);
|
34 |
add_action('wpcf7_mail_components','dnd_cf7_mail_components', 50, 2);
|
35 |
|
50 |
load_plugin_textdomain( 'dnd-upload-cf7', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages' );
|
51 |
}
|
52 |
|
53 |
+
// Modify contact form posted_data
|
54 |
+
function dnd_wpcf7_posted_data( $posted_data ){
|
55 |
+
|
56 |
+
// Subbmisson instance from CF7
|
57 |
+
$submission = WPCF7_Submission::get_instance();
|
58 |
+
|
59 |
+
// Make sure we have the data
|
60 |
+
if ( ! $posted_data ) {
|
61 |
+
$posted_data = $submission->get_posted_data();
|
62 |
+
}
|
63 |
+
|
64 |
+
// Scan and get all form tags from cf7 generator
|
65 |
+
$forms_tags = $submission->get_contact_form();
|
66 |
+
$uploads_dir = dnd_get_upload_dir();
|
67 |
+
|
68 |
+
if( $forms = $forms_tags->scan_form_tags() ) {
|
69 |
+
foreach( $forms as $field ) {
|
70 |
+
$field_name = $field->name;
|
71 |
+
if( $field->basetype == 'mfile' && isset( $posted_data[$field_name] ) && ! empty( $posted_data[$field_name] ) ) {
|
72 |
+
foreach( $posted_data[$field_name] as $key => $file ) {
|
73 |
+
$posted_data[$field_name][$key] = trailingslashit( $uploads_dir['upload_url'] ) . basename( $file );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
return $posted_data;
|
80 |
+
}
|
81 |
+
|
82 |
// Hooks for admin settings
|
83 |
function dnd_admin_settings() {
|
84 |
add_submenu_page( 'wpcf7', 'Drag & Drop Uploader - Settings', 'Drag & Drop Upload', 'manage_options', 'drag-n-drop-upload','dnd_upload_admin_settings');
|
222 |
foreach( $fields as $field ) {
|
223 |
if( $field->basetype == 'mfile') {
|
224 |
if( isset( $submitted['posted_data'][$field->name] ) && ! empty( $submitted['posted_data'][$field->name] ) ) {
|
225 |
+
$files = implode( "\n" , $submitted['posted_data'][$field->name] );
|
226 |
+
$mail['body'] = str_replace( "[$field->name]", "\n" . $files, $mail['body'] );
|
227 |
if( $mail_2['active'] ) {
|
228 |
+
$mail_2['body'] = str_replace( "[$field->name]", "\n" . $files, $mail_2['body'] );
|
229 |
}
|
230 |
}
|
231 |
}
|
685 |
|
686 |
// Save admin settings
|
687 |
function dnd_upload_register_settings() {
|
688 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_mail_attachment','sanitize_text_field' );
|
689 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_text','sanitize_text_field' );
|
690 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_separator','sanitize_text_field' );
|
691 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_browse_text','sanitize_text_field' );
|
692 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_server_limit','sanitize_text_field' );
|
693 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_failed_to_upload','sanitize_text_field' );
|
694 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_files_too_large','sanitize_text_field' );
|
695 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_invalid_file','sanitize_text_field' );
|
696 |
+
register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_max_file','sanitize_text_field' );
|
697 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
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.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,12 +50,16 @@ Checkout available features on **PRO version**.
|
|
50 |
* Improved Security
|
51 |
* Optimized Code and Performance
|
52 |
* 1 Month Premium Support
|
|
|
|
|
|
|
|
|
53 |
|
54 |
You can get [PRO Version here](https://www.codedropz.com/purchase-plugin/)!
|
55 |
|
56 |
### Other Plugin You May Like
|
57 |
|
58 |
-
* [Drag & Drop Multiple File Upload - WPForms](https://www.codedropz.com/drag-drop-file-uploader-wpforms/)
|
59 |
An extension for **WPForms** - Transform your simple file upload into beautiful **"Drag & Drop Multiple File Upload"**.
|
60 |
|
61 |
== Frequently Asked Questions ==
|
@@ -116,6 +120,10 @@ To install this plugin see below:
|
|
116 |
|
117 |
== Changelog ==
|
118 |
|
|
|
|
|
|
|
|
|
119 |
= 1.3.1 =
|
120 |
* Fixed - Browser Compatibility ( Error Uploading files in Edge, Safari and Internet Explorer )
|
121 |
* Improved - Removed error text if there are muliple error ( File upload validation )
|
2 |
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.3.2
|
6 |
+
Stable tag: 1.3.2
|
7 |
Requires PHP: 5.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
50 |
* Improved Security
|
51 |
* Optimized Code and Performance
|
52 |
* 1 Month Premium Support
|
53 |
+
* Chunks Upload *( Break large files into smaller Chunks )* - **Coming Soon**
|
54 |
+
* Max Total Size *( All Uploaded Files )* - **Coming Soon**
|
55 |
+
* Parallel/Sequential Upload *( Number of files to simultaneously upload )* - **Coming Soon**
|
56 |
+
|
57 |
|
58 |
You can get [PRO Version here](https://www.codedropz.com/purchase-plugin/)!
|
59 |
|
60 |
### Other Plugin You May Like
|
61 |
|
62 |
+
* [Drag & Drop Multiple File Upload - WPForms](https://www.codedropz.com/drag-drop-file-uploader-wpforms/)
|
63 |
An extension for **WPForms** - Transform your simple file upload into beautiful **"Drag & Drop Multiple File Upload"**.
|
64 |
|
65 |
== Frequently Asked Questions ==
|
120 |
|
121 |
== Changelog ==
|
122 |
|
123 |
+
= 1.3.2 =
|
124 |
+
* Fixed - Sanitized Admin Option Fields - For Security Reason
|
125 |
+
* Added - Filter for `wpcf7_posted_data` from CF7 to get the full link of the file.
|
126 |
+
|
127 |
= 1.3.1 =
|
128 |
* Fixed - Browser Compatibility ( Error Uploading files in Edge, Safari and Internet Explorer )
|
129 |
* Improved - Removed error text if there are muliple error ( File upload validation )
|