PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.22
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.22
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / admin / settings / admin-settings-ie-users.php

admin-settings-ie-users.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.22, at admin/settings/admin-settings-ie-users.php

466 lines 20.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 wp_enqueue_script( 'plupload' );
3 ?>
4 <style type="text/css">
5 .uwp-export-submit-wrap [type="submit"] {
6 vertical-align: top;
7 line-height: normal;
8 }
9 .uwp-ie-container .uwp-progress {
10 width: calc(100% - 50px);
11 height: 16px;
12 background-color: #ddd;
13 float: left;
14 position: relative;
15 }
16 .uwp-ie-container .uwp-progress div {
17 background-color: orange;
18 height: 100%;
19 width: 0;
20 display: block
21 }
22 .uwp-ie-container .uwp-progress > span {
23 position: absolute;
24 height: 100%;
25 width: 100%;
26 display: block;
27 font-size: 13px;
28 line-height: 14px;
29 text-align: center;
30 vertical-align: top;
31 top: 0;
32 }
33 .uwp-ie-container .uwp-msg-wrap {
34 padding: 12px;
35 background-color: #f4f4f4;
36 border-style: solid;
37 border-width: 1px 0;
38 border-color: #eae9e9;
39 overflow: auto;
40 margin: 20px -12px -23px;
41 position: relative;
42 }
43
44 .uwp-ie-container .uwp-import-users-form input[type="submit"]{
45 display: none;
46 }
47 .uwp-ie-container .uwp-import-users-form .uwp-msg-wrap{
48 margin: 20px 0;
49 }
50 .uwp-ie-container .uwp-msg-wrap .uwp-export-loader, .uwp-ie-container .uwp-msg-wrap .uwp-import-loader {
51 display: inline-block;
52 float: right;
53 margin: 0;
54 vertical-align: middle;
55 width: 40px;
56 height: 16px;
57 text-align: center;
58 }
59 .uwp-ie-container .uwp-export-loader .fa, .uwp-ie-container .uwp-import-loader .fa {
60 font-size: 17px;
61 color: orange;
62 }
63 .uwp-ie-container .uwp-export-loader .fa-spin, .uwp-ie-container .uwp-import-loader .fa-spin {
64 color: #000;
65 }
66 .uwp-msg-wrap .updated {
67 margin: 0 0 2px 0 !important;
68 }
69 .uwp-export-file, .uwp-import-file {
70 display: block;
71 padding-top: 7px;
72 clear: both;
73 display: block;
74 }
75 .uwp-export-file a, .uwp-import-file a {
76 text-decoration: none;
77 }
78 .uwp-import-users-form .uwp-ie-report {
79 max-height: 120px;
80 overflow-y: scroll;
81 width: auto;
82 background-color: #fffbcc;
83 padding: 0px 10px;
84 margin: 30px 0 0 0;
85 }
86
87 .uwp-import-users-form .uwp-ie-report p {
88 font-size: 12px;
89 margin: 7px 0px;
90 padding: 0;
91 }
92 </style>
93 <?php
94 $uwp_chunk_sizes = array(
95 50 => 50,
96 100 => 100,
97 200 => 200,
98 500 => 500,
99 1000 => 1000,
100 2000 => 2000,
101 5000 => 5000,
102 10000 => 10000,
103 20000 => 20000,
104 50000 => 50000,
105 100000 => 100000,
106 );
107
108 $uwp_chunk_sizes = apply_filters('uwp_ie_csv_chunks_options', $uwp_chunk_sizes);
109 $uwp_chunk_sizes_opts = '';
110 foreach ($uwp_chunk_sizes as $value => $title) {
111 $uwp_chunk_sizes_opts .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>';
112 }
113
114 $users_count = count_users();
115 $total_users = $users_count['total_users'];
116 ?>
117 <div class="metabox-holder uwp-ie-container">
118 <div class="postbox uwp-export-users">
119 <h3><span><?php _e( 'Export Users Data', 'userswp' ); ?></span></h3>
120 <div class="inside">
121 <p><?php _e( 'Download a CSV of all users data for usersWP.', 'invoicing' ); ?></p>
122 <form id="uwp-export-users" class="uwp-export-users-form" method="post">
123 <table class="form-table">
124 <tbody>
125 <tr>
126 <th class=""><label for="uwp_ie_chunk_size"><?php _e( 'Max entries per csv file:', 'userswp' );?></label></th>
127 <td><select name="uwp_ie_chunk_size" id="uwp_ie_chunk_size" data-ucount = "<?php echo $total_users;?>" style="min-width:140px"><?php echo $uwp_chunk_sizes_opts;?></select><p class="description"><?php _e( 'The maximum number of entries per csv file (default to 5000, you might want to lower this to prevent memory issues.)', 'userswp' );?></p></td>
128 </tr>
129 </tbody>
130 </table>
131 <div class="uwp-export-submit-wrap">
132 <input type="hidden" name="uwp_ie_action" value="export_users" />
133 <?php wp_nonce_field( 'uwp_export_users_nonce', 'uwp_export_users_nonce' ); ?>
134 <?php submit_button( __( 'Export CSV' ), 'primary', 'submit', false ); ?>
135 </div>
136 </form>
137 </div>
138 </div>
139
140 <div class="postbox">
141 <h3><span><?php _e( 'Import Users' ); ?></span></h3>
142 <div class="inside" id="uwp-imp-container">
143 <p><?php _e( 'Import the users data from a .csv file. This file can be obtained by exporting the data on another site using the form above.' ); ?></p>
144 <form method="post" enctype="multipart/form-data" class="uwp-import-users-form">
145 <p class="uwp-imp-uploaded-file">
146 <a id="uwp-imp-browse" class="button file-selector button-primary" href="#"><?php _e( 'Select File', 'userswp' ); ?></a>
147 </p>
148 <p>
149 <input type="hidden" value="" name="uwp_import_users_file" class="uwp_import_users_file">
150 <?php wp_nonce_field( 'uwp_import_users_nonce', 'uwp_import_users_nonce' ); ?>
151 <?php submit_button( __( 'Import', 'userswp' ), 'primary', 'submit', false ); ?>
152 </p>
153 </form>
154 </div>
155 </div>
156 </div>
157
158 <script type="text/javascript">
159 jQuery(function($) {
160 var UWP_IE = {
161 init: function() {
162 this.submit();
163 this.clearMessage();
164 },
165 submit: function() {
166 var $this = this;
167 $('.uwp-export-users-form').submit(function(e) {
168 e.preventDefault();
169 var $form = $(this);
170 var submitBtn = $form.find('input[type="submit"]');
171 if (!submitBtn.attr('disabled')) {
172 var data = $form.serialize();
173 submitBtn.attr('disabled', true);
174 $form.find('.uwp-msg-wrap').remove();
175 $form.append('<div class="uwp-msg-wrap"><div class="uwp-progress"><div></div><span>0%</span></div><span class="uwp-export-loader"><i class="fas fa-spin fa-spinner"></i></span></div>');
176 // start the process
177 $this.step(1, data, $form, $this);
178 }
179 });
180 $('.uwp-import-users-form').submit(function(e) {
181 e.preventDefault();
182 var $form = $(this);
183 var submitBtn = $form.find('input[type="submit"]');
184 submitBtn.hide();
185 if (!submitBtn.attr('disabled')) {
186 var data = $form.serialize();
187 submitBtn.attr('disabled', true);
188 $form.find('.uwp-msg-wrap').remove();
189 $form.append('<div class="uwp-msg-wrap"><div class="uwp-progress"><div></div><span>0%</span></div><span class="uwp-import-loader"><i class="fas fa-spin fa-spinner"></i></span></div>');
190 $form.find('.uwp-msg-wrap').append('<div class="uwp-ie-report"></div>');
191 // start the process
192 $this.imp_step(1, data, $form, $this);
193 }
194 });
195 },
196 step: function(step, data, $form, $this) {
197 var message = $form.find('.uwp-msg-wrap');
198 var post_data = {
199 action: 'uwp_ajax_export_users',
200 step: step,
201 data: data,
202 };
203 $.ajax({
204 url: ajaxurl,
205 type: 'POST',
206 cache: false,
207 dataType: 'json',
208 data: post_data,
209 beforeSend: function(jqXHR, settings) {},
210 success: function(res) {
211 if (res && typeof res == 'object') {
212 if (res.success) {
213 if ('done' == res.data.step || res.data.done >= 100) {
214 $form.find('input[type="submit"]').removeAttr('disabled');
215 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
216 $('.uwp-progress div').animate({
217 width: res.data.done + '%'
218 }, 100, function() {});
219 if (res.msg) {
220 message.html('<div id="uwp-export-success" class="updated notice is-dismissible"><p>' + msg + '<span class="notice-dismiss"></span></p></div>');
221 }
222 if (res.data.file && res.data.file.u) {
223 message.append('<span class="uwp-export-file"><a href="' + res.data.file.u + '" target="_blank"><i class="fas fa-download"></i> ' + res.data.file.u + '</a><span> - ' + res.data.file.s + '<span><span>');
224 }
225 message.find('.uwp-export-loader').html('<i class="fas fa-check-circle"></i>');
226 } else {
227 var next = parseInt(res.data.step) > 0 ? parseInt(res.data.step) : 1;
228 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
229 $('.uwp-progress div').animate({
230 width: res.data.done + '%'
231 }, 100, function() {});
232 $this.step(parseInt(next), data, $form, $this);
233 }
234 } else {
235 $form.find('input[type="submit"]').removeAttr('disabled');
236 if (res.msg) {
237 message.html('<div class="updated error"><p>' + res.msg + '</p></div>');
238 }
239 }
240 } else {
241 $form.find('input[type="submit"]').removeAttr('disabled');
242 message.html('<div class="updated error">' + res + '</div>');
243 }
244 }
245 }).fail(function(res) {
246 if (window.console && window.console.log) {
247 console.log(res);
248 }
249 });
250 },
251 imp_step: function(step, data, $form, $this) {
252 var message = $form.find('.uwp-msg-wrap');
253 var post_data = {
254 action: 'uwp_ajax_import_users',
255 step: step,
256 data: data,
257 };
258 $.ajax({
259 url: ajaxurl,
260 type: 'POST',
261 cache: false,
262 dataType: 'json',
263 data: post_data,
264 beforeSend: function(jqXHR, settings) {},
265 success: function(res) {
266 if (res && typeof res == 'object') {
267 if (res.success) {
268 if (res.total.msg) {
269 message.find('.uwp-ie-report').append('<p>' + res.total.msg + '</p>');
270 }
271 if ('done' == res.data.step || res.data.done >= 100) {
272 $form.find('input[type="submit"]').removeAttr('disabled');
273 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
274 $('.uwp-progress div').animate({
275 width: res.data.done + '%'
276 }, 100, function() {});
277 if (res.msg) {
278 message.append('<div id="uwp-export-success" class="updated notice is-dismissible"><p>' + res.msg + '<span class="notice-dismiss"></span></p></div>');
279 }
280 message.find('.uwp-import-loader').html('<i class="fas fa-check-circle"></i>');
281 } else {
282 var next = parseInt(res.data.step) > 0 ? parseInt(res.data.step) : 1;
283 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
284 $('.uwp-progress div').animate({
285 width: res.data.done + '%'
286 }, 100, function() {});
287 if (res.data.msg) {
288 message.find('.uwp-ie-report').append('<p>' + res.data.msg + '</p>');
289 }
290 $this.imp_step(parseInt(next), data, $form, $this);
291 }
292 } else {
293 $form.find('input[type="submit"]').removeAttr('disabled');
294 if (res.msg) {
295 message.html('<div class="updated error"><p>' + res.msg + '</p></div>');
296 }
297 }
298 } else {
299 $form.find('input[type="submit"]').removeAttr('disabled');
300 message.html('<div class="updated error">' + res + '</div>');
301 }
302 }
303 }).fail(function(res) {
304 if (window.console && window.console.log) {
305 console.log(res);
306 }
307 });
308 },
309 clearMessage: function() {
310 $('body').on('click', '#uwp-export-success .notice-dismiss', function() {
311 $(this).closest('#uwp-export-success').parent().slideUp('fast');
312 });
313 $('body').on('click', '#uwp-import-success .notice-dismiss', function() {
314 $(this).closest('#uwp-import-success').parent().slideUp('fast');
315 });
316 }
317 };
318 UWP_IE.init();
319
320 window.UWP_IE_Uploader = function (browse_button, container, max, type, allowed_type, max_file_size) {
321 this.removed_files = [],
322 this.container = container;
323 this.browse_button = browse_button;
324 this.max = max || 1;
325 this.count = $('#' + container).find('.uwp-attachment-list > li').length; //count how many items are there
326 this.perFileCount = 0;
327 if( !$('#'+browse_button).length ) {
328 return;
329 }
330
331 this.uploader = new plupload.Uploader({
332 runtimes: 'html5,html4',
333 browse_button: browse_button,
334 container: container,
335 multipart: true,
336 multipart_params: {
337 action: 'uwp_ie_upload_file',
338 },
339 max_file_count : 1,
340 urlstream_upload: true,
341 file_data_name: 'import_file',
342 max_file_size: max_file_size + 'kb',
343 url: '<?php echo admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'uwp-ie-file-upload-nonce' ); ?>' + '&type=' + type,
344 filters: [{
345 title: '<?php _e('Allowed Files', 'userswp'); ?>',
346 extensions: allowed_type
347 }]
348 });
349
350 //attach event handlers
351 this.uploader.bind('Init', $.proxy(this, 'init'));
352 this.uploader.bind('FilesAdded', $.proxy(this, 'added'));
353 this.uploader.bind('QueueChanged', $.proxy(this, 'upload'));
354 this.uploader.bind('UploadProgress', $.proxy(this, 'progress'));
355 this.uploader.bind('Error', $.proxy(this, 'error'));
356 this.uploader.bind('FileUploaded', $.proxy(this, 'uploaded'));
357
358 this.uploader.init();
359
360 return this.uploader;
361 };
362
363 UWP_IE_Uploader.prototype = {
364
365 init: function (up, params) {
366 this.showHide();
367 $('#' + this.container).prepend('<div class="uwp-file-warning"></div>');
368 },
369
370 showHide: function () {
371
372 if ( this.count >= this.max) {
373
374 if ( this.count > this.max ) {
375 $('#' + this.container + ' .uwp-file-warning').addClass('error').html( '<?php _e( 'Maximum number of files reached!', 'userswp' ); ?>' );
376 $('#' + this.container).find('.file-selector').hide();
377
378 return;
379 }
380 };
381 $('#' + this.container + ' .uwp-file-warning').removeClass('error').html( '' );
382 $('#' + this.container).find('.file-selector').show();
383 },
384
385 added: function (up, files) {
386 var $container = $('#' + this.container).find('.uwp-imp-uploaded-file');
387
388 this.showHide();
389 $('.uwp-import-users-form').find('.uwp-msg-wrap').remove();
390
391 $.each(files, function(i, file) {
392 $container.append(
393 '<div class="upload-item uwp-msg-wrap" id="' + file.id + '"><div class="uwp-progress"><div class="bar"></div><span class="percent">0%</span></div><span class="uwp-import-loader"><i class="fas fa-spin fa-spinner"></i></span><span class="uwp-import-file filename original">' +
394 file.name + '<span> - ' + plupload.formatSize(file.size) + '</span></span>' +
395 '</div></div>');
396 });
397
398 up.refresh();
399 up.start();
400 },
401
402 upload: function (uploader) {
403
404 this.count = uploader.files.length - this.removed_files.length ;
405 this.showHide();
406
407 },
408
409 progress: function (up, file) {
410 var item = $('#' + file.id);
411
412 $('.bar', item).css({ width: file.percent + '%' });
413 $('.percent', item).html( file.percent + '%' );
414 },
415
416 error: function (up, error) {
417 $('#' + this.container).find('#' + error.file.id).remove();
418
419 var msg = '';
420 switch (error.code) {
421 case -600:
422 msg = '<?php _e( 'The file you have uploaded exceeds the file size limit. Please try again.', 'userswp' ); ?>'
423 break;
424
425 case -601:
426 msg = '<?php _e( 'Invalid file uploaded. Please upload .csv file. Please try again.', 'userswp' ); ?>'
427 break;
428
429 default:
430 msg = 'Error #' + error.code + ': ' + error.message;
431 break;
432 }
433
434 alert(msg);
435
436 this.count -= 1;
437 this.showHide();
438 this.uploader.refresh();
439 },
440
441 uploaded: function (up, file, response) {
442 var self = this;
443
444 $('#' + file.id + " .percent").html("100%");
445 $('#' + file.id).find('.uwp-import-loader').html('<i class="fas fa-check-circle"></i>');
446
447 if(response.response !== 'error') {
448 $('#' + this.container).find('.file-selector').hide();
449 $('.uwp-import-users-form').find('input[type="submit"]').show();
450 $('.uwp-import-users-form').find('.uwp_import_users_file').val(response.response);
451
452 } else {
453 alert(response.error);
454
455 this.count -= 1;
456 this.showHide();
457 }
458 },
459
460 };
461
462 $(document).ready( function(){
463 var uploader = new UWP_IE_Uploader('uwp-imp-browse', 'uwp-imp-container', 1, 'uwp_ie_import_file', 'csv', 2048);
464 });
465 });
466 </script>