PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.19
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.19
1.2.73 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 All 173 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.19, at admin/settings/admin-settings-ie-users.php

435 lines 18.8 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
94 <div class="metabox-holder uwp-ie-container">
95 <div class="postbox uwp-export-users">
96 <h3><span><?php _e( 'Export Users Data', 'userswp' ); ?></span></h3>
97 <div class="inside">
98 <p><?php _e( 'Download a CSV of all users data for usersWP.', 'invoicing' ); ?></p>
99 <form id="uwp-export-users" class="uwp-export-users-form" method="post">
100 <div class="uwp-export-submit-wrap">
101 <input type="hidden" name="uwp_ie_action" value="export_users" />
102 <?php wp_nonce_field( 'uwp_export_users_nonce', 'uwp_export_users_nonce' ); ?>
103 <?php submit_button( __( 'Export CSV' ), 'primary', 'submit', false ); ?>
104 </div>
105 </form>
106 </div>
107 </div>
108
109 <div class="postbox">
110 <h3><span><?php _e( 'Import Users' ); ?></span></h3>
111 <div class="inside" id="uwp-imp-container">
112 <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>
113 <form method="post" enctype="multipart/form-data" class="uwp-import-users-form">
114 <p class="uwp-imp-uploaded-file">
115 <a id="uwp-imp-browse" class="button file-selector button-primary" href="#"><?php _e( 'Select File', 'userswp' ); ?></a>
116 </p>
117 <p>
118 <input type="hidden" value="" name="uwp_import_users_file" class="uwp_import_users_file">
119 <?php wp_nonce_field( 'uwp_import_users_nonce', 'uwp_import_users_nonce' ); ?>
120 <?php submit_button( __( 'Import', 'userswp' ), 'primary', 'submit', false ); ?>
121 </p>
122 </form>
123 </div>
124 </div>
125 </div>
126
127 <script type="text/javascript">
128 jQuery(function($) {
129 var UWP_IE = {
130 init: function() {
131 this.submit();
132 this.clearMessage();
133 },
134 submit: function() {
135 var $this = this;
136 $('.uwp-export-users-form').submit(function(e) {
137 e.preventDefault();
138 var $form = $(this);
139 var submitBtn = $form.find('input[type="submit"]');
140 if (!submitBtn.attr('disabled')) {
141 var data = $form.serialize();
142 submitBtn.attr('disabled', true);
143 $form.find('.uwp-msg-wrap').remove();
144 $form.append('<div class="uwp-msg-wrap"><div class="uwp-progress"><div></div><span>0%</span></div><span class="uwp-export-loader"><i class="fa fa-spin fa-spinner"></i></span></div>');
145 // start the process
146 $this.step(1, data, $form, $this);
147 }
148 });
149 $('.uwp-import-users-form').submit(function(e) {
150 e.preventDefault();
151 var $form = $(this);
152 var submitBtn = $form.find('input[type="submit"]');
153 submitBtn.hide();
154 if (!submitBtn.attr('disabled')) {
155 var data = $form.serialize();
156 submitBtn.attr('disabled', true);
157 $form.find('.uwp-msg-wrap').remove();
158 $form.append('<div class="uwp-msg-wrap"><div class="uwp-progress"><div></div><span>0%</span></div><span class="uwp-import-loader"><i class="fa fa-spin fa-spinner"></i></span></div>');
159 $form.find('.uwp-msg-wrap').append('<div class="uwp-ie-report"></div>');
160 // start the process
161 $this.imp_step(1, data, $form, $this);
162 }
163 });
164 },
165 step: function(step, data, $form, $this) {
166 var message = $form.find('.uwp-msg-wrap');
167 var post_data = {
168 action: 'uwp_ajax_export_users',
169 step: step,
170 data: data,
171 };
172 $.ajax({
173 url: ajaxurl,
174 type: 'POST',
175 cache: false,
176 dataType: 'json',
177 data: post_data,
178 beforeSend: function(jqXHR, settings) {},
179 success: function(res) {
180 if (res && typeof res == 'object') {
181 if (res.success) {
182 if ('done' == res.data.step || res.data.done >= 100) {
183 $form.find('input[type="submit"]').removeAttr('disabled');
184 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
185 $('.uwp-progress div').animate({
186 width: res.data.done + '%'
187 }, 100, function() {});
188 if (res.msg) {
189 message.html('<div id="uwp-export-success" class="updated notice is-dismissible"><p>' + msg + '<span class="notice-dismiss"></span></p></div>');
190 }
191 if (res.data.file && res.data.file.u) {
192 message.append('<span class="uwp-export-file"><a href="' + res.data.file.u + '" target="_blank"><i class="fa fa-download"></i> ' + res.data.file.u + '</a><span> - ' + res.data.file.s + '<span><span>');
193 }
194 message.find('.uwp-export-loader').html('<i class="fa fa-check-circle"></i>');
195 } else {
196 var next = parseInt(res.data.step) > 0 ? parseInt(res.data.step) : 1;
197 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
198 $('.uwp-progress div').animate({
199 width: res.data.done + '%'
200 }, 100, function() {});
201 $this.step(parseInt(next), data, $form, $this);
202 }
203 } else {
204 $form.find('input[type="submit"]').removeAttr('disabled');
205 if (res.msg) {
206 message.html('<div class="updated error"><p>' + res.msg + '</p></div>');
207 }
208 }
209 } else {
210 $form.find('input[type="submit"]').removeAttr('disabled');
211 message.html('<div class="updated error">' + res + '</div>');
212 }
213 }
214 }).fail(function(res) {
215 if (window.console && window.console.log) {
216 console.log(res);
217 }
218 });
219 },
220 imp_step: function(step, data, $form, $this) {
221 var message = $form.find('.uwp-msg-wrap');
222 var post_data = {
223 action: 'uwp_ajax_import_users',
224 step: step,
225 data: data,
226 };
227 $.ajax({
228 url: ajaxurl,
229 type: 'POST',
230 cache: false,
231 dataType: 'json',
232 data: post_data,
233 beforeSend: function(jqXHR, settings) {},
234 success: function(res) {
235 if (res && typeof res == 'object') {
236 if (res.success) {
237 if (res.total.msg) {
238 message.find('.uwp-ie-report').append('<p>' + res.total.msg + '</p>');
239 }
240 if ('done' == res.data.step || res.data.done >= 100) {
241 $form.find('input[type="submit"]').removeAttr('disabled');
242 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
243 $('.uwp-progress div').animate({
244 width: res.data.done + '%'
245 }, 100, function() {});
246 if (res.msg) {
247 message.append('<div id="uwp-export-success" class="updated notice is-dismissible"><p>' + res.msg + '<span class="notice-dismiss"></span></p></div>');
248 }
249 message.find('.uwp-import-loader').html('<i class="fa fa-check-circle"></i>');
250 } else {
251 var next = parseInt(res.data.step) > 0 ? parseInt(res.data.step) : 1;
252 $('.uwp-progress > span').text(parseInt(res.data.done) + '%');
253 $('.uwp-progress div').animate({
254 width: res.data.done + '%'
255 }, 100, function() {});
256 if (res.data.msg) {
257 message.find('.uwp-ie-report').append('<p>' + res.data.msg + '</p>');
258 }
259 $this.imp_step(parseInt(next), data, $form, $this);
260 }
261 } else {
262 $form.find('input[type="submit"]').removeAttr('disabled');
263 if (res.msg) {
264 message.html('<div class="updated error"><p>' + res.msg + '</p></div>');
265 }
266 }
267 } else {
268 $form.find('input[type="submit"]').removeAttr('disabled');
269 message.html('<div class="updated error">' + res + '</div>');
270 }
271 }
272 }).fail(function(res) {
273 if (window.console && window.console.log) {
274 console.log(res);
275 }
276 });
277 },
278 clearMessage: function() {
279 $('body').on('click', '#uwp-export-success .notice-dismiss', function() {
280 $(this).closest('#uwp-export-success').parent().slideUp('fast');
281 });
282 $('body').on('click', '#uwp-import-success .notice-dismiss', function() {
283 $(this).closest('#uwp-import-success').parent().slideUp('fast');
284 });
285 }
286 };
287 UWP_IE.init();
288
289 window.UWP_IE_Uploader = function (browse_button, container, max, type, allowed_type, max_file_size) {
290 this.removed_files = [],
291 this.container = container;
292 this.browse_button = browse_button;
293 this.max = max || 1;
294 this.count = $('#' + container).find('.uwp-attachment-list > li').length; //count how many items are there
295 this.perFileCount = 0;
296 if( !$('#'+browse_button).length ) {
297 return;
298 }
299
300 this.uploader = new plupload.Uploader({
301 runtimes: 'html5,html4',
302 browse_button: browse_button,
303 container: container,
304 multipart: true,
305 multipart_params: {
306 action: 'uwp_ie_upload_file',
307 },
308 max_file_count : 1,
309 urlstream_upload: true,
310 file_data_name: 'import_file',
311 max_file_size: max_file_size + 'kb',
312 url: '<?php echo admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'uwp-ie-file-upload-nonce' ); ?>' + '&type=' + type,
313 filters: [{
314 title: '<?php _e('Allowed Files', 'userswp'); ?>',
315 extensions: allowed_type
316 }]
317 });
318
319 //attach event handlers
320 this.uploader.bind('Init', $.proxy(this, 'init'));
321 this.uploader.bind('FilesAdded', $.proxy(this, 'added'));
322 this.uploader.bind('QueueChanged', $.proxy(this, 'upload'));
323 this.uploader.bind('UploadProgress', $.proxy(this, 'progress'));
324 this.uploader.bind('Error', $.proxy(this, 'error'));
325 this.uploader.bind('FileUploaded', $.proxy(this, 'uploaded'));
326
327 this.uploader.init();
328
329 return this.uploader;
330 };
331
332 UWP_IE_Uploader.prototype = {
333
334 init: function (up, params) {
335 this.showHide();
336 $('#' + this.container).prepend('<div class="uwp-file-warning"></div>');
337 },
338
339 showHide: function () {
340
341 if ( this.count >= this.max) {
342
343 if ( this.count > this.max ) {
344 $('#' + this.container + ' .uwp-file-warning').addClass('error').html( '<?php _e( 'Maximum number of files reached!', 'userswp' ); ?>' );
345 $('#' + this.container).find('.file-selector').hide();
346
347 return;
348 }
349 };
350 $('#' + this.container + ' .uwp-file-warning').removeClass('error').html( '' );
351 $('#' + this.container).find('.file-selector').show();
352 },
353
354 added: function (up, files) {
355 var $container = $('#' + this.container).find('.uwp-imp-uploaded-file');
356
357 this.showHide();
358 $('.uwp-import-users-form').find('.uwp-msg-wrap').remove();
359
360 $.each(files, function(i, file) {
361 $container.append(
362 '<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="fa fa-spin fa-spinner"></i></span><span class="uwp-import-file filename original">' +
363 file.name + '<span> - ' + plupload.formatSize(file.size) + '</span></span>' +
364 '</div></div>');
365 });
366
367 up.refresh();
368 up.start();
369 },
370
371 upload: function (uploader) {
372
373 this.count = uploader.files.length - this.removed_files.length ;
374 this.showHide();
375
376 },
377
378 progress: function (up, file) {
379 var item = $('#' + file.id);
380
381 $('.bar', item).css({ width: file.percent + '%' });
382 $('.percent', item).html( file.percent + '%' );
383 },
384
385 error: function (up, error) {
386 $('#' + this.container).find('#' + error.file.id).remove();
387
388 var msg = '';
389 switch (error.code) {
390 case -600:
391 msg = '<?php _e( 'The file you have uploaded exceeds the file size limit. Please try again.', 'userswp' ); ?>'
392 break;
393
394 case -601:
395 msg = '<?php _e( 'Invalid file uploaded. Please upload .csv file. Please try again.', 'userswp' ); ?>'
396 break;
397
398 default:
399 msg = 'Error #' + error.code + ': ' + error.message;
400 break;
401 }
402
403 alert(msg);
404
405 this.count -= 1;
406 this.showHide();
407 this.uploader.refresh();
408 },
409
410 uploaded: function (up, file, response) {
411 var self = this;
412
413 $('#' + file.id + " .percent").html("100%");
414 $('#' + file.id).find('.uwp-import-loader').html('<i class="fa fa-check-circle"></i>');
415
416 if(response.response !== 'error') {
417 $('#' + this.container).find('.file-selector').hide();
418 $('.uwp-import-users-form').find('input[type="submit"]').show();
419 $('.uwp-import-users-form').find('.uwp_import_users_file').val(response.response);
420
421 } else {
422 alert(response.error);
423
424 this.count -= 1;
425 this.showHide();
426 }
427 },
428
429 };
430
431 $(document).ready( function(){
432 var uploader = new UWP_IE_Uploader('uwp-imp-browse', 'uwp-imp-container', 1, 'uwp_ie_import_file', 'csv', 2048);
433 });
434 });
435 </script>