PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.21
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.21
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
← All changes | assets/js/weforms.js +28 -9 1.6.51.6.21 View file →
@@ -10,9 +10,24 @@
10 10 $(this).width(liw-s);
11 11 });
12 12 });
13 13 };
14 -
14 + $.fn.extend({
15 + /**
16 + * Custom jQuery serialize wrapper.
17 + *
18 + * When WordPress 5.6 increased the jQuery version to 3.5.1, the serialize function changed. Instead of
19 + * sending spaces as "+", they are sent as "%20". This wrapper is for backwards compatibility.
20 + *
21 + * @todo This function is duplicated in both the frontend and backend. Need to have the code live in
22 + * just one location.
23 + *
24 + * @since 1.6.7
25 + */
26 + weSerialize: function() {
27 + return $( this ).serialize().replaceAll( '%20', '+' );
28 + },
29 + });
15 30 window.WP_User_Frontend = {
16 31
17 32 init: function() {
18 33
@@ -307,9 +322,9 @@
307 322 e.preventDefault();
308 323
309 324 var self = $(this),
310 325 form = $(this).closest('form'),
311 - form_data = form.serialize() + '&action=wpuf_draft_post',
326 + form_data = form.weSerialize() + '&action=wpuf_draft_post',
312 327 post_id = form.find('input[type="hidden"][name="post_id"]').val();
313 328
314 329 var rich_texts = [],
315 330 val;
@@ -353,9 +368,9 @@
353 368 account_update_profile: function (e) {
354 369 e.preventDefault();
355 370 var form = $(this).closest('form');
356 371
357 - $.post(wpuf_frontend.ajaxurl, form.serialize(), function (res) {
372 + $.post(wpuf_frontend.ajaxurl, form.weSerialize(), function (res) {
358 373 if (res.success) {
359 374 form.find('.wpuf-error').hide();
360 375 form.find('.wpuf-success').show();
361 376 } else {
@@ -462,15 +477,13 @@
462 477 // remove all initial errors if any
463 478 WP_User_Frontend.removeErrors(self);
464 479 WP_User_Frontend.removeErrorNotice(self);
465 480
466 - // ===== Validate: Text and Textarea ========
481 + // Validate: Required Fields
467 482 var required = self.find('[data-required="yes"]:visible');
468 483
469 484 required.each(function(i, item) {
470 - // temp_val = $.trim($(item).val());
471 485
472 - // console.log( $(item).data('type') );
473 486 var data_type = $(item).data('type')
474 487 val = '';
475 488
476 489 switch(data_type) {
@@ -645,9 +658,9 @@
645 658
646 659 return false;
647 660 }
648 661
649 - var form_data = self.serialize(),
662 + var form_data = self.weSerialize(),
650 663 rich_texts = [];
651 664
652 665 // grab rich texts from tinyMCE
653 666 $('.wpuf-rich-validation', self).each(function (index, item) {
@@ -715,11 +728,17 @@
715 728 isValidEmail: function( email ) {
716 729 var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
717 730 return pattern.test(email);
718 731 },
719 -
732 + /**
733 + * Validate a url.
734 + *
735 + * While we could use the standard HTML5 form validator for urls, this regex does a more thorough job.
736 + *
737 + * @link https://gist.github.com/dperini/729294
738 + */
720 739 isValidURL: function(url) {
721 - var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.|http:\/\/|https:\/\/){1}([0-9A-Za-z]+\.)");
740 + var urlregex = new RegExp(/^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/);
722 741 return urlregex.test(url);
723 742 },
724 743
725 744 insertImage: function(button, form_id) {