Ultimate Member – User Profile & Membership Plugin - Version 2.1.6

Version Description

Download this release

Release Info

Developer nsinelnikov
Plugin Icon 128x128 Ultimate Member – User Profile & Membership Plugin
Version 2.1.6
Comparing to
See all releases

Code changes from version 2.1.5 to 2.1.6

Files changed (43) hide show
  1. assets/js/um-account.js +9 -9
  2. assets/js/um-account.min.js +1 -1
  3. assets/js/um-conditional.js +193 -162
  4. assets/js/um-conditional.min.js +1 -1
  5. assets/js/um-functions.js +183 -183
  6. assets/js/um-functions.min.js +1 -1
  7. assets/js/um-modal.js +1 -1
  8. assets/js/um-modal.min.js +1 -1
  9. assets/js/um-profile.js +2 -2
  10. assets/js/um-profile.min.js +1 -1
  11. includes/admin/core/class-admin-builder.php +6 -1
  12. includes/admin/core/class-admin-forms.php +23 -3
  13. includes/admin/core/class-admin-metabox.php +34 -9
  14. includes/admin/core/class-admin-navmenu.php +116 -15
  15. includes/admin/core/class-admin-settings.php +80 -80
  16. includes/admin/core/list-tables/emails-list-table.php +14 -5
  17. includes/admin/templates/directory/general.php +11 -0
  18. includes/admin/templates/role/admin-permissions.php +39 -39
  19. includes/class-config.php +1 -0
  20. includes/core/class-enqueue.php +1 -1
  21. includes/core/class-fields.php +17 -5
  22. includes/core/class-login.php +76 -3
  23. includes/core/class-member-directory-meta.php +91 -20
  24. includes/core/class-member-directory.php +30 -1
  25. includes/core/class-modal.php +9 -1
  26. includes/core/class-roles-capabilities.php +16 -21
  27. includes/core/class-shortcodes.php +65 -21
  28. includes/core/class-user.php +1 -1
  29. includes/core/um-actions-account.php +90 -53
  30. includes/core/um-actions-form.php +49 -48
  31. includes/core/um-actions-global.php +1 -1
  32. includes/core/um-actions-login.php +9 -22
  33. includes/core/um-actions-profile.php +89 -14
  34. includes/core/um-actions-register.php +6 -1
  35. includes/core/um-actions-wpadmin.php +1 -5
  36. includes/core/um-filters-fields.php +3 -3
  37. includes/core/um-filters-login.php +13 -54
  38. includes/um-deprecated-functions.php +5 -1
  39. includes/widgets/class-um-search-widget.php +6 -1
  40. languages/ultimate-member-en_US.mo +0 -0
  41. languages/ultimate-member-en_US.po +541 -515
  42. readme.txt +31 -2
  43. ultimate-member.php +1 -1
assets/js/um-account.js CHANGED
@@ -5,28 +5,28 @@ jQuery(document).ready(function() {
5
  if ( current_tab ) {
6
  jQuery('.um-account-tab[data-tab="'+current_tab+'"]').show();
7
 
8
- jQuery('.um-account-tab:not(:visible)').find( 'input:not(:disabled)' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
9
  }
10
 
11
  jQuery( document.body ).on( 'click', '.um-account-side li a', function(e) {
12
  e.preventDefault();
13
  var link = jQuery(this);
14
-
15
  link.parents('ul').find('li a').removeClass('current');
16
  link.addClass('current');
17
-
18
  var url_ = jQuery(this).attr('href');
19
  var tab_ = jQuery(this).attr('data-tab');
20
-
21
  jQuery('input[id="_um_account_tab"]:hidden').val( tab_ );
22
-
23
  window.history.pushState("", "", url_);
24
 
25
  jQuery('.um-account-tab').hide();
26
  jQuery('.um-account-tab[data-tab="'+tab_+'"]').fadeIn();
27
 
28
- jQuery('.um-account-tab:visible').find( 'input.um_account_inactive:disabled' ).removeClass('um_account_inactive').prop( 'disabled', false ).attr( 'disabled', false );
29
- jQuery('.um-account-tab:not(:visible)').find( 'input:not(:disabled)' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
30
 
31
  jQuery('.um-account-nav a').removeClass('current');
32
  jQuery('.um-account-nav a[data-tab="'+tab_+'"]').addClass('current');
@@ -56,8 +56,8 @@ jQuery(document).ready(function() {
56
  link.addClass('current');
57
  }
58
 
59
- jQuery('.um-account-tab:visible').find( 'input.um_account_inactive:disabled' ).removeClass('um_account_inactive').prop( 'disabled', false ).attr( 'disabled', false );
60
- jQuery('.um-account-tab:not(:visible)').find( 'input:not(:disabled)' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
61
 
62
  jQuery('.um-account-side li a').removeClass('current');
63
  jQuery('.um-account-side li a[data-tab="'+tab_+'"]').addClass('current');
5
  if ( current_tab ) {
6
  jQuery('.um-account-tab[data-tab="'+current_tab+'"]').show();
7
 
8
+ jQuery('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
9
  }
10
 
11
  jQuery( document.body ).on( 'click', '.um-account-side li a', function(e) {
12
  e.preventDefault();
13
  var link = jQuery(this);
14
+
15
  link.parents('ul').find('li a').removeClass('current');
16
  link.addClass('current');
17
+
18
  var url_ = jQuery(this).attr('href');
19
  var tab_ = jQuery(this).attr('data-tab');
20
+
21
  jQuery('input[id="_um_account_tab"]:hidden').val( tab_ );
22
+
23
  window.history.pushState("", "", url_);
24
 
25
  jQuery('.um-account-tab').hide();
26
  jQuery('.um-account-tab[data-tab="'+tab_+'"]').fadeIn();
27
 
28
+ jQuery('.um-account-tab:visible').find( 'input, select, textarea' ).filter( '.um_account_inactive:disabled' ).removeClass('um_account_inactive').prop( 'disabled', false ).attr( 'disabled', false );
29
+ jQuery('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
30
 
31
  jQuery('.um-account-nav a').removeClass('current');
32
  jQuery('.um-account-nav a[data-tab="'+tab_+'"]').addClass('current');
56
  link.addClass('current');
57
  }
58
 
59
+ jQuery('.um-account-tab:visible').find( 'input, select, textarea' ).filter( '.um_account_inactive:disabled' ).removeClass('um_account_inactive').prop( 'disabled', false ).attr( 'disabled', false );
60
+ jQuery('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
61
 
62
  jQuery('.um-account-side li a').removeClass('current');
63
  jQuery('.um-account-side li a[data-tab="'+tab_+'"]').addClass('current');
assets/js/um-account.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input:not(:disabled)").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var t=jQuery(this);t.parents("ul").find("li a").removeClass("current"),t.addClass("current");var e=jQuery(this).attr("href"),u=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(u),window.history.pushState("","",e),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+u+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input.um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input:not(:disabled)").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+u+'"]').addClass("current"),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var t=jQuery(this).attr("data-tab"),e=jQuery(this).parents("div"),u=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(t),jQuery(".um-account-tab").hide(),u.hasClass("current")?(e.next(".um-account-tab").slideUp(),u.removeClass("current")):(e.next(".um-account-tab").slideDown(),u.parents("div").find("a").removeClass("current"),u.addClass("current")),jQuery(".um-account-tab:visible").find("input.um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input:not(:disabled)").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+t+'"]').addClass("current"),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var t=jQuery(this).data("action"),e=jQuery("#"+t).val();if(jQuery(".um-field-area-response."+t).hide(),""===e)jQuery(".um-field-error."+t).show();else{jQuery(".um-field-error."+t).hide();var u={request_action:t,password:e,nonce:um_scripts.nonce};wp.ajax.send("um_request_user_data",{data:u,success:function(a){jQuery(".um-field-area-response."+t).text(a.answer).show()},error:function(a){console.log(a)}})}})});
1
+ jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var e=jQuery(this);e.parents("ul").find("li a").removeClass("current"),e.addClass("current");var t=jQuery(this).attr("href"),u=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(u),window.history.pushState("","",t),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+u+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+u+'"]').addClass("current"),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var e=jQuery(this).attr("data-tab"),t=jQuery(this).parents("div"),u=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(e),jQuery(".um-account-tab").hide(),u.hasClass("current")?(t.next(".um-account-tab").slideUp(),u.removeClass("current")):(t.next(".um-account-tab").slideDown(),u.parents("div").find("a").removeClass("current"),u.addClass("current")),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+e+'"]').addClass("current"),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var e=jQuery(this).data("action"),t=jQuery("#"+e).val();if(jQuery(".um-field-area-response."+e).hide(),""===t)jQuery(".um-field-error."+e).show();else{jQuery(".um-field-error."+e).hide();var u={request_action:e,password:t,nonce:um_scripts.nonce};wp.ajax.send("um_request_user_data",{data:u,success:function(a){jQuery(".um-field-area-response."+e).text(a.answer).show()},error:function(a){console.log(a)}})}})});
assets/js/um-conditional.js CHANGED
@@ -4,12 +4,13 @@ var um_field_default_values = {};
4
 
5
  /**
6
  * Get field default value
7
- * @param object $dom
8
- * @return string
 
9
  */
10
  function um_get_field_default_value( $dom ) {
11
  var default_value = '';
12
- var type = um_get_field_type($dom);
13
  switch ( type ) {
14
 
15
  case 'text':
@@ -17,7 +18,7 @@ function um_get_field_default_value( $dom ) {
17
  case 'date':
18
  case 'textarea':
19
  case 'select':
20
- default_value = $dom.find('input:text,input[type=number],textarea,select').val();
21
  break;
22
 
23
  case 'multiselect':
@@ -25,28 +26,29 @@ function um_get_field_default_value( $dom ) {
25
  break;
26
 
27
  case 'radio':
28
- if ($dom.find('input[type=radio]:checked').length >= 1) {
29
- default_value = $dom.find('input[type=radio]:checked').val();
30
  }
31
-
32
  break;
33
- case 'checkbox':
34
 
35
- if ($dom.find('input[type=checkbox]:checked').length >= 1) {
 
36
 
37
- if ($dom.find('input[type=checkbox]:checked').length > 1) {
38
  var arr_values = [];
39
- arr_values.push( default_value );
40
- $dom.find('input[type=checkbox]:checked').each(function () {
41
  arr_values.push( jQuery(this).val() );
42
  });
43
  default_value = arr_values;
44
  } else {
45
- default_value = $dom.find('input[type=checkbox]:checked').val();
46
  }
47
-
48
  }
49
  break;
 
 
 
50
  }
51
 
52
  return {type: type, value: default_value};
@@ -54,74 +56,64 @@ function um_get_field_default_value( $dom ) {
54
 
55
  /**
56
  * Get field element by field wrapper
57
- * @param object $dom
58
- * @return object
 
59
  */
60
  function um_get_field_element( $dom ) {
61
- var default_value = '';
62
- var type = um_get_field_type($dom);
63
-
64
- switch ( type ) {
65
-
66
- case 'text':
67
- case 'number':
68
- case 'date':
69
- case 'textarea':
70
- case 'select':
71
- case 'multiselect':
72
- case 'radio':
73
- case 'checkbox':
74
- return $dom.find('input,textarea,select');
75
- break;
76
 
 
 
77
 
78
- }
79
 
80
- return '';
81
  }
82
 
83
  /**
84
  * Get field type
85
- * @param object $dom
86
- * @return string
 
87
  */
88
- function um_get_field_type($dom) {
89
  var type = '';
90
- var classes = $dom.attr( 'class' );
91
- jQuery.each( classes.split(' '), function (i, d) {
92
- if (d.indexOf('um-field-type') != -1) {
93
- type = d.split('_')[1];
 
94
  }
95
  });
96
 
97
  return type;
98
-
99
  }
100
 
101
  /**
102
  * Get field siblings/chidren conditions
103
- * @param string field_key
104
- * @return array
 
105
  */
106
- function um_get_field_children(field_key) {
107
  var arr_conditions = [];
108
- jQuery.each(arr_all_conditions, function (ii, condition) {
109
- if (condition.field.parent == field_key) {
110
- arr_conditions.push(condition.field.condition);
111
  }
112
  });
113
 
114
  return arr_conditions;
115
-
116
  }
117
 
118
  /**
119
  * Split single array to multi-dimensional array
120
- * @param array arr
121
- * @param integer n
122
- * @return array
 
123
  */
124
- function um_splitup_array(arr, n) {
125
  var rest = arr.length % n,
126
  restUsed = rest,
127
  partLength = Math.floor(arr.length / n),
@@ -151,7 +143,7 @@ function um_splitup_array(arr, n) {
151
  if_field: dd[1],
152
  operator: dd[2],
153
  value: dd[3]
154
- })
155
  });
156
 
157
  return obj_result;
@@ -159,10 +151,11 @@ function um_splitup_array(arr, n) {
159
 
160
  /**
161
  * Get field live value
162
- * @param object $dom
163
- * @return mixed
 
164
  */
165
- function um_get_field_data($dom) {
166
  um_live_field = $dom.parents('.um-field').data('key');
167
  um_live_value = $dom.val();
168
 
@@ -187,13 +180,21 @@ function um_get_field_data($dom) {
187
  }
188
 
189
  return um_live_value;
190
-
191
  }
192
 
193
- function um_in_array(needle, haystack, strict){
194
- var found = false, key, strict = !!strict;
195
- for (key in haystack) {
196
- if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
 
 
 
 
 
 
 
 
 
197
  found = true;
198
  break;
199
  }
@@ -204,11 +205,11 @@ function um_in_array(needle, haystack, strict){
204
 
205
  /**
206
  * Apply field conditions
207
- * @param object $dom
208
- * @param boolean is_single_update
 
209
  */
210
  function um_apply_conditions( $dom, is_single_update ) {
211
- var operators = ['empty', 'not empty', 'equals to', 'not equals', 'greater than', 'less than', 'contains'];
212
  if ( ! $dom.parents('.um-field[data-key]').length ) {
213
  return;
214
  }
@@ -218,160 +219,189 @@ function um_apply_conditions( $dom, is_single_update ) {
218
  return;
219
  }
220
 
 
221
  var live_field_value = um_get_field_data( $dom );
222
 
223
  var $owners = {};
224
  var $owners_values = {};
225
  var $owner_conditions = {};
226
 
227
- jQuery.each(conditions, function (index, condition) {
228
- if (typeof $owners_values[condition.owner] == 'undefined') {
229
- $owners_values[condition.owner] = [];
230
- $owner_conditions[condition.owner] = {}
231
  }
232
- $owners_values[condition.owner].push(condition.value);
233
- $owner_conditions[condition.owner] = condition;
234
  });
235
 
236
- jQuery.each(conditions, function (index, condition) {
237
- if (typeof $owners[condition.owner] == 'undefined') {
238
- $owners[condition.owner] = {};
239
  }
240
- if (condition.operator == 'empty') {
241
- if (!live_field_value || live_field_value == '' && um_in_array(live_field_value, $owners_values[condition.owner])) {
242
- $owners[condition.owner][index] = true;
 
 
243
  } else {
244
- $owners[condition.owner][index] = false;
245
  }
246
  }
247
 
248
- if (condition.operator == 'not empty') {
249
- if (live_field_value && live_field_value != '' && !um_in_array(live_field_value, $owners_values[condition.owner])) {
250
- $owners[condition.owner][index] = true;
 
251
  } else {
252
- $owners[condition.owner][index] = false;
253
  }
254
  }
255
 
256
- if (condition.operator == 'equals to') {
257
- if (condition.value == live_field_value && um_in_array(live_field_value, $owners_values[condition.owner])) {
258
- $owners[condition.owner][index] = true;
 
259
  } else {
260
- $owners[condition.owner][index] = false;
261
  }
262
  }
263
 
264
- if (condition.operator == 'not equals') {
265
- if (jQuery.isNumeric(condition.value) && parseInt(live_field_value) != parseInt(condition.value) && live_field_value && !um_in_array(live_field_value, $owners_values[condition.owner])) {
266
- $owners[condition.owner][index] = true;
267
- } else if (condition.value != live_field_value && !um_in_array(live_field_value, $owners_values[condition.owner])) {
268
- $owners[condition.owner][index] = true;
 
269
  } else {
270
- $owners[condition.owner][index] = false;
271
  }
272
  }
273
 
274
- if (condition.operator == 'greater than') {
275
- if (jQuery.isNumeric(condition.value) && parseInt(live_field_value) > parseInt(condition.value)) {
276
- $owners[condition.owner][index] = true;
 
277
  } else {
278
- $owners[condition.owner][index] = false;
279
  }
280
  }
281
 
282
- if (condition.operator == 'less than') {
283
- if (jQuery.isNumeric(condition.value) && parseInt(live_field_value) < parseInt(condition.value)) {
284
- $owners[condition.owner][index] = true;
 
285
  } else {
286
- $owners[condition.owner][index] = false;
287
  }
288
  }
289
 
290
- if ( condition.operator == 'contains' ) {
291
- if ( 'multiselect' == um_get_field_type( $dom.parents('.um-field[data-key]') ) ) {
292
- if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 && um_in_array( condition.value, live_field_value ) ) {
293
- $owners[condition.owner][index] = true;
294
- } else {
295
- $owners[condition.owner][index] = false;
296
- }
297
- } else if ( 'checkbox' == um_get_field_type( $dom.parents('.um-field[data-key]') ) ) {
298
- if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 ) {
299
- $owners[condition.owner][index] = true;
300
- } else {
301
- $owners[condition.owner][index] = false;
302
- }
303
- } else {
304
- if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 && um_in_array( live_field_value, $owners_values[ condition.owner ] ) ) {
305
- $owners[condition.owner][index] = true;
306
- } else {
307
- $owners[condition.owner][index] = false;
308
- }
 
 
 
 
 
 
 
 
 
 
 
309
  }
310
  }
311
 
312
  }); // end foreach `conditions`
313
- jQuery.each($owners, function (index, field) {
314
- if (um_in_array(true, field)) {
315
- um_field_apply_action($dom, $owner_conditions[index], true);
 
316
  } else {
317
- um_field_apply_action($dom, $owner_conditions[index], false);
318
  }
319
  });
320
- $dom.trigger('um_fields_change');
 
321
 
322
  }
323
 
324
  /**
325
  * Apply condition's action
326
- * @param object $dom
327
- * @param string condition
328
- * @param boolean is_true
 
 
329
  */
330
  function um_field_apply_action($dom, condition, is_true) {
331
  var child_dom = jQuery('div.um-field[data-key="' + condition.owner + '"]');
332
 
333
- if (condition.action == 'show' && is_true /*&& child_dom.is(':hidden')*/) {
 
 
 
334
  child_dom.show();
335
  _show_in_ie( child_dom );
336
- um_field_restore_default_value(child_dom);
337
  }
338
 
339
- if (condition.action == 'show' && !is_true /*&& child_dom.is(':visible') */) {
340
  child_dom.hide();
341
  _hide_in_ie( child_dom );
342
  }
343
 
344
- if (condition.action == 'hide' && is_true /*&& child_dom.is(':visible')*/) {
345
  child_dom.hide();
346
  _hide_in_ie( child_dom );
347
  }
348
 
349
- if (condition.action == 'hide' && !is_true /*&& child_dom.is(':hidden')*/) {
 
 
 
350
  child_dom.show();
351
  _show_in_ie( child_dom );
352
- um_field_restore_default_value( child_dom );
353
 
354
  }
355
- $dom.removeClass('um-field-has-changed');
356
  }
357
 
 
358
  /**
359
  * Restores default field value
360
- * @param object $dom
 
361
  */
362
  function um_field_restore_default_value( $dom ) {
363
- //um_field_default_values
364
 
365
  var type = um_get_field_type( $dom );
366
  var key = $dom.data('key');
367
- var field = um_field_default_values[key];
 
368
  switch ( type ) {
369
 
370
  case 'text':
371
  case 'number':
372
  case 'date':
373
  case 'textarea':
374
- $dom.find('input:text,input[type=number],textareas').val(field.value);
375
  break;
376
 
377
  case 'select':
@@ -389,57 +419,56 @@ function um_field_restore_default_value( $dom ) {
389
  break;
390
 
391
  case 'checkbox':
 
392
 
393
-
394
- if ( $dom.find('input[type=checkbox]:checked').length >= 1 ) {
395
-
396
- $dom.find('input[type=checkbox]:checked').removeAttr('checked');
397
  $dom.find('span.um-field-checkbox-state i').removeClass('um-icon-android-checkbox-outline');
398
  $dom.find('span.um-field-checkbox-state i').addClass('um-icon-android-checkbox-outline-blank');
399
  $dom.find('.um-field-checkbox.active').removeClass('active');
400
 
401
- if (jQuery.isArray(field.value)) {
402
- jQuery.each(field.value, function (i, value) {
403
- var cbox_elem = $dom.find('input[type=checkbox][value="' + value + '"]');
404
  cbox_elem.attr('checked', true);
405
  cbox_elem.closest('.um-field-checkbox').find('i').removeClass('um-icon-android-checkbox-outline-blank');
406
  cbox_elem.closest('.um-field-checkbox').find('i').addClass('um-icon-android-checkbox-outline');
407
  cbox_elem.closest('.um-field-checkbox').addClass('active');
408
  });
409
  } else {
410
- var cbox_elem = $dom.find('input[type=checkbox][value="' + field.value + '"]');
411
  cbox_elem.attr('checked', true);
412
  cbox_elem.closest('.um-field-checkbox').find('i').removeClass('um-icon-android-checkbox-outline-blank');
413
  cbox_elem.closest('.um-field-checkbox').find('i').addClass('um-icon-android-checkbox-outline');
414
  cbox_elem.closest('.um-field-checkbox').addClass('active');
415
- }
416
-
417
  }
418
-
419
  break;
 
420
  case 'radio':
421
 
422
- if ( $dom.find('input[type=radio]:checked').length >= 1 ) {
423
 
424
- setTimeout(function () {
425
 
426
- $dom.find('input[type=radio]:checked').removeAttr('checked');
427
 
428
  $dom.find('span.um-field-radio-state i').removeClass('um-icon-android-radio-button-on');
429
  $dom.find('span.um-field-radio-state i').addClass('um-icon-android-radio-button-off');
430
  $dom.find('.um-field-radio.active').removeClass('active');
431
 
432
- var radio_elem = $dom.find("input[type=radio][value='" + field.value + "']");
433
  radio_elem.attr('checked', true);
434
  radio_elem.closest('.um-field-radio').find('i').removeClass('um-icon-android-radio-button-off');
435
  radio_elem.closest('.um-field-radio').find('i').addClass('um-icon-android-radio-button-on');
436
  radio_elem.closest('.um-field-radio').addClass('active');
437
 
438
- }, 100);
439
  }
440
-
441
  break;
442
 
 
 
 
443
 
444
  } // end switch type
445
 
@@ -447,7 +476,7 @@ function um_field_restore_default_value( $dom ) {
447
  if ( ! $dom.hasClass( 'um-field-has-changed' ) ) {
448
  var me = um_get_field_element( $dom );
449
 
450
- if ( type == 'radio' || type == 'checkbox' ) {
451
  me = me.find( ':checked' );
452
  }
453
 
@@ -480,7 +509,7 @@ function um_field_restore_default_value( $dom ) {
480
  function um_field_hide_siblings() {
481
 
482
  jQuery.each(um_field_conditions, function (index, conditions) {
483
- if (jQuery('.um-field[data-key="' + index + '"]:hidden').length >= 1 || jQuery('.um-field[data-key="' + index + '"]').css('display') == 'none') {
484
  jQuery.each(conditions, function (key, condition) {
485
  jQuery('.um-field[data-key="' + condition.owner + '"]').hide();
486
  });
@@ -492,20 +521,22 @@ function um_field_hide_siblings() {
492
 
493
  /**
494
  * Hides div for IE browser
495
- * @param object $dom
 
496
  */
497
  function _hide_in_ie( $dom ){
498
- if ( typeof( jQuery.browser ) != 'undefined' && jQuery.browser.msie ) {
499
  $dom.css({"visibility":"hidden"});
500
  }
501
  }
502
 
503
  /**
504
  * Shows div for IE browser
505
- * @param object $dom
 
506
  */
507
  function _show_in_ie( $dom ){
508
- if ( typeof( jQuery.browser ) != 'undefined' && jQuery.browser.msie ) {
509
  $dom.css({"visibility":"visible"});
510
  }
511
  }
@@ -524,7 +555,7 @@ function um_init_field_conditions() {
524
 
525
  var parse_attrs = {};
526
  jQuery.each( jQuery(this)[0].attributes, function ( index, attribute ) {
527
- if ( attribute.name.indexOf( 'data-cond' ) != -1 ) {
528
  // replace "data-cond-"
529
  var cond_field_id_and_attr = attribute.name.slice( 10 );
530
  // return "n"
@@ -532,7 +563,7 @@ function um_init_field_conditions() {
532
  //replace "n-"
533
  var cond_field_attr = cond_field_id_and_attr.slice( 2 );
534
 
535
- if ( typeof parse_attrs[cond_field_id] == 'undefined' )
536
  parse_attrs[cond_field_id] = {};
537
 
538
  parse_attrs[cond_field_id][cond_field_attr] = attribute.value;
4
 
5
  /**
6
  * Get field default value
7
+ *
8
+ * @param {object} $dom
9
+ * @return {object}
10
  */
11
  function um_get_field_default_value( $dom ) {
12
  var default_value = '';
13
+ var type = um_get_field_type( $dom );
14
  switch ( type ) {
15
 
16
  case 'text':
18
  case 'date':
19
  case 'textarea':
20
  case 'select':
21
+ default_value = $dom.find('input:text,input[type="number"],textarea,select').val();
22
  break;
23
 
24
  case 'multiselect':
26
  break;
27
 
28
  case 'radio':
29
+ if ( $dom.find('input[type="radio"]:checked').length >= 1 ) {
30
+ default_value = $dom.find('input[type="radio"]:checked').val();
31
  }
 
32
  break;
 
33
 
34
+ case 'checkbox':
35
+ if ( $dom.find('input[type="checkbox"]:checked').length >= 1 ) {
36
 
37
+ if ( $dom.find('input[type="checkbox"]:checked').length > 1 ) {
38
  var arr_values = [];
39
+ arr_values.push( default_value );
40
+ $dom.find('input[type="checkbox"]:checked').each( function() {
41
  arr_values.push( jQuery(this).val() );
42
  });
43
  default_value = arr_values;
44
  } else {
45
+ default_value = $dom.find('input[type="checkbox"]:checked').val();
46
  }
 
47
  }
48
  break;
49
+ default:
50
+ default_value = wp.hooks.applyFilters( 'um_conditional_logic_default_value', default_value, type, $dom );
51
+ break;
52
  }
53
 
54
  return {type: type, value: default_value};
56
 
57
  /**
58
  * Get field element by field wrapper
59
+ *
60
+ * @param {object} $dom
61
+ * @return {object}
62
  */
63
  function um_get_field_element( $dom ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ var field_element = $dom.find( 'input,textarea,select' );
66
+ var type = um_get_field_type( $dom );
67
 
68
+ field_element = wp.hooks.applyFilters( 'um_conditional_logic_field_element', field_element, type, $dom );
69
 
70
+ return field_element;
71
  }
72
 
73
  /**
74
  * Get field type
75
+ *
76
+ * @param {object} $dom
77
+ * @return {string}
78
  */
79
+ function um_get_field_type( $dom ) {
80
  var type = '';
81
+ var classes = $dom.attr( 'class' ).split(' ');
82
+
83
+ jQuery.each( classes, function ( i, d ) {
84
+ if ( /um-field-type_/.test( d ) ) {
85
+ type = d.replace( 'um-field-type_', '' ).trim();
86
  }
87
  });
88
 
89
  return type;
 
90
  }
91
 
92
  /**
93
  * Get field siblings/chidren conditions
94
+ *
95
+ * @param {string} field_key
96
+ * @return {array}
97
  */
98
+ function um_get_field_children( field_key ) {
99
  var arr_conditions = [];
100
+ jQuery.each( arr_all_conditions, function ( ii, condition ) {
101
+ if ( condition.field.parent === field_key ) {
102
+ arr_conditions.push( condition.field.condition );
103
  }
104
  });
105
 
106
  return arr_conditions;
 
107
  }
108
 
109
  /**
110
  * Split single array to multi-dimensional array
111
+ *
112
+ * @param {array} arr
113
+ * @param {integer} n
114
+ * @return {array}
115
  */
116
+ function um_splitup_array( arr, n ) {
117
  var rest = arr.length % n,
118
  restUsed = rest,
119
  partLength = Math.floor(arr.length / n),
143
  if_field: dd[1],
144
  operator: dd[2],
145
  value: dd[3]
146
+ });
147
  });
148
 
149
  return obj_result;
151
 
152
  /**
153
  * Get field live value
154
+ *
155
+ * @param {object} $dom
156
+ * @return {mixed}
157
  */
158
+ function um_get_field_data( $dom ) {
159
  um_live_field = $dom.parents('.um-field').data('key');
160
  um_live_value = $dom.val();
161
 
180
  }
181
 
182
  return um_live_value;
 
183
  }
184
 
185
+ /**
186
+ * Checks if a value exists in an array
187
+ *
188
+ * @param {String} needle
189
+ * @param {Array} haystack
190
+ * @param {Boolean} strict
191
+ * @returns {Boolean}
192
+ */
193
+ function um_in_array( needle, haystack, strict ) {
194
+ var found = false, key;
195
+ strict = !!strict;
196
+ for ( key in haystack ) {
197
+ if ( ( strict && haystack[ key ] === needle ) || ( ! strict && haystack[ key ] == needle ) ) {
198
  found = true;
199
  break;
200
  }
205
 
206
  /**
207
  * Apply field conditions
208
+ *
209
+ * @param {object} $dom
210
+ * @param {boolean} is_single_update
211
  */
212
  function um_apply_conditions( $dom, is_single_update ) {
 
213
  if ( ! $dom.parents('.um-field[data-key]').length ) {
214
  return;
215
  }
219
  return;
220
  }
221
 
222
+ var field_type = um_get_field_type( $dom.parents('.um-field[data-key]') );
223
  var live_field_value = um_get_field_data( $dom );
224
 
225
  var $owners = {};
226
  var $owners_values = {};
227
  var $owner_conditions = {};
228
 
229
+ jQuery.each( conditions, function ( index, condition ) {
230
+ if ( typeof $owners_values[ condition.owner ] == 'undefined' ) {
231
+ $owners_values[ condition.owner ] = [];
232
+ $owner_conditions[ condition.owner ] = {}
233
  }
234
+ $owners_values[ condition.owner ].push( condition.value );
235
+ $owner_conditions[ condition.owner ] = condition;
236
  });
237
 
238
+ jQuery.each( conditions, function ( index, condition ) {
239
+ if ( typeof $owners[ condition.owner ] == 'undefined' ) {
240
+ $owners[ condition.owner ] = {};
241
  }
242
+
243
+ if ( condition.operator === 'empty' ) {
244
+ var field_value = jQuery.isArray( live_field_value ) ? live_field_value.join('') : live_field_value;
245
+ if ( ! field_value || field_value === '' ) {
246
+ $owners[ condition.owner ][ index ] = true;
247
  } else {
248
+ $owners[ condition.owner ][ index ] = false;
249
  }
250
  }
251
 
252
+ if ( condition.operator === 'not empty' ) {
253
+ var field_value = jQuery.isArray( live_field_value ) ? live_field_value.join('') : live_field_value;
254
+ if ( field_value && field_value !== '' ) {
255
+ $owners[ condition.owner ][ index ] = true;
256
  } else {
257
+ $owners[ condition.owner ][ index ] = false;
258
  }
259
  }
260
 
261
+ if ( condition.operator === 'equals to' ) {
262
+ var field_value = ( jQuery.isArray( live_field_value ) && live_field_value.length === 1 ) ? live_field_value[0] : live_field_value;
263
+ if ( condition.value === field_value && um_in_array( field_value, $owners_values[ condition.owner ] ) ) {
264
+ $owners[ condition.owner ][ index ] = true;
265
  } else {
266
+ $owners[ condition.owner ][ index ] = false;
267
  }
268
  }
269
 
270
+ if ( condition.operator === 'not equals' ) {
271
+ var field_value = ( jQuery.isArray( live_field_value ) && live_field_value.length === 1 ) ? live_field_value[0] : live_field_value;
272
+ if ( jQuery.isNumeric(condition.value) && parseInt(field_value) !== parseInt( condition.value ) && field_value && ! um_in_array( field_value, $owners_values[ condition.owner ] ) ) {
273
+ $owners[ condition.owner ][ index ] = true;
274
+ } else if ( condition.value != field_value && ! um_in_array( field_value, $owners_values[ condition.owner ] ) ) {
275
+ $owners[ condition.owner ][ index ] = true;
276
  } else {
277
+ $owners[ condition.owner ][ index ] = false;
278
  }
279
  }
280
 
281
+ if ( condition.operator === 'greater than' ) {
282
+ var field_value = ( jQuery.isArray( live_field_value ) && live_field_value.length === 1 ) ? live_field_value[0] : live_field_value;
283
+ if ( jQuery.isNumeric( condition.value ) && parseInt( field_value ) > parseInt( condition.value ) ) {
284
+ $owners[ condition.owner ][ index ] = true;
285
  } else {
286
+ $owners[ condition.owner ][ index ] = false;
287
  }
288
  }
289
 
290
+ if ( condition.operator === 'less than' ) {
291
+ var field_value = ( jQuery.isArray( live_field_value ) && live_field_value.length === 1 ) ? live_field_value[0] : live_field_value;
292
+ if ( jQuery.isNumeric( condition.value ) && parseInt( field_value ) < parseInt( condition.value ) ) {
293
+ $owners[ condition.owner ][ index ] = true;
294
  } else {
295
+ $owners[ condition.owner ][ index ] = false;
296
  }
297
  }
298
 
299
+ if ( condition.operator === 'contains' ) {
300
+ switch ( field_type ) {
301
+ case 'multiselect':
302
+ if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 && um_in_array( condition.value, live_field_value ) ) {
303
+ $owners[ condition.owner ][ index ] = true;
304
+ } else {
305
+ $owners[ condition.owner ][ index ] = false;
306
+ }
307
+ break;
308
+
309
+ case 'checkbox':
310
+ if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 ) {
311
+ $owners[ condition.owner ][ index ] = true;
312
+ } else {
313
+ $owners[ condition.owner ][ index ] = false;
314
+ }
315
+ break;
316
+
317
+ default:
318
+
319
+ $owners = wp.hooks.applyFilters( 'um_conditional_logic_contains_operator_owners', $owners, field_type, live_field_value, condition, index );
320
+ if ( typeof $owners[ condition.owner ][ index ] === 'undefined' ) {
321
+ if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 && um_in_array( live_field_value, $owners_values[ condition.owner ] ) ) {
322
+ $owners[ condition.owner ][ index ] = true;
323
+ } else {
324
+ $owners[ condition.owner ][ index ] = false;
325
+ }
326
+ }
327
+
328
+ break;
329
  }
330
  }
331
 
332
  }); // end foreach `conditions`
333
+
334
+ jQuery.each( $owners, function ( index, field ) {
335
+ if ( um_in_array( true, field ) ) {
336
+ um_field_apply_action( $dom, $owner_conditions[ index ], true );
337
  } else {
338
+ um_field_apply_action( $dom, $owner_conditions[ index ], false );
339
  }
340
  });
341
+
342
+ $dom.trigger( 'um_fields_change' );
343
 
344
  }
345
 
346
  /**
347
  * Apply condition's action
348
+ *
349
+ * @param {object} $dom
350
+ * @param {string} condition
351
+ * @param {boolean} is_true
352
+ * @returns {jQuery}
353
  */
354
  function um_field_apply_action($dom, condition, is_true) {
355
  var child_dom = jQuery('div.um-field[data-key="' + condition.owner + '"]');
356
 
357
+ if ( condition.action === 'show' && is_true /*&& child_dom.is(':hidden')*/ ) {
358
+ if( child_dom.is(':hidden') ){
359
+ um_field_restore_default_value(child_dom);
360
+ }
361
  child_dom.show();
362
  _show_in_ie( child_dom );
 
363
  }
364
 
365
+ if ( condition.action === 'show' && ! is_true /*&& child_dom.is(':visible')*/ ) {
366
  child_dom.hide();
367
  _hide_in_ie( child_dom );
368
  }
369
 
370
+ if ( condition.action === 'hide' && is_true /*&& child_dom.is(':visible')*/ ) {
371
  child_dom.hide();
372
  _hide_in_ie( child_dom );
373
  }
374
 
375
+ if ( condition.action === 'hide' && ! is_true /*&& child_dom.is(':hidden')*/ ) {
376
+ if( child_dom.is(':hidden') ){
377
+ um_field_restore_default_value(child_dom);
378
+ }
379
  child_dom.show();
380
  _show_in_ie( child_dom );
 
381
 
382
  }
383
+ return $dom.removeClass( 'um-field-has-changed' );
384
  }
385
 
386
+
387
  /**
388
  * Restores default field value
389
+ *
390
+ * @param {object} $dom
391
  */
392
  function um_field_restore_default_value( $dom ) {
 
393
 
394
  var type = um_get_field_type( $dom );
395
  var key = $dom.data('key');
396
+ var field = um_field_default_values[ key ];
397
+
398
  switch ( type ) {
399
 
400
  case 'text':
401
  case 'number':
402
  case 'date':
403
  case 'textarea':
404
+ $dom.find('input:text,input[type="number"],textareas').val(field.value);
405
  break;
406
 
407
  case 'select':
419
  break;
420
 
421
  case 'checkbox':
422
+ if ( $dom.find('input[type="checkbox"]:checked').length >= 1 ) {
423
 
424
+ $dom.find('input[type="checkbox"]:checked').removeAttr('checked');
 
 
 
425
  $dom.find('span.um-field-checkbox-state i').removeClass('um-icon-android-checkbox-outline');
426
  $dom.find('span.um-field-checkbox-state i').addClass('um-icon-android-checkbox-outline-blank');
427
  $dom.find('.um-field-checkbox.active').removeClass('active');
428
 
429
+ if ( jQuery.isArray( field.value ) ) {
430
+ jQuery.each( field.value, function ( i, value ) {
431
+ var cbox_elem = $dom.find('input[type="checkbox"][value="' + value + '"]');
432
  cbox_elem.attr('checked', true);
433
  cbox_elem.closest('.um-field-checkbox').find('i').removeClass('um-icon-android-checkbox-outline-blank');
434
  cbox_elem.closest('.um-field-checkbox').find('i').addClass('um-icon-android-checkbox-outline');
435
  cbox_elem.closest('.um-field-checkbox').addClass('active');
436
  });
437
  } else {
438
+ var cbox_elem = $dom.find('input[type="checkbox"][value="' + field.value + '"]');
439
  cbox_elem.attr('checked', true);
440
  cbox_elem.closest('.um-field-checkbox').find('i').removeClass('um-icon-android-checkbox-outline-blank');
441
  cbox_elem.closest('.um-field-checkbox').find('i').addClass('um-icon-android-checkbox-outline');
442
  cbox_elem.closest('.um-field-checkbox').addClass('active');
443
+ }
 
444
  }
 
445
  break;
446
+
447
  case 'radio':
448
 
449
+ if ( $dom.find('input[type="radio"]:checked').length >= 1 ) {
450
 
451
+ setTimeout( function() {
452
 
453
+ $dom.find('input[type="radio"]:checked').removeAttr('checked');
454
 
455
  $dom.find('span.um-field-radio-state i').removeClass('um-icon-android-radio-button-on');
456
  $dom.find('span.um-field-radio-state i').addClass('um-icon-android-radio-button-off');
457
  $dom.find('.um-field-radio.active').removeClass('active');
458
 
459
+ var radio_elem = $dom.find('input[type="radio"][value="' + field.value + '"]');
460
  radio_elem.attr('checked', true);
461
  radio_elem.closest('.um-field-radio').find('i').removeClass('um-icon-android-radio-button-off');
462
  radio_elem.closest('.um-field-radio').find('i').addClass('um-icon-android-radio-button-on');
463
  radio_elem.closest('.um-field-radio').addClass('active');
464
 
465
+ }, 100 );
466
  }
 
467
  break;
468
 
469
+ default:
470
+ wp.hooks.doAction( 'um_conditional_logic_restore_default_value', type, $dom, field );
471
+ break;
472
 
473
  } // end switch type
474
 
476
  if ( ! $dom.hasClass( 'um-field-has-changed' ) ) {
477
  var me = um_get_field_element( $dom );
478
 
479
+ if ( type === 'radio' || type === 'checkbox' ) {
480
  me = me.find( ':checked' );
481
  }
482
 
509
  function um_field_hide_siblings() {
510
 
511
  jQuery.each(um_field_conditions, function (index, conditions) {
512
+ if (jQuery('.um-field[data-key="' + index + '"]:hidden').length >= 1 || jQuery('.um-field[data-key="' + index + '"]').css('display') === 'none') {
513
  jQuery.each(conditions, function (key, condition) {
514
  jQuery('.um-field[data-key="' + condition.owner + '"]').hide();
515
  });
521
 
522
  /**
523
  * Hides div for IE browser
524
+ *
525
+ * @param {object} $dom
526
  */
527
  function _hide_in_ie( $dom ){
528
+ if ( typeof( jQuery.browser ) !== 'undefined' && jQuery.browser.msie ) {
529
  $dom.css({"visibility":"hidden"});
530
  }
531
  }
532
 
533
  /**
534
  * Shows div for IE browser
535
+ *
536
+ * @param {object} $dom
537
  */
538
  function _show_in_ie( $dom ){
539
+ if ( typeof( jQuery.browser ) !== 'undefined' && jQuery.browser.msie ) {
540
  $dom.css({"visibility":"visible"});
541
  }
542
  }
555
 
556
  var parse_attrs = {};
557
  jQuery.each( jQuery(this)[0].attributes, function ( index, attribute ) {
558
+ if ( attribute.name.indexOf( 'data-cond' ) !== -1 ) {
559
  // replace "data-cond-"
560
  var cond_field_id_and_attr = attribute.name.slice( 10 );
561
  // return "n"
563
  //replace "n-"
564
  var cond_field_attr = cond_field_id_and_attr.slice( 2 );
565
 
566
+ if ( typeof parse_attrs[cond_field_id] === 'undefined' )
567
  parse_attrs[cond_field_id] = {};
568
 
569
  parse_attrs[cond_field_id][cond_field_attr] = attribute.value;
assets/js/um-conditional.min.js CHANGED
@@ -1 +1 @@
1
- var arr_all_conditions=[],um_field_conditions={},um_field_default_values={};function um_get_field_default_value(e){var i="",n=um_get_field_type(e);switch(n){case"text":case"number":case"date":case"textarea":case"select":i=e.find("input:text,input[type=number],textarea,select").val();break;case"multiselect":i=e.find("select").val();break;case"radio":1<=e.find("input[type=radio]:checked").length&&(i=e.find("input[type=radio]:checked").val());break;case"checkbox":if(1<=e.find("input[type=checkbox]:checked").length)if(1<e.find("input[type=checkbox]:checked").length){var a=[];a.push(i),e.find("input[type=checkbox]:checked").each(function(){a.push(jQuery(this).val())}),i=a}else i=e.find("input[type=checkbox]:checked").val()}return{type:n,value:i}}function um_get_field_element(e){switch(um_get_field_type(e)){case"text":case"number":case"date":case"textarea":case"select":case"multiselect":case"radio":case"checkbox":return e.find("input,textarea,select")}return""}function um_get_field_type(e){var n="",i=e.attr("class");return jQuery.each(i.split(" "),function(e,i){-1!=i.indexOf("um-field-type")&&(n=i.split("_")[1])}),n}function um_get_field_children(n){var a=[];return jQuery.each(arr_all_conditions,function(e,i){i.field.parent==n&&a.push(i.field.condition)}),a}function um_splitup_array(e,i){for(var n=e.length%i,a=n,t=Math.floor(e.length/i),u=[],r=0;r<e.length;r+=t){var o=t+r,d=!1;0!==n&&a&&(o++,a--,d=!0),u.push(e.slice(r,o)),d&&r++}var c=[];return jQuery.each(u,function(e,i){c.push({action:i[0],if_field:i[1],operator:i[2],value:i[3]})}),c}function um_get_field_data(e){return um_live_field=e.parents(".um-field").data("key"),um_live_value=e.val(),e.is(":checkbox")&&(um_live_value="",1<e.parents(".um-field").find("input:checked").length?e.parents(".um-field").find("input:checked").each(function(){um_live_value=um_live_value+jQuery(this).val()+" "}):1<=e.parents(".um-field").find("input:checked").length&&(um_live_value=e.parents(".um-field").find("input:checked").val())),e.is(":radio")&&(um_live_value=e.parents(".um-field").find("input[type=radio]:checked").val()),um_live_value}function um_in_array(e,i,n){var a,t=!1;n=!!n;for(a in i)if(n&&i[a]===e||!n&&i[a]==e){t=!0;break}return t}function um_apply_conditions(n,e){if(n.parents(".um-field[data-key]").length){var i=n.parents(".um-field[data-key]").data("key"),a=um_field_conditions[i];if(void 0!==a){var t=um_get_field_data(n),u={},r={},o={};jQuery.each(a,function(e,i){void 0===r[i.owner]&&(r[i.owner]=[],o[i.owner]={}),r[i.owner].push(i.value),o[i.owner]=i}),jQuery.each(a,function(e,i){void 0===u[i.owner]&&(u[i.owner]={}),"empty"==i.operator&&(!t||""==t&&um_in_array(t,r[i.owner])?u[i.owner][e]=!0:u[i.owner][e]=!1),"not empty"==i.operator&&(t&&""!=t&&!um_in_array(t,r[i.owner])?u[i.owner][e]=!0:u[i.owner][e]=!1),"equals to"==i.operator&&(i.value==t&&um_in_array(t,r[i.owner])?u[i.owner][e]=!0:u[i.owner][e]=!1),"not equals"==i.operator&&(jQuery.isNumeric(i.value)&&parseInt(t)!=parseInt(i.value)&&t&&!um_in_array(t,r[i.owner])?u[i.owner][e]=!0:i.value==t||um_in_array(t,r[i.owner])?u[i.owner][e]=!1:u[i.owner][e]=!0),"greater than"==i.operator&&(jQuery.isNumeric(i.value)&&parseInt(t)>parseInt(i.value)?u[i.owner][e]=!0:u[i.owner][e]=!1),"less than"==i.operator&&(jQuery.isNumeric(i.value)&&parseInt(t)<parseInt(i.value)?u[i.owner][e]=!0:u[i.owner][e]=!1),"contains"==i.operator&&("multiselect"==um_get_field_type(n.parents(".um-field[data-key]"))?t&&0<=t.indexOf(i.value)&&um_in_array(i.value,t)?u[i.owner][e]=!0:u[i.owner][e]=!1:"checkbox"==um_get_field_type(n.parents(".um-field[data-key]"))?t&&0<=t.indexOf(i.value)?u[i.owner][e]=!0:u[i.owner][e]=!1:t&&0<=t.indexOf(i.value)&&um_in_array(t,r[i.owner])?u[i.owner][e]=!0:u[i.owner][e]=!1)}),jQuery.each(u,function(e,i){um_in_array(!0,i)?um_field_apply_action(n,o[e],!0):um_field_apply_action(n,o[e],!1)}),n.trigger("um_fields_change")}}}function um_field_apply_action(e,i,n){var a=jQuery('div.um-field[data-key="'+i.owner+'"]');"show"==i.action&&n&&(a.show(),_show_in_ie(a),um_field_restore_default_value(a)),"show"!=i.action||n||(a.hide(),_hide_in_ie(a)),"hide"==i.action&&n&&(a.hide(),_hide_in_ie(a)),"hide"!=i.action||n||(a.show(),_show_in_ie(a),um_field_restore_default_value(a)),e.removeClass("um-field-has-changed")}function um_field_restore_default_value(a){var e=um_get_field_type(a),i=a.data("key"),n=um_field_default_values[i];switch(e){case"text":case"number":case"date":case"textarea":a.find("input:text,input[type=number],textareas").val(n.value);break;case"select":a.find("select").find("option").prop("selected",!1),a.find("select").val(n.value),a.find("select").trigger("change");break;case"multiselect":a.find("select").find("option").prop("selected",!1),jQuery.each(n.value,function(e,i){a.find("select").find('option[value="'+i+'"]').attr("selected",!0)}),a.find("select").trigger("change");break;case"checkbox":if(1<=a.find("input[type=checkbox]:checked").length)if(a.find("input[type=checkbox]:checked").removeAttr("checked"),a.find("span.um-field-checkbox-state i").removeClass("um-icon-android-checkbox-outline"),a.find("span.um-field-checkbox-state i").addClass("um-icon-android-checkbox-outline-blank"),a.find(".um-field-checkbox.active").removeClass("active"),jQuery.isArray(n.value))jQuery.each(n.value,function(e,i){var n=a.find('input[type=checkbox][value="'+i+'"]');n.attr("checked",!0),n.closest(".um-field-checkbox").find("i").removeClass("um-icon-android-checkbox-outline-blank"),n.closest(".um-field-checkbox").find("i").addClass("um-icon-android-checkbox-outline"),n.closest(".um-field-checkbox").addClass("active")});else{var t=a.find('input[type=checkbox][value="'+n.value+'"]');t.attr("checked",!0),t.closest(".um-field-checkbox").find("i").removeClass("um-icon-android-checkbox-outline-blank"),t.closest(".um-field-checkbox").find("i").addClass("um-icon-android-checkbox-outline"),t.closest(".um-field-checkbox").addClass("active")}break;case"radio":1<=a.find("input[type=radio]:checked").length&&setTimeout(function(){a.find("input[type=radio]:checked").removeAttr("checked"),a.find("span.um-field-radio-state i").removeClass("um-icon-android-radio-button-on"),a.find("span.um-field-radio-state i").addClass("um-icon-android-radio-button-off"),a.find(".um-field-radio.active").removeClass("active");var e=a.find("input[type=radio][value='"+n.value+"']");e.attr("checked",!0),e.closest(".um-field-radio").find("i").removeClass("um-icon-android-radio-button-off"),e.closest(".um-field-radio").find("i").addClass("um-icon-android-radio-button-on"),e.closest(".um-field-radio").addClass("active")},100)}if(!a.hasClass("um-field-has-changed")){var u=um_get_field_element(a);"radio"!=e&&"checkbox"!=e||(u=u.find(":checked")),u&&(u.trigger("change"),a.addClass("um-field-has-changed"))}}function um_field_hide_siblings(){jQuery.each(um_field_conditions,function(e,i){(1<=jQuery('.um-field[data-key="'+e+'"]:hidden').length||"none"==jQuery('.um-field[data-key="'+e+'"]').css("display"))&&jQuery.each(i,function(e,i){jQuery('.um-field[data-key="'+i.owner+'"]').hide()})})}function _hide_in_ie(e){void 0!==jQuery.browser&&jQuery.browser.msie&&e.css({visibility:"hidden"})}function _show_in_ie(e){void 0!==jQuery.browser&&jQuery.browser.msie&&e.css({visibility:"visible"})}function um_init_field_conditions(){var e=[];jQuery(".um-field[data-key]").each(function(){var a=jQuery(this).data("key");e.push(a);var u={};jQuery.each(jQuery(this)[0].attributes,function(e,i){if(-1!=i.name.indexOf("data-cond")){var n=i.name.slice(10),a=n.substring(1,0),t=n.slice(2);void 0===u[a]&&(u[a]={}),u[a][t]=i.value}}),jQuery.each(u,function(e,i){var n={field:{owner:a,action:i.action,parent:i.field,operator:i.operator,value:i.value,condition:{owner:a,action:i.action,operator:i.operator,value:i.value}}};arr_all_conditions.push(n)}),um_field_default_values[jQuery(this).data("key")]=um_get_field_default_value(jQuery(this))}),jQuery.each(e,function(e,i){um_field_conditions[i]=um_get_field_children(i)}),jQuery(".um-field[data-key]:visible").each(function(){var e=um_get_field_element(jQuery(this));void 0!==e.trigger&&e.trigger("change")})}jQuery(document).ready(function(){jQuery(document).on("change",'.um-field select, .um-field input[type="radio"], .um-field input[type="checkbox"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("input change",'.um-field input[type="text"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("input change",'.um-field input[type="number"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("input change",'.um-field input[type="password"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("um_fields_change",function(){um_field_hide_siblings(),um_field_hide_siblings()}),um_init_field_conditions()});
1
+ var arr_all_conditions=[],um_field_conditions={},um_field_default_values={};function um_get_field_default_value(e){var i="",n=um_get_field_type(e);switch(n){case"text":case"number":case"date":case"textarea":case"select":i=e.find('input:text,input[type="number"],textarea,select').val();break;case"multiselect":i=e.find("select").val();break;case"radio":1<=e.find('input[type="radio"]:checked').length&&(i=e.find('input[type="radio"]:checked').val());break;case"checkbox":if(1<=e.find('input[type="checkbox"]:checked').length)if(1<e.find('input[type="checkbox"]:checked').length){var a=[];a.push(i),e.find('input[type="checkbox"]:checked').each(function(){a.push(jQuery(this).val())}),i=a}else i=e.find('input[type="checkbox"]:checked').val();break;default:i=wp.hooks.applyFilters("um_conditional_logic_default_value",i,n,e)}return{type:n,value:i}}function um_get_field_element(e){var i=e.find("input,textarea,select"),n=um_get_field_type(e);return i=wp.hooks.applyFilters("um_conditional_logic_field_element",i,n,e)}function um_get_field_type(e){var n="",i=e.attr("class").split(" ");return jQuery.each(i,function(e,i){/um-field-type_/.test(i)&&(n=i.replace("um-field-type_","").trim())}),n}function um_get_field_children(n){var a=[];return jQuery.each(arr_all_conditions,function(e,i){i.field.parent===n&&a.push(i.field.condition)}),a}function um_splitup_array(e,i){for(var n=e.length%i,a=n,t=Math.floor(e.length/i),u=[],o=0;o<e.length;o+=t){var r=t+o,d=!1;0!==n&&a&&(r++,a--,d=!0),u.push(e.slice(o,r)),d&&o++}var c=[];return jQuery.each(u,function(e,i){c.push({action:i[0],if_field:i[1],operator:i[2],value:i[3]})}),c}function um_get_field_data(e){return um_live_field=e.parents(".um-field").data("key"),um_live_value=e.val(),e.is(":checkbox")&&(um_live_value="",1<e.parents(".um-field").find("input:checked").length?e.parents(".um-field").find("input:checked").each(function(){um_live_value=um_live_value+jQuery(this).val()+" "}):1<=e.parents(".um-field").find("input:checked").length&&(um_live_value=e.parents(".um-field").find("input:checked").val())),e.is(":radio")&&(um_live_value=e.parents(".um-field").find("input[type=radio]:checked").val()),um_live_value}function um_in_array(e,i,n){var a,t=!1;for(a in n=!!n,i)if(n&&i[a]===e||!n&&i[a]==e){t=!0;break}return t}function um_apply_conditions(n,e){if(n.parents(".um-field[data-key]").length){var i=n.parents(".um-field[data-key]").data("key"),a=um_field_conditions[i];if(void 0!==a){var t=um_get_field_type(n.parents(".um-field[data-key]")),u=um_get_field_data(n),o={},r={},d={};jQuery.each(a,function(e,i){void 0===r[i.owner]&&(r[i.owner]=[],d[i.owner]={}),r[i.owner].push(i.value),d[i.owner]=i}),jQuery.each(a,function(e,i){if(void 0===o[i.owner]&&(o[i.owner]={}),"empty"===i.operator){var n=jQuery.isArray(u)?u.join(""):u;o[i.owner][e]=!n||""===n}if("not empty"===i.operator){n=jQuery.isArray(u)?u.join(""):u;o[i.owner][e]=!(!n||""===n)}if("equals to"===i.operator){n=jQuery.isArray(u)&&1===u.length?u[0]:u;i.value===n&&um_in_array(n,r[i.owner])?o[i.owner][e]=!0:o[i.owner][e]=!1}if("not equals"===i.operator){n=jQuery.isArray(u)&&1===u.length?u[0]:u;jQuery.isNumeric(i.value)&&parseInt(n)!==parseInt(i.value)&&n&&!um_in_array(n,r[i.owner])?o[i.owner][e]=!0:i.value==n||um_in_array(n,r[i.owner])?o[i.owner][e]=!1:o[i.owner][e]=!0}if("greater than"===i.operator){n=jQuery.isArray(u)&&1===u.length?u[0]:u;jQuery.isNumeric(i.value)&&parseInt(n)>parseInt(i.value)?o[i.owner][e]=!0:o[i.owner][e]=!1}if("less than"===i.operator){n=jQuery.isArray(u)&&1===u.length?u[0]:u;jQuery.isNumeric(i.value)&&parseInt(n)<parseInt(i.value)?o[i.owner][e]=!0:o[i.owner][e]=!1}if("contains"===i.operator)switch(t){case"multiselect":u&&0<=u.indexOf(i.value)&&um_in_array(i.value,u)?o[i.owner][e]=!0:o[i.owner][e]=!1;break;case"checkbox":u&&0<=u.indexOf(i.value)?o[i.owner][e]=!0:o[i.owner][e]=!1;break;default:void 0===(o=wp.hooks.applyFilters("um_conditional_logic_contains_operator_owners",o,t,u,i,e))[i.owner][e]&&(u&&0<=u.indexOf(i.value)&&um_in_array(u,r[i.owner])?o[i.owner][e]=!0:o[i.owner][e]=!1)}}),jQuery.each(o,function(e,i){um_in_array(!0,i)?um_field_apply_action(n,d[e],!0):um_field_apply_action(n,d[e],!1)}),n.trigger("um_fields_change")}}}function um_field_apply_action(e,i,n){var a=jQuery('div.um-field[data-key="'+i.owner+'"]');return"show"===i.action&&n&&(a.is(":hidden")&&um_field_restore_default_value(a),a.show(),_show_in_ie(a)),"show"!==i.action||n||(a.hide(),_hide_in_ie(a)),"hide"===i.action&&n&&(a.hide(),_hide_in_ie(a)),"hide"!==i.action||n||(a.is(":hidden")&&um_field_restore_default_value(a),a.show(),_show_in_ie(a)),e.removeClass("um-field-has-changed")}function um_field_restore_default_value(a){var e=um_get_field_type(a),i=a.data("key"),n=um_field_default_values[i];switch(e){case"text":case"number":case"date":case"textarea":a.find('input:text,input[type="number"],textareas').val(n.value);break;case"select":a.find("select").find("option").prop("selected",!1),a.find("select").val(n.value),a.find("select").trigger("change");break;case"multiselect":a.find("select").find("option").prop("selected",!1),jQuery.each(n.value,function(e,i){a.find("select").find('option[value="'+i+'"]').attr("selected",!0)}),a.find("select").trigger("change");break;case"checkbox":if(1<=a.find('input[type="checkbox"]:checked').length)if(a.find('input[type="checkbox"]:checked').removeAttr("checked"),a.find("span.um-field-checkbox-state i").removeClass("um-icon-android-checkbox-outline"),a.find("span.um-field-checkbox-state i").addClass("um-icon-android-checkbox-outline-blank"),a.find(".um-field-checkbox.active").removeClass("active"),jQuery.isArray(n.value))jQuery.each(n.value,function(e,i){var n=a.find('input[type="checkbox"][value="'+i+'"]');n.attr("checked",!0),n.closest(".um-field-checkbox").find("i").removeClass("um-icon-android-checkbox-outline-blank"),n.closest(".um-field-checkbox").find("i").addClass("um-icon-android-checkbox-outline"),n.closest(".um-field-checkbox").addClass("active")});else{var t=a.find('input[type="checkbox"][value="'+n.value+'"]');t.attr("checked",!0),t.closest(".um-field-checkbox").find("i").removeClass("um-icon-android-checkbox-outline-blank"),t.closest(".um-field-checkbox").find("i").addClass("um-icon-android-checkbox-outline"),t.closest(".um-field-checkbox").addClass("active")}break;case"radio":1<=a.find('input[type="radio"]:checked').length&&setTimeout(function(){a.find('input[type="radio"]:checked').removeAttr("checked"),a.find("span.um-field-radio-state i").removeClass("um-icon-android-radio-button-on"),a.find("span.um-field-radio-state i").addClass("um-icon-android-radio-button-off"),a.find(".um-field-radio.active").removeClass("active");var e=a.find('input[type="radio"][value="'+n.value+'"]');e.attr("checked",!0),e.closest(".um-field-radio").find("i").removeClass("um-icon-android-radio-button-off"),e.closest(".um-field-radio").find("i").addClass("um-icon-android-radio-button-on"),e.closest(".um-field-radio").addClass("active")},100);break;default:wp.hooks.doAction("um_conditional_logic_restore_default_value",e,a,n)}if(!a.hasClass("um-field-has-changed")){var u=um_get_field_element(a);"radio"!==e&&"checkbox"!==e||(u=u.find(":checked")),u&&(u.trigger("change"),a.addClass("um-field-has-changed"))}}function um_field_hide_siblings(){jQuery.each(um_field_conditions,function(e,i){(1<=jQuery('.um-field[data-key="'+e+'"]:hidden').length||"none"===jQuery('.um-field[data-key="'+e+'"]').css("display"))&&jQuery.each(i,function(e,i){jQuery('.um-field[data-key="'+i.owner+'"]').hide()})})}function _hide_in_ie(e){void 0!==jQuery.browser&&jQuery.browser.msie&&e.css({visibility:"hidden"})}function _show_in_ie(e){void 0!==jQuery.browser&&jQuery.browser.msie&&e.css({visibility:"visible"})}function um_init_field_conditions(){var e=[];jQuery(".um-field[data-key]").each(function(){var a=jQuery(this).data("key");e.push(a);var u={};jQuery.each(jQuery(this)[0].attributes,function(e,i){if(-1!==i.name.indexOf("data-cond")){var n=i.name.slice(10),a=n.substring(1,0),t=n.slice(2);void 0===u[a]&&(u[a]={}),u[a][t]=i.value}}),jQuery.each(u,function(e,i){var n={field:{owner:a,action:i.action,parent:i.field,operator:i.operator,value:i.value,condition:{owner:a,action:i.action,operator:i.operator,value:i.value}}};arr_all_conditions.push(n)}),um_field_default_values[jQuery(this).data("key")]=um_get_field_default_value(jQuery(this))}),jQuery.each(e,function(e,i){um_field_conditions[i]=um_get_field_children(i)}),jQuery(".um-field[data-key]:visible").each(function(){var e=um_get_field_element(jQuery(this));void 0!==e.trigger&&e.trigger("change")})}jQuery(document).ready(function(){jQuery(document).on("change",'.um-field select, .um-field input[type="radio"], .um-field input[type="checkbox"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("input change",'.um-field input[type="text"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("input change",'.um-field input[type="number"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("input change",'.um-field input[type="password"]',function(){um_apply_conditions(jQuery(this),!1)}),jQuery(document).on("um_fields_change",function(){um_field_hide_siblings(),um_field_hide_siblings()}),um_init_field_conditions()});
assets/js/um-functions.js CHANGED
@@ -209,217 +209,217 @@ function um_responsive(){
209
 
210
  function initImageUpload_UM( trigger ) {
211
 
212
- if (trigger.data('upload_help_text')){
213
- upload_help_text = '<span class="help">' + trigger.data('upload_help_text') + '</span>';
214
- } else {
215
- upload_help_text = '';
216
- }
217
 
218
- if ( trigger.data('icon') ) {
219
- icon = '<span class="icon"><i class="'+ trigger.data('icon') + '"></i></span>';
220
- } else {
221
- icon = '';
222
- }
223
 
224
- if ( trigger.data('upload_text') ) {
225
- upload_text = '<span class="str">' + trigger.data('upload_text') + '</span>';
226
- } else {
227
- upload_text = '';
228
- }
229
 
230
- var user_id = 0;
231
-
232
- if( jQuery('#um_upload_single:visible').data('user_id') ){
233
- user_id = jQuery('#um_upload_single:visible').data('user_id');
234
- }
235
-
236
- trigger.uploadFile({
237
- url: wp.ajax.settings.url,
238
- method: "POST",
239
- multiple: false,
240
- formData: {
241
- action: 'um_imageupload',
242
- key: trigger.data('key'),
243
- set_id: trigger.data('set_id'),
244
- set_mode: trigger.data('set_mode'),
245
- _wpnonce: trigger.data('nonce'),
246
- timestamp: trigger.data('timestamp'),
247
- user_id: user_id
248
- },
249
- fileName: trigger.data('key'),
250
- allowedTypes: trigger.data('allowed_types'),
251
- maxFileSize: trigger.data('max_size'),
252
- dragDropStr: icon + upload_text + upload_help_text,
253
- sizeErrorStr: trigger.data('max_size_error'),
254
- extErrorStr: trigger.data('extension_error'),
255
- maxFileCountErrorStr: trigger.data('max_files_error'),
256
- maxFileCount: 1,
257
- showDelete: false,
258
- showAbort: false,
259
- showDone: false,
260
- showFileCounter: false,
261
- showStatusAfterSuccess: true,
262
- returnType: 'json',
263
- onSubmit:function(files){
264
-
265
- trigger.parents('.um-modal-body').find('.um-error-block').remove();
266
-
267
- },
268
- onSuccess:function( files, response, xhr ){
269
-
270
- trigger.selectedFiles = 0;
271
-
272
- if ( response.success && response.success == false || typeof response.data.error !== 'undefined' ) {
273
-
274
- trigger.parents('.um-modal-body').append('<div class="um-error-block">'+response.data.error+'</div>');
275
- trigger.parents('.um-modal-body').find('.upload-statusbar').hide(0);
276
- um_modal_responsive();
 
 
277
 
278
- } else {
279
-
280
- jQuery.each( response.data, function( i, d ) {
281
-
282
- var img_id = trigger.parents('.um-modal-body').find('.um-single-image-preview img');
283
- var img_id_h = trigger.parents('.um-modal-body').find('.um-single-image-preview');
284
 
285
- var cache_ts = new Date();
286
-
287
- img_id.attr("src", d.url + "?"+cache_ts.getTime() );
288
- img_id.data("file", d.file );
289
 
290
- img_id.load(function(){
291
 
292
- trigger.parents('.um-modal-body').find('.um-modal-btn.um-finish-upload.disabled').removeClass('disabled');
293
- trigger.parents('.um-modal-body').find('.ajax-upload-dragdrop,.upload-statusbar').hide(0);
294
- img_id_h.show(0);
295
- um_modal_responsive();
296
 
297
- });
 
 
 
 
 
298
 
299
  });
300
 
301
- }
302
 
303
- },
304
- onError: function ( e ){
305
- console.log( e );
306
  }
307
- });
 
 
 
 
 
308
 
309
  }
310
 
311
  function initFileUpload_UM( trigger ) {
312
 
313
- if (trigger.data('upload_help_text')){
314
- upload_help_text = '<span class="help">' + trigger.data('upload_help_text') + '</span>';
315
- } else {
316
- upload_help_text = '';
317
- }
318
 
319
- if ( trigger.data('icon') ) {
320
- icon = '<span class="icon"><i class="'+ trigger.data('icon') + '"></i></span>';
321
- } else {
322
- icon = '';
323
- }
324
 
325
- if ( trigger.data('upload_text') ) {
326
- upload_text = '<span class="str">' + trigger.data('upload_text') + '</span>';
327
- } else {
328
- upload_text = '';
329
- }
330
 
331
- if( jQuery('#um_upload_single:visible').data('user_id') ){
332
- user_id = jQuery('#um_upload_single:visible').data('user_id');
333
- }
334
-
335
- trigger.uploadFile({
336
- url: wp.ajax.settings.url,
337
- method: "POST",
338
- multiple: false,
339
- formData: {
340
- action: 'um_fileupload',
341
- key: trigger.data('key'),
342
- set_id: trigger.data('set_id'),
343
- user_id: trigger.data('user_id'),
344
- set_mode: trigger.data('set_mode'),
345
- _wpnonce: trigger.data('nonce'),
346
- timestamp: trigger.data('timestamp')
347
- },
348
- fileName: trigger.data('key'),
349
- allowedTypes: trigger.data('allowed_types'),
350
- maxFileSize: trigger.data('max_size'),
351
- dragDropStr: icon + upload_text + upload_help_text,
352
- sizeErrorStr: trigger.data('max_size_error'),
353
- extErrorStr: trigger.data('extension_error'),
354
- maxFileCountErrorStr: trigger.data('max_files_error'),
355
- maxFileCount: 1,
356
- showDelete: false,
357
- showAbort: false,
358
- showDone: false,
359
- showFileCounter: false,
360
- showStatusAfterSuccess: true,
361
- onSubmit:function(files){
362
-
363
- trigger.parents('.um-modal-body').find('.um-error-block').remove();
364
-
365
- },
366
- onSuccess:function( files, response ,xhr ){
367
-
368
- trigger.selectedFiles = 0;
369
-
370
- if ( response.success && response.success == false || typeof response.data.error !== 'undefined' ) {
371
-
372
- trigger.parents('.um-modal-body').append('<div class="um-error-block">'+ response.data.error+'</div>');
373
- trigger.parents('.um-modal-body').find('.upload-statusbar').hide(0);
374
-
375
- setTimeout(function(){
376
- um_modal_responsive();
377
- },1000);
378
 
379
- } else {
380
 
381
- jQuery.each( response.data , function(key, value) {
382
 
383
- trigger.parents('.um-modal-body').find('.um-modal-btn.um-finish-upload.disabled').removeClass('disabled');
384
- trigger.parents('.um-modal-body').find('.ajax-upload-dragdrop,.upload-statusbar').hide(0);
385
- trigger.parents('.um-modal-body').find('.um-single-file-preview').show(0);
386
-
387
- if ( key == 'icon' ) {
388
-
389
- trigger.parents('.um-modal-body').find('.um-single-fileinfo i').removeClass().addClass( value );
390
-
391
- } else if ( key == 'icon_bg' ) {
392
-
393
- trigger.parents('.um-modal-body').find('.um-single-fileinfo span.icon').css({'background-color' : value } );
394
-
395
- } else if ( key == 'filename' ) {
396
-
397
- trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('data-file', value );
398
-
399
- }else if( key == 'original_name' ){
400
-
401
- trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('data-orignal-name', value );
402
- trigger.parents('.um-modal-body').find('.um-single-fileinfo span.filename').html( value );
403
-
404
- } else if ( key == 'url' ) {
405
-
406
- trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('href', value);
407
-
408
- }
409
 
410
- });
411
 
412
- setTimeout(function(){
413
- um_modal_responsive();
414
- },1000);
415
 
416
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
 
418
- },
419
- onError: function ( e ){
420
- console.log( e );
421
  }
422
- });
 
 
 
 
 
423
 
424
  }
425
 
@@ -548,7 +548,7 @@ function um_new_modal( id, size, isPhoto, source ){
548
  var photo_maxh = jQuery(window).height() - ( jQuery(window).height() * 0.25 );
549
 
550
  photo_.attr("src", source);
551
- photo_.load(function(){
552
 
553
  jQuery('#' + id).show();
554
  jQuery('.um-modal').show();
209
 
210
  function initImageUpload_UM( trigger ) {
211
 
212
+ if (trigger.data('upload_help_text')){
213
+ upload_help_text = '<span class="help">' + trigger.data('upload_help_text') + '</span>';
214
+ } else {
215
+ upload_help_text = '';
216
+ }
217
 
218
+ if ( trigger.data('icon') ) {
219
+ icon = '<span class="icon"><i class="'+ trigger.data('icon') + '"></i></span>';
220
+ } else {
221
+ icon = '';
222
+ }
223
 
224
+ if ( trigger.data('upload_text') ) {
225
+ upload_text = '<span class="str">' + trigger.data('upload_text') + '</span>';
226
+ } else {
227
+ upload_text = '';
228
+ }
229
 
230
+ var user_id = 0;
231
+
232
+ if( jQuery('#um_upload_single:visible').data('user_id') ){
233
+ user_id = jQuery('#um_upload_single:visible').data('user_id');
234
+ }
235
+
236
+ trigger.uploadFile({
237
+ url: wp.ajax.settings.url,
238
+ method: "POST",
239
+ multiple: false,
240
+ formData: {
241
+ action: 'um_imageupload',
242
+ key: trigger.data('key'),
243
+ set_id: trigger.data('set_id'),
244
+ set_mode: trigger.data('set_mode'),
245
+ _wpnonce: trigger.data('nonce'),
246
+ timestamp: trigger.data('timestamp'),
247
+ user_id: user_id
248
+ },
249
+ fileName: trigger.data('key'),
250
+ allowedTypes: trigger.data('allowed_types'),
251
+ maxFileSize: trigger.data('max_size'),
252
+ dragDropStr: icon + upload_text + upload_help_text,
253
+ sizeErrorStr: trigger.data('max_size_error'),
254
+ extErrorStr: trigger.data('extension_error'),
255
+ maxFileCountErrorStr: trigger.data('max_files_error'),
256
+ maxFileCount: 1,
257
+ showDelete: false,
258
+ showAbort: false,
259
+ showDone: false,
260
+ showFileCounter: false,
261
+ showStatusAfterSuccess: true,
262
+ returnType: 'json',
263
+ onSubmit:function(files){
264
+
265
+ trigger.parents('.um-modal-body').find('.um-error-block').remove();
266
+
267
+ },
268
+ onSuccess:function( files, response, xhr ){
269
+
270
+ trigger.selectedFiles = 0;
271
+
272
+ if ( response.success && response.success == false || typeof response.data.error !== 'undefined' ) {
273
+
274
+ trigger.parents('.um-modal-body').append('<div class="um-error-block">'+response.data.error+'</div>');
275
+ trigger.parents('.um-modal-body').find('.upload-statusbar').hide(0);
276
+ um_modal_responsive();
277
+
278
+ } else {
279
 
280
+ jQuery.each( response.data, function( i, d ) {
 
 
 
 
 
281
 
282
+ var img_id = trigger.parents('.um-modal-body').find('.um-single-image-preview img');
283
+ var img_id_h = trigger.parents('.um-modal-body').find('.um-single-image-preview');
 
 
284
 
285
+ var cache_ts = new Date();
286
 
287
+ img_id.attr("src", d.url + "?"+cache_ts.getTime() );
288
+ img_id.data("file", d.file );
 
 
289
 
290
+ img_id.on( 'load', function() {
291
+
292
+ trigger.parents('.um-modal-body').find('.um-modal-btn.um-finish-upload.disabled').removeClass('disabled');
293
+ trigger.parents('.um-modal-body').find('.ajax-upload-dragdrop,.upload-statusbar').hide(0);
294
+ img_id_h.show(0);
295
+ um_modal_responsive();
296
 
297
  });
298
 
299
+ });
300
 
 
 
 
301
  }
302
+
303
+ },
304
+ onError: function ( e ){
305
+ console.log( e );
306
+ }
307
+ });
308
 
309
  }
310
 
311
  function initFileUpload_UM( trigger ) {
312
 
313
+ if (trigger.data('upload_help_text')){
314
+ upload_help_text = '<span class="help">' + trigger.data('upload_help_text') + '</span>';
315
+ } else {
316
+ upload_help_text = '';
317
+ }
318
 
319
+ if ( trigger.data('icon') ) {
320
+ icon = '<span class="icon"><i class="'+ trigger.data('icon') + '"></i></span>';
321
+ } else {
322
+ icon = '';
323
+ }
324
 
325
+ if ( trigger.data('upload_text') ) {
326
+ upload_text = '<span class="str">' + trigger.data('upload_text') + '</span>';
327
+ } else {
328
+ upload_text = '';
329
+ }
330
 
331
+ if( jQuery('#um_upload_single:visible').data('user_id') ){
332
+ user_id = jQuery('#um_upload_single:visible').data('user_id');
333
+ }
334
+
335
+ trigger.uploadFile({
336
+ url: wp.ajax.settings.url,
337
+ method: "POST",
338
+ multiple: false,
339
+ formData: {
340
+ action: 'um_fileupload',
341
+ key: trigger.data('key'),
342
+ set_id: trigger.data('set_id'),
343
+ user_id: trigger.data('user_id'),
344
+ set_mode: trigger.data('set_mode'),
345
+ _wpnonce: trigger.data('nonce'),
346
+ timestamp: trigger.data('timestamp')
347
+ },
348
+ fileName: trigger.data('key'),
349
+ allowedTypes: trigger.data('allowed_types'),
350
+ maxFileSize: trigger.data('max_size'),
351
+ dragDropStr: icon + upload_text + upload_help_text,
352
+ sizeErrorStr: trigger.data('max_size_error'),
353
+ extErrorStr: trigger.data('extension_error'),
354
+ maxFileCountErrorStr: trigger.data('max_files_error'),
355
+ maxFileCount: 1,
356
+ showDelete: false,
357
+ showAbort: false,
358
+ showDone: false,
359
+ showFileCounter: false,
360
+ showStatusAfterSuccess: true,
361
+ onSubmit:function(files){
362
+
363
+ trigger.parents('.um-modal-body').find('.um-error-block').remove();
364
+
365
+ },
366
+ onSuccess:function( files, response ,xhr ){
367
+
368
+ trigger.selectedFiles = 0;
369
+
370
+ if ( response.success && response.success == false || typeof response.data.error !== 'undefined' ) {
371
+
372
+ trigger.parents('.um-modal-body').append('<div class="um-error-block">'+ response.data.error+'</div>');
373
+ trigger.parents('.um-modal-body').find('.upload-statusbar').hide(0);
374
+
375
+ setTimeout(function(){
376
+ um_modal_responsive();
377
+ },1000);
378
 
379
+ } else {
380
 
381
+ jQuery.each( response.data , function(key, value) {
382
 
383
+ trigger.parents('.um-modal-body').find('.um-modal-btn.um-finish-upload.disabled').removeClass('disabled');
384
+ trigger.parents('.um-modal-body').find('.ajax-upload-dragdrop,.upload-statusbar').hide(0);
385
+ trigger.parents('.um-modal-body').find('.um-single-file-preview').show(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
 
387
+ if ( key == 'icon' ) {
388
 
389
+ trigger.parents('.um-modal-body').find('.um-single-fileinfo i').removeClass().addClass( value );
 
 
390
 
391
+ } else if ( key == 'icon_bg' ) {
392
+
393
+ trigger.parents('.um-modal-body').find('.um-single-fileinfo span.icon').css({'background-color' : value } );
394
+
395
+ } else if ( key == 'filename' ) {
396
+
397
+ trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('data-file', value );
398
+
399
+ }else if( key == 'original_name' ){
400
+
401
+ trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('data-orignal-name', value );
402
+ trigger.parents('.um-modal-body').find('.um-single-fileinfo span.filename').html( value );
403
+
404
+ } else if ( key == 'url' ) {
405
+
406
+ trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('href', value);
407
+
408
+ }
409
+
410
+ });
411
+
412
+ setTimeout(function(){
413
+ um_modal_responsive();
414
+ },1000);
415
 
 
 
 
416
  }
417
+
418
+ },
419
+ onError: function ( e ){
420
+ console.log( e );
421
+ }
422
+ });
423
 
424
  }
425
 
548
  var photo_maxh = jQuery(window).height() - ( jQuery(window).height() * 0.25 );
549
 
550
  photo_.attr("src", source);
551
+ photo_.on( 'load', function() {
552
 
553
  jQuery('#' + id).show();
554
  jQuery('.um-modal').show();
assets/js/um-functions.min.js CHANGED
@@ -1 +1 @@
1
- function UM_check_password_matched(){jQuery(document).on("keyup","input[data-key=user_password],input[data-key=confirm_user_password]",function(e){var t=jQuery("input[data-key=user_password]").val(),a=jQuery("input[data-key=confirm_user_password]").val(),o=jQuery("input[data-key=user_password],input[data-key=confirm_user_password]");t||a?t!==a?o.removeClass("um-validate-matched").addClass("um-validate-not-matched"):o.removeClass("um-validate-not-matched").addClass("um-validate-matched"):o.removeClass("um-validate-matched").removeClass("um-validate-not-matched")})}function UM_hide_menus(){var e=jQuery(".um-dropdown");e.parents("div").find("a").removeClass("active"),e.hide()}function UM_domenus(){jQuery(".um-dropdown").each(function(){var e=jQuery(this),t=jQuery(this).attr("data-element"),a=jQuery(this).attr("data-position");if(jQuery(t).addClass("um-trigger-menu-on-"+e.attr("data-trigger")),"lc"===a&&"rtl"===jQuery("html").attr("dir")&&(a="rc"),jQuery(window).width()<=1200&&"div.um-profile-edit"===t&&(a="rtl"===jQuery("html").attr("dir")?"rc":"lc"),jQuery(t).find("img").width()<200?left_p=(jQuery(t).width()-jQuery(t).find("img").width())/2+(jQuery(t).find("img").width()-200)/2:left_p=(jQuery(t).width()-jQuery(t).find("img").width())/2,top_=parseInt(jQuery(t).find("a").css("top")),top_?top_p=jQuery(t).find("img").height()+4+top_:top_p=jQuery(t).find("img").height()+4,4==top_p&&"div.um-cover"===t?top_p=jQuery(t).height()/2+e.height()/2:4==top_p&&(top_p=jQuery(t).height()+20),"lc"===a)gap_right=jQuery(t).width()+17,e.css({top:0,width:200,left:"auto",right:gap_right+"px","text-align":"center"}),e.find(".um-dropdown-arr").find("i").removeClass().addClass("um-icon-arrow-right-b"),e.find(".um-dropdown-arr").css({top:"4px",left:"auto",right:"-17px"});else if("rc"===a)gap_right=jQuery(t).width()+25,e.css({top:0,width:200,left:gap_right+"px",right:"auto","text-align":"center"}),e.find(".um-dropdown-arr").find("i").removeClass().addClass("um-icon-arrow-left-b"),e.find(".um-dropdown-arr").css({top:"4px",left:"-17px",right:"auto"});else if("bc"===a){var o=0,i=e.data("top-offset");void 0!==i&&(o=1*i),e.css({top:top_p+o,width:200,left:left_p,right:"auto","text-align":"center"}),e.find(".um-dropdown-arr").find("i").removeClass().addClass("um-icon-arrow-up-b"),e.find(".um-dropdown-arr").css({top:"-17px",left:e.width()/2-12,right:"auto"})}})}function um_responsive(){jQuery(".um").each(function(){element_width=jQuery(this).width(),element_width<=340?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob340")):element_width<=500?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob500")):element_width<=800?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob800")):element_width<=960?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob960")):960<element_width&&(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960")),0<jQuery(".um-account-nav").length&&jQuery(".um-account-side").is(":visible")&&0==jQuery(".um-account-tab:visible").length&&jQuery(".um-account-side li a.current").trigger("click"),jQuery(this).css("opacity",1)}),jQuery(".um-cover, .um-member-cover, .um-cover-e").each(function(){var e=jQuery(this),t=e.data("ratio"),a=e.width(),o=t.split(":");calcHeight=Math.round(a/o[0])+"px",e.height(calcHeight),e.find(".um-cover-add").height(calcHeight)}),UM_domenus()}function initImageUpload_UM(r){r.data("upload_help_text")?upload_help_text='<span class="help">'+r.data("upload_help_text")+"</span>":upload_help_text="",r.data("icon")?icon='<span class="icon"><i class="'+r.data("icon")+'"></i></span>':icon="",r.data("upload_text")?upload_text='<span class="str">'+r.data("upload_text")+"</span>":upload_text="";var e=0;jQuery("#um_upload_single:visible").data("user_id")&&(e=jQuery("#um_upload_single:visible").data("user_id")),r.uploadFile({url:wp.ajax.settings.url,method:"POST",multiple:!1,formData:{action:"um_imageupload",key:r.data("key"),set_id:r.data("set_id"),set_mode:r.data("set_mode"),_wpnonce:r.data("nonce"),timestamp:r.data("timestamp"),user_id:e},fileName:r.data("key"),allowedTypes:r.data("allowed_types"),maxFileSize:r.data("max_size"),dragDropStr:icon+upload_text+upload_help_text,sizeErrorStr:r.data("max_size_error"),extErrorStr:r.data("extension_error"),maxFileCountErrorStr:r.data("max_files_error"),maxFileCount:1,showDelete:!1,showAbort:!1,showDone:!1,showFileCounter:!1,showStatusAfterSuccess:!0,returnType:"json",onSubmit:function(e){r.parents(".um-modal-body").find(".um-error-block").remove()},onSuccess:function(e,t,a){r.selectedFiles=0,t.success&&0==t.success||void 0!==t.data.error?(r.parents(".um-modal-body").append('<div class="um-error-block">'+t.data.error+"</div>"),r.parents(".um-modal-body").find(".upload-statusbar").hide(0),um_modal_responsive()):jQuery.each(t.data,function(e,t){var a=r.parents(".um-modal-body").find(".um-single-image-preview img"),o=r.parents(".um-modal-body").find(".um-single-image-preview"),i=new Date;a.attr("src",t.url+"?"+i.getTime()),a.data("file",t.file),a.load(function(){r.parents(".um-modal-body").find(".um-modal-btn.um-finish-upload.disabled").removeClass("disabled"),r.parents(".um-modal-body").find(".ajax-upload-dragdrop,.upload-statusbar").hide(0),o.show(0),um_modal_responsive()})})},onError:function(e){console.log(e)}})}function initFileUpload_UM(o){o.data("upload_help_text")?upload_help_text='<span class="help">'+o.data("upload_help_text")+"</span>":upload_help_text="",o.data("icon")?icon='<span class="icon"><i class="'+o.data("icon")+'"></i></span>':icon="",o.data("upload_text")?upload_text='<span class="str">'+o.data("upload_text")+"</span>":upload_text="",jQuery("#um_upload_single:visible").data("user_id")&&(user_id=jQuery("#um_upload_single:visible").data("user_id")),o.uploadFile({url:wp.ajax.settings.url,method:"POST",multiple:!1,formData:{action:"um_fileupload",key:o.data("key"),set_id:o.data("set_id"),user_id:o.data("user_id"),set_mode:o.data("set_mode"),_wpnonce:o.data("nonce"),timestamp:o.data("timestamp")},fileName:o.data("key"),allowedTypes:o.data("allowed_types"),maxFileSize:o.data("max_size"),dragDropStr:icon+upload_text+upload_help_text,sizeErrorStr:o.data("max_size_error"),extErrorStr:o.data("extension_error"),maxFileCountErrorStr:o.data("max_files_error"),maxFileCount:1,showDelete:!1,showAbort:!1,showDone:!1,showFileCounter:!1,showStatusAfterSuccess:!0,onSubmit:function(e){o.parents(".um-modal-body").find(".um-error-block").remove()},onSuccess:function(e,t,a){o.selectedFiles=0,t.success&&0==t.success||void 0!==t.data.error?(o.parents(".um-modal-body").append('<div class="um-error-block">'+t.data.error+"</div>"),o.parents(".um-modal-body").find(".upload-statusbar").hide(0)):jQuery.each(t.data,function(e,t){o.parents(".um-modal-body").find(".um-modal-btn.um-finish-upload.disabled").removeClass("disabled"),o.parents(".um-modal-body").find(".ajax-upload-dragdrop,.upload-statusbar").hide(0),o.parents(".um-modal-body").find(".um-single-file-preview").show(0),"icon"==e?o.parents(".um-modal-body").find(".um-single-fileinfo i").removeClass().addClass(t):"icon_bg"==e?o.parents(".um-modal-body").find(".um-single-fileinfo span.icon").css({"background-color":t}):"filename"==e?o.parents(".um-modal-body").find(".um-single-fileinfo a").attr("data-file",t):"original_name"==e?(o.parents(".um-modal-body").find(".um-single-fileinfo a").attr("data-orignal-name",t),o.parents(".um-modal-body").find(".um-single-fileinfo span.filename").html(t)):"url"==e&&o.parents(".um-modal-body").find(".um-single-fileinfo a").attr("href",t)}),setTimeout(function(){um_modal_responsive()},1e3)},onError:function(e){console.log(e)}})}function initCrop_UM(){var t=jQuery(".um-modal .um-single-image-preview img").first(),e=jQuery(".um-modal .um-single-image-preview"),a=t.parent().attr("data-crop"),o=t.parent().attr("data-min_width"),i=t.parent().attr("data-min_height"),r=t.parent().attr("data-ratio");if(jQuery(".um-modal").find("#um_upload_single").attr("data-ratio"))r=(r=jQuery(".um-modal").find("#um_upload_single").attr("data-ratio")).split(":")[0];if(t.length&&""!=t.attr("src")){var d=jQuery(window).height()-(jQuery(".um-modal-footer a").height()+20)-50-jQuery(".um-modal-header:visible").height();if(t.css({height:"auto"}),e.css({height:"auto"}),jQuery(window).height()<=400?(e.css({height:d+"px","max-height":d+"px"}),t.css({height:"auto"})):(t.css({height:"auto","max-height":d+"px"}),e.css({height:t.height(),"max-height":d+"px"})),"square"==a)var u={minWidth:o,minHeight:i,dragCrop:!1,aspectRatio:1,zoomable:!1,rotatable:!1,dashed:!1,done:function(e){t.parent().attr("data-coord",Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height))}};else if("cover"==a){0<Math.round(o/r)&&(i=Math.round(o/r));u={minWidth:o,minHeight:i,dragCrop:!1,aspectRatio:r,zoomable:!1,rotatable:!1,dashed:!1,done:function(e){t.parent().attr("data-coord",Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height))}}}else if("user"==a)u={minWidth:o,minHeight:i,dragCrop:!0,aspectRatio:"auto",zoomable:!1,rotatable:!1,dashed:!1,done:function(e){t.parent().attr("data-coord",Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height))}};0!=a&&(t.cropper(u),jQuery(".um-single-image-preview img.cropper-hidden").cropper("destroy"),jQuery(".um-single-image-preview img.lazyloaded").addClass("cropper-hidden"),jQuery(".um-single-image-preview img.lazyloaded").removeClass("lazyloaded"),jQuery(".um-single-image-preview .cropper-container").append('<div class="um-clear"></div>'))}}function um_new_modal(e,t,a,o){if(0==jQuery("body").find(".um-modal-overlay").length)if(jQuery(".tipsy").hide(),UM_hide_menus(),jQuery("body,html,textarea").css("overflow","hidden"),jQuery(document).bind("touchmove",function(e){e.preventDefault()}),jQuery(".um-modal").on("touchmove",function(e){e.stopPropagation()}),a?jQuery("body").append('<div class="um-modal-overlay"></div><div class="um-modal is-photo"></div>'):jQuery("body").append('<div class="um-modal-overlay"></div><div class="um-modal no-photo"></div>'),jQuery("#"+e).prependTo(".um-modal"),a){jQuery(".um-modal").find(".um-modal-photo").html("<img />");var i=jQuery(".um-modal-photo img"),r=jQuery(window).width()-60,d=jQuery(window).height()-.25*jQuery(window).height();i.attr("src",o),i.load(function(){jQuery("#"+e).show(),jQuery(".um-modal").show(),i.css({opacity:0}),i.css({"max-width":r}),i.css({"max-height":d}),jQuery(".um-modal").css({width:i.width(),"margin-left":"-"+i.width()/2+"px"}),i.animate({opacity:1},1e3),um_modal_responsive()})}else jQuery("#"+e).show(),jQuery(".um-modal").show(),um_modal_size(t),initImageUpload_UM(jQuery(".um-modal:visible").find(".um-single-image-upload")),initFileUpload_UM(jQuery(".um-modal:visible").find(".um-single-file-upload")),um_modal_responsive()}function um_modal_responsive(){var e=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,a=jQuery(".um-modal:visible");if(jQuery(".um-modal-body.photo:visible").length){a.removeClass("uimob340"),a.removeClass("uimob500");var o=jQuery(".um-modal-photo img"),i=e-60,r=t-.25*t;o.css({opacity:0}),o.css({"max-width":i}),o.css({"max-height":r}),jQuery(".um-modal").css({width:o.width(),"margin-left":"-"+o.width()/2+"px"}),o.animate({opacity:1},1e3);var d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}else if(a.length)if(a.removeClass("uimob340"),a.removeClass("uimob500"),e<=340)a.addClass("uimob340"),initCrop_UM(),a.animate({bottom:0},300);else if(e<=500)a.addClass("uimob500"),initCrop_UM(),a.animate({bottom:0},300);else if(e<=800){initCrop_UM();d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}else if(e<=960){initCrop_UM();d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}else if(960<e){initCrop_UM();d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}}function um_remove_modal(){jQuery("img.cropper-hidden").cropper("destroy"),jQuery("body,html,textarea").css("overflow","auto"),jQuery(document).unbind("touchmove"),jQuery('.um-modal div[id^="um_"]').hide().appendTo("body"),jQuery(".um-modal,.um-modal-overlay").remove()}function um_modal_size(e){jQuery(".um-modal:visible").addClass(e)}function um_modal_add_attr(e,t){jQuery(".um-modal:visible").data(e,t)}function prepare_Modal(){0==jQuery(".um-popup-overlay").length&&(jQuery("body").append('<div class="um-popup-overlay"></div>'),jQuery("body").append('<div class="um-popup"></div>'),jQuery(".um-popup").addClass("loading"),jQuery("body,html").css({overflow:"hidden"}))}function remove_Modal(){jQuery(".um-popup-overlay").length&&(jQuery(document).trigger("um_before_modal_removed"),jQuery(".tipsy").remove(),jQuery(".um-popup").empty().remove(),jQuery(".um-popup-overlay").empty().remove(),jQuery("body,html").css({overflow:"auto"}))}function show_Modal(e){jQuery(".um-popup-overlay").length&&(jQuery(".um-popup").removeClass("loading").html(e),jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,offset:3}))}function responsive_Modal(){jQuery(".um-popup-overlay").length&&(ag_height=jQuery(window).height()-jQuery(".um-popup .um-popup-header").outerHeight()-jQuery(".um-popup .um-popup-footer").outerHeight()-80,350<ag_height&&(ag_height=350),jQuery(".um-popup-autogrow:visible").length?jQuery(".um-popup-autogrow:visible").css({height:ag_height+"px"}):jQuery(".um-popup-autogrow2:visible").length&&jQuery(".um-popup-autogrow2:visible").css({"max-height":ag_height+"px"}))}function um_reset_field(e){jQuery(e).find("div.um-field-area").find("input,textarea,select").not(":button, :submit, :reset, :hidden").val("").removeAttr("checked").removeAttr("selected")}function um_selected(e,t){if(e==t)return"selected='selected'"}jQuery(function(){jQuery(".um-search form *").keypress(function(e){if(13==e.which)return jQuery(".um-search form").submit(),!1}),2==jQuery("input[data-key=user_password],input[data-key=confirm_user_password]").length&&UM_check_password_matched()});
1
+ function UM_check_password_matched(){jQuery(document).on("keyup","input[data-key=user_password],input[data-key=confirm_user_password]",function(e){var t=jQuery("input[data-key=user_password]").val(),a=jQuery("input[data-key=confirm_user_password]").val(),o=jQuery("input[data-key=user_password],input[data-key=confirm_user_password]");t||a?t!==a?o.removeClass("um-validate-matched").addClass("um-validate-not-matched"):o.removeClass("um-validate-not-matched").addClass("um-validate-matched"):o.removeClass("um-validate-matched").removeClass("um-validate-not-matched")})}function UM_hide_menus(){var e=jQuery(".um-dropdown");e.parents("div").find("a").removeClass("active"),e.hide()}function UM_domenus(){jQuery(".um-dropdown").each(function(){var e=jQuery(this),t=jQuery(this).attr("data-element"),a=jQuery(this).attr("data-position");if(jQuery(t).addClass("um-trigger-menu-on-"+e.attr("data-trigger")),"lc"===a&&"rtl"===jQuery("html").attr("dir")&&(a="rc"),jQuery(window).width()<=1200&&"div.um-profile-edit"===t&&(a="rtl"===jQuery("html").attr("dir")?"rc":"lc"),jQuery(t).find("img").width()<200?left_p=(jQuery(t).width()-jQuery(t).find("img").width())/2+(jQuery(t).find("img").width()-200)/2:left_p=(jQuery(t).width()-jQuery(t).find("img").width())/2,top_=parseInt(jQuery(t).find("a").css("top")),top_?top_p=jQuery(t).find("img").height()+4+top_:top_p=jQuery(t).find("img").height()+4,4==top_p&&"div.um-cover"===t?top_p=jQuery(t).height()/2+e.height()/2:4==top_p&&(top_p=jQuery(t).height()+20),"lc"===a)gap_right=jQuery(t).width()+17,e.css({top:0,width:200,left:"auto",right:gap_right+"px","text-align":"center"}),e.find(".um-dropdown-arr").find("i").removeClass().addClass("um-icon-arrow-right-b"),e.find(".um-dropdown-arr").css({top:"4px",left:"auto",right:"-17px"});else if("rc"===a)gap_right=jQuery(t).width()+25,e.css({top:0,width:200,left:gap_right+"px",right:"auto","text-align":"center"}),e.find(".um-dropdown-arr").find("i").removeClass().addClass("um-icon-arrow-left-b"),e.find(".um-dropdown-arr").css({top:"4px",left:"-17px",right:"auto"});else if("bc"===a){var o=0,i=e.data("top-offset");void 0!==i&&(o=1*i),e.css({top:top_p+o,width:200,left:left_p,right:"auto","text-align":"center"}),e.find(".um-dropdown-arr").find("i").removeClass().addClass("um-icon-arrow-up-b"),e.find(".um-dropdown-arr").css({top:"-17px",left:e.width()/2-12,right:"auto"})}})}function um_responsive(){jQuery(".um").each(function(){element_width=jQuery(this).width(),element_width<=340?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob340")):element_width<=500?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob500")):element_width<=800?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob800")):element_width<=960?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob960")):960<element_width&&(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960")),0<jQuery(".um-account-nav").length&&jQuery(".um-account-side").is(":visible")&&0==jQuery(".um-account-tab:visible").length&&jQuery(".um-account-side li a.current").trigger("click"),jQuery(this).css("opacity",1)}),jQuery(".um-cover, .um-member-cover, .um-cover-e").each(function(){var e=jQuery(this),t=e.data("ratio"),a=e.width(),o=t.split(":");calcHeight=Math.round(a/o[0])+"px",e.height(calcHeight),e.find(".um-cover-add").height(calcHeight)}),UM_domenus()}function initImageUpload_UM(r){r.data("upload_help_text")?upload_help_text='<span class="help">'+r.data("upload_help_text")+"</span>":upload_help_text="",r.data("icon")?icon='<span class="icon"><i class="'+r.data("icon")+'"></i></span>':icon="",r.data("upload_text")?upload_text='<span class="str">'+r.data("upload_text")+"</span>":upload_text="";var e=0;jQuery("#um_upload_single:visible").data("user_id")&&(e=jQuery("#um_upload_single:visible").data("user_id")),r.uploadFile({url:wp.ajax.settings.url,method:"POST",multiple:!1,formData:{action:"um_imageupload",key:r.data("key"),set_id:r.data("set_id"),set_mode:r.data("set_mode"),_wpnonce:r.data("nonce"),timestamp:r.data("timestamp"),user_id:e},fileName:r.data("key"),allowedTypes:r.data("allowed_types"),maxFileSize:r.data("max_size"),dragDropStr:icon+upload_text+upload_help_text,sizeErrorStr:r.data("max_size_error"),extErrorStr:r.data("extension_error"),maxFileCountErrorStr:r.data("max_files_error"),maxFileCount:1,showDelete:!1,showAbort:!1,showDone:!1,showFileCounter:!1,showStatusAfterSuccess:!0,returnType:"json",onSubmit:function(e){r.parents(".um-modal-body").find(".um-error-block").remove()},onSuccess:function(e,t,a){r.selectedFiles=0,t.success&&0==t.success||void 0!==t.data.error?(r.parents(".um-modal-body").append('<div class="um-error-block">'+t.data.error+"</div>"),r.parents(".um-modal-body").find(".upload-statusbar").hide(0),um_modal_responsive()):jQuery.each(t.data,function(e,t){var a=r.parents(".um-modal-body").find(".um-single-image-preview img"),o=r.parents(".um-modal-body").find(".um-single-image-preview"),i=new Date;a.attr("src",t.url+"?"+i.getTime()),a.data("file",t.file),a.on("load",function(){r.parents(".um-modal-body").find(".um-modal-btn.um-finish-upload.disabled").removeClass("disabled"),r.parents(".um-modal-body").find(".ajax-upload-dragdrop,.upload-statusbar").hide(0),o.show(0),um_modal_responsive()})})},onError:function(e){console.log(e)}})}function initFileUpload_UM(o){o.data("upload_help_text")?upload_help_text='<span class="help">'+o.data("upload_help_text")+"</span>":upload_help_text="",o.data("icon")?icon='<span class="icon"><i class="'+o.data("icon")+'"></i></span>':icon="",o.data("upload_text")?upload_text='<span class="str">'+o.data("upload_text")+"</span>":upload_text="",jQuery("#um_upload_single:visible").data("user_id")&&(user_id=jQuery("#um_upload_single:visible").data("user_id")),o.uploadFile({url:wp.ajax.settings.url,method:"POST",multiple:!1,formData:{action:"um_fileupload",key:o.data("key"),set_id:o.data("set_id"),user_id:o.data("user_id"),set_mode:o.data("set_mode"),_wpnonce:o.data("nonce"),timestamp:o.data("timestamp")},fileName:o.data("key"),allowedTypes:o.data("allowed_types"),maxFileSize:o.data("max_size"),dragDropStr:icon+upload_text+upload_help_text,sizeErrorStr:o.data("max_size_error"),extErrorStr:o.data("extension_error"),maxFileCountErrorStr:o.data("max_files_error"),maxFileCount:1,showDelete:!1,showAbort:!1,showDone:!1,showFileCounter:!1,showStatusAfterSuccess:!0,onSubmit:function(e){o.parents(".um-modal-body").find(".um-error-block").remove()},onSuccess:function(e,t,a){o.selectedFiles=0,t.success&&0==t.success||void 0!==t.data.error?(o.parents(".um-modal-body").append('<div class="um-error-block">'+t.data.error+"</div>"),o.parents(".um-modal-body").find(".upload-statusbar").hide(0)):jQuery.each(t.data,function(e,t){o.parents(".um-modal-body").find(".um-modal-btn.um-finish-upload.disabled").removeClass("disabled"),o.parents(".um-modal-body").find(".ajax-upload-dragdrop,.upload-statusbar").hide(0),o.parents(".um-modal-body").find(".um-single-file-preview").show(0),"icon"==e?o.parents(".um-modal-body").find(".um-single-fileinfo i").removeClass().addClass(t):"icon_bg"==e?o.parents(".um-modal-body").find(".um-single-fileinfo span.icon").css({"background-color":t}):"filename"==e?o.parents(".um-modal-body").find(".um-single-fileinfo a").attr("data-file",t):"original_name"==e?(o.parents(".um-modal-body").find(".um-single-fileinfo a").attr("data-orignal-name",t),o.parents(".um-modal-body").find(".um-single-fileinfo span.filename").html(t)):"url"==e&&o.parents(".um-modal-body").find(".um-single-fileinfo a").attr("href",t)}),setTimeout(function(){um_modal_responsive()},1e3)},onError:function(e){console.log(e)}})}function initCrop_UM(){var t=jQuery(".um-modal .um-single-image-preview img").first(),e=jQuery(".um-modal .um-single-image-preview"),a=t.parent().attr("data-crop"),o=t.parent().attr("data-min_width"),i=t.parent().attr("data-min_height"),r=t.parent().attr("data-ratio");if(jQuery(".um-modal").find("#um_upload_single").attr("data-ratio"))r=(r=jQuery(".um-modal").find("#um_upload_single").attr("data-ratio")).split(":")[0];if(t.length&&""!=t.attr("src")){var d=jQuery(window).height()-(jQuery(".um-modal-footer a").height()+20)-50-jQuery(".um-modal-header:visible").height();if(t.css({height:"auto"}),e.css({height:"auto"}),jQuery(window).height()<=400?(e.css({height:d+"px","max-height":d+"px"}),t.css({height:"auto"})):(t.css({height:"auto","max-height":d+"px"}),e.css({height:t.height(),"max-height":d+"px"})),"square"==a)var u={minWidth:o,minHeight:i,dragCrop:!1,aspectRatio:1,zoomable:!1,rotatable:!1,dashed:!1,done:function(e){t.parent().attr("data-coord",Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height))}};else if("cover"==a){0<Math.round(o/r)&&(i=Math.round(o/r));u={minWidth:o,minHeight:i,dragCrop:!1,aspectRatio:r,zoomable:!1,rotatable:!1,dashed:!1,done:function(e){t.parent().attr("data-coord",Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height))}}}else if("user"==a)u={minWidth:o,minHeight:i,dragCrop:!0,aspectRatio:"auto",zoomable:!1,rotatable:!1,dashed:!1,done:function(e){t.parent().attr("data-coord",Math.round(e.x)+","+Math.round(e.y)+","+Math.round(e.width)+","+Math.round(e.height))}};0!=a&&(t.cropper(u),jQuery(".um-single-image-preview img.cropper-hidden").cropper("destroy"),jQuery(".um-single-image-preview img.lazyloaded").addClass("cropper-hidden"),jQuery(".um-single-image-preview img.lazyloaded").removeClass("lazyloaded"),jQuery(".um-single-image-preview .cropper-container").append('<div class="um-clear"></div>'))}}function um_new_modal(e,t,a,o){if(0==jQuery("body").find(".um-modal-overlay").length)if(jQuery(".tipsy").hide(),UM_hide_menus(),jQuery("body,html,textarea").css("overflow","hidden"),jQuery(document).bind("touchmove",function(e){e.preventDefault()}),jQuery(".um-modal").on("touchmove",function(e){e.stopPropagation()}),a?jQuery("body").append('<div class="um-modal-overlay"></div><div class="um-modal is-photo"></div>'):jQuery("body").append('<div class="um-modal-overlay"></div><div class="um-modal no-photo"></div>'),jQuery("#"+e).prependTo(".um-modal"),a){jQuery(".um-modal").find(".um-modal-photo").html("<img />");var i=jQuery(".um-modal-photo img"),r=jQuery(window).width()-60,d=jQuery(window).height()-.25*jQuery(window).height();i.attr("src",o),i.on("load",function(){jQuery("#"+e).show(),jQuery(".um-modal").show(),i.css({opacity:0}),i.css({"max-width":r}),i.css({"max-height":d}),jQuery(".um-modal").css({width:i.width(),"margin-left":"-"+i.width()/2+"px"}),i.animate({opacity:1},1e3),um_modal_responsive()})}else jQuery("#"+e).show(),jQuery(".um-modal").show(),um_modal_size(t),initImageUpload_UM(jQuery(".um-modal:visible").find(".um-single-image-upload")),initFileUpload_UM(jQuery(".um-modal:visible").find(".um-single-file-upload")),um_modal_responsive()}function um_modal_responsive(){var e=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,a=jQuery(".um-modal:visible");if(jQuery(".um-modal-body.photo:visible").length){a.removeClass("uimob340"),a.removeClass("uimob500");var o=jQuery(".um-modal-photo img"),i=e-60,r=t-.25*t;o.css({opacity:0}),o.css({"max-width":i}),o.css({"max-height":r}),jQuery(".um-modal").css({width:o.width(),"margin-left":"-"+o.width()/2+"px"}),o.animate({opacity:1},1e3);var d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}else if(a.length)if(a.removeClass("uimob340"),a.removeClass("uimob500"),e<=340)a.addClass("uimob340"),initCrop_UM(),a.animate({bottom:0},300);else if(e<=500)a.addClass("uimob500"),initCrop_UM(),a.animate({bottom:0},300);else if(e<=800){initCrop_UM();d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}else if(e<=960){initCrop_UM();d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}else if(960<e){initCrop_UM();d=(t-a.innerHeight())/2+"px";a.animate({bottom:d},300)}}function um_remove_modal(){jQuery("img.cropper-hidden").cropper("destroy"),jQuery("body,html,textarea").css("overflow","auto"),jQuery(document).unbind("touchmove"),jQuery('.um-modal div[id^="um_"]').hide().appendTo("body"),jQuery(".um-modal,.um-modal-overlay").remove()}function um_modal_size(e){jQuery(".um-modal:visible").addClass(e)}function um_modal_add_attr(e,t){jQuery(".um-modal:visible").data(e,t)}function prepare_Modal(){0==jQuery(".um-popup-overlay").length&&(jQuery("body").append('<div class="um-popup-overlay"></div>'),jQuery("body").append('<div class="um-popup"></div>'),jQuery(".um-popup").addClass("loading"),jQuery("body,html").css({overflow:"hidden"}))}function remove_Modal(){jQuery(".um-popup-overlay").length&&(jQuery(document).trigger("um_before_modal_removed"),jQuery(".tipsy").remove(),jQuery(".um-popup").empty().remove(),jQuery(".um-popup-overlay").empty().remove(),jQuery("body,html").css({overflow:"auto"}))}function show_Modal(e){jQuery(".um-popup-overlay").length&&(jQuery(".um-popup").removeClass("loading").html(e),jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,offset:3}))}function responsive_Modal(){jQuery(".um-popup-overlay").length&&(ag_height=jQuery(window).height()-jQuery(".um-popup .um-popup-header").outerHeight()-jQuery(".um-popup .um-popup-footer").outerHeight()-80,350<ag_height&&(ag_height=350),jQuery(".um-popup-autogrow:visible").length?jQuery(".um-popup-autogrow:visible").css({height:ag_height+"px"}):jQuery(".um-popup-autogrow2:visible").length&&jQuery(".um-popup-autogrow2:visible").css({"max-height":ag_height+"px"}))}function um_reset_field(e){jQuery(e).find("div.um-field-area").find("input,textarea,select").not(":button, :submit, :reset, :hidden").val("").removeAttr("checked").removeAttr("selected")}function um_selected(e,t){if(e==t)return"selected='selected'"}jQuery(function(){jQuery(".um-search form *").keypress(function(e){if(13==e.which)return jQuery(".um-search form").submit(),!1}),2==jQuery("input[data-key=user_password],input[data-key=confirm_user_password]").length&&UM_check_password_matched()});
assets/js/um-modal.js CHANGED
@@ -9,7 +9,7 @@ jQuery(document).ready(function() {
9
  um_remove_modal();
10
  });
11
 
12
- jQuery(document).on('click', 'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal a', function(e){
13
  e.preventDefault();
14
  return false;
15
  });
9
  um_remove_modal();
10
  });
11
 
12
+ jQuery(document).on('click', 'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a', function(e){
13
  e.preventDefault();
14
  return false;
15
  });
assets/js/um-modal.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href"),i=a.find(".um-single-file-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src"),i=a.find(".um-single-image-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);var t=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(t)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a=jQuery(this),t=jQuery(this).attr("data-key"),e=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),i=e.find("img").attr("src"),r=e.attr("data-coord"),u=e.find("img").data("file"),n=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(n=jQuery(this).parents("#um_upload_single").data("user_id"));var m=0,o="";if(1===jQuery('div.um-field-image[data-key="'+t+'"]').length){var s=jQuery('div.um-field-image[data-key="'+t+'"]').closest(".um-form");m=s.find('input[name="form_id"]').val(),o=s.attr("data-mode")}r?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:i,coord:r,user_id:n,key:t,set_id:m,set_mode:o,nonce:um_scripts.nonce},success:function(e){e.success&&(d=new Date,"profile_photo"===t?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+d.getTime()):"cover_photo"===t&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";if(jQuery(this).data("modal-size"))t=jQuery(this).data("modal-size");jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery("input[type=hidden][name='user_id']").length&&jQuery("#"+a).attr("data-user_id",jQuery("input[type=hidden][name='user_id']").val())),um_new_modal(a,t)})});
1
+ jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href"),i=a.find(".um-single-file-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src"),i=a.find(".um-single-image-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);var t=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(t)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a=jQuery(this),t=jQuery(this).attr("data-key"),e=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),i=e.find("img").attr("src"),r=e.attr("data-coord"),u=e.find("img").data("file"),m=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(m=jQuery(this).parents("#um_upload_single").data("user_id"));var n=0,o="";if(1===jQuery('div.um-field-image[data-key="'+t+'"]').length){var s=jQuery('div.um-field-image[data-key="'+t+'"]').closest(".um-form");n=s.find('input[name="form_id"]').val(),o=s.attr("data-mode")}r?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:i,coord:r,user_id:m,key:t,set_id:n,set_mode:o,nonce:um_scripts.nonce},success:function(e){e.success&&(d=new Date,"profile_photo"===t?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+d.getTime()):"cover_photo"===t&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";if(jQuery(this).data("modal-size"))t=jQuery(this).data("modal-size");jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery("input[type=hidden][name='user_id']").length&&jQuery("#"+a).attr("data-user_id",jQuery("input[type=hidden][name='user_id']").val())),um_new_modal(a,t)})});
assets/js/um-profile.js CHANGED
@@ -9,7 +9,7 @@ jQuery(document).ready(function() {
9
  });
10
 
11
  if ( jQuery('.um-profile.um-viewing .um-profile-body').length && jQuery('.um-profile.um-viewing .um-profile-body').find('.um-field').length == 0 ) {
12
- jQuery('.um-row-heading,.um-row').remove();
13
  jQuery('.um-profile-note').show();
14
  }
15
 
@@ -129,7 +129,7 @@ jQuery(document).ready(function() {
129
  return false;
130
  }
131
  });
132
-
133
  /**
134
  * Fix profile nav links for iPhone
135
  * @see https://www.html5rocks.com/en/mobile/touchandmouse/
9
  });
10
 
11
  if ( jQuery('.um-profile.um-viewing .um-profile-body').length && jQuery('.um-profile.um-viewing .um-profile-body').find('.um-field').length == 0 ) {
12
+ jQuery('.um-profile.um-viewing .um-profile-body').find('.um-row-heading,.um-row').remove();
13
  jQuery('.um-profile-note').show();
14
  }
15
 
129
  return false;
130
  }
131
  });
132
+
133
  /**
134
  * Fix profile nav links for iPhone
135
  * @see https://www.html5rocks.com/en/mobile/touchandmouse/
assets/js/um-profile.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){jQuery(".um-profile.um-viewing .um-profile-body .um-row").each(function(){var e=jQuery(this);0==e.find(".um-field").length&&(e.prev(".um-row-heading").remove(),e.remove())}),jQuery(".um-profile.um-viewing .um-profile-body").length&&0==jQuery(".um-profile.um-viewing .um-profile-body").find(".um-field").length&&(jQuery(".um-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document.body).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").submit(),!1}),jQuery(document.body).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document.body).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){e.preventDefault()}),jQuery(document.body).on("click",".um-photo-modal",function(e){e.preventDefault();var t=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,t),!1}),jQuery(document.body).on("click",".um-reset-profile-photo",function(e){return jQuery(".um-profile-photo-img img").attr("src",jQuery(this).attr("data-default_src")),user_id=jQuery(this).attr("data-user_id"),metakey="profile_photo",UM_hide_menus(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce}}),jQuery(this).parents("li").hide(),!1}),jQuery(document.body).on("click",".um-reset-cover-photo",function(e){var t=jQuery(this);return jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html('<a href="javascript:void(0);" class="um-cover-add" style="height: 370px;"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" original-title="Upload a cover photo"></i></span></a>'),um_responsive(),user_id=jQuery(this).attr("data-user_id"),metakey="cover_photo",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_cover_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce},success:function(e){t.hide()}}),UM_hide_menus(),!1}),jQuery(document.body).on("change, keyup",'textarea[id="um-meta-bio"]',function(){if(void 0!==jQuery(this).val()){var e=jQuery(this).attr("data-character-limit")-jQuery(this).val().length;jQuery("span.um-meta-bio-character span.um-bio-limit").text(e),e<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color","")}}),jQuery('textarea[id="um-meta-bio"]').trigger("change"),jQuery(".um-profile-edit a.um_delete-item").click(function(e){if(e.preventDefault(),!confirm(wp.i18n.__("Are you sure that you want to delete this user?","ultimate-member")))return!1}),jQuery(".um-profile-nav a").on("touchend",function(e){e.currentTarget.click()})});
1
+ jQuery(document).ready(function(){jQuery(".um-profile.um-viewing .um-profile-body .um-row").each(function(){var e=jQuery(this);0==e.find(".um-field").length&&(e.prev(".um-row-heading").remove(),e.remove())}),jQuery(".um-profile.um-viewing .um-profile-body").length&&0==jQuery(".um-profile.um-viewing .um-profile-body").find(".um-field").length&&(jQuery(".um-profile.um-viewing .um-profile-body").find(".um-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document.body).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").submit(),!1}),jQuery(document.body).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document.body).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){e.preventDefault()}),jQuery(document.body).on("click",".um-photo-modal",function(e){e.preventDefault();var t=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,t),!1}),jQuery(document.body).on("click",".um-reset-profile-photo",function(e){return jQuery(".um-profile-photo-img img").attr("src",jQuery(this).attr("data-default_src")),user_id=jQuery(this).attr("data-user_id"),metakey="profile_photo",UM_hide_menus(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce}}),jQuery(this).parents("li").hide(),!1}),jQuery(document.body).on("click",".um-reset-cover-photo",function(e){var t=jQuery(this);return jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html('<a href="javascript:void(0);" class="um-cover-add" style="height: 370px;"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" original-title="Upload a cover photo"></i></span></a>'),um_responsive(),user_id=jQuery(this).attr("data-user_id"),metakey="cover_photo",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_cover_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce},success:function(e){t.hide()}}),UM_hide_menus(),!1}),jQuery(document.body).on("change, keyup",'textarea[id="um-meta-bio"]',function(){if(void 0!==jQuery(this).val()){var e=jQuery(this).attr("data-character-limit")-jQuery(this).val().length;jQuery("span.um-meta-bio-character span.um-bio-limit").text(e),e<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color","")}}),jQuery('textarea[id="um-meta-bio"]').trigger("change"),jQuery(".um-profile-edit a.um_delete-item").click(function(e){if(e.preventDefault(),!confirm(wp.i18n.__("Are you sure that you want to delete this user?","ultimate-member")))return!1}),jQuery(".um-profile-nav a").on("touchend",function(e){e.currentTarget.click()})});
includes/admin/core/class-admin-builder.php CHANGED
@@ -1055,7 +1055,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
1055
  }
1056
 
1057
  $output = '<div class="um-admin-preview-overlay"></div>';
1058
- $output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
 
 
 
 
 
1059
 
1060
  break;
1061
 
1055
  }
1056
 
1057
  $output = '<div class="um-admin-preview-overlay"></div>';
1058
+
1059
+ if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
1060
+ $output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
1061
+ } else {
1062
+ $output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
1063
+ }
1064
 
1065
  break;
1066
 
includes/admin/core/class-admin-forms.php CHANGED
@@ -1092,7 +1092,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1092
  $columns = ( ! empty( $field_data['columns'] ) && is_numeric( $field_data['columns'] ) ) ? $field_data['columns'] : 1;
1093
  while ( $i < $columns ) {
1094
  $per_page = ceil( count( $field_data['options'] ) / $columns );
1095
- $section_fields_per_page = array_slice( $field_data['options'], $i*$per_page, $per_page );
1096
  $html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
1097
 
1098
  foreach ( $section_fields_per_page as $k => $title ) {
@@ -1362,6 +1362,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1362
  }
1363
 
1364
 
 
 
 
 
 
1365
  function render_md_default_filters( $field_data ) {
1366
  if ( empty( $field_data['id'] ) ) {
1367
  return false;
@@ -1445,6 +1450,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1445
  }
1446
 
1447
 
 
 
 
 
 
1448
  function render_md_sorting_fields( $field_data ) {
1449
  if ( empty( $field_data['id'] ) ) {
1450
  return false;
@@ -1560,6 +1570,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1560
  return $html;
1561
  }
1562
 
 
1563
  /**
1564
  * Get field value
1565
  *
@@ -1568,8 +1579,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1568
  * @return string|array
1569
  */
1570
  function get_field_value( $field_data, $i = '' ) {
1571
- $default = ( $field_data['type'] == 'multi_checkbox' ) ? array() : '';
1572
- $default = isset( $field_data[ 'default' . $i ] ) ? $field_data[ 'default' . $i ] : $default;
 
 
 
 
 
 
 
 
 
1573
 
1574
  if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) {
1575
  $value = ( isset( $field_data[ 'value' . $i ] ) && '' !== $field_data[ 'value' . $i ] ) ? $field_data[ 'value' . $i ] : $default;
1092
  $columns = ( ! empty( $field_data['columns'] ) && is_numeric( $field_data['columns'] ) ) ? $field_data['columns'] : 1;
1093
  while ( $i < $columns ) {
1094
  $per_page = ceil( count( $field_data['options'] ) / $columns );
1095
+ $section_fields_per_page = array_slice( $field_data['options'], $i*$per_page, $per_page, true );
1096
  $html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
1097
 
1098
  foreach ( $section_fields_per_page as $k => $title ) {
1362
  }
1363
 
1364
 
1365
+ /**
1366
+ * @param $field_data
1367
+ *
1368
+ * @return string
1369
+ */
1370
  function render_md_default_filters( $field_data ) {
1371
  if ( empty( $field_data['id'] ) ) {
1372
  return false;
1450
  }
1451
 
1452
 
1453
+ /**
1454
+ * @param $field_data
1455
+ *
1456
+ * @return string
1457
+ */
1458
  function render_md_sorting_fields( $field_data ) {
1459
  if ( empty( $field_data['id'] ) ) {
1460
  return false;
1570
  return $html;
1571
  }
1572
 
1573
+
1574
  /**
1575
  * Get field value
1576
  *
1579
  * @return string|array
1580
  */
1581
  function get_field_value( $field_data, $i = '' ) {
1582
+
1583
+ $default = '';
1584
+ if ( $field_data['type'] === 'multi_checkbox' ) {
1585
+ $default = array();
1586
+ if ( isset( $field_data['default'] ) ) {
1587
+ $default = is_array( $field_data['default'] ) ? $field_data['default'] : array( $field_data['default'] );
1588
+ }
1589
+ }
1590
+ if ( isset( $field_data[ 'default' . $i ] ) ) {
1591
+ $default = $field_data[ 'default' . $i ];
1592
+ }
1593
 
1594
  if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) {
1595
  $value = ( isset( $field_data[ 'value' . $i ] ) && '' !== $field_data[ 'value' . $i ] ) ? $field_data[ 'value' . $i ] : $default;
includes/admin/core/class-admin-metabox.php CHANGED
@@ -10,6 +10,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
10
 
11
  /**
12
  * Class Admin_Metabox
 
13
  * @package um\admin\core
14
  */
15
  class Admin_Metabox {
@@ -19,7 +20,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
19
  * @var bool
20
  */
21
  private $form_nonce_added = false;
 
 
 
 
 
22
  private $directory_nonce_added = false;
 
 
 
 
 
23
  private $custom_nonce_added = false;
24
 
25
 
@@ -1073,6 +1084,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
1073
  delete_post_meta( $post_id, '_um_roles_can_search' );
1074
  delete_post_meta( $post_id, '_um_roles_can_filter' );
1075
  delete_post_meta( $post_id, '_um_show_these_users' );
 
1076
 
1077
  delete_post_meta( $post_id, '_um_search_filters' );
1078
  delete_post_meta( $post_id, '_um_search_filters_gmt' );
@@ -1084,6 +1096,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
1084
  $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1085
  }
1086
 
 
 
 
 
1087
  if ( strstr( $k, '_um_' ) ) {
1088
 
1089
  if ( $k === '_um_is_default' ) {
@@ -2249,15 +2265,24 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
2249
  break;
2250
 
2251
  case '_public':
2252
- ?>
2253
-
2254
- <p><label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
2255
- <select name="_public" id="_public" class="um-adm-conditional" data-cond1='-2' data-cond1-show='_roles' data-cond2='-3' data-cond2-show='_roles' style="width: 100%">
2256
- <option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Everyone', 'ultimate-member' ) ?></option>
2257
- <option value="2" <?php selected( 2, $this->edit_mode_value ); ?>><?php _e( 'Members', 'ultimate-member' ) ?></option>
2258
- <option value="-1" <?php selected( -1, $this->edit_mode_value ); ?>><?php _e( 'Only visible to profile owner and admins', 'ultimate-member' ) ?></option>
2259
- <option value="-3" <?php selected( -3, $this->edit_mode_value ); ?>><?php _e( 'Only visible to profile owner and specific roles', 'ultimate-member' ) ?></option>
2260
- <option value="-2" <?php selected( -2, $this->edit_mode_value ); ?>><?php _e( 'Only specific member roles', 'ultimate-member' ) ?></option>
 
 
 
 
 
 
 
 
 
2261
  </select>
2262
  </p>
2263
 
10
 
11
  /**
12
  * Class Admin_Metabox
13
+ *
14
  * @package um\admin\core
15
  */
16
  class Admin_Metabox {
20
  * @var bool
21
  */
22
  private $form_nonce_added = false;
23
+
24
+
25
+ /**
26
+ * @var bool
27
+ */
28
  private $directory_nonce_added = false;
29
+
30
+
31
+ /**
32
+ * @var bool
33
+ */
34
  private $custom_nonce_added = false;
35
 
36
 
1084
  delete_post_meta( $post_id, '_um_roles_can_search' );
1085
  delete_post_meta( $post_id, '_um_roles_can_filter' );
1086
  delete_post_meta( $post_id, '_um_show_these_users' );
1087
+ delete_post_meta( $post_id, '_um_exclude_these_users' );
1088
 
1089
  delete_post_meta( $post_id, '_um_search_filters' );
1090
  delete_post_meta( $post_id, '_um_search_filters_gmt' );
1096
  $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1097
  }
1098
 
1099
+ if ( $k == '_um_exclude_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) {
1100
+ $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1101
+ }
1102
+
1103
  if ( strstr( $k, '_um_' ) ) {
1104
 
1105
  if ( $k === '_um_is_default' ) {
2265
  break;
2266
 
2267
  case '_public':
2268
+ $privacy_options = array(
2269
+ '1' => __( 'Everyone', 'ultimate-member' ),
2270
+ '2' => __( 'Members', 'ultimate-member' ),
2271
+ '-1' => __( 'Only visible to profile owner and admins', 'ultimate-member' ),
2272
+ '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2273
+ '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2274
+ );
2275
+
2276
+ $privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
2277
+
2278
+ <p>
2279
+ <label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
2280
+ <select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
2281
+ <?php foreach ( $privacy_options as $value => $title ) { ?>
2282
+ <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
2283
+ <?php echo $title ?>
2284
+ </option>
2285
+ <?php } ?>
2286
  </select>
2287
  </p>
2288
 
includes/admin/core/class-admin-navmenu.php CHANGED
@@ -18,20 +18,133 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
18
  protected static $fields = array();
19
 
20
 
 
 
 
21
  function __construct() {
 
 
22
  self::$fields = array(
23
  'um_nav_public' => __( 'Display Mode', 'ultimate-member' ),
24
  'um_nav_roles' => __( 'By Role', 'ultimate-member' )
25
  );
26
 
 
 
 
 
 
 
 
27
  add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 );
28
- //add_filter( 'manage_nav-menus_columns', array( &$this, '_columns' ), 99 );
29
 
30
- add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) );
31
- add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * @param $menu_id
37
  * @param $menu_item_db_id
@@ -69,18 +182,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
69
  }
70
 
71
 
72
- /**
73
- * @param $columns
74
- *
75
- * @return array
76
- */
77
- function _columns( $columns ) {
78
- $columns = array_merge( $columns, self::$fields );
79
-
80
- return $columns;
81
- }
82
-
83
-
84
  /**
85
  *
86
  */
18
  protected static $fields = array();
19
 
20
 
21
+ /**
22
+ * Admin_Navmenu constructor.
23
+ */
24
  function __construct() {
25
+ global $wp_version;
26
+
27
  self::$fields = array(
28
  'um_nav_public' => __( 'Display Mode', 'ultimate-member' ),
29
  'um_nav_roles' => __( 'By Role', 'ultimate-member' )
30
  );
31
 
32
+ if ( $wp_version < '5.4' ) {
33
+ add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) );
34
+ add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) );
35
+ } else {
36
+ add_action( 'load-customize.php', array( &$this, 'enqueue_nav_menus_scripts' ) );
37
+ }
38
+
39
  add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 );
 
40
 
41
+ add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'wp_nav_menu_item_custom_fields' ), 20, 5 );
42
+ //add_action( 'wp_nav_menu_item_custom_fields_customize_template', array( $this, 'wp_nav_menu_item_custom_fields_customize_template' ), 20 ); //waiting wp.org answer
43
+ }
44
+
45
+
46
+ /**
47
+ * Fires just before the move buttons of a nav menu item in the menu editor.
48
+ * Adds block "Ultimate Member Menu Settings"
49
+ *
50
+ * @since WP 5.4.0
51
+ * @hook wp_nav_menu_item_custom_fields
52
+ *
53
+ * @param int $item_id Menu item ID.
54
+ * @param \WP_Post $item Menu item data object.
55
+ * @param int $depth Depth of menu item. Used for padding.
56
+ * @param \stdClass $args An object of menu item arguments.
57
+ * @param int $id Nav menu ID.
58
+ */
59
+ function wp_nav_menu_item_custom_fields( $item_id, $item, $depth, $args, $id ) {
60
+
61
+ $um_nav_public = get_post_meta( $item->ID, 'menu-item-um_nav_public', true );
62
+ $_nav_roles_meta = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true );
63
+ $um_nav_roles = array();
64
+ if ( $_nav_roles_meta ) {
65
+ foreach ( $_nav_roles_meta as $key => $value ) {
66
+ if ( is_int( $key ) ) {
67
+ $um_nav_roles[] = $value;
68
+ }
69
+ }
70
+ }
71
+ $options = UM()->roles()->get_roles( false, array( 'administrator' ) );
72
+ ?>
73
+ <div class="um-nav-edit">
74
+ <div class="clear"></div>
75
+ <h4 style="margin-bottom: 0.6em;"><?php _e( 'Ultimate Member Menu Settings', 'ultimate-member' ) ?></h4>
76
+
77
+ <p class="description description-wide um-nav-mode">
78
+ <label for="edit-menu-item-um_nav_public-<?php echo esc_attr( $item_id ); ?>">
79
+ <?php _e( "Who can see this menu link?", 'ultimate-member' ); ?><br/>
80
+ <select id="edit-menu-item-um_nav_public-<?php echo esc_attr( $item_id ); ?>" name="menu-item-um_nav_public[<?php echo esc_attr( $item_id ); ?>]" style="width:100%;">
81
+ <option value="0" <?php selected( $um_nav_public, 0 ); ?>><?php _e( 'Everyone', 'ultimate-member' ) ?></option>
82
+ <option value="1" <?php selected( $um_nav_public, 1 ); ?>><?php _e( 'Logged Out Users', 'ultimate-member' ) ?></option>
83
+ <option value="2" <?php selected( $um_nav_public, 2 ); ?>><?php _e( 'Logged In Users', 'ultimate-member' ) ?></option>
84
+ </select>
85
+ </label>
86
+ </p>
87
+
88
+ <p class="description description-wide um-nav-roles" <?php echo $um_nav_public == 2 ? 'style="display: block;"' : ''; ?>><?php _e( "Select the member roles that can see this link", 'ultimate-member' ) ?><br>
89
+
90
+ <?php
91
+ $i = 0;
92
+ $html = '';
93
+ $columns = apply_filters( 'wp_nav_menu_item:um_nav_columns', 2, $item_id, $item );
94
+ $per_page = ceil( count( $options ) / $columns );
95
+ while ( $i < $columns ) {
96
+ $section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
97
+ $html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
98
+
99
+ foreach ( $section_fields_per_page as $k => $title ) {
100
+ $id_attr = ' id="edit-menu-item-um_nav_roles-' . $item_id . '_' . $k . '" ';
101
+ $for_attr = ' for="edit-menu-item-um_nav_roles-' . $item_id . '_' . $k . '" ';
102
+ $checked_attr = checked( in_array($k,$um_nav_roles), true, false );
103
+ $html .= "<label {$for_attr}> <input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{$item_id}][{$k}]' value='1' {$checked_attr} /> <span>{$title}</span> </label>";
104
+ }
105
+
106
+ $html .= '</span>';
107
+ $i++;
108
+ }
109
+ echo $html;
110
+ ?>
111
+ </p>
112
+ <div class="clear"></div>
113
+ </div>
114
+ <?php
115
+ }
116
+
117
+
118
+ /**
119
+ *
120
+ */
121
+ function wp_nav_menu_item_custom_fields_customize_template() {
122
+ ?>
123
+ <div class="um-nav-edit">
124
+ <div class="clear"></div>
125
+ <h4 style="margin-bottom: 0.6em;"><?php _e( 'Ultimate Member Menu Settings', 'ultimate-member' ) ?></h4>
126
+
127
+ <# console.log( data ); #>
128
+
129
+ <div class="clear"></div>
130
+ </div>
131
+ <?php
132
  }
133
 
134
 
135
+
136
+
137
+
138
+
139
+
140
+
141
+ /**
142
+ *
143
+ * Backward compatibility with WP < 5.4
144
+ *
145
+ */
146
+
147
+
148
  /**
149
  * @param $menu_id
150
  * @param $menu_item_db_id
182
  }
183
 
184
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  /**
186
  *
187
  */
includes/admin/core/class-admin-settings.php CHANGED
@@ -637,63 +637,63 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
637
  'title' => __( 'Account', 'ultimate-member' ),
638
  'fields' => array(
639
  array(
640
- 'id' => 'account_tab_password',
641
- 'type' => 'checkbox',
642
- 'label' => __( 'Password Account Tab','ultimate-member' ),
643
- 'tooltip' => 'Enable/disable the Password account tab in account page',
644
  ),
645
  array(
646
- 'id' => 'account_tab_privacy',
647
- 'type' => 'checkbox',
648
- 'label' => __( 'Privacy Account Tab','ultimate-member' ),
649
- 'tooltip' => __('Enable/disable the Privacy account tab in account page','ultimate-member'),
650
  ),
651
  array(
652
- 'id' => 'account_tab_notifications',
653
- 'type' => 'checkbox',
654
- 'label' => __( 'Notifications Account Tab','ultimate-member' ),
655
- 'tooltip' => __('Enable/disable the Notifications account tab in account page','ultimate-member'),
656
  ),
657
  array(
658
- 'id' => 'account_tab_delete',
659
- 'type' => 'checkbox',
660
- 'label' => __( 'Delete Account Tab','ultimate-member' ),
661
- 'tooltip' => __('Enable/disable the Delete account tab in account page','ultimate-member'),
662
  ),
663
  array(
664
- 'id' => 'delete_account_text',
665
- 'type' => 'textarea', // bug with wp 4.4? should be editor
666
- 'label' => __( 'Account Deletion Custom Text','ultimate-member' ),
667
- 'tooltip' => __('This is custom text that will be displayed to users before they delete their accounts from your site','ultimate-member'),
668
- 'args' => array(
669
  'textarea_rows' => 6
670
  ),
671
  ),
672
  array(
673
- 'id' => 'account_name',
674
- 'type' => 'checkbox',
675
- 'label' => __( 'Add a First & Last Name fields','ultimate-member' ),
676
- 'tooltip' => __('Whether to enable these fields on the user account page by default or hide them.','ultimate-member'),
677
  ),
678
  array(
679
- 'id' => 'account_name_disable',
680
- 'type' => 'checkbox',
681
- 'label' => __( 'Disable First & Last Name fields','ultimate-member' ),
682
- 'tooltip' => __('Whether to allow users changing their first and last name in account page.','ultimate-member'),
683
- 'conditional' => array( 'account_name', '=', '1' ),
684
  ),
685
  array(
686
- 'id' => 'account_name_require',
687
- 'type' => 'checkbox',
688
- 'label' => __( 'Require First & Last Name','ultimate-member' ),
689
- 'tooltip' => __('Require first and last name?','ultimate-member'),
690
- 'conditional' => array( 'account_name', '=', '1' ),
691
  ),
692
  array(
693
- 'id' => 'account_email',
694
- 'type' => 'checkbox',
695
- 'label' => __( 'Allow users to change e-mail','ultimate-member' ),
696
- 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
697
  ),
698
  array(
699
  'id' => 'account_general_password',
@@ -731,63 +731,63 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
731
  'title' => __( 'Uploads', 'ultimate-member' ),
732
  'fields' => array(
733
  array(
734
- 'id' => 'profile_photo_max_size',
735
- 'type' => 'text',
736
- 'size' => 'small',
737
- 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
738
- 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
739
  ),
740
 
741
  array(
742
- 'id' => 'cover_photo_max_size',
743
- 'type' => 'text',
744
- 'size' => 'small',
745
- 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
746
- 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
747
  ),
748
  array(
749
- 'id' => 'photo_thumb_sizes',
750
- 'type' => 'multi_text',
751
- 'size' => 'small',
752
- 'label' => __( 'Profile Photo Thumbnail Sizes (px)','ultimate-member' ),
753
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.','ultimate-member' ),
754
- 'validate' => 'numeric',
755
- 'add_text' => __('Add New Size','ultimate-member'),
756
- 'show_default_number' => 1,
757
  ),
758
  array(
759
- 'id' => 'cover_thumb_sizes',
760
- 'type' => 'multi_text',
761
- 'size' => 'small',
762
- 'label' => __( 'Cover Photo Thumbnail Sizes (px)','ultimate-member' ),
763
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.','ultimate-member' ),
764
- 'validate' => 'numeric',
765
- 'add_text' => __('Add New Size','ultimate-member'),
766
- 'show_default_number' => 1,
767
  ),
768
 
769
  array(
770
- 'id' => 'image_compression',
771
- 'type' => 'text',
772
- 'size' => 'small',
773
- 'label' => __( 'Image Quality','ultimate-member'),
774
- 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ),
775
  ),
776
 
777
  array(
778
- 'id' => 'image_max_width',
779
- 'type' => 'text',
780
- 'size' => 'small',
781
- 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
782
- 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
783
  ),
784
 
785
  array(
786
- 'id' => 'cover_min_width',
787
- 'type' => 'text',
788
- 'size' => 'small',
789
- 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
790
- 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
791
  ),
792
  )
793
  )
637
  'title' => __( 'Account', 'ultimate-member' ),
638
  'fields' => array(
639
  array(
640
+ 'id' => 'account_tab_password',
641
+ 'type' => 'checkbox',
642
+ 'label' => __( 'Password Account Tab', 'ultimate-member' ),
643
+ 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
644
  ),
645
  array(
646
+ 'id' => 'account_tab_privacy',
647
+ 'type' => 'checkbox',
648
+ 'label' => __( 'Privacy Account Tab','ultimate-member' ),
649
+ 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
650
  ),
651
  array(
652
+ 'id' => 'account_tab_notifications',
653
+ 'type' => 'checkbox',
654
+ 'label' => __( 'Notifications Account Tab','ultimate-member' ),
655
+ 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
656
  ),
657
  array(
658
+ 'id' => 'account_tab_delete',
659
+ 'type' => 'checkbox',
660
+ 'label' => __( 'Delete Account Tab','ultimate-member' ),
661
+ 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
662
  ),
663
  array(
664
+ 'id' => 'delete_account_text',
665
+ 'type' => 'textarea', // bug with wp 4.4? should be editor
666
+ 'label' => __( 'Account Deletion Custom Text','ultimate-member' ),
667
+ 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site', 'ultimate-member' ),
668
+ 'args' => array(
669
  'textarea_rows' => 6
670
  ),
671
  ),
672
  array(
673
+ 'id' => 'account_name',
674
+ 'type' => 'checkbox',
675
+ 'label' => __( 'Add a First & Last Name fields','ultimate-member' ),
676
+ 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
677
  ),
678
  array(
679
+ 'id' => 'account_name_disable',
680
+ 'type' => 'checkbox',
681
+ 'label' => __( 'Disable First & Last Name fields','ultimate-member' ),
682
+ 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
683
+ 'conditional' => array( 'account_name', '=', '1' ),
684
  ),
685
  array(
686
+ 'id' => 'account_name_require',
687
+ 'type' => 'checkbox',
688
+ 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
689
+ 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
690
+ 'conditional' => array( 'account_name', '=', '1' ),
691
  ),
692
  array(
693
+ 'id' => 'account_email',
694
+ 'type' => 'checkbox',
695
+ 'label' => __( 'Allow users to change e-mail','ultimate-member' ),
696
+ 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
697
  ),
698
  array(
699
  'id' => 'account_general_password',
731
  'title' => __( 'Uploads', 'ultimate-member' ),
732
  'fields' => array(
733
  array(
734
+ 'id' => 'profile_photo_max_size',
735
+ 'type' => 'text',
736
+ 'size' => 'small',
737
+ 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
738
+ 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
739
  ),
740
 
741
  array(
742
+ 'id' => 'cover_photo_max_size',
743
+ 'type' => 'text',
744
+ 'size' => 'small',
745
+ 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
746
+ 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
747
  ),
748
  array(
749
+ 'id' => 'photo_thumb_sizes',
750
+ 'type' => 'multi_text',
751
+ 'size' => 'small',
752
+ 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
753
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
754
+ 'validate' => 'numeric',
755
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
756
+ 'show_default_number' => 1,
757
  ),
758
  array(
759
+ 'id' => 'cover_thumb_sizes',
760
+ 'type' => 'multi_text',
761
+ 'size' => 'small',
762
+ 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
763
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
764
+ 'validate' => 'numeric',
765
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
766
+ 'show_default_number' => 1,
767
  ),
768
 
769
  array(
770
+ 'id' => 'image_compression',
771
+ 'type' => 'text',
772
+ 'size' => 'small',
773
+ 'label' => __( 'Image Quality', 'ultimate-member' ),
774
+ 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ),
775
  ),
776
 
777
  array(
778
+ 'id' => 'image_max_width',
779
+ 'type' => 'text',
780
+ 'size' => 'small',
781
+ 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
782
+ 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
783
  ),
784
 
785
  array(
786
+ 'id' => 'cover_min_width',
787
+ 'type' => 'text',
788
+ 'size' => 'small',
789
+ 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
790
+ 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
791
  ),
792
  )
793
  )
includes/admin/core/list-tables/emails-list-table.php CHANGED