Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | Ultimate Member – User Profile & Membership Plugin |
Version | 2.3.2 |
Comparing to | |
See all releases |
Code changes from version 2.3.2-rc.1 to 2.3.2
- includes/admin/assets/js/um-admin-forms.js +1040 -1040
- includes/admin/core/class-admin-ajax-hooks.php +38 -38
- includes/admin/core/class-admin-enqueue.php +697 -697
- includes/admin/core/class-admin-forms.php +1671 -1671
- includes/admin/core/class-admin-notices.php +715 -715
- includes/admin/core/class-admin-settings.php +3458 -3458
- includes/admin/core/class-admin-users.php +584 -584
- includes/core/class-fields.php +4868 -4868
- includes/core/um-filters-fields.php +901 -901
- includes/core/um-filters-login.php +107 -107
- languages/ultimate-member.pot +0 -2162
includes/admin/assets/js/um-admin-forms.js
CHANGED
@@ -1,1040 +1,1040 @@
|
|
1 |
-
function um_admin_init_users_select() {
|
2 |
-
if ( jQuery('.um-user-select-field').length ) {
|
3 |
-
var select2_atts = {
|
4 |
-
ajax: {
|
5 |
-
url: wp.ajax.settings.url,
|
6 |
-
dataType: 'json',
|
7 |
-
delay: 250, // delay in ms while typing when to perform a AJAX search
|
8 |
-
data: function( params ) {
|
9 |
-
return {
|
10 |
-
search: params.term, // search query
|
11 |
-
action: 'um_get_users', // AJAX action for admin-ajax.php
|
12 |
-
page: params.page || 1, // infinite scroll pagination
|
13 |
-
nonce: um_admin_scripts.nonce
|
14 |
-
};
|
15 |
-
},
|
16 |
-
processResults: function( response, params ) {
|
17 |
-
params.page = params.page || 1;
|
18 |
-
var options = [];
|
19 |
-
|
20 |
-
if ( response.data.users ) {
|
21 |
-
jQuery.each( response.data.users, function( index, text ) {
|
22 |
-
options.push( { id: text.ID, text: text.user_login + ' (#' + text.ID + ')' } );
|
23 |
-
});
|
24 |
-
}
|
25 |
-
|
26 |
-
return {
|
27 |
-
results: options,
|
28 |
-
pagination: {
|
29 |
-
more: ( params.page * 20 ) < response.data.total_count
|
30 |
-
}
|
31 |
-
};
|
32 |
-
},
|
33 |
-
cache: true
|
34 |
-
},
|
35 |
-
minimumInputLength: 0, // the minimum of symbols to input before perform a search
|
36 |
-
allowClear: true,
|
37 |
-
width: "100%",
|
38 |
-
allowHtml: true,
|
39 |
-
dropdownCssClass: 'um-select2-users-dropdown',
|
40 |
-
containerCssClass : 'um-select2-users-container',
|
41 |
-
placeholder: jQuery(this).data('placeholder')
|
42 |
-
};
|
43 |
-
|
44 |
-
jQuery('.um-user-select-field').select2( select2_atts );
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
jQuery(document).ready( function() {
|
50 |
-
um_admin_init_users_select();
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Same page upgrade field
|
54 |
-
*/
|
55 |
-
jQuery( document.body ).on( 'click', '.um-forms-field[data-log-object]', function() {
|
56 |
-
var obj = jQuery( this ).data( 'log-object' );
|
57 |
-
if ( jQuery( this ).is( ':checked' ) ) {
|
58 |
-
jQuery( this ).siblings( '.um-same-page-update-' + obj ).show();
|
59 |
-
} else {
|
60 |
-
jQuery( this ).siblings( '.um-same-page-update-' + obj ).hide();
|
61 |
-
}
|
62 |
-
});
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
jQuery( document.body ).on( 'click', '.um-admin-form-same-page-update', function() {
|
67 |
-
var field_key = jQuery(this).data('upgrade_cb');
|
68 |
-
jQuery(this).prop( 'disabled', true );
|
69 |
-
|
70 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Upgrade Process Started...', 'ultimate-member' ) );
|
71 |
-
|
72 |
-
if ( field_key === 'sync_metatable' ) {
|
73 |
-
var metadata_pages = 0;
|
74 |
-
var metadata_per_page = 500;
|
75 |
-
var current_page;
|
76 |
-
|
77 |
-
jQuery.ajax({
|
78 |
-
url: wp.ajax.settings.url,
|
79 |
-
type: 'POST',
|
80 |
-
dataType: 'json',
|
81 |
-
data: {
|
82 |
-
action: 'um_same_page_update',
|
83 |
-
cb_func: 'um_usermeta_fields',
|
84 |
-
nonce: um_admin_scripts.nonce
|
85 |
-
},
|
86 |
-
success: function( response ) {
|
87 |
-
get_metadata();
|
88 |
-
},
|
89 |
-
error: function() {
|
90 |
-
um_same_page_something_wrong( field_key );
|
91 |
-
}
|
92 |
-
});
|
93 |
-
|
94 |
-
|
95 |
-
/**
|
96 |
-
*
|
97 |
-
* @returns {boolean}
|
98 |
-
*/
|
99 |
-
function get_metadata() {
|
100 |
-
current_page = 1;
|
101 |
-
|
102 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Getting metadata', 'ultimate-member' ) );
|
103 |
-
jQuery.ajax({
|
104 |
-
url: wp.ajax.settings.url,
|
105 |
-
type: 'POST',
|
106 |
-
dataType: 'json',
|
107 |
-
data: {
|
108 |
-
action: 'um_same_page_update',
|
109 |
-
cb_func: 'um_get_metadata',
|
110 |
-
nonce: um_admin_scripts.nonce
|
111 |
-
},
|
112 |
-
success: function( response ) {
|
113 |
-
if ( typeof response.data.count != 'undefined' ) {
|
114 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'There are ', 'ultimate-member' ) + response.data.count + wp.i18n.__( ' metadata rows...', 'ultimate-member' ) );
|
115 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Start metadata upgrading...', 'ultimate-member' ) );
|
116 |
-
|
117 |
-
metadata_pages = Math.ceil( response.data.count / metadata_per_page );
|
118 |
-
|
119 |
-
update_metadata_per_page();
|
120 |
-
} else {
|
121 |
-
um_same_page_wrong_ajax( field_key );
|
122 |
-
}
|
123 |
-
},
|
124 |
-
error: function() {
|
125 |
-
um_same_page_something_wrong( field_key );
|
126 |
-
}
|
127 |
-
});
|
128 |
-
|
129 |
-
return false;
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
function update_metadata_per_page() {
|
134 |
-
if ( current_page <= metadata_pages ) {
|
135 |
-
jQuery.ajax({
|
136 |
-
url: wp.ajax.settings.url,
|
137 |
-
type: 'POST',
|
138 |
-
dataType: 'json',
|
139 |
-
data: {
|
140 |
-
action: 'um_same_page_update',
|
141 |
-
cb_func: 'um_update_metadata_per_page',
|
142 |
-
page: current_page,
|
143 |
-
nonce: um_admin_scripts.nonce
|
144 |
-
},
|
145 |
-
success: function( response ) {
|
146 |
-
if ( typeof response.data != 'undefined' ) {
|
147 |
-
um_add_same_page_log( field_key, response.data.message );
|
148 |
-
current_page++;
|
149 |
-
update_metadata_per_page();
|
150 |
-
} else {
|
151 |
-
um_same_page_wrong_ajax( field_key );
|
152 |
-
}
|
153 |
-
},
|
154 |
-
error: function() {
|
155 |
-
um_same_page_something_wrong( field_key );
|
156 |
-
}
|
157 |
-
});
|
158 |
-
} else {
|
159 |
-
window.location = um_forms_data.successfully_redirect;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
}
|
163 |
-
});
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
/**
|
168 |
-
*
|
169 |
-
* @param field_key
|
170 |
-
* @param line
|
171 |
-
*/
|
172 |
-
function um_add_same_page_log( field_key, line ) {
|
173 |
-
var log_field = jQuery( '.um-same-page-update-' + field_key ).find( '.upgrade_log' );
|
174 |
-
var previous_html = log_field.html();
|
175 |
-
log_field.html( previous_html + line + "<br />" );
|
176 |
-
}
|
177 |
-
|
178 |
-
|
179 |
-
function um_same_page_wrong_ajax( field_key ) {
|
180 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Wrong AJAX response...', 'ultimate-member' ) );
|
181 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Your upgrade was crashed, please contact with support', 'ultimate-member' ) );
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
function um_same_page_something_wrong( field_key ) {
|
186 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Something went wrong with AJAX request...', 'ultimate-member' ) );
|
187 |
-
um_add_same_page_log( field_key, wp.i18n.__( 'Your upgrade was crashed, please contact with support', 'ultimate-member' ) );
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Sortable items
|
192 |
-
*/
|
193 |
-
jQuery('.um-sortable-items-field').sortable({
|
194 |
-
items: '.um-sortable-item',
|
195 |
-
connectWith: '.um-admin-drag-col,.um-admin-drag-group',
|
196 |
-
forcePlaceholderSize: true,
|
197 |
-
update: function( event, ui ) {
|
198 |
-
var sortable_value = [];
|
199 |
-
jQuery(this).find('li').each( function() {
|
200 |
-
if ( ! jQuery(this).hasClass( 'um-hidden-item' ) ) {
|
201 |
-
sortable_value.push( jQuery(this).data('tab-id') );
|
202 |
-
}
|
203 |
-
});
|
204 |
-
|
205 |
-
jQuery(this).siblings('.um-sortable-items-value' ).val( sortable_value.join( ',' ) );
|
206 |
-
}
|
207 |
-
});
|
208 |
-
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Multi-selects sort
|
212 |
-
*/
|
213 |
-
jQuery('.um-multi-selects-list.um-sortable-multi-selects').sortable({
|
214 |
-
items: '.um-admin-drag-fld',
|
215 |
-
connectWith: '.um-admin-drag-col,.um-admin-drag-group',
|
216 |
-
forcePlaceholderSize: true
|
217 |
-
});
|
218 |
-
|
219 |
-
jQuery('.um-multi-selects-list[data-field_id="_um_sorting_fields"] li').each( function() {
|
220 |
-
var if_other = jQuery(this).find( '.um-field-wrapper:not(.um-custom-order-fields) select' ).val();
|
221 |
-
if ( if_other === 'other' ) {
|
222 |
-
jQuery(this).find( '.um-field-wrapper.um-custom-order-fields' ).show();
|
223 |
-
} else {
|
224 |
-
jQuery(this).find( '.um-field-wrapper.um-custom-order-fields' ).hide();
|
225 |
-
}
|
226 |
-
});
|
227 |
-
|
228 |
-
jQuery( '.um-forms-line[data-field_type="md_sorting_fields"] .um-multi-selects-add-option' ).on('click', function() {
|
229 |
-
var list = jQuery(this).siblings('ul.um-multi-selects-list');
|
230 |
-
|
231 |
-
var sortable = list.hasClass( 'um-sortable-multi-selects' );
|
232 |
-
|
233 |
-
var field_id = list.data('field_id');
|
234 |
-
var k = 0;
|
235 |
-
if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) {
|
236 |
-
k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-");
|
237 |
-
k = k[1]*1 + 1;
|
238 |
-
}
|
239 |
-
|
240 |
-
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html();
|
241 |
-
|
242 |
-
var html = '<li class="um-multi-selects-option-line' + ( sortable ? ' um-admin-drag-fld' : '' ) + '">';
|
243 |
-
if ( sortable ) {
|
244 |
-
html += '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
245 |
-
}
|
246 |
-
|
247 |
-
html += '<span class="um-field-wrapper">' + selector_html + '</span>' +
|
248 |
-
'<span class="um-field-control">' +
|
249 |
-
'<a href="javascript:void(0);" class="um-select-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a>' +
|
250 |
-
'</span>' +
|
251 |
-
'<span class="um-field-wrapper um-custom-order-fields"><label>' + wp.i18n.__( 'Meta key', 'ultimate-member' ) + ': <input type="text" name="meta_key" /></label></span>' +
|
252 |
-
'<span class="um-field-wrapper um-custom-order-fields"><label>' + wp.i18n.__( 'Label', 'ultimate-member' ) + ': <input type="text" name="label" /></label></span>' +
|
253 |
-
'</li>';
|
254 |
-
list.append( html );
|
255 |
-
|
256 |
-
list.find('li:last .um-hidden-multi-selects').attr('name', jQuery(this).data('name') ).
|
257 |
-
addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-selects').attr('id', list.data('id_attr') + '-' + k).trigger('change');
|
258 |
-
|
259 |
-
jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields input[name="meta_key"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][meta_key]');
|
260 |
-
jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields input[name="label"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][label]');
|
261 |
-
});
|
262 |
-
|
263 |
-
|
264 |
-
jQuery( document.body ).on( 'change', '.um-multi-selects-list[data-field_id="_um_sorting_fields"] .um-field-wrapper:not(.um-custom-order-fields) select', function() {
|
265 |
-
var if_other = jQuery(this).val();
|
266 |
-
|
267 |
-
if ( if_other === 'other' ) {
|
268 |
-
jQuery(this).parents('li').find( '.um-field-wrapper.um-custom-order-fields' ).show();
|
269 |
-
} else {
|
270 |
-
jQuery(this).parents('li').find( '.um-field-wrapper.um-custom-order-fields' ).hide();
|
271 |
-
}
|
272 |
-
});
|
273 |
-
|
274 |
-
|
275 |
-
/**
|
276 |
-
* Multi-selects field
|
277 |
-
*/
|
278 |
-
jQuery( document.body ).on( 'click', '.um-multi-selects-option-line .um-select-delete', function() {
|
279 |
-
jQuery( this ).parents( 'li.um-multi-selects-option-line' ).remove();
|
280 |
-
});
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Multi-selects field
|
284 |
-
*/
|
285 |
-
jQuery( document.body ).on( 'click', '.um-md-default-filters-option-line .um-select-delete', function() {
|
286 |
-
jQuery( this ).parents( 'li.um-md-default-filters-option-line' ).remove();
|
287 |
-
});
|
288 |
-
|
289 |
-
jQuery( '.um-multi-selects-add-option' ).on('click', function() {
|
290 |
-
if ( jQuery(this).parents( '.um-forms-line[data-field_type="md_sorting_fields"]' ).length ) {
|
291 |
-
return;
|
292 |
-
}
|
293 |
-
|
294 |
-
var list = jQuery(this).siblings('ul.um-multi-selects-list');
|
295 |
-
|
296 |
-
var sortable = list.hasClass( 'um-sortable-multi-selects' );
|
297 |
-
|
298 |
-
var field_id = list.data('field_id');
|
299 |
-
var k = 0;
|
300 |
-
if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) {
|
301 |
-
k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-");
|
302 |
-
k = k[1]*1 + 1;
|
303 |
-
}
|
304 |
-
|
305 |
-
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html();
|
306 |
-
|
307 |
-
var html = '<li class="um-multi-selects-option-line' + ( sortable ? ' um-admin-drag-fld' : '' ) + '">';
|
308 |
-
if ( sortable ) {
|
309 |
-
html += '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
310 |
-
}
|
311 |
-
|
312 |
-
html += '<span class="um-field-wrapper">' + selector_html + '</span>' +
|
313 |
-
'<span class="um-field-control">' +
|
314 |
-
'<a href="javascript:void(0);" class="um-select-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a>' +
|
315 |
-
'</span>' +
|
316 |
-
'</li>';
|
317 |
-
list.append( html );
|
318 |
-
|
319 |
-
list.find('li:last .um-hidden-multi-selects').attr('name', jQuery(this).data('name') ).
|
320 |
-
addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-selects').attr('id', list.data('id_attr') + '-' + k);
|
321 |
-
});
|
322 |
-
|
323 |
-
var um_local_date = new Date();
|
324 |
-
var um_gmt_hours = -um_local_date.getTimezoneOffset() / 60;
|
325 |
-
jQuery('input[name="um-gmt-offset"]').val( um_gmt_hours );
|
326 |
-
|
327 |
-
//slider filter
|
328 |
-
jQuery('.um-admin-metabox').find('.um-slider').each( function() {
|
329 |
-
var slider = jQuery( this );
|
330 |
-
|
331 |
-
var min_default_value = parseInt( slider.data('min') );
|
332 |
-
var max_default_value = parseInt( slider.data('max') );
|
333 |
-
|
334 |
-
if ( typeof jQuery( '#' + slider.data('field_name') + '_min' ).val() != 'undefined' ) {
|
335 |
-
min_default_value = jQuery( '#' + slider.data('field_name') + '_min' ).val();
|
336 |
-
}
|
337 |
-
if ( typeof jQuery( '#' + slider.data('field_name') + '_max' ).val() != 'undefined' ) {
|
338 |
-
max_default_value = jQuery( '#' + slider.data('field_name') + '_max' ).val();
|
339 |
-
}
|
340 |
-
|
341 |
-
var default_value = [ min_default_value, max_default_value ];
|
342 |
-
|
343 |
-
slider.slider({
|
344 |
-
range: true,
|
345 |
-
min: parseInt( slider.data('min') ),
|
346 |
-
max: parseInt( slider.data('max') ),
|
347 |
-
values: default_value,
|
348 |
-
create: function( event, ui ) {
|
349 |
-
//console.log( ui );
|
350 |
-
},
|
351 |
-
step: 1,
|
352 |
-
slide: function( event, ui ) {
|
353 |
-
um_set_range_label( jQuery( this ), ui );
|
354 |
-
},
|
355 |
-
stop: function( event, ui ) {
|
356 |
-
|
357 |
-
}
|
358 |
-
});
|
359 |
-
|
360 |
-
um_set_range_label( slider );
|
361 |
-
});
|
362 |
-
|
363 |
-
|
364 |
-
//datepicker filter
|
365 |
-
jQuery('.um-admin-metabox').find('.um-datepicker-filter').each( function() {
|
366 |
-
var elem = jQuery(this);
|
367 |
-
|
368 |
-
var min = new Date( elem.data('date_min')*1000 );
|
369 |
-
var max = new Date( elem.data('date_max')*1000 );
|
370 |
-
|
371 |
-
var $input = elem.pickadate({
|
372 |
-
selectYears: true,
|
373 |
-
min: min,
|
374 |
-
max: max,
|
375 |
-
formatSubmit: 'yyyy/mm/dd',
|
376 |
-
hiddenName: true,
|
377 |
-
onOpen: function() {
|
378 |
-
elem.blur();
|
379 |
-
},
|
380 |
-
onClose: function() {
|
381 |
-
elem.blur();
|
382 |
-
},
|
383 |
-
onSet: function( context ) {
|
384 |
-
|
385 |
-
}
|
386 |
-
});
|
387 |
-
|
388 |
-
var $picker = $input.pickadate('picker');
|
389 |
-
$picker.set( 'select', elem.data('value')*1000 );
|
390 |
-
});
|
391 |
-
|
392 |
-
|
393 |
-
//timepicker filter
|
394 |
-
jQuery('.um-admin-metabox').find('.um-timepicker-filter').each( function() {
|
395 |
-
var elem = jQuery(this);
|
396 |
-
|
397 |
-
//using arrays formatted as [HOUR,MINUTE]
|
398 |
-
|
399 |
-
var min = elem.data('min');
|
400 |
-
var max = elem.data('max');
|
401 |
-
var picker_min = min.split(':');
|
402 |
-
var picker_max = max.split(':');
|
403 |
-
|
404 |
-
var $input = elem.pickatime({
|
405 |
-
format: elem.data('format'),
|
406 |
-
interval: parseInt( elem.data('intervals') ),
|
407 |
-
min: [picker_min[0],picker_min[1]],
|
408 |
-
max: [picker_max[0],picker_max[1]],
|
409 |
-
formatSubmit: 'HH:i',
|
410 |
-
hiddenName: true,
|
411 |
-
onOpen: function() { elem.blur(); },
|
412 |
-
onClose: function() { elem.blur(); },
|
413 |
-
onSet: function( context ) {
|
414 |
-
|
415 |
-
}
|
416 |
-
});
|
417 |
-
});
|
418 |
-
|
419 |
-
var um_member_dir_filters_busy = false;
|
420 |
-
|
421 |
-
jQuery( document.body ).on( 'change', '.um-md-default-filters-option-line .um-field-wrapper select', function() {
|
422 |
-
if ( um_member_dir_filters_busy ) {
|
423 |
-
return;
|
424 |
-
}
|
425 |
-
|
426 |
-
var obj = jQuery(this);
|
427 |
-
var filter_key = obj.val();
|
428 |
-
var directory_id = obj.data('member_directory');
|
429 |
-
|
430 |
-
um_member_dir_filters_busy = true;
|
431 |
-
wp.ajax.send( 'um_member_directory_default_filter_settings', {
|
432 |
-
data: {
|
433 |
-
key: filter_key,
|
434 |
-
directory_id: directory_id,
|
435 |
-
nonce: um_admin_scripts.nonce
|
436 |
-
},
|
437 |
-
success: function( data ) {
|
438 |
-
var field_wrapper = obj.parents( '.um-md-default-filters-option-line' ).find('.um-field-wrapper2');
|
439 |
-
field_wrapper.html( data.field_html );
|
440 |
-
|
441 |
-
um_member_dir_filters_busy = false;
|
442 |
-
|
443 |
-
//slider filter
|
444 |
-
field_wrapper.find('.um-slider').each( function() {
|
445 |
-
var slider = jQuery( this );
|
446 |
-
var min_default_value = parseInt( slider.data('min') );
|
447 |
-
var max_default_value = parseInt( slider.data('max') );
|
448 |
-
|
449 |
-
var default_value = [ min_default_value, max_default_value ];
|
450 |
-
|
451 |
-
slider.slider({
|
452 |
-
range: true,
|
453 |
-
min: parseInt( slider.data('min') ),
|
454 |
-
max: parseInt( slider.data('max') ),
|
455 |
-
values: default_value,
|
456 |
-
create: function( event, ui ) {
|
457 |
-
//console.log( ui );
|
458 |
-
},
|
459 |
-
step: 1,
|
460 |
-
slide: function( event, ui ) {
|
461 |
-
um_set_range_label( jQuery( this ), ui );
|
462 |
-
},
|
463 |
-
stop: function( event, ui ) {
|
464 |
-
|
465 |
-
}
|
466 |
-
});
|
467 |
-
|
468 |
-
um_set_range_label( slider );
|
469 |
-
});
|
470 |
-
|
471 |
-
|
472 |
-
//datepicker filter
|
473 |
-
field_wrapper.find('.um-datepicker-filter').each( function() {
|
474 |
-
var elem = jQuery(this);
|
475 |
-
|
476 |
-
var min = new Date( elem.data('date_min')*1000 );
|
477 |
-
var max = new Date( elem.data('date_max')*1000 );
|
478 |
-
|
479 |
-
var $input = elem.pickadate({
|
480 |
-
selectYears: true,
|
481 |
-
min: min,
|
482 |
-
max: max,
|
483 |
-
formatSubmit: 'yyyy/mm/dd',
|
484 |
-
hiddenName: true,
|
485 |
-
onOpen: function() {
|
486 |
-
elem.blur();
|
487 |
-
},
|
488 |
-
onClose: function() {
|
489 |
-
elem.blur();
|
490 |
-
},
|
491 |
-
onSet: function( context ) {
|
492 |
-
|
493 |
-
}
|
494 |
-
});
|
495 |
-
});
|
496 |
-
|
497 |
-
|
498 |
-
//timepicker filter
|
499 |
-
field_wrapper.find('.um-timepicker-filter').each( function() {
|
500 |
-
var elem = jQuery(this);
|
501 |
-
|
502 |
-
//using arrays formatted as [HOUR,MINUTE]
|
503 |
-
|
504 |
-
var min = elem.data('min');
|
505 |
-
var max = elem.data('max');
|
506 |
-
var picker_min = min.split(':');
|
507 |
-
var picker_max = max.split(':');
|
508 |
-
|
509 |
-
var $input = elem.pickatime({
|
510 |
-
format: elem.data('format'),
|
511 |
-
interval: parseInt( elem.data('intervals') ),
|
512 |
-
min: [picker_min[0],picker_min[1]],
|
513 |
-
max: [picker_max[0],picker_max[1]],
|
514 |
-
formatSubmit: 'HH:i',
|
515 |
-
hiddenName: true,
|
516 |
-
onOpen: function() { elem.blur(); },
|
517 |
-
onClose: function() { elem.blur(); },
|
518 |
-
onSet: function( context ) {
|
519 |
-
|
520 |
-
}
|
521 |
-
});
|
522 |
-
});
|
523 |
-
|
524 |
-
|
525 |
-
},
|
526 |
-
error: function( data ) {
|
527 |
-
return false;
|
528 |
-
}
|
529 |
-
});
|
530 |
-
|
531 |
-
});
|
532 |
-
|
533 |
-
function um_set_range_label( slider, ui ) {
|
534 |
-
var placeholder = '';
|
535 |
-
var placeholder_s = slider.siblings( '.um-slider-range' ).data( 'placeholder-s' );
|
536 |
-
var placeholder_p = slider.siblings( '.um-slider-range' ).data( 'placeholder-p' );
|
537 |
-
var um_range_min, um_range_max;
|
538 |
-
|
539 |
-
if ( ui ) {
|
540 |
-
if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
|
541 |
-
placeholder = placeholder_s.replace( '\{value\}', ui.values[ 0 ] )
|
542 |
-
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
543 |
-
.data('label') );
|
544 |
-
} else {
|
545 |
-
placeholder = placeholder_p.replace( '\{min_range\}', ui.values[ 0 ] )
|
546 |
-
.replace( '\{max_range\}', ui.values[ 1 ] )
|
547 |
-
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
548 |
-
.data('label') );
|
549 |
-
}
|
550 |
-
um_range_min = ui.values[0];
|
551 |
-
um_range_max = ui.values[1];
|
552 |
-
} else {
|
553 |
-
if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
|
554 |
-
placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
|
555 |
-
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
556 |
-
.data('label') );
|
557 |
-
} else {
|
558 |
-
placeholder = placeholder_p.replace( '\{min_range\}', slider.slider( "values", 0 ) )
|
559 |
-
.replace( '\{max_range\}', slider.slider( "values", 1 ) )
|
560 |
-
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
561 |
-
.data('label') );
|
562 |
-
}
|
563 |
-
um_range_min = slider.slider( "values", 0 );
|
564 |
-
um_range_max = slider.slider( "values", 1 );
|
565 |
-
}
|
566 |
-
slider.siblings( '.um-slider-range' ).html( placeholder );
|
567 |
-
|
568 |
-
slider.siblings( ".um_range_min" ).val( um_range_min );
|
569 |
-
slider.siblings( ".um_range_max" ).val( um_range_max );
|
570 |
-
}
|
571 |
-
|
572 |
-
|
573 |
-
jQuery( '.um-md-default-filters-add-option' ).on('click', function() {
|
574 |
-
if ( um_member_dir_filters_busy ) {
|
575 |
-
return;
|
576 |
-
}
|
577 |
-
|
578 |
-
var list = jQuery(this).siblings('ul.um-md-default-filters-list');
|
579 |
-
|
580 |
-
var field_id = list.data('field_id');
|
581 |
-
var k = 0;
|
582 |
-
if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) {
|
583 |
-
k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-");
|
584 |
-
k = k[1]*1 + 1;
|
585 |
-
}
|
586 |
-
|
587 |
-
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-md-default-filters').clone() ).html();
|
588 |
-
|
589 |
-
list.append(
|
590 |
-
'<li class="um-md-default-filters-option-line"><span class="um-field-wrapper">' + selector_html +
|
591 |
-
'</span></span><span class="um-field-control"><a href="javascript:void(0);" class="um-select-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a></span><span class="um-field-wrapper2 um"></li>'
|
592 |
-
);
|
593 |
-
|
594 |
-
list.find('li:last .um-hidden-md-default-filters').attr('name', jQuery(this).data('name') ).
|
595 |
-
addClass('um-forms-field um-long-field').removeClass('um-hidden-md-default-filters').attr('id', list.data('id_attr') + '-' + k);
|
596 |
-
|
597 |
-
list.find('li:last .um-field-wrapper select').trigger('change');
|
598 |
-
});
|
599 |
-
|
600 |
-
|
601 |
-
/**
|
602 |
-
* Multi-text field
|
603 |
-
*/
|
604 |
-
jQuery( document.body ).on( 'click', '.um-text-delete', function() {
|
605 |
-
jQuery(this).parents('li.um-multi-text-option-line').remove();
|
606 |
-
});
|
607 |
-
|
608 |
-
|
609 |
-
jQuery( '.um-multi-text-add-option' ).on('click', function() {
|
610 |
-
var list = jQuery(this).siblings( 'ul.um-multi-text-list' );
|
611 |
-
|
612 |
-
var k = 0;
|
613 |
-
if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) {
|
614 |
-
k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-");
|
615 |
-
k = k[1]*1 + 1;
|
616 |
-
}
|
617 |
-
|
618 |
-
var text_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-text').clone() ).html();
|
619 |
-
|
620 |
-
var classes = list.data('item_class');
|
621 |
-
|
622 |
-
list.append(
|
623 |
-
'<li class="' + classes + '"><span class="um-field-wrapper">' + text_html +
|
624 |
-
'</span><span class="um-field-control"><a href="javascript:void(0);" class="um-text-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a></span></li>'
|
625 |
-
);
|
626 |
-
|
627 |
-
list.find('li:last .um-hidden-multi-text').attr('name', jQuery(this).data('name') ).
|
628 |
-
addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-text').attr('id', list.data('id_attr') + '-' + k);
|
629 |
-
});
|
630 |
-
|
631 |
-
|
632 |
-
/**
|
633 |
-
* Media uploader
|
634 |
-
*/
|
635 |
-
jQuery( '.um-media-upload' ).each( function() {
|
636 |
-
var field = jQuery(this).find( '.um-forms-field' );
|
637 |
-
var default_value = field.data('default');
|
638 |
-
|
639 |
-
if ( field.val() != '' && field.val() != default_value ) {
|
640 |
-
field.siblings('.um-set-image').hide();
|
641 |
-
field.siblings('.um-clear-image').show();
|
642 |
-
field.siblings('.icon_preview').show();
|
643 |
-
} else {
|
644 |
-
if ( field.val() == default_value ) {
|
645 |
-
field.siblings('.icon_preview').show();
|
646 |
-
}
|
647 |
-
field.siblings('.um-set-image').show();
|
648 |
-
field.siblings('.um-clear-image').hide();
|
649 |
-
}
|
650 |
-
});
|
651 |
-
|
652 |
-
|
653 |
-
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
|
654 |
-
var frame;
|
655 |
-
|
656 |
-
jQuery( '.um-set-image' ).on('click', function(e) {
|
657 |
-
var button = jQuery(this);
|
658 |
-
|
659 |
-
e.preventDefault();
|
660 |
-
|
661 |
-
// If the media frame already exists, reopen it.
|
662 |
-
if ( frame ) {
|
663 |
-
frame.remove();
|
664 |
-
/*frame.open();
|
665 |
-
return;*/
|
666 |
-
}
|
667 |
-
|
668 |
-
// Create a new media frame
|
669 |
-
frame = wp.media({
|
670 |
-
title: button.data('upload_frame'),
|
671 |
-
button: {
|
672 |
-
text: wp.i18n.__( 'Select', 'ultimate-member' )
|
673 |
-
},
|
674 |
-
multiple: false // Set to true to allow multiple files to be selected
|
675 |
-
});
|
676 |
-
|
677 |
-
// When an image is selected in the media frame...
|
678 |
-
frame.on( 'select', function() {
|
679 |
-
// Get media attachment details from the frame state
|
680 |
-
var attachment = frame.state().get('selection').first().toJSON();
|
681 |
-
|
682 |
-
// Send the attachment URL to our custom image input field.
|
683 |
-
button.siblings('.icon_preview').attr( 'src', attachment.url ).show();
|
684 |
-
|
685 |
-
button.siblings('.um-forms-field').val( attachment.url );
|
686 |
-
button.siblings('.um-media-upload-data-id').val(attachment.id);
|
687 |
-
button.siblings('.um-media-upload-data-width').val(attachment.width);
|
688 |
-
button.siblings('.um-media-upload-data-height').val(attachment.height);
|
689 |
-
button.siblings('.um-media-upload-data-thumbnail').val(attachment.thumbnail);
|
690 |
-
button.siblings('.um-media-upload-data-url').trigger('change');
|
691 |
-
button.siblings('.um-media-upload-url').val(attachment.url);
|
692 |
-
|
693 |
-
button.siblings('.um-clear-image').show();
|
694 |
-
button.hide();
|
695 |
-
|
696 |
-
jQuery( document ).trigger( 'um_media_upload_select', [button, attachment] );
|
697 |
-
});
|
698 |
-
|
699 |
-
frame.open();
|
700 |
-
});
|
701 |
-
|
702 |
-
jQuery('.icon_preview').on('click', function(e) {
|
703 |
-
jQuery(this).siblings('.um-set-image').trigger('click');
|
704 |
-
});
|
705 |
-
|
706 |
-
jQuery('.um-clear-image').on('click', function(e) {
|
707 |
-
var clear_button = jQuery(this);
|
708 |
-
var default_image_url = clear_button.siblings('.um-forms-field').data('default');
|
709 |
-
clear_button.siblings('.um-set-image').show();
|
710 |
-
clear_button.hide();
|
711 |
-
clear_button.siblings('.icon_preview').attr( 'src', default_image_url );
|
712 |
-
clear_button.siblings('.um-media-upload-data-id').val('');
|
713 |
-
clear_button.siblings('.um-media-upload-data-width').val('');
|
714 |
-
clear_button.siblings('.um-media-upload-data-height').val('');
|
715 |
-
clear_button.siblings('.um-media-upload-data-thumbnail').val('');
|
716 |
-
clear_button.siblings('.um-forms-field').val( default_image_url );
|
717 |
-
clear_button.siblings('.um-media-upload-data-url').trigger('change');
|
718 |
-
clear_button.siblings('.um-media-upload-url').val( default_image_url );
|
719 |
-
|
720 |
-
jQuery( document ).trigger( 'um_media_upload_clear', clear_button );
|
721 |
-
});
|
722 |
-
}
|
723 |
-
|
724 |
-
|
725 |
-
/**
|
726 |
-
* On option fields change
|
727 |
-
*/
|
728 |
-
jQuery( document.body ).on('change', '.um-forms-field', function() {
|
729 |
-
if ( jQuery('.um-forms-line[data-conditional*=\'"' + jQuery(this).data('field_id') + '",\']').length > 0 || jQuery('.um-forms-line[data-conditional*=\'' + jQuery(this).data('field_id') + '|\']').length > 0 || jQuery('.um-forms-line[data-conditional*=\'|' + jQuery(this).data('field_id') + '\']').length > 0 ) {
|
730 |
-
run_check_conditions();
|
731 |
-
}
|
732 |
-
});
|
733 |
-
|
734 |
-
|
735 |
-
//first load hide unconditional fields
|
736 |
-
run_check_conditions();
|
737 |
-
|
738 |
-
|
739 |
-
/**
|
740 |
-
* Run conditional logic
|
741 |
-
*/
|
742 |
-
function run_check_conditions() {
|
743 |
-
jQuery( '.um-forms-line' ).removeClass('um-forms-line-conditioned').each( function() {
|
744 |
-
if ( typeof jQuery(this).data('conditional') === 'undefined' || jQuery(this).hasClass('um-forms-line-conditioned') )
|
745 |
-
return;
|
746 |
-
|
747 |
-
if ( check_condition( jQuery(this) ) ) {
|
748 |
-
jQuery(this).show();
|
749 |
-
} else {
|
750 |
-
jQuery(this).hide();
|
751 |
-
}
|
752 |
-
});
|
753 |
-
}
|
754 |
-
|
755 |
-
|
756 |
-
function um_distinct( value, index, self ) {
|
757 |
-
return self.indexOf( value ) === index;
|
758 |
-
}
|
759 |
-
|
760 |
-
|
761 |
-
/**
|
762 |
-
* Conditional logic
|
763 |
-
*
|
764 |
-
* true - show field
|
765 |
-
* false - hide field
|
766 |
-
*
|
767 |
-
* @returns {boolean}
|
768 |
-
*/
|
769 |
-
function check_condition( form_line ) {
|
770 |
-
|
771 |
-
form_line.addClass( 'um-forms-line-conditioned' );
|
772 |
-
|
773 |
-
var conditional = form_line.data('conditional');
|
774 |
-
var condition = conditional[1];
|
775 |
-
var value = conditional[2];
|
776 |
-
|
777 |
-
var prefix = form_line.data( 'prefix' );
|
778 |
-
var parent_condition = true;
|
779 |
-
|
780 |
-
if ( condition === '=' || condition === '!=' ) {
|
781 |
-
if ( conditional[0].indexOf( '||' ) === -1 ) {
|
782 |
-
var condition_field = jQuery( '#' + prefix + '_' + conditional[0] );
|
783 |
-
|
784 |
-
if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
785 |
-
parent_condition = check_condition( condition_field.parents('.um-forms-line') );
|
786 |
-
}
|
787 |
-
}
|
788 |
-
} else if ( condition === '~' ) {
|
789 |
-
var selectors = conditional[0].split('|');
|
790 |
-
var condition_fields = [];
|
791 |
-
jQuery.each( selectors, function(i) {
|
792 |
-
condition_fields.push( jQuery( '#' + prefix + '_' + selectors[i] ) );
|
793 |
-
});
|
794 |
-
if ( typeof condition_fields[0].parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
795 |
-
parent_condition = check_condition( condition_fields[0].parents('.um-forms-line') );
|
796 |
-
}
|
797 |
-
} else if ( condition === '><' ) {
|
798 |
-
var condition_field = jQuery( '#' + prefix + '_' + conditional[0] + '_' + conditional[2] );
|
799 |
-
|
800 |
-
if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
801 |
-
parent_condition = check_condition( condition_field.parents('.um-forms-line') );
|
802 |
-
}
|
803 |
-
}
|
804 |
-
|
805 |
-
var own_condition = false;
|
806 |
-
if ( condition === '=' ) {
|
807 |
-
if ( conditional[0].indexOf( '||' ) !== -1 ) {
|
808 |
-
var selectors = conditional[0].split('||');
|
809 |
-
var complete_condition = false;
|
810 |
-
|
811 |
-
jQuery.each( selectors, function(i) {
|
812 |
-
var cond_field = jQuery( '#' + prefix + '_' + selectors[i] );
|
813 |
-
|
814 |
-
own_condition = false;
|
815 |
-
parent_condition = true;
|
816 |
-
|
817 |
-
if ( typeof cond_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
818 |
-
parent_condition = check_condition( cond_field.parents('.um-forms-line') );
|
819 |
-
}
|
820 |
-
|
821 |
-
var tagName = cond_field.prop("tagName").toLowerCase();
|
822 |
-
|
823 |
-
if ( tagName === 'input' ) {
|
824 |
-
var input_type = cond_field.attr('type');
|
825 |
-
if ( input_type === 'checkbox' ) {
|
826 |
-
own_condition = ( value == '1' ) ? cond_field.is(':checked') : ! cond_field.is(':checked');
|
827 |
-
} else {
|
828 |
-
if ( Array.isArray( value ) ) {
|
829 |
-
own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
|
830 |
-
} else {
|
831 |
-
own_condition = ( cond_field.val() == value );
|
832 |
-
}
|
833 |
-
}
|
834 |
-
} else if ( tagName === 'select' ) {
|
835 |
-
|
836 |
-
if ( Array.isArray( value ) ) {
|
837 |
-
own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
|
838 |
-
} else {
|
839 |
-
own_condition = ( cond_field.val() == value );
|
840 |
-
}
|
841 |
-
|
842 |
-
}
|
843 |
-
|
844 |
-
if ( own_condition && parent_condition ) {
|
845 |
-
complete_condition = true;
|
846 |
-
}
|
847 |
-
});
|
848 |
-
|
849 |
-
return complete_condition;
|
850 |
-
} else {
|
851 |
-
var tagName = condition_field.prop("tagName").toLowerCase();
|
852 |
-
|
853 |
-
if ( tagName == 'input' ) {
|
854 |
-
var input_type = condition_field.attr('type');
|
855 |
-
if ( input_type == 'checkbox' ) {
|
856 |
-
own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
|
857 |
-
} else {
|
858 |
-
|
859 |
-
if ( Array.isArray( value ) ) {
|
860 |
-
own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
|
861 |
-
} else {
|
862 |
-
own_condition = ( condition_field.val() == value );
|
863 |
-
}
|
864 |
-
|
865 |
-
}
|
866 |
-
} else if ( tagName == 'select' ) {
|
867 |
-
|
868 |
-
if ( Array.isArray( value ) ) {
|
869 |
-
own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
|
870 |
-
} else {
|
871 |
-
own_condition = ( condition_field.val() == value );
|
872 |
-
}
|
873 |
-
|
874 |
-
}
|
875 |
-
|
876 |
-
return ( own_condition && parent_condition );
|
877 |
-
}
|
878 |
-
|
879 |
-
} else if ( condition === '!=' ) {
|
880 |
-
if ( conditional[0].indexOf( '||' ) !== -1 ) {
|
881 |
-
var selectors = conditional[0].split('||');
|
882 |
-
var complete_condition = false;
|
883 |
-
|
884 |
-
jQuery.each( selectors, function(i) {
|
885 |
-
var cond_field = jQuery( '#' + prefix + '_' + selectors[i] );
|
886 |
-
|
887 |
-
own_condition = false;
|
888 |
-
parent_condition = true;
|
889 |
-
if ( typeof cond_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
890 |
-
parent_condition = check_condition( cond_field.parents('.um-forms-line') );
|
891 |
-
}
|
892 |
-
|
893 |
-
var tagName = cond_field.prop("tagName").toLowerCase();
|
894 |
-
|
895 |
-
if ( tagName === 'input' ) {
|
896 |
-
var input_type = cond_field.attr('type');
|
897 |
-
if ( input_type === 'checkbox' ) {
|
898 |
-
own_condition = ( value == '1' ) ? ! cond_field.is(':checked') : cond_field.is(':checked');
|
899 |
-
} else {
|
900 |
-
own_condition = ( cond_field.val() != value );
|
901 |
-
}
|
902 |
-
} else if ( tagName === 'select' ) {
|
903 |
-
own_condition = ( cond_field.val() != value );
|
904 |
-
}
|
905 |
-
|
906 |
-
if ( own_condition && parent_condition ) {
|
907 |
-
complete_condition = true;
|
908 |
-
}
|
909 |
-
});
|
910 |
-
|
911 |
-
return complete_condition;
|
912 |
-
} else {
|
913 |
-
var tagName = condition_field.prop("tagName").toLowerCase();
|
914 |
-
|
915 |
-
if ( tagName == 'input' ) {
|
916 |
-
var input_type = condition_field.attr('type');
|
917 |
-
if ( input_type == 'checkbox' ) {
|
918 |
-
own_condition = ( value == '1' ) ? ! condition_field.is(':checked') : condition_field.is(':checked');
|
919 |
-
} else {
|
920 |
-
own_condition = ( condition_field.val() != value );
|
921 |
-
}
|
922 |
-
} else if ( tagName == 'select' ) {
|
923 |
-
own_condition = ( condition_field.val() != value );
|
924 |
-
}
|
925 |
-
|
926 |
-
return ( own_condition && parent_condition );
|
927 |
-
}
|
928 |
-
|
929 |
-
} else if ( condition === '~' ) {
|
930 |
-
var field_id;
|
931 |
-
var visible_options = [];
|
932 |
-
var lines_field;
|
933 |
-
|
934 |
-
if ( form_line.data('field_type') === 'sortable_items' ) {
|
935 |
-
field_id = form_line.find( '.um-sortable-items-value' ).data('field_id');
|
936 |
-
|
937 |
-
jQuery.each( condition_fields, function(i) {
|
938 |
-
var condition_field = condition_fields[ i ];
|
939 |
-
|
940 |
-
var tagName = condition_field.prop("tagName").toLowerCase();
|
941 |
-
|
942 |
-
if ( tagName === 'input' ) {
|
943 |
-
var input_type = condition_field.attr('type');
|
944 |
-
if ( input_type === 'checkbox' ) {
|
945 |
-
if ( value == '1' && condition_field.is(':checked') ) {
|
946 |
-
visible_options.push( condition_field.data( 'fill_' + field_id ) );
|
947 |
-
}
|
948 |
-
}
|
949 |
-
} else if ( tagName == 'select' ) {
|
950 |
-
if ( ! value && condition_field.val() ) {
|
951 |
-
visible_options = visible_options.concat( condition_field.val() );
|
952 |
-
visible_options = visible_options.filter( um_distinct );
|
953 |
-
}
|
954 |
-
}
|
955 |
-
});
|
956 |
-
|
957 |
-
lines_field = jQuery( '[data-field_id="' + field_id + '"]' );
|
958 |
-
|
959 |
-
if ( visible_options.length ) {
|
960 |
-
lines_field.siblings('.um-sortable-items-field').find('li').addClass('um-hidden-item');
|
961 |
-
jQuery.each( visible_options, function(i) {
|
962 |
-
lines_field.siblings('.um-sortable-items-field').find('li[data-tab-id="' + visible_options[ i ] + '"]').removeClass('um-hidden-item');
|
963 |
-
});
|
964 |
-
|
965 |
-
var sortable_value = [];
|
966 |
-
lines_field.siblings('.um-sortable-items-field').find('li').each( function() {
|
967 |
-
if ( ! jQuery(this).hasClass( 'um-hidden-item' ) ) {
|
968 |
-
sortable_value.push( jQuery(this).data('tab-id') );
|
969 |
-
}
|
970 |
-
});
|
971 |
-
|
972 |
-
lines_field.val( sortable_value.join( ',' ) );
|
973 |
-
lines_field.siblings( '.um-sortable-items-field' ).sortable( 'refresh' );
|
974 |
-
|
975 |
-
own_condition = true;
|
976 |
-
} else {
|
977 |
-
lines_field.val( null );
|
978 |
-
}
|
979 |
-
} else {
|
980 |
-
field_id = form_line.find( form_line.data('field_type') ).data('field_id');
|
981 |
-
|
982 |
-
jQuery.each( condition_fields, function(i) {
|
983 |
-
var condition_field = condition_fields[ i ];
|
984 |
-
|
985 |
-
var tagName = condition_field.prop("tagName").toLowerCase();
|
986 |
-
|
987 |
-
if ( tagName === 'input' ) {
|
988 |
-
var input_type = condition_field.attr('type');
|
989 |
-
if ( input_type === 'checkbox' ) {
|
990 |
-
if ( value == '1' && condition_field.is(':checked') ) {
|
991 |
-
visible_options.push( condition_field.data( 'fill_' + field_id ) );
|
992 |
-
}
|
993 |
-
}
|
994 |
-
} else if ( tagName == 'select' ) {
|
995 |
-
if ( ! value && condition_field.val() ) {
|
996 |
-
visible_options = visible_options.concat( condition_field.val() );
|
997 |
-
visible_options = visible_options.filter( um_distinct );
|
998 |
-
}
|
999 |
-
}
|
1000 |
-
});
|
1001 |
-
|
1002 |
-
lines_field = jQuery( '[data-field_id="' + field_id + '"]' );
|
1003 |
-
|
1004 |
-
if ( visible_options.length ) {
|
1005 |
-
lines_field.find( 'option' ).hide();
|
1006 |
-
jQuery.each( visible_options, function(i) {
|
1007 |
-
lines_field.find( 'option[value="' + visible_options[ i ] + '"]' ).show();
|
1008 |
-
});
|
1009 |
-
if ( visible_options.indexOf( lines_field.val() ) === -1 ) {
|
1010 |
-
lines_field.val( visible_options[0] );
|
1011 |
-
lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false );
|
1012 |
-
lines_field.find( 'option[value="' + visible_options[0] + '"]' ).attr( 'selected', true ).prop( 'selected', true );
|
1013 |
-
}
|
1014 |
-
own_condition = true;
|
1015 |
-
} else {
|
1016 |
-
lines_field.val( null );
|
1017 |
-
lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false );
|
1018 |
-
}
|
1019 |
-
}
|
1020 |
-
|
1021 |
-
return ( own_condition && parent_condition );
|
1022 |
-
} else if ( condition === '><' ) {
|
1023 |
-
|
1024 |
-
var tagName = condition_field.prop("tagName").toLowerCase();
|
1025 |
-
|
1026 |
-
if ( tagName == 'input' ) {
|
1027 |
-
var input_type = condition_field.attr('type');
|
1028 |
-
if ( input_type == 'checkbox' ) {
|
1029 |
-
own_condition = condition_field.is(':checked');
|
1030 |
-
}
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
return ( own_condition && parent_condition );
|
1034 |
-
|
1035 |
-
}
|
1036 |
-
|
1037 |
-
return false;
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
});
|
1 |
+
function um_admin_init_users_select() {
|
2 |
+
if ( jQuery('.um-user-select-field').length ) {
|
3 |
+
var select2_atts = {
|
4 |
+
ajax: {
|
5 |
+
url: wp.ajax.settings.url,
|
6 |
+
dataType: 'json',
|
7 |
+
delay: 250, // delay in ms while typing when to perform a AJAX search
|
8 |
+
data: function( params ) {
|
9 |
+
return {
|
10 |
+
search: params.term, // search query
|
11 |
+
action: 'um_get_users', // AJAX action for admin-ajax.php
|
12 |
+
page: params.page || 1, // infinite scroll pagination
|
13 |
+
nonce: um_admin_scripts.nonce
|
14 |
+
};
|
15 |
+
},
|
16 |
+
processResults: function( response, params ) {
|
17 |
+
params.page = params.page || 1;
|
18 |
+
var options = [];
|
19 |
+
|
20 |
+
if ( response.data.users ) {
|
21 |
+
jQuery.each( response.data.users, function( index, text ) {
|
22 |
+
options.push( { id: text.ID, text: text.user_login + ' (#' + text.ID + ')' } );
|
23 |
+
});
|
24 |
+
}
|
25 |
+
|
26 |
+
return {
|
27 |
+
results: options,
|
28 |
+
pagination: {
|
29 |
+
more: ( params.page * 20 ) < response.data.total_count
|
30 |
+
}
|
31 |
+
};
|
32 |
+
},
|
33 |
+
cache: true
|
34 |
+
},
|
35 |
+
minimumInputLength: 0, // the minimum of symbols to input before perform a search
|
36 |
+
allowClear: true,
|
37 |
+
width: "100%",
|
38 |
+
allowHtml: true,
|
39 |
+
dropdownCssClass: 'um-select2-users-dropdown',
|
40 |
+
containerCssClass : 'um-select2-users-container',
|
41 |
+
placeholder: jQuery(this).data('placeholder')
|
42 |
+
};
|
43 |
+
|
44 |
+
jQuery('.um-user-select-field').select2( select2_atts );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
jQuery(document).ready( function() {
|
50 |
+
um_admin_init_users_select();
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Same page upgrade field
|
54 |
+
*/
|
55 |
+
jQuery( document.body ).on( 'click', '.um-forms-field[data-log-object]', function() {
|
56 |
+
var obj = jQuery( this ).data( 'log-object' );
|
57 |
+
if ( jQuery( this ).is( ':checked' ) ) {
|
58 |
+
jQuery( this ).siblings( '.um-same-page-update-' + obj ).show();
|
59 |
+
} else {
|
60 |
+
jQuery( this ).siblings( '.um-same-page-update-' + obj ).hide();
|
61 |
+
}
|
62 |
+
});
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
jQuery( document.body ).on( 'click', '.um-admin-form-same-page-update', function() {
|
67 |
+
var field_key = jQuery(this).data('upgrade_cb');
|
68 |
+
jQuery(this).prop( 'disabled', true );
|
69 |
+
|
70 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Upgrade Process Started...', 'ultimate-member' ) );
|
71 |
+
|
72 |
+
if ( field_key === 'sync_metatable' ) {
|
73 |
+
var metadata_pages = 0;
|
74 |
+
var metadata_per_page = 500;
|
75 |
+
var current_page;
|
76 |
+
|
77 |
+
jQuery.ajax({
|
78 |
+
url: wp.ajax.settings.url,
|
79 |
+
type: 'POST',
|
80 |
+
dataType: 'json',
|
81 |
+
data: {
|
82 |
+
action: 'um_same_page_update',
|
83 |
+
cb_func: 'um_usermeta_fields',
|
84 |
+
nonce: um_admin_scripts.nonce
|
85 |
+
},
|
86 |
+
success: function( response ) {
|
87 |
+
get_metadata();
|
88 |
+
},
|
89 |
+
error: function() {
|
90 |
+
um_same_page_something_wrong( field_key );
|
91 |
+
}
|
92 |
+
});
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
*
|
97 |
+
* @returns {boolean}
|
98 |
+
*/
|
99 |
+
function get_metadata() {
|
100 |
+
current_page = 1;
|
101 |
+
|
102 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Getting metadata', 'ultimate-member' ) );
|
103 |
+
jQuery.ajax({
|
104 |
+
url: wp.ajax.settings.url,
|
105 |
+
type: 'POST',
|
106 |
+
dataType: 'json',
|
107 |
+
data: {
|
108 |
+
action: 'um_same_page_update',
|
109 |
+
cb_func: 'um_get_metadata',
|
110 |
+
nonce: um_admin_scripts.nonce
|
111 |
+
},
|
112 |
+
success: function( response ) {
|
113 |
+
if ( typeof response.data.count != 'undefined' ) {
|
114 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'There are ', 'ultimate-member' ) + response.data.count + wp.i18n.__( ' metadata rows...', 'ultimate-member' ) );
|
115 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Start metadata upgrading...', 'ultimate-member' ) );
|
116 |
+
|
117 |
+
metadata_pages = Math.ceil( response.data.count / metadata_per_page );
|
118 |
+
|
119 |
+
update_metadata_per_page();
|
120 |
+
} else {
|
121 |
+
um_same_page_wrong_ajax( field_key );
|
122 |
+
}
|
123 |
+
},
|
124 |
+
error: function() {
|
125 |
+
um_same_page_something_wrong( field_key );
|
126 |
+
}
|
127 |
+
});
|
128 |
+
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
function update_metadata_per_page() {
|
134 |
+
if ( current_page <= metadata_pages ) {
|
135 |
+
jQuery.ajax({
|
136 |
+
url: wp.ajax.settings.url,
|
137 |
+
type: 'POST',
|
138 |
+
dataType: 'json',
|
139 |
+
data: {
|
140 |
+
action: 'um_same_page_update',
|
141 |
+
cb_func: 'um_update_metadata_per_page',
|
142 |
+
page: current_page,
|
143 |
+
nonce: um_admin_scripts.nonce
|
144 |
+
},
|
145 |
+
success: function( response ) {
|
146 |
+
if ( typeof response.data != 'undefined' ) {
|
147 |
+
um_add_same_page_log( field_key, response.data.message );
|
148 |
+
current_page++;
|
149 |
+
update_metadata_per_page();
|
150 |
+
} else {
|
151 |
+
um_same_page_wrong_ajax( field_key );
|
152 |
+
}
|
153 |
+
},
|
154 |
+
error: function() {
|
155 |
+
um_same_page_something_wrong( field_key );
|
156 |
+
}
|
157 |
+
});
|
158 |
+
} else {
|
159 |
+
window.location = um_forms_data.successfully_redirect;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
});
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* @param field_key
|
170 |
+
* @param line
|
171 |
+
*/
|
172 |
+
function um_add_same_page_log( field_key, line ) {
|
173 |
+
var log_field = jQuery( '.um-same-page-update-' + field_key ).find( '.upgrade_log' );
|
174 |
+
var previous_html = log_field.html();
|
175 |
+
log_field.html( previous_html + line + "<br />" );
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
function um_same_page_wrong_ajax( field_key ) {
|
180 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Wrong AJAX response...', 'ultimate-member' ) );
|
181 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Your upgrade was crashed, please contact with support', 'ultimate-member' ) );
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
function um_same_page_something_wrong( field_key ) {
|
186 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Something went wrong with AJAX request...', 'ultimate-member' ) );
|
187 |
+
um_add_same_page_log( field_key, wp.i18n.__( 'Your upgrade was crashed, please contact with support', 'ultimate-member' ) );
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Sortable items
|
192 |
+
*/
|
193 |
+
jQuery('.um-sortable-items-field').sortable({
|
194 |
+
items: '.um-sortable-item',
|
195 |
+
connectWith: '.um-admin-drag-col,.um-admin-drag-group',
|
196 |
+
forcePlaceholderSize: true,
|
197 |
+
update: function( event, ui ) {
|
198 |
+
var sortable_value = [];
|
199 |
+
jQuery(this).find('li').each( function() {
|
200 |
+
if ( ! jQuery(this).hasClass( 'um-hidden-item' ) ) {
|
201 |
+
sortable_value.push( jQuery(this).data('tab-id') );
|
202 |
+
}
|
203 |
+
});
|
204 |
+
|
205 |
+
jQuery(this).siblings('.um-sortable-items-value' ).val( sortable_value.join( ',' ) );
|
206 |
+
}
|
207 |
+
});
|
208 |
+
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Multi-selects sort
|
212 |
+
*/
|
213 |
+
jQuery('.um-multi-selects-list.um-sortable-multi-selects').sortable({
|
214 |
+
items: '.um-admin-drag-fld',
|
215 |
+
connectWith: '.um-admin-drag-col,.um-admin-drag-group',
|
216 |
+
forcePlaceholderSize: true
|
217 |
+
});
|
218 |
+
|
219 |
+
jQuery('.um-multi-selects-list[data-field_id="_um_sorting_fields"] li').each( function() {
|
220 |
+
var if_other = jQuery(this).find( '.um-field-wrapper:not(.um-custom-order-fields) select' ).val();
|
221 |
+
if ( if_other === 'other' ) {
|
222 |
+
jQuery(this).find( '.um-field-wrapper.um-custom-order-fields' ).show();
|
223 |
+
} else {
|
224 |
+
jQuery(this).find( '.um-field-wrapper.um-custom-order-fields' ).hide();
|
225 |
+
}
|
226 |
+
});
|
227 |
+
|
228 |
+
jQuery( '.um-forms-line[data-field_type="md_sorting_fields"] .um-multi-selects-add-option' ).on('click', function() {
|
229 |
+
var list = jQuery(this).siblings('ul.um-multi-selects-list');
|
230 |
+
|
231 |
+
var sortable = list.hasClass( 'um-sortable-multi-selects' );
|
232 |
+
|
233 |
+
var field_id = list.data('field_id');
|
234 |
+
var k = 0;
|
235 |
+
if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) {
|
236 |
+
k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-");
|
237 |
+
k = k[1]*1 + 1;
|
238 |
+
}
|
239 |
+
|
240 |
+
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html();
|
241 |
+
|
242 |
+
var html = '<li class="um-multi-selects-option-line' + ( sortable ? ' um-admin-drag-fld' : '' ) + '">';
|
243 |
+
if ( sortable ) {
|
244 |
+
html += '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
245 |
+
}
|
246 |
+
|
247 |
+
html += '<span class="um-field-wrapper">' + selector_html + '</span>' +
|
248 |
+
'<span class="um-field-control">' +
|
249 |
+
'<a href="javascript:void(0);" class="um-select-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a>' +
|
250 |
+
'</span>' +
|
251 |
+
'<span class="um-field-wrapper um-custom-order-fields"><label>' + wp.i18n.__( 'Meta key', 'ultimate-member' ) + ': <input type="text" name="meta_key" /></label></span>' +
|
252 |
+
'<span class="um-field-wrapper um-custom-order-fields"><label>' + wp.i18n.__( 'Label', 'ultimate-member' ) + ': <input type="text" name="label" /></label></span>' +
|
253 |
+
'</li>';
|
254 |
+
list.append( html );
|
255 |
+
|
256 |
+
list.find('li:last .um-hidden-multi-selects').attr('name', jQuery(this).data('name') ).
|
257 |
+
addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-selects').attr('id', list.data('id_attr') + '-' + k).trigger('change');
|
258 |
+
|
259 |
+
jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields input[name="meta_key"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][meta_key]');
|
260 |
+
jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields input[name="label"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][label]');
|
261 |
+
});
|
262 |
+
|
263 |
+
|
264 |
+
jQuery( document.body ).on( 'change', '.um-multi-selects-list[data-field_id="_um_sorting_fields"] .um-field-wrapper:not(.um-custom-order-fields) select', function() {
|
265 |
+
var if_other = jQuery(this).val();
|
266 |
+
|
267 |
+
if ( if_other === 'other' ) {
|
268 |
+
jQuery(this).parents('li').find( '.um-field-wrapper.um-custom-order-fields' ).show();
|
269 |
+
} else {
|
270 |
+
jQuery(this).parents('li').find( '.um-field-wrapper.um-custom-order-fields' ).hide();
|
271 |
+
}
|
272 |
+
});
|
273 |
+
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Multi-selects field
|
277 |
+
*/
|
278 |
+
jQuery( document.body ).on( 'click', '.um-multi-selects-option-line .um-select-delete', function() {
|
279 |
+
jQuery( this ).parents( 'li.um-multi-selects-option-line' ).remove();
|
280 |
+
});
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Multi-selects field
|
284 |
+
*/
|
285 |
+
jQuery( document.body ).on( 'click', '.um-md-default-filters-option-line .um-select-delete', function() {
|
286 |
+
jQuery( this ).parents( 'li.um-md-default-filters-option-line' ).remove();
|
287 |
+
});
|
288 |
+
|
289 |
+
jQuery( '.um-multi-selects-add-option' ).on('click', function() {
|
290 |
+
if ( jQuery(this).parents( '.um-forms-line[data-field_type="md_sorting_fields"]' ).length ) {
|
291 |
+
return;
|
292 |
+
}
|
293 |
+
|
294 |
+
var list = jQuery(this).siblings('ul.um-multi-selects-list');
|
295 |
+
|
296 |
+
var sortable = list.hasClass( 'um-sortable-multi-selects' );
|
297 |
+
|
298 |
+
var field_id = list.data('field_id');
|
299 |
+
var k = 0;
|
300 |
+
if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) {
|
301 |
+
k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-");
|
302 |
+
k = k[1]*1 + 1;
|
303 |
+
}
|
304 |
+
|
305 |
+
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html();
|
306 |
+
|
307 |
+
var html = '<li class="um-multi-selects-option-line' + ( sortable ? ' um-admin-drag-fld' : '' ) + '">';
|
308 |
+
if ( sortable ) {
|
309 |
+
html += '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
310 |
+
}
|
311 |
+
|
312 |
+
html += '<span class="um-field-wrapper">' + selector_html + '</span>' +
|
313 |
+
'<span class="um-field-control">' +
|
314 |
+
'<a href="javascript:void(0);" class="um-select-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a>' +
|
315 |
+
'</span>' +
|
316 |
+
'</li>';
|
317 |
+
list.append( html );
|
318 |
+
|
319 |
+
list.find('li:last .um-hidden-multi-selects').attr('name', jQuery(this).data('name') ).
|
320 |
+
addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-selects').attr('id', list.data('id_attr') + '-' + k);
|
321 |
+
});
|
322 |
+
|
323 |
+
var um_local_date = new Date();
|
324 |
+
var um_gmt_hours = -um_local_date.getTimezoneOffset() / 60;
|
325 |
+
jQuery('input[name="um-gmt-offset"]').val( um_gmt_hours );
|
326 |
+
|
327 |
+
//slider filter
|
328 |
+
jQuery('.um-admin-metabox').find('.um-slider').each( function() {
|
329 |
+
var slider = jQuery( this );
|
330 |
+
|
331 |
+
var min_default_value = parseInt( slider.data('min') );
|
332 |
+
var max_default_value = parseInt( slider.data('max') );
|
333 |
+
|
334 |
+
if ( typeof jQuery( '#' + slider.data('field_name') + '_min' ).val() != 'undefined' ) {
|
335 |
+
min_default_value = jQuery( '#' + slider.data('field_name') + '_min' ).val();
|
336 |
+
}
|
337 |
+
if ( typeof jQuery( '#' + slider.data('field_name') + '_max' ).val() != 'undefined' ) {
|
338 |
+
max_default_value = jQuery( '#' + slider.data('field_name') + '_max' ).val();
|
339 |
+
}
|
340 |
+
|
341 |
+
var default_value = [ min_default_value, max_default_value ];
|
342 |
+
|
343 |
+
slider.slider({
|
344 |
+
range: true,
|
345 |
+
min: parseInt( slider.data('min') ),
|
346 |
+
max: parseInt( slider.data('max') ),
|
347 |
+
values: default_value,
|
348 |
+
create: function( event, ui ) {
|
349 |
+
//console.log( ui );
|
350 |
+
},
|
351 |
+
step: 1,
|
352 |
+
slide: function( event, ui ) {
|
353 |
+
um_set_range_label( jQuery( this ), ui );
|
354 |
+
},
|
355 |
+
stop: function( event, ui ) {
|
356 |
+
|
357 |
+
}
|
358 |
+
});
|
359 |
+
|
360 |
+
um_set_range_label( slider );
|
361 |
+
});
|
362 |
+
|
363 |
+
|
364 |
+
//datepicker filter
|
365 |
+
jQuery('.um-admin-metabox').find('.um-datepicker-filter').each( function() {
|
366 |
+
var elem = jQuery(this);
|
367 |
+
|
368 |
+
var min = new Date( elem.data('date_min')*1000 );
|
369 |
+
var max = new Date( elem.data('date_max')*1000 );
|
370 |
+
|
371 |
+
var $input = elem.pickadate({
|
372 |
+
selectYears: true,
|
373 |
+
min: min,
|
374 |
+
max: max,
|
375 |
+
formatSubmit: 'yyyy/mm/dd',
|
376 |
+
hiddenName: true,
|
377 |
+
onOpen: function() {
|
378 |
+
elem.blur();
|
379 |
+
},
|
380 |
+
onClose: function() {
|
381 |
+
elem.blur();
|
382 |
+
},
|
383 |
+
onSet: function( context ) {
|
384 |
+
|
385 |
+
}
|
386 |
+
});
|
387 |
+
|
388 |
+
var $picker = $input.pickadate('picker');
|
389 |
+
$picker.set( 'select', elem.data('value')*1000 );
|
390 |
+
});
|
391 |
+
|
392 |
+
|
393 |
+
//timepicker filter
|
394 |
+
jQuery('.um-admin-metabox').find('.um-timepicker-filter').each( function() {
|
395 |
+
var elem = jQuery(this);
|
396 |
+
|
397 |
+
//using arrays formatted as [HOUR,MINUTE]
|
398 |
+
|
399 |
+
var min = elem.data('min');
|
400 |
+
var max = elem.data('max');
|
401 |
+
var picker_min = min.split(':');
|
402 |
+
var picker_max = max.split(':');
|
403 |
+
|
404 |
+
var $input = elem.pickatime({
|
405 |
+
format: elem.data('format'),
|
406 |
+
interval: parseInt( elem.data('intervals') ),
|
407 |
+
min: [picker_min[0],picker_min[1]],
|
408 |
+
max: [picker_max[0],picker_max[1]],
|
409 |
+
formatSubmit: 'HH:i',
|
410 |
+
hiddenName: true,
|
411 |
+
onOpen: function() { elem.blur(); },
|
412 |
+
onClose: function() { elem.blur(); },
|
413 |
+
onSet: function( context ) {
|
414 |
+
|
415 |
+
}
|
416 |
+
});
|
417 |
+
});
|
418 |
+
|
419 |
+
var um_member_dir_filters_busy = false;
|
420 |
+
|
421 |
+
jQuery( document.body ).on( 'change', '.um-md-default-filters-option-line .um-field-wrapper select', function() {
|
422 |
+
if ( um_member_dir_filters_busy ) {
|
423 |
+
return;
|
424 |
+
}
|
425 |
+
|
426 |
+
var obj = jQuery(this);
|
427 |
+
var filter_key = obj.val();
|
428 |
+
var directory_id = obj.data('member_directory');
|
429 |
+
|
430 |
+
um_member_dir_filters_busy = true;
|
431 |
+
wp.ajax.send( 'um_member_directory_default_filter_settings', {
|
432 |
+
data: {
|
433 |
+
key: filter_key,
|
434 |
+
directory_id: directory_id,
|
435 |
+
nonce: um_admin_scripts.nonce
|
436 |
+
},
|
437 |
+
success: function( data ) {
|
438 |
+
var field_wrapper = obj.parents( '.um-md-default-filters-option-line' ).find('.um-field-wrapper2');
|
439 |
+
field_wrapper.html( data.field_html );
|
440 |
+
|
441 |
+
um_member_dir_filters_busy = false;
|
442 |
+
|
443 |
+
//slider filter
|
444 |
+
field_wrapper.find('.um-slider').each( function() {
|
445 |
+
var slider = jQuery( this );
|
446 |
+
var min_default_value = parseInt( slider.data('min') );
|
447 |
+
var max_default_value = parseInt( slider.data('max') );
|
448 |
+
|
449 |
+
var default_value = [ min_default_value, max_default_value ];
|
450 |
+
|
451 |
+
slider.slider({
|
452 |
+
range: true,
|
453 |
+
min: parseInt( slider.data('min') ),
|
454 |
+
max: parseInt( slider.data('max') ),
|
455 |
+
values: default_value,
|
456 |
+
create: function( event, ui ) {
|
457 |
+
//console.log( ui );
|
458 |
+
},
|
459 |
+
step: 1,
|
460 |
+
slide: function( event, ui ) {
|
461 |
+
um_set_range_label( jQuery( this ), ui );
|
462 |
+
},
|
463 |
+
stop: function( event, ui ) {
|
464 |
+
|
465 |
+
}
|
466 |
+
});
|
467 |
+
|
468 |
+
um_set_range_label( slider );
|
469 |
+
});
|
470 |
+
|
471 |
+
|
472 |
+
//datepicker filter
|
473 |
+
field_wrapper.find('.um-datepicker-filter').each( function() {
|
474 |
+
var elem = jQuery(this);
|
475 |
+
|
476 |
+
var min = new Date( elem.data('date_min')*1000 );
|
477 |
+
var max = new Date( elem.data('date_max')*1000 );
|
478 |
+
|
479 |
+
var $input = elem.pickadate({
|
480 |
+
selectYears: true,
|
481 |
+
min: min,
|
482 |
+
max: max,
|
483 |
+
formatSubmit: 'yyyy/mm/dd',
|
484 |
+
hiddenName: true,
|
485 |
+
onOpen: function() {
|
486 |
+
elem.blur();
|
487 |
+
},
|
488 |
+
onClose: function() {
|
489 |
+
elem.blur();
|
490 |
+
},
|
491 |
+
onSet: function( context ) {
|
492 |
+
|
493 |
+
}
|
494 |
+
});
|
495 |
+
});
|
496 |
+
|
497 |
+
|
498 |
+
//timepicker filter
|
499 |
+
field_wrapper.find('.um-timepicker-filter').each( function() {
|
500 |
+
var elem = jQuery(this);
|
501 |
+
|
502 |
+
//using arrays formatted as [HOUR,MINUTE]
|
503 |
+
|
504 |
+
var min = elem.data('min');
|
505 |
+
var max = elem.data('max');
|
506 |
+
var picker_min = min.split(':');
|
507 |
+
var picker_max = max.split(':');
|
508 |
+
|
509 |
+
var $input = elem.pickatime({
|
510 |
+
format: elem.data('format'),
|
511 |
+
interval: parseInt( elem.data('intervals') ),
|
512 |
+
min: [picker_min[0],picker_min[1]],
|
513 |
+
max: [picker_max[0],picker_max[1]],
|
514 |
+
formatSubmit: 'HH:i',
|
515 |
+
hiddenName: true,
|
516 |
+
onOpen: function() { elem.blur(); },
|
517 |
+
onClose: function() { elem.blur(); },
|
518 |
+
onSet: function( context ) {
|
519 |
+
|
520 |
+
}
|
521 |
+
});
|
522 |
+
});
|
523 |
+
|
524 |
+
|
525 |
+
},
|
526 |
+
error: function( data ) {
|
527 |
+
return false;
|
528 |
+
}
|
529 |
+
});
|
530 |
+
|
531 |
+
});
|
532 |
+
|
533 |
+
function um_set_range_label( slider, ui ) {
|
534 |
+
var placeholder = '';
|
535 |
+
var placeholder_s = slider.siblings( '.um-slider-range' ).data( 'placeholder-s' );
|
536 |
+
var placeholder_p = slider.siblings( '.um-slider-range' ).data( 'placeholder-p' );
|
537 |
+
var um_range_min, um_range_max;
|
538 |
+
|
539 |
+
if ( ui ) {
|
540 |
+
if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
|
541 |
+
placeholder = placeholder_s.replace( '\{value\}', ui.values[ 0 ] )
|
542 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
543 |
+
.data('label') );
|
544 |
+
} else {
|
545 |
+
placeholder = placeholder_p.replace( '\{min_range\}', ui.values[ 0 ] )
|
546 |
+
.replace( '\{max_range\}', ui.values[ 1 ] )
|
547 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
548 |
+
.data('label') );
|
549 |
+
}
|
550 |
+
um_range_min = ui.values[0];
|
551 |
+
um_range_max = ui.values[1];
|
552 |
+
} else {
|
553 |
+
if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
|
554 |
+
placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
|
555 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
556 |
+
.data('label') );
|
557 |
+
} else {
|
558 |
+
placeholder = placeholder_p.replace( '\{min_range\}', slider.slider( "values", 0 ) )
|
559 |
+
.replace( '\{max_range\}', slider.slider( "values", 1 ) )
|
560 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
561 |
+
.data('label') );
|
562 |
+
}
|
563 |
+
um_range_min = slider.slider( "values", 0 );
|
564 |
+
um_range_max = slider.slider( "values", 1 );
|
565 |
+
}
|
566 |
+
slider.siblings( '.um-slider-range' ).html( placeholder );
|
567 |
+
|
568 |
+
slider.siblings( ".um_range_min" ).val( um_range_min );
|
569 |
+
slider.siblings( ".um_range_max" ).val( um_range_max );
|
570 |
+
}
|
571 |
+
|
572 |
+
|
573 |
+
jQuery( '.um-md-default-filters-add-option' ).on('click', function() {
|
574 |
+
if ( um_member_dir_filters_busy ) {
|
575 |
+
return;
|
576 |
+
}
|
577 |
+
|
578 |
+
var list = jQuery(this).siblings('ul.um-md-default-filters-list');
|
579 |
+
|
580 |
+
var field_id = list.data('field_id');
|
581 |
+
var k = 0;
|
582 |
+
if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) {
|
583 |
+
k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-");
|
584 |
+
k = k[1]*1 + 1;
|
585 |
+
}
|
586 |
+
|
587 |
+
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-md-default-filters').clone() ).html();
|
588 |
+
|
589 |
+
list.append(
|
590 |
+
'<li class="um-md-default-filters-option-line"><span class="um-field-wrapper">' + selector_html +
|
591 |
+
'</span></span><span class="um-field-control"><a href="javascript:void(0);" class="um-select-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a></span><span class="um-field-wrapper2 um"></li>'
|
592 |
+
);
|
593 |
+
|
594 |
+
list.find('li:last .um-hidden-md-default-filters').attr('name', jQuery(this).data('name') ).
|
595 |
+
addClass('um-forms-field um-long-field').removeClass('um-hidden-md-default-filters').attr('id', list.data('id_attr') + '-' + k);
|
596 |
+
|
597 |
+
list.find('li:last .um-field-wrapper select').trigger('change');
|
598 |
+
});
|
599 |
+
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Multi-text field
|
603 |
+
*/
|
604 |
+
jQuery( document.body ).on( 'click', '.um-text-delete', function() {
|
605 |
+
jQuery(this).parents('li.um-multi-text-option-line').remove();
|
606 |
+
});
|
607 |
+
|
608 |
+
|
609 |
+
jQuery( '.um-multi-text-add-option' ).on('click', function() {
|
610 |
+
var list = jQuery(this).siblings( 'ul.um-multi-text-list' );
|
611 |
+
|
612 |
+
var k = 0;
|
613 |
+
if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) {
|
614 |
+
k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-");
|
615 |
+
k = k[1]*1 + 1;
|
616 |
+
}
|
617 |
+
|
618 |
+
var text_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-text').clone() ).html();
|
619 |
+
|
620 |
+
var classes = list.data('item_class');
|
621 |
+
|
622 |
+
list.append(
|
623 |
+
'<li class="' + classes + '"><span class="um-field-wrapper">' + text_html +
|
624 |
+
'</span><span class="um-field-control"><a href="javascript:void(0);" class="um-text-delete">' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '</a></span></li>'
|
625 |
+
);
|
626 |
+
|
627 |
+
list.find('li:last .um-hidden-multi-text').attr('name', jQuery(this).data('name') ).
|
628 |
+
addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-text').attr('id', list.data('id_attr') + '-' + k);
|
629 |
+
});
|
630 |
+
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Media uploader
|
634 |
+
*/
|
635 |
+
jQuery( '.um-media-upload' ).each( function() {
|
636 |
+
var field = jQuery(this).find( '.um-forms-field' );
|
637 |
+
var default_value = field.data('default');
|
638 |
+
|
639 |
+
if ( field.val() != '' && field.val() != default_value ) {
|
640 |
+
field.siblings('.um-set-image').hide();
|
641 |
+
field.siblings('.um-clear-image').show();
|
642 |
+
field.siblings('.icon_preview').show();
|
643 |
+
} else {
|
644 |
+
if ( field.val() == default_value ) {
|
645 |
+
field.siblings('.icon_preview').show();
|
646 |
+
}
|
647 |
+
field.siblings('.um-set-image').show();
|
648 |
+
field.siblings('.um-clear-image').hide();
|
649 |
+
}
|
650 |
+
});
|
651 |
+
|
652 |
+
|
653 |
+
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
|
654 |
+
var frame;
|
655 |
+
|
656 |
+
jQuery( '.um-set-image' ).on('click', function(e) {
|
657 |
+
var button = jQuery(this);
|
658 |
+
|
659 |
+
e.preventDefault();
|
660 |
+
|
661 |
+
// If the media frame already exists, reopen it.
|
662 |
+
if ( frame ) {
|
663 |
+
frame.remove();
|
664 |
+
/*frame.open();
|
665 |
+
return;*/
|
666 |
+
}
|
667 |
+
|
668 |
+
// Create a new media frame
|
669 |
+
frame = wp.media({
|
670 |
+
title: button.data('upload_frame'),
|
671 |
+
button: {
|
672 |
+
text: wp.i18n.__( 'Select', 'ultimate-member' )
|
673 |
+
},
|
674 |
+
multiple: false // Set to true to allow multiple files to be selected
|
675 |
+
});
|
676 |
+
|
677 |
+
// When an image is selected in the media frame...
|
678 |
+
frame.on( 'select', function() {
|
679 |
+
// Get media attachment details from the frame state
|
680 |
+
var attachment = frame.state().get('selection').first().toJSON();
|
681 |
+
|
682 |
+
// Send the attachment URL to our custom image input field.
|
683 |
+
button.siblings('.icon_preview').attr( 'src', attachment.url ).show();
|
684 |
+
|
685 |
+
button.siblings('.um-forms-field').val( attachment.url );
|
686 |
+
button.siblings('.um-media-upload-data-id').val(attachment.id);
|
687 |
+
button.siblings('.um-media-upload-data-width').val(attachment.width);
|
688 |
+
button.siblings('.um-media-upload-data-height').val(attachment.height);
|
689 |
+
button.siblings('.um-media-upload-data-thumbnail').val(attachment.thumbnail);
|
690 |
+
button.siblings('.um-media-upload-data-url').trigger('change');
|
691 |
+
button.siblings('.um-media-upload-url').val(attachment.url);
|
692 |
+
|
693 |
+
button.siblings('.um-clear-image').show();
|
694 |
+
button.hide();
|
695 |
+
|
696 |
+
jQuery( document ).trigger( 'um_media_upload_select', [button, attachment] );
|
697 |
+
});
|
698 |
+
|
699 |
+
frame.open();
|
700 |
+
});
|
701 |
+
|
702 |
+
jQuery('.icon_preview').on('click', function(e) {
|
703 |
+
jQuery(this).siblings('.um-set-image').trigger('click');
|
704 |
+
});
|
705 |
+
|
706 |
+
jQuery('.um-clear-image').on('click', function(e) {
|
707 |
+
var clear_button = jQuery(this);
|
708 |
+
var default_image_url = clear_button.siblings('.um-forms-field').data('default');
|
709 |
+
clear_button.siblings('.um-set-image').show();
|
710 |
+
clear_button.hide();
|
711 |
+
clear_button.siblings('.icon_preview').attr( 'src', default_image_url );
|
712 |
+
clear_button.siblings('.um-media-upload-data-id').val('');
|
713 |
+
clear_button.siblings('.um-media-upload-data-width').val('');
|
714 |
+
clear_button.siblings('.um-media-upload-data-height').val('');
|
715 |
+
clear_button.siblings('.um-media-upload-data-thumbnail').val('');
|
716 |
+
clear_button.siblings('.um-forms-field').val( default_image_url );
|
717 |
+
clear_button.siblings('.um-media-upload-data-url').trigger('change');
|
718 |
+
clear_button.siblings('.um-media-upload-url').val( default_image_url );
|
719 |
+
|
720 |
+
jQuery( document ).trigger( 'um_media_upload_clear', clear_button );
|
721 |
+
});
|
722 |
+
}
|
723 |
+
|
724 |
+
|
725 |
+
/**
|
726 |
+
* On option fields change
|
727 |
+
*/
|
728 |
+
jQuery( document.body ).on('change', '.um-forms-field', function() {
|
729 |
+
if ( jQuery('.um-forms-line[data-conditional*=\'"' + jQuery(this).data('field_id') + '",\']').length > 0 || jQuery('.um-forms-line[data-conditional*=\'' + jQuery(this).data('field_id') + '|\']').length > 0 || jQuery('.um-forms-line[data-conditional*=\'|' + jQuery(this).data('field_id') + '\']').length > 0 ) {
|
730 |
+
run_check_conditions();
|
731 |
+
}
|
732 |
+
});
|
733 |
+
|
734 |
+
|
735 |
+
//first load hide unconditional fields
|
736 |
+
run_check_conditions();
|
737 |
+
|
738 |
+
|
739 |
+
/**
|
740 |
+
* Run conditional logic
|
741 |
+
*/
|
742 |
+
function run_check_conditions() {
|
743 |
+
jQuery( '.um-forms-line' ).removeClass('um-forms-line-conditioned').each( function() {
|
744 |
+
if ( typeof jQuery(this).data('conditional') === 'undefined' || jQuery(this).hasClass('um-forms-line-conditioned') )
|
745 |
+
return;
|
746 |
+
|
747 |
+
if ( check_condition( jQuery(this) ) ) {
|
748 |
+
jQuery(this).show();
|
749 |
+
} else {
|
750 |
+
jQuery(this).hide();
|
751 |
+
}
|
752 |
+
});
|
753 |
+
}
|
754 |
+
|
755 |
+
|
756 |
+
function um_distinct( value, index, self ) {
|
757 |
+
return self.indexOf( value ) === index;
|
758 |
+
}
|
759 |
+
|
760 |
+
|
761 |
+
/**
|
762 |
+
* Conditional logic
|
763 |
+
*
|
764 |
+
* true - show field
|
765 |
+
* false - hide field
|
766 |
+
*
|
767 |
+
* @returns {boolean}
|
768 |
+
*/
|
769 |
+
function check_condition( form_line ) {
|
770 |
+
|
771 |
+
form_line.addClass( 'um-forms-line-conditioned' );
|
772 |
+
|
773 |
+
var conditional = form_line.data('conditional');
|
774 |
+
var condition = conditional[1];
|
775 |
+
var value = conditional[2];
|
776 |
+
|
777 |
+
var prefix = form_line.data( 'prefix' );
|
778 |
+
var parent_condition = true;
|
779 |
+
|
780 |
+
if ( condition === '=' || condition === '!=' ) {
|
781 |
+
if ( conditional[0].indexOf( '||' ) === -1 ) {
|
782 |
+
var condition_field = jQuery( '#' + prefix + '_' + conditional[0] );
|
783 |
+
|
784 |
+
if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
785 |
+
parent_condition = check_condition( condition_field.parents('.um-forms-line') );
|
786 |
+
}
|
787 |
+
}
|
788 |
+
} else if ( condition === '~' ) {
|
789 |
+
var selectors = conditional[0].split('|');
|
790 |
+
var condition_fields = [];
|
791 |
+
jQuery.each( selectors, function(i) {
|
792 |
+
condition_fields.push( jQuery( '#' + prefix + '_' + selectors[i] ) );
|
793 |
+
});
|
794 |
+
if ( typeof condition_fields[0].parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
795 |
+
parent_condition = check_condition( condition_fields[0].parents('.um-forms-line') );
|
796 |
+
}
|
797 |
+
} else if ( condition === '><' ) {
|
798 |
+
var condition_field = jQuery( '#' + prefix + '_' + conditional[0] + '_' + conditional[2] );
|
799 |
+
|
800 |
+
if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
801 |
+
parent_condition = check_condition( condition_field.parents('.um-forms-line') );
|
802 |
+
}
|
803 |
+
}
|
804 |
+
|
805 |
+
var own_condition = false;
|
806 |
+
if ( condition === '=' ) {
|
807 |
+
if ( conditional[0].indexOf( '||' ) !== -1 ) {
|
808 |
+
var selectors = conditional[0].split('||');
|
809 |
+
var complete_condition = false;
|
810 |
+
|
811 |
+
jQuery.each( selectors, function(i) {
|
812 |
+
var cond_field = jQuery( '#' + prefix + '_' + selectors[i] );
|
813 |
+
|
814 |
+
own_condition = false;
|
815 |
+
parent_condition = true;
|
816 |
+
|
817 |
+
if ( typeof cond_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
818 |
+
parent_condition = check_condition( cond_field.parents('.um-forms-line') );
|
819 |
+
}
|
820 |
+
|
821 |
+
var tagName = cond_field.prop("tagName").toLowerCase();
|
822 |
+
|
823 |
+
if ( tagName === 'input' ) {
|
824 |
+
var input_type = cond_field.attr('type');
|
825 |
+
if ( input_type === 'checkbox' ) {
|
826 |
+
own_condition = ( value == '1' ) ? cond_field.is(':checked') : ! cond_field.is(':checked');
|
827 |
+
} else {
|
828 |
+
if ( Array.isArray( value ) ) {
|
829 |
+
own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
|
830 |
+
} else {
|
831 |
+
own_condition = ( cond_field.val() == value );
|
832 |
+
}
|
833 |
+
}
|
834 |
+
} else if ( tagName === 'select' ) {
|
835 |
+
|
836 |
+
if ( Array.isArray( value ) ) {
|
837 |
+
own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
|
838 |
+
} else {
|
839 |
+
own_condition = ( cond_field.val() == value );
|
840 |
+
}
|
841 |
+
|
842 |
+
}
|
843 |
+
|
844 |
+
if ( own_condition && parent_condition ) {
|
845 |
+
complete_condition = true;
|
846 |
+
}
|
847 |
+
});
|
848 |
+
|
849 |
+
return complete_condition;
|
850 |
+
} else {
|
851 |
+
var tagName = condition_field.prop("tagName").toLowerCase();
|
852 |
+
|
853 |
+
if ( tagName == 'input' ) {
|
854 |
+
var input_type = condition_field.attr('type');
|
855 |
+
if ( input_type == 'checkbox' ) {
|
856 |
+
own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
|
857 |
+
} else {
|
858 |
+
|
859 |
+
if ( Array.isArray( value ) ) {
|
860 |
+
own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
|
861 |
+
} else {
|
862 |
+
own_condition = ( condition_field.val() == value );
|
863 |
+
}
|
864 |
+
|
865 |
+
}
|
866 |
+
} else if ( tagName == 'select' ) {
|
867 |
+
|
868 |
+
if ( Array.isArray( value ) ) {
|
869 |
+
own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
|
870 |
+
} else {
|
871 |
+
own_condition = ( condition_field.val() == value );
|
872 |
+
}
|
873 |
+
|
874 |
+
}
|
875 |
+
|
876 |
+
return ( own_condition && parent_condition );
|
877 |
+
}
|
878 |
+
|
879 |
+
} else if ( condition === '!=' ) {
|
880 |
+
if ( conditional[0].indexOf( '||' ) !== -1 ) {
|
881 |
+
var selectors = conditional[0].split('||');
|
882 |
+
var complete_condition = false;
|
883 |
+
|
884 |
+
jQuery.each( selectors, function(i) {
|
885 |
+
var cond_field = jQuery( '#' + prefix + '_' + selectors[i] );
|
886 |
+
|
887 |
+
own_condition = false;
|
888 |
+
parent_condition = true;
|
889 |
+
if ( typeof cond_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
890 |
+
parent_condition = check_condition( cond_field.parents('.um-forms-line') );
|
891 |
+
}
|
892 |
+
|
893 |
+
var tagName = cond_field.prop("tagName").toLowerCase();
|
894 |
+
|
895 |
+
if ( tagName === 'input' ) {
|
896 |
+
var input_type = cond_field.attr('type');
|
897 |
+
if ( input_type === 'checkbox' ) {
|
898 |
+
own_condition = ( value == '1' ) ? ! cond_field.is(':checked') : cond_field.is(':checked');
|
899 |
+
} else {
|
900 |
+
own_condition = ( cond_field.val() != value );
|
901 |
+
}
|
902 |
+
} else if ( tagName === 'select' ) {
|
903 |
+
own_condition = ( cond_field.val() != value );
|
904 |
+
}
|
905 |
+
|
906 |
+
if ( own_condition && parent_condition ) {
|
907 |
+
complete_condition = true;
|
908 |
+
}
|
909 |
+
});
|
910 |
+
|
911 |
+
return complete_condition;
|
912 |
+
} else {
|
913 |
+
var tagName = condition_field.prop("tagName").toLowerCase();
|
914 |
+
|
915 |
+
if ( tagName == 'input' ) {
|
916 |
+
var input_type = condition_field.attr('type');
|
917 |
+
if ( input_type == 'checkbox' ) {
|
918 |
+
own_condition = ( value == '1' ) ? ! condition_field.is(':checked') : condition_field.is(':checked');
|
919 |
+
} else {
|
920 |
+
own_condition = ( condition_field.val() != value );
|
921 |
+
}
|
922 |
+
} else if ( tagName == 'select' ) {
|
923 |
+
own_condition = ( condition_field.val() != value );
|
924 |
+
}
|
925 |
+
|
926 |
+
return ( own_condition && parent_condition );
|
927 |
+
}
|
928 |
+
|
929 |
+
} else if ( condition === '~' ) {
|
930 |
+
var field_id;
|
931 |
+
var visible_options = [];
|
932 |
+
var lines_field;
|
933 |
+
|
934 |
+
if ( form_line.data('field_type') === 'sortable_items' ) {
|
935 |
+
field_id = form_line.find( '.um-sortable-items-value' ).data('field_id');
|
936 |
+
|
937 |
+
jQuery.each( condition_fields, function(i) {
|
938 |
+
var condition_field = condition_fields[ i ];
|
939 |
+
|
940 |
+
var tagName = condition_field.prop("tagName").toLowerCase();
|
941 |
+
|
942 |
+
if ( tagName === 'input' ) {
|
943 |
+
var input_type = condition_field.attr('type');
|
944 |
+
if ( input_type === 'checkbox' ) {
|
945 |
+
if ( value == '1' && condition_field.is(':checked') ) {
|
946 |
+
visible_options.push( condition_field.data( 'fill_' + field_id ) );
|
947 |
+
}
|
948 |
+
}
|
949 |
+
} else if ( tagName == 'select' ) {
|
950 |
+
if ( ! value && condition_field.val() ) {
|
951 |
+
visible_options = visible_options.concat( condition_field.val() );
|
952 |
+
visible_options = visible_options.filter( um_distinct );
|
953 |
+
}
|
954 |
+
}
|
955 |
+
});
|
956 |
+
|
957 |
+
lines_field = jQuery( '[data-field_id="' + field_id + '"]' );
|
958 |
+
|
959 |
+
if ( visible_options.length ) {
|
960 |
+
lines_field.siblings('.um-sortable-items-field').find('li').addClass('um-hidden-item');
|
961 |
+
jQuery.each( visible_options, function(i) {
|
962 |
+
lines_field.siblings('.um-sortable-items-field').find('li[data-tab-id="' + visible_options[ i ] + '"]').removeClass('um-hidden-item');
|
963 |
+
});
|
964 |
+
|
965 |
+
var sortable_value = [];
|
966 |
+
lines_field.siblings('.um-sortable-items-field').find('li').each( function() {
|
967 |
+
if ( ! jQuery(this).hasClass( 'um-hidden-item' ) ) {
|
968 |
+
sortable_value.push( jQuery(this).data('tab-id') );
|
969 |
+
}
|
970 |
+
});
|
971 |
+
|
972 |
+
lines_field.val( sortable_value.join( ',' ) );
|
973 |
+
lines_field.siblings( '.um-sortable-items-field' ).sortable( 'refresh' );
|
974 |
+
|
975 |
+
own_condition = true;
|
976 |
+
} else {
|
977 |
+
lines_field.val( null );
|
978 |
+
}
|
979 |
+
} else {
|
980 |
+
field_id = form_line.find( form_line.data('field_type') ).data('field_id');
|
981 |
+
|
982 |
+
jQuery.each( condition_fields, function(i) {
|
983 |
+
var condition_field = condition_fields[ i ];
|
984 |
+
|
985 |
+
var tagName = condition_field.prop("tagName").toLowerCase();
|
986 |
+
|
987 |
+
if ( tagName === 'input' ) {
|
988 |
+
var input_type = condition_field.attr('type');
|
989 |
+
if ( input_type === 'checkbox' ) {
|
990 |
+
if ( value == '1' && condition_field.is(':checked') ) {
|
991 |
+
visible_options.push( condition_field.data( 'fill_' + field_id ) );
|
992 |
+
}
|
993 |
+
}
|
994 |
+
} else if ( tagName == 'select' ) {
|
995 |
+
if ( ! value && condition_field.val() ) {
|
996 |
+
visible_options = visible_options.concat( condition_field.val() );
|
997 |
+
visible_options = visible_options.filter( um_distinct );
|
998 |
+
}
|
999 |
+
}
|
1000 |
+
});
|
1001 |
+
|
1002 |
+
lines_field = jQuery( '[data-field_id="' + field_id + '"]' );
|
1003 |
+
|
1004 |
+
if ( visible_options.length ) {
|
1005 |
+
lines_field.find( 'option' ).hide();
|
1006 |
+
jQuery.each( visible_options, function(i) {
|
1007 |
+
lines_field.find( 'option[value="' + visible_options[ i ] + '"]' ).show();
|
1008 |
+
});
|
1009 |
+
if ( visible_options.indexOf( lines_field.val() ) === -1 ) {
|
1010 |
+
lines_field.val( visible_options[0] );
|
1011 |
+
lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false );
|
1012 |
+
lines_field.find( 'option[value="' + visible_options[0] + '"]' ).attr( 'selected', true ).prop( 'selected', true );
|
1013 |
+
}
|
1014 |
+
own_condition = true;
|
1015 |
+
} else {
|
1016 |
+
lines_field.val( null );
|
1017 |
+
lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false );
|
1018 |
+
}
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
return ( own_condition && parent_condition );
|
1022 |
+
} else if ( condition === '><' ) {
|
1023 |
+
|
1024 |
+
var tagName = condition_field.prop("tagName").toLowerCase();
|
1025 |
+
|
1026 |
+
if ( tagName == 'input' ) {
|
1027 |
+
var input_type = condition_field.attr('type');
|
1028 |
+
if ( input_type == 'checkbox' ) {
|
1029 |
+
own_condition = condition_field.is(':checked');
|
1030 |
+
}
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
return ( own_condition && parent_condition );
|
1034 |
+
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
return false;
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
});
|
includes/admin/core/class-admin-ajax-hooks.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
// Exit if accessed directly.
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
-
|
8 |
-
|
9 |
-
if ( ! class_exists( 'um\admin\core\Admin_Ajax_Hooks' ) ) {
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Admin_Ajax_Hooks
|
14 |
-
* @package um\admin\core
|
15 |
-
*/
|
16 |
-
class Admin_Ajax_Hooks {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Admin_Columns constructor.
|
21 |
-
*/
|
22 |
-
function __construct() {
|
23 |
-
add_action( 'wp_ajax_um_do_ajax_action', array( UM()->fields(), 'do_ajax_action' ) );
|
24 |
-
add_action( 'wp_ajax_um_update_builder', array( UM()->builder(), 'update_builder' ) );
|
25 |
-
add_action( 'wp_ajax_um_update_order', array( UM()->dragdrop(), 'update_order' ) );
|
26 |
-
add_action( 'wp_ajax_um_update_field', array( UM()->builder(), 'update_field' ) );
|
27 |
-
add_action( 'wp_ajax_um_dynamic_modal_content', array( UM()->builder(), 'dynamic_modal_content' ) );
|
28 |
-
add_action( 'wp_ajax_um_populate_dropdown_options', array( UM()->builder(), 'populate_dropdown_options' ) );
|
29 |
-
add_action( 'wp_ajax_um_rated', array( UM()->admin_menu(), 'ultimatemember_rated' ) );
|
30 |
-
add_action( 'wp_ajax_um_member_directory_default_filter_settings', array( UM()->member_directory(), 'default_filter_settings' ) );
|
31 |
-
|
32 |
-
add_action( 'wp_ajax_um_same_page_update', array( UM()->admin_settings(), 'same_page_update_ajax' ) );
|
33 |
-
|
34 |
-
add_action( 'wp_ajax_um_get_users', array( UM()->users(), 'get_users' ) );
|
35 |
-
}
|
36 |
-
|
37 |
-
}
|
38 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
// Exit if accessed directly.
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
+
|
8 |
+
|
9 |
+
if ( ! class_exists( 'um\admin\core\Admin_Ajax_Hooks' ) ) {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Admin_Ajax_Hooks
|
14 |
+
* @package um\admin\core
|
15 |
+
*/
|
16 |
+
class Admin_Ajax_Hooks {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Admin_Columns constructor.
|
21 |
+
*/
|
22 |
+
function __construct() {
|
23 |
+
add_action( 'wp_ajax_um_do_ajax_action', array( UM()->fields(), 'do_ajax_action' ) );
|
24 |
+
add_action( 'wp_ajax_um_update_builder', array( UM()->builder(), 'update_builder' ) );
|
25 |
+
add_action( 'wp_ajax_um_update_order', array( UM()->dragdrop(), 'update_order' ) );
|
26 |
+
add_action( 'wp_ajax_um_update_field', array( UM()->builder(), 'update_field' ) );
|
27 |
+
add_action( 'wp_ajax_um_dynamic_modal_content', array( UM()->builder(), 'dynamic_modal_content' ) );
|
28 |
+
add_action( 'wp_ajax_um_populate_dropdown_options', array( UM()->builder(), 'populate_dropdown_options' ) );
|
29 |
+
add_action( 'wp_ajax_um_rated', array( UM()->admin_menu(), 'ultimatemember_rated' ) );
|
30 |
+
add_action( 'wp_ajax_um_member_directory_default_filter_settings', array( UM()->member_directory(), 'default_filter_settings' ) );
|
31 |
+
|
32 |
+
add_action( 'wp_ajax_um_same_page_update', array( UM()->admin_settings(), 'same_page_update_ajax' ) );
|
33 |
+
|
34 |
+
add_action( 'wp_ajax_um_get_users', array( UM()->users(), 'get_users' ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
}
|
includes/admin/core/class-admin-enqueue.php
CHANGED
@@ -1,697 +1,697 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Enqueue
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Enqueue {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var string
|
20 |
-
*/
|
21 |
-
var $js_url;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var string
|
26 |
-
*/
|
27 |
-
var $css_url;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var string
|
32 |
-
*/
|
33 |
-
var $front_js_baseurl;
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var string
|
38 |
-
*/
|
39 |
-
var $front_css_baseurl;
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
var $suffix;
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @var bool
|
50 |
-
*/
|
51 |
-
var $um_cpt_form_screen;
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @var bool
|
56 |
-
*/
|
57 |
-
var $post_page;
|
58 |
-
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Admin_Enqueue constructor.
|
62 |
-
*/
|
63 |
-
function __construct() {
|
64 |
-
$this->js_url = um_url . 'includes/admin/assets/js/';
|
65 |
-
$this->css_url = um_url . 'includes/admin/assets/css/';
|
66 |
-
|
67 |
-
$this->front_js_baseurl = um_url . 'assets/js/';
|
68 |
-
$this->front_css_baseurl = um_url . 'assets/css/';
|
69 |
-
|
70 |
-
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
|
71 |
-
|
72 |
-
$this->um_cpt_form_screen = false;
|
73 |
-
|
74 |
-
add_action( 'admin_head', array( &$this, 'admin_head' ), 9 );
|
75 |
-
|
76 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
77 |
-
|
78 |
-
add_filter( 'enter_title_here', array( &$this, 'enter_title_here' ) );
|
79 |
-
|
80 |
-
add_action( 'load-user-new.php', array( &$this, 'enqueue_role_wrapper' ) );
|
81 |
-
add_action( 'load-user-edit.php', array( &$this, 'enqueue_role_wrapper' ) );
|
82 |
-
|
83 |
-
add_action( 'load-post-new.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
84 |
-
add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
85 |
-
|
86 |
-
global $wp_version;
|
87 |
-
if ( version_compare( $wp_version, '5.8', '>=' ) ) {
|
88 |
-
add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 );
|
89 |
-
} else {
|
90 |
-
add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
function enqueue_role_wrapper() {
|
96 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'load_role_wrapper' ) );
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
/**
|
101 |
-
*
|
102 |
-
*/
|
103 |
-
function enqueue_cpt_scripts() {
|
104 |
-
if ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
|
105 |
-
( isset( $_GET['post'] ) && 'um_form' === get_post_type( absint( $_GET['post'] ) ) ) ) {
|
106 |
-
$this->um_cpt_form_screen = true;
|
107 |
-
add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 );
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
|
112 |
-
/**
|
113 |
-
*
|
114 |
-
*/
|
115 |
-
function enqueue_frontend_preview_assets() {
|
116 |
-
//scripts for FRONTEND PREVIEW
|
117 |
-
if ( class_exists( 'WooCommerce' ) ) {
|
118 |
-
wp_dequeue_style( 'select2' );
|
119 |
-
wp_deregister_style( 'select2' );
|
120 |
-
|
121 |
-
wp_dequeue_script( 'select2' );
|
122 |
-
wp_deregister_script( 'select2' );
|
123 |
-
}
|
124 |
-
|
125 |
-
|
126 |
-
wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
|
127 |
-
wp_register_script( 'um_jquery_form', $this->front_js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
128 |
-
wp_register_script( 'um_fileupload', $this->front_js_baseurl . 'um-fileupload.js', array( 'jquery' ), ultimatemember_version, true );
|
129 |
-
wp_register_script( 'um_crop', $this->front_js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
130 |
-
wp_register_script( 'um_tipsy', $this->front_js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
131 |
-
wp_register_script( 'um_functions', $this->front_js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'um_tipsy', 'um_scrollbar' ), ultimatemember_version, true );
|
132 |
-
|
133 |
-
wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
|
134 |
-
wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
135 |
-
wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
136 |
-
//wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
137 |
-
// load a localized version for date/time
|
138 |
-
$locale = get_locale();
|
139 |
-
if ( $locale ) {
|
140 |
-
if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
|
141 |
-
wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
142 |
-
} elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
|
143 |
-
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
wp_register_script( 'um_scripts', $this->front_js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'um_functions', 'um_crop', 'um_raty', 'select2', 'um_jquery_form', 'um_fileupload', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
|
148 |
-
wp_register_script( 'um_responsive', $this->front_js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'um_scripts' ), ultimatemember_version, true );
|
149 |
-
wp_register_script( 'um_modal', $this->front_js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'um_responsive' ), ultimatemember_version, true );
|
150 |
-
|
151 |
-
|
152 |
-
wp_register_style( 'select2', $this->front_css_baseurl . 'select2/select2' . $this->suffix . '.css', array(), '4.0.13' );
|
153 |
-
wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
154 |
-
wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
155 |
-
wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
156 |
-
|
157 |
-
wp_register_style( 'um_scrollbar', $this->front_css_baseurl . 'simplebar.css', array(), ultimatemember_version );
|
158 |
-
wp_register_style( 'um_crop', $this->front_css_baseurl . 'um-crop.css', array(), ultimatemember_version );
|
159 |
-
wp_register_style( 'um_tipsy', $this->front_css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
|
160 |
-
wp_register_style( 'um_responsive', $this->front_css_baseurl . 'um-responsive.css', array(), ultimatemember_version );
|
161 |
-
wp_register_style( 'um_modal', $this->front_css_baseurl . 'um-modal.css', array(), ultimatemember_version );
|
162 |
-
wp_register_style( 'um_styles', $this->front_css_baseurl . 'um-styles.css', array(), ultimatemember_version );
|
163 |
-
wp_register_style( 'um_members', $this->front_css_baseurl . 'um-members.css', array(), ultimatemember_version );
|
164 |
-
wp_register_style( 'um_profile', $this->front_css_baseurl . 'um-profile.css', array(), ultimatemember_version );
|
165 |
-
wp_register_style( 'um_account', $this->front_css_baseurl . 'um-account.css', array(), ultimatemember_version );
|
166 |
-
wp_register_style( 'um_misc', $this->front_css_baseurl . 'um-misc.css', array(), ultimatemember_version );
|
167 |
-
wp_register_style( 'um_default_css', $this->front_css_baseurl . 'um-old-default.css', array( 'um_crop', 'um_tipsy', 'um_raty', 'um_responsive', 'um_modal', 'um_styles', 'um_members', 'um_profile', 'um_account', 'um_misc', 'um_datetime_date', 'um_datetime_time', 'um_scrollbar', 'select2' ), ultimatemember_version );
|
168 |
-
|
169 |
-
wp_enqueue_script( 'um_modal' );
|
170 |
-
wp_enqueue_style( 'um_default_css' );
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Load js for Add/Edit User form
|
176 |
-
*/
|
177 |
-
function load_role_wrapper() {
|
178 |
-
wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', array( 'jquery' ), ultimatemember_version, true );
|
179 |
-
$localize_roles_data = get_option( 'um_roles', array() );
|
180 |
-
wp_localize_script( 'um_admin_role_wrapper', 'um_roles', (array) $localize_roles_data );
|
181 |
-
wp_enqueue_script( 'um_admin_role_wrapper' );
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Enter title placeholder
|
187 |
-
*
|
188 |
-
* @param $title
|
189 |
-
*
|
190 |
-
* @return string
|
191 |
-
*/
|
192 |
-
function enter_title_here( $title ) {
|
193 |
-
$screen = get_current_screen();
|
194 |
-
if ( 'um_directory' == $screen->post_type ) {
|
195 |
-
$title = __( 'e.g. Member Directory', 'ultimate-member' );
|
196 |
-
} elseif ( 'um_form' == $screen->post_type ) {
|
197 |
-
$title = __( 'e.g. New Registration Form', 'ultimate-member' );
|
198 |
-
}
|
199 |
-
return $title;
|
200 |
-
}
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Runs on admin head
|
205 |
-
*/
|
206 |
-
function admin_head() {
|
207 |
-
if ( UM()->admin()->is_plugin_post_type() ) { ?>
|
208 |
-
<style type="text/css">
|
209 |
-
.um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#slugdiv,
|
210 |
-
.um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#minor-publishing,
|
211 |
-
.um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#screen-meta-links
|
212 |
-
{display:none}
|
213 |
-
</style>
|
214 |
-
<?php }
|
215 |
-
}
|
216 |
-
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Load Form
|
220 |
-
*/
|
221 |
-
function load_form() {
|
222 |
-
wp_register_style( 'um_admin_form', $this->css_url . 'um-admin-form.css', array(), ultimatemember_version );
|
223 |
-
wp_enqueue_style( 'um_admin_form' );
|
224 |
-
|
225 |
-
wp_register_script( 'um_admin_form', $this->js_url . 'um-admin-form.js', array( 'jquery' ), ultimatemember_version, true );
|
226 |
-
wp_enqueue_script( 'um_admin_form' );
|
227 |
-
}
|
228 |
-
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Load Forms
|
232 |
-
*/
|
233 |
-
function load_forms() {
|
234 |
-
if ( class_exists( 'WooCommerce' ) ) {
|
235 |
-
wp_dequeue_style( 'select2' );
|
236 |
-
wp_deregister_style( 'select2' );
|
237 |
-
|
238 |
-
wp_dequeue_script( 'select2' );
|
239 |
-
wp_deregister_script( 'select2' );
|
240 |
-
}
|
241 |
-
|
242 |
-
wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
|
243 |
-
wp_register_style( 'select2', $this->front_css_baseurl . 'select2/select2' . $this->suffix . '.css', array(), '4.0.13' );
|
244 |
-
|
245 |
-
wp_register_style( 'um_ui', $this->front_css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
|
246 |
-
wp_register_style( 'um_admin_forms', $this->css_url . 'um-admin-forms.css', array( 'wp-color-picker', 'um_ui', 'select2' ), ultimatemember_version );
|
247 |
-
wp_enqueue_style( 'um_admin_forms' );
|
248 |
-
|
249 |
-
wp_register_script( 'um_admin_forms', $this->js_url . 'um-admin-forms.js', array( 'jquery', 'wp-i18n', 'select2' ), ultimatemember_version, true );
|
250 |
-
|
251 |
-
wp_localize_script( 'um_admin_forms', 'um_forms_data', array(
|
252 |
-
'successfully_redirect' => add_query_arg( array( 'page' => 'um_options', 'tab' => 'misc', 'msg' => 'updated' ), admin_url( 'admin.php' ) ),
|
253 |
-
) );
|
254 |
-
|
255 |
-
wp_enqueue_script( 'um_admin_forms' );
|
256 |
-
}
|
257 |
-
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Load dashboard
|
261 |
-
*/
|
262 |
-
function load_dashboard() {
|
263 |
-
wp_register_style( 'um_admin_dashboard', $this->css_url . 'um-admin-dashboard.css', array(), ultimatemember_version );
|
264 |
-
wp_enqueue_style( 'um_admin_dashboard' );
|
265 |
-
}
|
266 |
-
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Load settings
|
270 |
-
*/
|
271 |
-
function load_settings() {
|
272 |
-
wp_register_style( 'um_admin_settings', $this->css_url . 'um-admin-settings.css', array(), ultimatemember_version );
|
273 |
-
wp_enqueue_style( 'um_admin_settings' );
|
274 |
-
|
275 |
-
wp_register_script( 'um_admin_settings', $this->js_url . 'um-admin-settings.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
|
276 |
-
wp_enqueue_script( 'um_admin_settings' );
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Load modal
|
282 |
-
*/
|
283 |
-
function load_modal() {
|
284 |
-
wp_register_style( 'um_admin_modal', $this->css_url . 'um-admin-modal.css', array( 'wp-color-picker' ), ultimatemember_version );
|
285 |
-
wp_enqueue_style( 'um_admin_modal' );
|
286 |
-
|
287 |
-
wp_register_script( 'um_admin_modal', $this->js_url . 'um-admin-modal.js', array( 'jquery', 'editor', 'wp-util', 'wp-color-picker', 'wp-tinymce', 'wp-i18n' ), ultimatemember_version, true );
|
288 |
-
wp_enqueue_script( 'um_admin_modal' );
|
289 |
-
}
|
290 |
-
|
291 |
-
|
292 |
-
/**
|
293 |
-
* Field Processing
|
294 |
-
*/
|
295 |
-
function load_field() {
|
296 |
-
wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util', 'wp-i18n'), ultimatemember_version, true );
|
297 |
-
wp_enqueue_script( 'um_admin_field' );
|
298 |
-
}
|
299 |
-
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Load Builder
|
303 |
-
*/
|
304 |
-
function load_builder() {
|
305 |
-
wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', array('jquery', 'wp-util'), ultimatemember_version, true );
|
306 |
-
wp_enqueue_script( 'um_admin_builder' );
|
307 |
-
|
308 |
-
//hide footer text on add/edit UM Forms
|
309 |
-
//layouts crashed because we load and hide metaboxes
|
310 |
-
//and WP calculate page height
|
311 |
-
$hide_footer = false;
|
312 |
-
global $pagenow, $post;
|
313 |
-
if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) &&
|
314 |
-
( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
|
315 |
-
( isset( $post->post_type ) && 'um_form' === $post->post_type ) ) ) {
|
316 |
-
$hide_footer = true;
|
317 |
-
}
|
318 |
-
|
319 |
-
$localize_data = array(
|
320 |
-
'hide_footer' => $hide_footer,
|
321 |
-
);
|
322 |
-
wp_localize_script( 'um_admin_builder', 'um_admin_builder_data', $localize_data );
|
323 |
-
|
324 |
-
wp_register_script( 'um_admin_dragdrop', $this->js_url . 'um-admin-dragdrop.js', array('jquery', 'wp-util'), ultimatemember_version, true );
|
325 |
-
wp_enqueue_script( 'um_admin_dragdrop' );
|
326 |
-
|
327 |
-
wp_register_style( 'um_admin_builder', $this->css_url . 'um-admin-builder.css', array(), ultimatemember_version );
|
328 |
-
wp_enqueue_style( 'um_admin_builder' );
|
329 |
-
}
|
330 |
-
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Load core WP styles/scripts
|
334 |
-
*/
|
335 |
-
function load_core_wp() {
|
336 |
-
wp_enqueue_script( 'jquery-ui-draggable' );
|
337 |
-
wp_enqueue_script( 'jquery-ui-sortable' );
|
338 |
-
|
339 |
-
wp_enqueue_script( 'jquery-ui-tooltip' );
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Load Admin Styles
|
345 |
-
*/
|
346 |
-
function load_css() {
|
347 |
-
wp_register_style( 'um_admin_menu', $this->css_url . 'um-admin-menu.css', array(), ultimatemember_version );
|
348 |
-
wp_enqueue_style( 'um_admin_menu' );
|
349 |
-
|
350 |
-
wp_register_style( 'um_admin_columns', $this->css_url . 'um-admin-columns.css', array(), ultimatemember_version );
|
351 |
-
wp_enqueue_style( 'um_admin_columns' );
|
352 |
-
|
353 |
-
wp_register_style( 'um_admin_misc', $this->css_url . 'um-admin-misc.css', array(), ultimatemember_version );
|
354 |
-
wp_enqueue_style( 'um_admin_misc' );
|
355 |
-
}
|
356 |
-
|
357 |
-
|
358 |
-
/**
|
359 |
-
* Load functions js
|
360 |
-
*/
|
361 |
-
function load_functions() {
|
362 |
-
wp_register_script( 'um_scrollbar', um_url . 'assets/js/simplebar.js', array( 'jquery' ), ultimatemember_version, true );
|
363 |
-
wp_register_script( 'um_functions', um_url . 'assets/js/um-functions.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
|
364 |
-
wp_enqueue_script( 'um_functions' );
|
365 |
-
}
|
366 |
-
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Load Fonticons
|
370 |
-
*/
|
371 |
-
function load_fonticons() {
|
372 |
-
wp_register_style( 'um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css', array(), ultimatemember_version );
|
373 |
-
wp_enqueue_style( 'um_fonticons_ii' );
|
374 |
-
|
375 |
-
wp_register_style( 'um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css', array(), ultimatemember_version );
|
376 |
-
wp_enqueue_style( 'um_fonticons_fa' );
|
377 |
-
}
|
378 |
-
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Load global css
|
382 |
-
*/
|
383 |
-
function load_global_scripts() {
|
384 |
-
wp_register_script( 'um_admin_global', $this->js_url . 'um-admin-global.js', array('jquery'), ultimatemember_version, true );
|
385 |
-
wp_enqueue_script( 'um_admin_global' );
|
386 |
-
|
387 |
-
wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css', array(), ultimatemember_version );
|
388 |
-
wp_enqueue_style( 'um_admin_global' );
|
389 |
-
}
|
390 |
-
|
391 |
-
|
392 |
-
/**
|
393 |
-
* Load jQuery custom code
|
394 |
-
*/
|
395 |
-
function load_custom_scripts() {
|
396 |
-
wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
|
397 |
-
wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
398 |
-
wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
399 |
-
//wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
400 |
-
// load a localized version for date/time
|
401 |
-
$locale = get_locale();
|
402 |
-
if ( $locale ) {
|
403 |
-
if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
|
404 |
-
wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
405 |
-
} elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
|
406 |
-
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
407 |
-
}
|
408 |
-
}
|
409 |
-
|
410 |
-
wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
411 |
-
wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
412 |
-
wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
413 |
-
|
414 |
-
wp_enqueue_style( 'um_datetime_date', 'um_datetime_time' );
|
415 |
-
|
416 |
-
wp_register_script( 'um_admin_scripts', $this->js_url . 'um-admin-scripts.js', array('jquery','wp-util', 'wp-color-picker', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
|
417 |
-
wp_enqueue_script( 'um_admin_scripts' );
|
418 |
-
}
|
419 |
-
|
420 |
-
|
421 |
-
/**
|
422 |
-
* Load jQuery custom code
|
423 |
-
*/
|
424 |
-
function load_nav_manus_scripts() {
|
425 |
-
wp_register_script( 'um_admin_nav_manus', $this->js_url . 'um-admin-nav-menu.js', array('jquery','wp-util'), ultimatemember_version, true );
|
426 |
-
wp_enqueue_script( 'um_admin_nav_manus' );
|
427 |
-
}
|
428 |
-
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Load AJAX
|
432 |
-
*/
|
433 |
-
function load_ajax_js() {
|
434 |
-
wp_register_script( 'um_admin_ajax', $this->js_url . 'um-admin-ajax.js', array('jquery','wp-util'), ultimatemember_version, true );
|
435 |
-
wp_enqueue_script( 'um_admin_ajax' );
|
436 |
-
}
|
437 |
-
|
438 |
-
|
439 |
-
/**
|
440 |
-
* Load Gutenberg scripts
|
441 |
-
*/
|
442 |
-
function load_gutenberg_js() {
|
443 |
-
//disable Gutenberg scripts to avoid the conflicts
|
444 |
-
$disable_script = apply_filters( 'um_disable_blocks_script', false );
|
445 |
-
if ( $disable_script ) {
|
446 |
-
return;
|
447 |
-
}
|
448 |
-
|
449 |
-
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
|
450 |
-
if ( empty( $restricted_blocks ) ) {
|
451 |
-
return;
|
452 |
-
}
|
453 |
-
|
454 |
-
wp_register_script( 'um_block_js', $this->js_url . 'um-admin-blocks.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-hooks' ), ultimatemember_version, true );
|
455 |
-
wp_set_script_translations( 'um_block_js', 'ultimate-member' );
|
456 |
-
|
457 |
-
$restrict_options = array();
|
458 |
-
$roles = UM()->roles()->get_roles( false );
|
459 |
-
if ( ! empty( $roles ) ) {
|
460 |
-
foreach ( $roles as $role_key => $title ) {
|
461 |
-
$restrict_options[] = array(
|
462 |
-
'label' => $title,
|
463 |
-
'value' => $role_key
|
464 |
-
);
|
465 |
-
}
|
466 |
-
}
|
467 |
-
wp_localize_script( 'um_block_js', 'um_restrict_roles', $restrict_options );
|
468 |
-
|
469 |
-
wp_enqueue_script( 'um_block_js' );
|
470 |
-
|
471 |
-
do_action( 'um_load_gutenberg_js' );
|
472 |
-
}
|
473 |
-
|
474 |
-
|
475 |
-
/**
|
476 |
-
* Load Gutenberg blocks js
|
477 |
-
*/
|
478 |
-
function load_gutenberg_shortcode_blocks() {
|
479 |
-
if ( ! function_exists( 'register_block_type' ) ) {
|
480 |
-
// Gutenberg is not active.
|
481 |
-
return;
|
482 |
-
}
|
483 |
-
|
484 |
-
//disable Gutenberg scripts to avoid the conflicts
|
485 |
-
$disable_script = apply_filters( 'um_disable_blocks_script', false );
|
486 |
-
if ( $disable_script ) {
|
487 |
-
return;
|
488 |
-
}
|
489 |
-
|
490 |
-
$enable_blocks = UM()->options()->get( 'enable_blocks' );
|
491 |
-
if ( empty( $enable_blocks ) ) {
|
492 |
-
return;
|
493 |
-
}
|
494 |
-
|
495 |
-
wp_register_script( 'um-blocks-shortcode-js', $this->js_url . 'um-admin-blocks-shortcode.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', /*'rich-text'*/ ), ultimatemember_version, true );
|
496 |
-
wp_set_script_translations( 'um-blocks-shortcode-js', 'ultimate-member' );
|
497 |
-
wp_enqueue_script( 'um-blocks-shortcode-js' );
|
498 |
-
|
499 |
-
$account_settings = array(
|
500 |
-
'password' => array(
|
501 |
-
'label' => __( 'Password', 'ultimate-member' ),
|
502 |
-
'enabled' => UM()->options()->get( 'account_tab_password' ),
|
503 |
-
),
|
504 |
-
'privacy' => array(
|
505 |
-
'label' => __( 'Privacy', 'ultimate-member' ),
|
506 |
-
'enabled' => UM()->options()->get( 'account_tab_privacy' ),
|
507 |
-
),
|
508 |
-
'notifications' => array(
|
509 |
-
'label' => __( 'Notifications', 'ultimate-member' ),
|
510 |
-
'enabled' => UM()->options()->get( 'account_tab_notifications' ),
|
511 |
-
),
|
512 |
-
'delete' => array(
|
513 |
-
'label' => __( 'Delete', 'ultimate-member' ),
|
514 |
-
'enabled' => UM()->options()->get( 'account_tab_delete' ),
|
515 |
-
),
|
516 |
-
);
|
517 |
-
wp_localize_script( 'um-blocks-shortcode-js', 'um_account_settings', $account_settings );
|
518 |
-
|
519 |
-
/**
|
520 |
-
* create gutenberg blocks
|
521 |
-
*/
|
522 |
-
register_block_type( 'um-block/um-forms', array(
|
523 |
-
'editor_script' => 'um-blocks-shortcode-js',
|
524 |
-
) );
|
525 |
-
|
526 |
-
register_block_type( 'um-block/um-member-directories', array(
|
527 |
-
'editor_script' => 'um-blocks-shortcode-js',
|
528 |
-
) );
|
529 |
-
|
530 |
-
register_block_type( 'um-block/um-password-reset', array(
|
531 |
-
'editor_script' => 'um-blocks-shortcode-js',
|
532 |
-
) );
|
533 |
-
|
534 |
-
register_block_type( 'um-block/um-account', array(
|
535 |
-
'editor_script' => 'um-blocks-shortcode-js',
|
536 |
-
) );
|
537 |
-
}
|
538 |
-
|
539 |
-
|
540 |
-
/**
|
541 |
-
* Add Gutenberg category for UM shortcodes
|
542 |
-
*
|
543 |
-
* @param array $categories
|
544 |
-
* @param \WP_Block_Editor_Context $context
|
545 |
-
*
|
546 |
-
* @return array
|
547 |
-
*/
|
548 |
-
function blocks_category( $categories, $context ) {
|
549 |
-
$enable_blocks = UM()->options()->get( 'enable_blocks' );
|
550 |
-
if ( empty( $enable_blocks ) ) {
|
551 |
-
return $categories;
|
552 |
-
}
|
553 |
-
|
554 |
-
return array_merge(
|
555 |
-
$categories,
|
556 |
-
array(
|
557 |
-
array(
|
558 |
-
'slug' => 'um-blocks',
|
559 |
-
'title' => __( 'Ultimate Member Blocks', 'ultimate-member' ),
|
560 |
-
),
|
561 |
-
)
|
562 |
-
);
|
563 |
-
}
|
564 |
-
|
565 |
-
/**
|
566 |
-
* Load localize scripts
|
567 |
-
*/
|
568 |
-
function load_localize_scripts() {
|
569 |
-
|
570 |
-
/**
|
571 |
-
* UM hook
|
572 |
-
*
|
573 |
-
* @type filter
|
574 |
-
* @title um_admin_enqueue_localize_data
|
575 |
-
* @description Extend localize data at wp-admin side
|
576 |
-
* @input_vars
|
577 |
-
* [{"var":"$localize_data","type":"array","desc":"Localize Data"}]
|
578 |
-
* @change_log
|
579 |
-
* ["Since: 2.0"]
|
580 |
-
* @usage add_filter( 'um_admin_enqueue_localize_data', 'function_name', 10, 1 );
|
581 |
-
* @example
|
582 |
-
* <?php
|
583 |
-
* add_filter( 'um_admin_enqueue_localize_data', 'my_admin_enqueue_localize_data', 10, 1 );
|
584 |
-
* function my_admin_enqueue_localize_data( $localize_data ) {
|
585 |
-
* // your code here
|
586 |
-
* return $localize_data;
|
587 |
-
* }
|
588 |
-
* ?>
|
589 |
-
*/
|
590 |
-
$localize_data = apply_filters( 'um_admin_enqueue_localize_data', array(
|
591 |
-
'nonce' => wp_create_nonce( "um-admin-nonce" )
|
592 |
-
)
|
593 |
-
);
|
594 |
-
|
595 |
-
wp_localize_script( 'um_admin_global', 'um_admin_scripts', $localize_data );
|
596 |
-
}
|
597 |
-
|
598 |
-
|
599 |
-
/**
|
600 |
-
* Enqueue scripts and styles
|
601 |
-
*/
|
602 |
-
function admin_enqueue_scripts() {
|
603 |
-
if ( UM()->admin()->is_um_screen() ) {
|
604 |
-
|
605 |
-
/*if ( get_post_type() != 'shop_order' ) {
|
606 |
-
UM()->enqueue()->wp_enqueue_scripts();
|
607 |
-
}*/
|
608 |
-
|
609 |
-
$modal_deps = array( 'um-admin-scripts' );
|
610 |
-
if ( $this->um_cpt_form_screen ) {
|
611 |
-
$this->enqueue_frontend_preview_assets();
|
612 |
-
$modal_deps[] = 'um-responsive';
|
613 |
-
}
|
614 |
-
|
615 |
-
$this->load_functions();
|
616 |
-
$this->load_global_scripts();
|
617 |
-
$this->load_form();
|
618 |
-
$this->load_forms();
|
619 |
-
$this->load_custom_scripts();
|
620 |
-
$this->load_modal();
|
621 |
-
$this->load_dashboard();
|
622 |
-
$this->load_settings();
|
623 |
-
$this->load_field();
|
624 |
-
$this->load_builder();
|
625 |
-
$this->load_css();
|
626 |
-
$this->load_core_wp();
|
627 |
-
$this->load_ajax_js();
|
628 |
-
$this->load_fonticons();
|
629 |
-
$this->load_localize_scripts();
|
630 |
-
|
631 |
-
|
632 |
-
//scripts for frontend preview
|
633 |
-
UM()->enqueue()->load_imagecrop();
|
634 |
-
UM()->enqueue()->load_css();
|
635 |
-
UM()->enqueue()->load_tipsy();
|
636 |
-
UM()->enqueue()->load_modal();
|
637 |
-
UM()->enqueue()->load_responsive();
|
638 |
-
|
639 |
-
wp_register_script( 'um_raty', um_url . 'assets/js/um-raty' . UM()->enqueue()->suffix . '.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
|
640 |
-
wp_register_style( 'um_raty', um_url . 'assets/css/um-raty.css', array(), ultimatemember_version );
|
641 |
-
|
642 |
-
wp_register_style( 'um_default_css', um_url . 'assets/css/um-old-default.css', '', ultimatemember_version, 'all' );
|
643 |
-
wp_enqueue_style( 'um_default_css' );
|
644 |
-
|
645 |
-
if ( is_rtl() ) {
|
646 |
-
wp_register_style( 'um_admin_rtl', $this->css_url . 'um-admin-rtl.css', array(), ultimatemember_version );
|
647 |
-
wp_enqueue_style( 'um_admin_rtl' );
|
648 |
-
}
|
649 |
-
|
650 |
-
} else {
|
651 |
-
|
652 |
-
$this->load_global_scripts();
|
653 |
-
$this->load_localize_scripts();
|
654 |
-
|
655 |
-
}
|
656 |
-
|
657 |
-
global $wp_version, $current_screen;
|
658 |
-
|
659 |
-
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
660 |
-
if ( $current_screen->is_block_editor() ) {
|
661 |
-
$this->load_gutenberg_js();
|
662 |
-
$this->load_gutenberg_shortcode_blocks();
|
663 |
-
}
|
664 |
-
}
|
665 |
-
}
|
666 |
-
|
667 |
-
|
668 |
-
/**
|
669 |
-
* Print editor scripts if they are not printed by default
|
670 |
-
*/
|
671 |
-
function admin_footer_scripts() {
|
672 |
-
/**
|
673 |
-
* @var $class \_WP_Editors
|
674 |
-
*/
|
675 |
-
$class = '\_WP_Editors';
|
676 |
-
|
677 |
-
if ( did_action( 'print_default_editor_scripts' ) ) {
|
678 |
-
return;
|
679 |
-
}
|
680 |
-
if ( did_action( 'wp_tiny_mce_init' ) ) {
|
681 |
-
return;
|
682 |
-
}
|
683 |
-
if ( has_action( 'admin_print_footer_scripts', array( $class, 'editor_js' ) ) ) {
|
684 |
-
return;
|
685 |
-
}
|
686 |
-
|
687 |
-
if ( ! class_exists( $class, false ) ) {
|
688 |
-
require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
|
689 |
-
}
|
690 |
-
|
691 |
-
$class::force_uncompressed_tinymce();
|
692 |
-
$class::enqueue_scripts();
|
693 |
-
$class::editor_js();
|
694 |
-
}
|
695 |
-
|
696 |
-
}
|
697 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Enqueue
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Enqueue {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
var $js_url;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
var $css_url;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
var $front_js_baseurl;
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
var $front_css_baseurl;
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
var $suffix;
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var bool
|
50 |
+
*/
|
51 |
+
var $um_cpt_form_screen;
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @var bool
|
56 |
+
*/
|
57 |
+
var $post_page;
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Admin_Enqueue constructor.
|
62 |
+
*/
|
63 |
+
function __construct() {
|
64 |
+
$this->js_url = um_url . 'includes/admin/assets/js/';
|
65 |
+
$this->css_url = um_url . 'includes/admin/assets/css/';
|
66 |
+
|
67 |
+
$this->front_js_baseurl = um_url . 'assets/js/';
|
68 |
+
$this->front_css_baseurl = um_url . 'assets/css/';
|
69 |
+
|
70 |
+
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
|
71 |
+
|
72 |
+
$this->um_cpt_form_screen = false;
|
73 |
+
|
74 |
+
add_action( 'admin_head', array( &$this, 'admin_head' ), 9 );
|
75 |
+
|
76 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
77 |
+
|
78 |
+
add_filter( 'enter_title_here', array( &$this, 'enter_title_here' ) );
|
79 |
+
|
80 |
+
add_action( 'load-user-new.php', array( &$this, 'enqueue_role_wrapper' ) );
|
81 |
+
add_action( 'load-user-edit.php', array( &$this, 'enqueue_role_wrapper' ) );
|
82 |
+
|
83 |
+
add_action( 'load-post-new.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
84 |
+
add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
85 |
+
|
86 |
+
global $wp_version;
|
87 |
+
if ( version_compare( $wp_version, '5.8', '>=' ) ) {
|
88 |
+
add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 );
|
89 |
+
} else {
|
90 |
+
add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
function enqueue_role_wrapper() {
|
96 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'load_role_wrapper' ) );
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
*
|
102 |
+
*/
|
103 |
+
function enqueue_cpt_scripts() {
|
104 |
+
if ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
|
105 |
+
( isset( $_GET['post'] ) && 'um_form' === get_post_type( absint( $_GET['post'] ) ) ) ) {
|
106 |
+
$this->um_cpt_form_screen = true;
|
107 |
+
add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 );
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
*
|
114 |
+
*/
|
115 |
+
function enqueue_frontend_preview_assets() {
|
116 |
+
//scripts for FRONTEND PREVIEW
|
117 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
118 |
+
wp_dequeue_style( 'select2' );
|
119 |
+
wp_deregister_style( 'select2' );
|
120 |
+
|
121 |
+
wp_dequeue_script( 'select2' );
|
122 |
+
wp_deregister_script( 'select2' );
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
|
127 |
+
wp_register_script( 'um_jquery_form', $this->front_js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
128 |
+
wp_register_script( 'um_fileupload', $this->front_js_baseurl . 'um-fileupload.js', array( 'jquery' ), ultimatemember_version, true );
|
129 |
+
wp_register_script( 'um_crop', $this->front_js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
130 |
+
wp_register_script( 'um_tipsy', $this->front_js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
131 |
+
wp_register_script( 'um_functions', $this->front_js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'um_tipsy', 'um_scrollbar' ), ultimatemember_version, true );
|
132 |
+
|
133 |
+
wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
|
134 |
+
wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
135 |
+
wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
136 |
+
//wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
137 |
+
// load a localized version for date/time
|
138 |
+
$locale = get_locale();
|
139 |
+
if ( $locale ) {
|
140 |
+
if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
|
141 |
+
wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
142 |
+
} elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
|
143 |
+
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
wp_register_script( 'um_scripts', $this->front_js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'um_functions', 'um_crop', 'um_raty', 'select2', 'um_jquery_form', 'um_fileupload', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
|
148 |
+
wp_register_script( 'um_responsive', $this->front_js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'um_scripts' ), ultimatemember_version, true );
|
149 |
+
wp_register_script( 'um_modal', $this->front_js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'um_responsive' ), ultimatemember_version, true );
|
150 |
+
|
151 |
+
|
152 |
+
wp_register_style( 'select2', $this->front_css_baseurl . 'select2/select2' . $this->suffix . '.css', array(), '4.0.13' );
|
153 |
+
wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
154 |
+
wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
155 |
+
wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
156 |
+
|
157 |
+
wp_register_style( 'um_scrollbar', $this->front_css_baseurl . 'simplebar.css', array(), ultimatemember_version );
|
158 |
+
wp_register_style( 'um_crop', $this->front_css_baseurl . 'um-crop.css', array(), ultimatemember_version );
|
159 |
+
wp_register_style( 'um_tipsy', $this->front_css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
|
160 |
+
wp_register_style( 'um_responsive', $this->front_css_baseurl . 'um-responsive.css', array(), ultimatemember_version );
|
161 |
+
wp_register_style( 'um_modal', $this->front_css_baseurl . 'um-modal.css', array(), ultimatemember_version );
|
162 |
+
wp_register_style( 'um_styles', $this->front_css_baseurl . 'um-styles.css', array(), ultimatemember_version );
|
163 |
+
wp_register_style( 'um_members', $this->front_css_baseurl . 'um-members.css', array(), ultimatemember_version );
|
164 |
+
wp_register_style( 'um_profile', $this->front_css_baseurl . 'um-profile.css', array(), ultimatemember_version );
|
165 |
+
wp_register_style( 'um_account', $this->front_css_baseurl . 'um-account.css', array(), ultimatemember_version );
|
166 |
+
wp_register_style( 'um_misc', $this->front_css_baseurl . 'um-misc.css', array(), ultimatemember_version );
|
167 |
+
wp_register_style( 'um_default_css', $this->front_css_baseurl . 'um-old-default.css', array( 'um_crop', 'um_tipsy', 'um_raty', 'um_responsive', 'um_modal', 'um_styles', 'um_members', 'um_profile', 'um_account', 'um_misc', 'um_datetime_date', 'um_datetime_time', 'um_scrollbar', 'select2' ), ultimatemember_version );
|
168 |
+
|
169 |
+
wp_enqueue_script( 'um_modal' );
|
170 |
+
wp_enqueue_style( 'um_default_css' );
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Load js for Add/Edit User form
|
176 |
+
*/
|
177 |
+
function load_role_wrapper() {
|
178 |
+
wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', array( 'jquery' ), ultimatemember_version, true );
|
179 |
+
$localize_roles_data = get_option( 'um_roles', array() );
|
180 |
+
wp_localize_script( 'um_admin_role_wrapper', 'um_roles', (array) $localize_roles_data );
|
181 |
+
wp_enqueue_script( 'um_admin_role_wrapper' );
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Enter title placeholder
|
187 |
+
*
|
188 |
+
* @param $title
|
189 |
+
*
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
+
function enter_title_here( $title ) {
|
193 |
+
$screen = get_current_screen();
|
194 |
+
if ( 'um_directory' == $screen->post_type ) {
|
195 |
+
$title = __( 'e.g. Member Directory', 'ultimate-member' );
|
196 |
+
} elseif ( 'um_form' == $screen->post_type ) {
|
197 |
+
$title = __( 'e.g. New Registration Form', 'ultimate-member' );
|
198 |
+
}
|
199 |
+
return $title;
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Runs on admin head
|
205 |
+
*/
|
206 |
+
function admin_head() {
|
207 |
+
if ( UM()->admin()->is_plugin_post_type() ) { ?>
|
208 |
+
<style type="text/css">
|
209 |
+
.um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#slugdiv,
|
210 |
+
.um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#minor-publishing,
|
211 |
+
.um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#screen-meta-links
|
212 |
+
{display:none}
|
213 |
+
</style>
|
214 |
+
<?php }
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Load Form
|
220 |
+
*/
|
221 |
+
function load_form() {
|
222 |
+
wp_register_style( 'um_admin_form', $this->css_url . 'um-admin-form.css', array(), ultimatemember_version );
|
223 |
+
wp_enqueue_style( 'um_admin_form' );
|
224 |
+
|
225 |
+
wp_register_script( 'um_admin_form', $this->js_url . 'um-admin-form.js', array( 'jquery' ), ultimatemember_version, true );
|
226 |
+
wp_enqueue_script( 'um_admin_form' );
|
227 |
+
}
|
228 |
+
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Load Forms
|
232 |
+
*/
|
233 |
+
function load_forms() {
|
234 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
235 |
+
wp_dequeue_style( 'select2' );
|
236 |
+
wp_deregister_style( 'select2' );
|
237 |
+
|
238 |
+
wp_dequeue_script( 'select2' );
|
239 |
+
wp_deregister_script( 'select2' );
|
240 |
+
}
|
241 |
+
|
242 |
+
wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
|
243 |
+
wp_register_style( 'select2', $this->front_css_baseurl . 'select2/select2' . $this->suffix . '.css', array(), '4.0.13' );
|
244 |
+
|
245 |
+
wp_register_style( 'um_ui', $this->front_css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
|
246 |
+
wp_register_style( 'um_admin_forms', $this->css_url . 'um-admin-forms.css', array( 'wp-color-picker', 'um_ui', 'select2' ), ultimatemember_version );
|
247 |
+
wp_enqueue_style( 'um_admin_forms' );
|
248 |
+
|
249 |
+
wp_register_script( 'um_admin_forms', $this->js_url . 'um-admin-forms.js', array( 'jquery', 'wp-i18n', 'select2' ), ultimatemember_version, true );
|
250 |
+
|
251 |
+
wp_localize_script( 'um_admin_forms', 'um_forms_data', array(
|
252 |
+
'successfully_redirect' => add_query_arg( array( 'page' => 'um_options', 'tab' => 'misc', 'msg' => 'updated' ), admin_url( 'admin.php' ) ),
|
253 |
+
) );
|
254 |
+
|
255 |
+
wp_enqueue_script( 'um_admin_forms' );
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Load dashboard
|
261 |
+
*/
|
262 |
+
function load_dashboard() {
|
263 |
+
wp_register_style( 'um_admin_dashboard', $this->css_url . 'um-admin-dashboard.css', array(), ultimatemember_version );
|
264 |
+
wp_enqueue_style( 'um_admin_dashboard' );
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Load settings
|
270 |
+
*/
|
271 |
+
function load_settings() {
|
272 |
+
wp_register_style( 'um_admin_settings', $this->css_url . 'um-admin-settings.css', array(), ultimatemember_version );
|
273 |
+
wp_enqueue_style( 'um_admin_settings' );
|
274 |
+
|
275 |
+
wp_register_script( 'um_admin_settings', $this->js_url . 'um-admin-settings.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
|
276 |
+
wp_enqueue_script( 'um_admin_settings' );
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Load modal
|
282 |
+
*/
|
283 |
+
function load_modal() {
|
284 |
+
wp_register_style( 'um_admin_modal', $this->css_url . 'um-admin-modal.css', array( 'wp-color-picker' ), ultimatemember_version );
|
285 |
+
wp_enqueue_style( 'um_admin_modal' );
|
286 |
+
|
287 |
+
wp_register_script( 'um_admin_modal', $this->js_url . 'um-admin-modal.js', array( 'jquery', 'editor', 'wp-util', 'wp-color-picker', 'wp-tinymce', 'wp-i18n' ), ultimatemember_version, true );
|
288 |
+
wp_enqueue_script( 'um_admin_modal' );
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Field Processing
|
294 |
+
*/
|
295 |
+
function load_field() {
|
296 |
+
wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util', 'wp-i18n'), ultimatemember_version, true );
|
297 |
+
wp_enqueue_script( 'um_admin_field' );
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Load Builder
|
303 |
+
*/
|
304 |
+
function load_builder() {
|
305 |
+
wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', array('jquery', 'wp-util'), ultimatemember_version, true );
|
306 |
+
wp_enqueue_script( 'um_admin_builder' );
|
307 |
+
|
308 |
+
//hide footer text on add/edit UM Forms
|
309 |
+
//layouts crashed because we load and hide metaboxes
|
310 |
+
//and WP calculate page height
|
311 |
+
$hide_footer = false;
|
312 |
+
global $pagenow, $post;
|
313 |
+
if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) &&
|
314 |
+
( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
|
315 |
+
( isset( $post->post_type ) && 'um_form' === $post->post_type ) ) ) {
|
316 |
+
$hide_footer = true;
|
317 |
+
}
|
318 |
+
|
319 |
+
$localize_data = array(
|
320 |
+
'hide_footer' => $hide_footer,
|
321 |
+
);
|
322 |
+
wp_localize_script( 'um_admin_builder', 'um_admin_builder_data', $localize_data );
|
323 |
+
|
324 |
+
wp_register_script( 'um_admin_dragdrop', $this->js_url . 'um-admin-dragdrop.js', array('jquery', 'wp-util'), ultimatemember_version, true );
|
325 |
+
wp_enqueue_script( 'um_admin_dragdrop' );
|
326 |
+
|
327 |
+
wp_register_style( 'um_admin_builder', $this->css_url . 'um-admin-builder.css', array(), ultimatemember_version );
|
328 |
+
wp_enqueue_style( 'um_admin_builder' );
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Load core WP styles/scripts
|
334 |
+
*/
|
335 |
+
function load_core_wp() {
|
336 |
+
wp_enqueue_script( 'jquery-ui-draggable' );
|
337 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
338 |
+
|
339 |
+
wp_enqueue_script( 'jquery-ui-tooltip' );
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Load Admin Styles
|
345 |
+
*/
|
346 |
+
function load_css() {
|
347 |
+
wp_register_style( 'um_admin_menu', $this->css_url . 'um-admin-menu.css', array(), ultimatemember_version );
|
348 |
+
wp_enqueue_style( 'um_admin_menu' );
|
349 |
+
|
350 |
+
wp_register_style( 'um_admin_columns', $this->css_url . 'um-admin-columns.css', array(), ultimatemember_version );
|
351 |
+
wp_enqueue_style( 'um_admin_columns' );
|
352 |
+
|
353 |
+
wp_register_style( 'um_admin_misc', $this->css_url . 'um-admin-misc.css', array(), ultimatemember_version );
|
354 |
+
wp_enqueue_style( 'um_admin_misc' );
|
355 |
+
}
|
356 |
+
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Load functions js
|
360 |
+
*/
|
361 |
+
function load_functions() {
|
362 |
+
wp_register_script( 'um_scrollbar', um_url . 'assets/js/simplebar.js', array( 'jquery' ), ultimatemember_version, true );
|
363 |
+
wp_register_script( 'um_functions', um_url . 'assets/js/um-functions.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
|
364 |
+
wp_enqueue_script( 'um_functions' );
|
365 |
+
}
|
366 |
+
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Load Fonticons
|
370 |
+
*/
|
371 |
+
function load_fonticons() {
|
372 |
+
wp_register_style( 'um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css', array(), ultimatemember_version );
|
373 |
+
wp_enqueue_style( 'um_fonticons_ii' );
|
374 |
+
|
375 |
+
wp_register_style( 'um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css', array(), ultimatemember_version );
|
376 |
+
wp_enqueue_style( 'um_fonticons_fa' );
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Load global css
|
382 |
+
*/
|
383 |
+
function load_global_scripts() {
|
384 |
+
wp_register_script( 'um_admin_global', $this->js_url . 'um-admin-global.js', array('jquery'), ultimatemember_version, true );
|
385 |
+
wp_enqueue_script( 'um_admin_global' );
|
386 |
+
|
387 |
+
wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css', array(), ultimatemember_version );
|
388 |
+
wp_enqueue_style( 'um_admin_global' );
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Load jQuery custom code
|
394 |
+
*/
|
395 |
+
function load_custom_scripts() {
|
396 |
+
wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
|
397 |
+
wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
398 |
+
wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
399 |
+
//wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
400 |
+
// load a localized version for date/time
|
401 |
+
$locale = get_locale();
|
402 |
+
if ( $locale ) {
|
403 |
+
if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
|
404 |
+
wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
405 |
+
} elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
|
406 |
+
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
410 |
+
wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
411 |
+
wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
412 |
+
wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
413 |
+
|
414 |
+
wp_enqueue_style( 'um_datetime_date', 'um_datetime_time' );
|
415 |
+
|
416 |
+
wp_register_script( 'um_admin_scripts', $this->js_url . 'um-admin-scripts.js', array('jquery','wp-util', 'wp-color-picker', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
|
417 |
+
wp_enqueue_script( 'um_admin_scripts' );
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Load jQuery custom code
|
423 |
+
*/
|
424 |
+
function load_nav_manus_scripts() {
|
425 |
+
wp_register_script( 'um_admin_nav_manus', $this->js_url . 'um-admin-nav-menu.js', array('jquery','wp-util'), ultimatemember_version, true );
|
426 |
+
wp_enqueue_script( 'um_admin_nav_manus' );
|
427 |
+
}
|
428 |
+
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Load AJAX
|
432 |
+
*/
|
433 |
+
function load_ajax_js() {
|
434 |
+
wp_register_script( 'um_admin_ajax', $this->js_url . 'um-admin-ajax.js', array('jquery','wp-util'), ultimatemember_version, true );
|
435 |
+
wp_enqueue_script( 'um_admin_ajax' );
|
436 |
+
}
|
437 |
+
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Load Gutenberg scripts
|
441 |
+
*/
|
442 |
+
function load_gutenberg_js() {
|
443 |
+
//disable Gutenberg scripts to avoid the conflicts
|
444 |
+
$disable_script = apply_filters( 'um_disable_blocks_script', false );
|
445 |
+
if ( $disable_script ) {
|
446 |
+
return;
|
447 |
+
}
|
448 |
+
|
449 |
+
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
|
450 |
+
if ( empty( $restricted_blocks ) ) {
|
451 |
+
return;
|
452 |
+
}
|
453 |
+
|
454 |
+
wp_register_script( 'um_block_js', $this->js_url . 'um-admin-blocks.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-hooks' ), ultimatemember_version, true );
|
455 |
+
wp_set_script_translations( 'um_block_js', 'ultimate-member' );
|
456 |
+
|
457 |
+
$restrict_options = array();
|
458 |
+
$roles = UM()->roles()->get_roles( false );
|
459 |
+
if ( ! empty( $roles ) ) {
|
460 |
+
foreach ( $roles as $role_key => $title ) {
|
461 |
+
$restrict_options[] = array(
|
462 |
+
'label' => $title,
|
463 |
+
'value' => $role_key
|
464 |
+
);
|
465 |
+
}
|
466 |
+
}
|
467 |
+
wp_localize_script( 'um_block_js', 'um_restrict_roles', $restrict_options );
|
468 |
+
|
469 |
+
wp_enqueue_script( 'um_block_js' );
|
470 |
+
|
471 |
+
do_action( 'um_load_gutenberg_js' );
|
472 |
+
}
|
473 |
+
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Load Gutenberg blocks js
|
477 |
+
*/
|
478 |
+
function load_gutenberg_shortcode_blocks() {
|
479 |
+
if ( ! function_exists( 'register_block_type' ) ) {
|
480 |
+
// Gutenberg is not active.
|
481 |
+
return;
|
482 |
+
}
|
483 |
+
|
484 |
+
//disable Gutenberg scripts to avoid the conflicts
|
485 |
+
$disable_script = apply_filters( 'um_disable_blocks_script', false );
|
486 |
+
if ( $disable_script ) {
|
487 |
+
return;
|
488 |
+
}
|
489 |
+
|
490 |
+
$enable_blocks = UM()->options()->get( 'enable_blocks' );
|
491 |
+
if ( empty( $enable_blocks ) ) {
|
492 |
+
return;
|
493 |
+
}
|
494 |
+
|
495 |
+
wp_register_script( 'um-blocks-shortcode-js', $this->js_url . 'um-admin-blocks-shortcode.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', /*'rich-text'*/ ), ultimatemember_version, true );
|
496 |
+
wp_set_script_translations( 'um-blocks-shortcode-js', 'ultimate-member' );
|
497 |
+
wp_enqueue_script( 'um-blocks-shortcode-js' );
|
498 |
+
|
499 |
+
$account_settings = array(
|
500 |
+
'password' => array(
|
501 |
+
'label' => __( 'Password', 'ultimate-member' ),
|
502 |
+
'enabled' => UM()->options()->get( 'account_tab_password' ),
|
503 |
+
),
|
504 |
+
'privacy' => array(
|
505 |
+
'label' => __( 'Privacy', 'ultimate-member' ),
|
506 |
+
'enabled' => UM()->options()->get( 'account_tab_privacy' ),
|
507 |
+
),
|
508 |
+
'notifications' => array(
|
509 |
+
'label' => __( 'Notifications', 'ultimate-member' ),
|
510 |
+
'enabled' => UM()->options()->get( 'account_tab_notifications' ),
|
511 |
+
),
|
512 |
+
'delete' => array(
|
513 |
+
'label' => __( 'Delete', 'ultimate-member' ),
|
514 |
+
'enabled' => UM()->options()->get( 'account_tab_delete' ),
|
515 |
+
),
|
516 |
+
);
|
517 |
+
wp_localize_script( 'um-blocks-shortcode-js', 'um_account_settings', $account_settings );
|
518 |
+
|
519 |
+
/**
|
520 |
+
* create gutenberg blocks
|
521 |
+
*/
|
522 |
+
register_block_type( 'um-block/um-forms', array(
|
523 |
+
'editor_script' => 'um-blocks-shortcode-js',
|
524 |
+
) );
|
525 |
+
|
526 |
+
register_block_type( 'um-block/um-member-directories', array(
|
527 |
+
'editor_script' => 'um-blocks-shortcode-js',
|
528 |
+
) );
|
529 |
+
|
530 |
+
register_block_type( 'um-block/um-password-reset', array(
|
531 |
+
'editor_script' => 'um-blocks-shortcode-js',
|
532 |
+
) );
|
533 |
+
|
534 |
+
register_block_type( 'um-block/um-account', array(
|
535 |
+
'editor_script' => 'um-blocks-shortcode-js',
|
536 |
+
) );
|
537 |
+
}
|
538 |
+
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Add Gutenberg category for UM shortcodes
|
542 |
+
*
|
543 |
+
* @param array $categories
|
544 |
+
* @param \WP_Block_Editor_Context $context
|
545 |
+
*
|
546 |
+
* @return array
|
547 |
+
*/
|
548 |
+
function blocks_category( $categories, $context ) {
|
549 |
+
$enable_blocks = UM()->options()->get( 'enable_blocks' );
|
550 |
+
if ( empty( $enable_blocks ) ) {
|
551 |
+
return $categories;
|
552 |
+
}
|
553 |
+
|
554 |
+
return array_merge(
|
555 |
+
$categories,
|
556 |
+
array(
|
557 |
+
array(
|
558 |
+
'slug' => 'um-blocks',
|
559 |
+
'title' => __( 'Ultimate Member Blocks', 'ultimate-member' ),
|
560 |
+
),
|
561 |
+
)
|
562 |
+
);
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Load localize scripts
|
567 |
+
*/
|
568 |
+
function load_localize_scripts() {
|
569 |
+
|
570 |
+
/**
|
571 |
+
* UM hook
|
572 |
+
*
|
573 |
+
* @type filter
|
574 |
+
* @title um_admin_enqueue_localize_data
|
575 |
+
* @description Extend localize data at wp-admin side
|
576 |
+
* @input_vars
|
577 |
+
* [{"var":"$localize_data","type":"array","desc":"Localize Data"}]
|
578 |
+
* @change_log
|
579 |
+
* ["Since: 2.0"]
|
580 |
+
* @usage add_filter( 'um_admin_enqueue_localize_data', 'function_name', 10, 1 );
|
581 |
+
* @example
|
582 |
+
* <?php
|
583 |
+
* add_filter( 'um_admin_enqueue_localize_data', 'my_admin_enqueue_localize_data', 10, 1 );
|
584 |
+
* function my_admin_enqueue_localize_data( $localize_data ) {
|
585 |
+
* // your code here
|
586 |
+
* return $localize_data;
|
587 |
+
* }
|
588 |
+
* ?>
|
589 |
+
*/
|
590 |
+
$localize_data = apply_filters( 'um_admin_enqueue_localize_data', array(
|
591 |
+
'nonce' => wp_create_nonce( "um-admin-nonce" )
|
592 |
+
)
|
593 |
+
);
|
594 |
+
|
595 |
+
wp_localize_script( 'um_admin_global', 'um_admin_scripts', $localize_data );
|
596 |
+
}
|
597 |
+
|
598 |
+
|
599 |
+
/**
|
600 |
+
* Enqueue scripts and styles
|
601 |
+
*/
|
602 |
+
function admin_enqueue_scripts() {
|
603 |
+
if ( UM()->admin()->is_um_screen() ) {
|
604 |
+
|
605 |
+
/*if ( get_post_type() != 'shop_order' ) {
|
606 |
+
UM()->enqueue()->wp_enqueue_scripts();
|
607 |
+
}*/
|
608 |
+
|
609 |
+
$modal_deps = array( 'um-admin-scripts' );
|
610 |
+
if ( $this->um_cpt_form_screen ) {
|
611 |
+
$this->enqueue_frontend_preview_assets();
|
612 |
+
$modal_deps[] = 'um-responsive';
|
613 |
+
}
|
614 |
+
|
615 |
+
$this->load_functions();
|
616 |
+
$this->load_global_scripts();
|
617 |
+
$this->load_form();
|
618 |
+
$this->load_forms();
|
619 |
+
$this->load_custom_scripts();
|
620 |
+
$this->load_modal();
|
621 |
+
$this->load_dashboard();
|
622 |
+
$this->load_settings();
|
623 |
+
$this->load_field();
|
624 |
+
$this->load_builder();
|
625 |
+
$this->load_css();
|
626 |
+
$this->load_core_wp();
|
627 |
+
$this->load_ajax_js();
|
628 |
+
$this->load_fonticons();
|
629 |
+
$this->load_localize_scripts();
|
630 |
+
|
631 |
+
|
632 |
+
//scripts for frontend preview
|
633 |
+
UM()->enqueue()->load_imagecrop();
|
634 |
+
UM()->enqueue()->load_css();
|
635 |
+
UM()->enqueue()->load_tipsy();
|
636 |
+
UM()->enqueue()->load_modal();
|
637 |
+
UM()->enqueue()->load_responsive();
|
638 |
+
|
639 |
+
wp_register_script( 'um_raty', um_url . 'assets/js/um-raty' . UM()->enqueue()->suffix . '.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
|
640 |
+
wp_register_style( 'um_raty', um_url . 'assets/css/um-raty.css', array(), ultimatemember_version );
|
641 |
+
|
642 |
+
wp_register_style( 'um_default_css', um_url . 'assets/css/um-old-default.css', '', ultimatemember_version, 'all' );
|
643 |
+
wp_enqueue_style( 'um_default_css' );
|
644 |
+
|
645 |
+
if ( is_rtl() ) {
|
646 |
+
wp_register_style( 'um_admin_rtl', $this->css_url . 'um-admin-rtl.css', array(), ultimatemember_version );
|
647 |
+
wp_enqueue_style( 'um_admin_rtl' );
|
648 |
+
}
|
649 |
+
|
650 |
+
} else {
|
651 |
+
|
652 |
+
$this->load_global_scripts();
|
653 |
+
$this->load_localize_scripts();
|
654 |
+
|
655 |
+
}
|
656 |
+
|
657 |
+
global $wp_version, $current_screen;
|
658 |
+
|
659 |
+
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
660 |
+
if ( $current_screen->is_block_editor() ) {
|
661 |
+
$this->load_gutenberg_js();
|
662 |
+
$this->load_gutenberg_shortcode_blocks();
|
663 |
+
}
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Print editor scripts if they are not printed by default
|
670 |
+
*/
|
671 |
+
function admin_footer_scripts() {
|
672 |
+
/**
|
673 |
+
* @var $class \_WP_Editors
|
674 |
+
*/
|
675 |
+
$class = '\_WP_Editors';
|
676 |
+
|
677 |
+
if ( did_action( 'print_default_editor_scripts' ) ) {
|
678 |
+
return;
|
679 |
+
}
|
680 |
+
if ( did_action( 'wp_tiny_mce_init' ) ) {
|
681 |
+
return;
|
682 |
+
}
|
683 |
+
if ( has_action( 'admin_print_footer_scripts', array( $class, 'editor_js' ) ) ) {
|
684 |
+
return;
|
685 |
+
}
|
686 |
+
|
687 |
+
if ( ! class_exists( $class, false ) ) {
|
688 |
+
require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
|
689 |
+
}
|
690 |
+
|
691 |
+
$class::force_uncompressed_tinymce();
|
692 |
+
$class::enqueue_scripts();
|
693 |
+
$class::editor_js();
|
694 |
+
}
|
695 |
+
|
696 |
+
}
|
697 |
+
}
|
includes/admin/core/class-admin-forms.php
CHANGED
@@ -1,1671 +1,1671 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Forms
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Forms {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var bool
|
20 |
-
*/
|
21 |
-
var $form_data;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Admin_Forms constructor.
|
26 |
-
* @param bool $form_data
|
27 |
-
*/
|
28 |
-
function __construct( $form_data = false ) {
|
29 |
-
if ( $form_data ) {
|
30 |
-
$this->form_data = $form_data;
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Set Form Data
|
37 |
-
*
|
38 |
-
* @param $data
|
39 |
-
*
|
40 |
-
* @return $this
|
41 |
-
*/
|
42 |
-
function set_data( $data ) {
|
43 |
-
$this->form_data = $data;
|
44 |
-
return $this;
|
45 |
-
}
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Render form
|
50 |
-
*
|
51 |
-
*
|
52 |
-
* @param bool $echo
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
function render_form( $echo = true ) {
|
56 |
-
|
57 |
-
if ( empty( $this->form_data['fields'] ) ) {
|
58 |
-
return '';
|
59 |
-
}
|
60 |
-
|
61 |
-
$class = 'form-table um-form-table ' . ( ! empty( $this->form_data['class'] ) ? $this->form_data['class'] : '' );
|
62 |
-
$class_attr = ' class="' . $class . '" ';
|
63 |
-
|
64 |
-
ob_start();
|
65 |
-
|
66 |
-
foreach ( $this->form_data['fields'] as $field_data ) {
|
67 |
-
if ( isset( $field_data['type'] ) && 'hidden' == $field_data['type'] ) {
|
68 |
-
echo $this->render_form_row( $field_data );
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
-
if ( empty( $this->form_data['without_wrapper'] ) ) { ?>
|
73 |
-
|
74 |
-
<table <?php echo $class_attr ?>>
|
75 |
-
<tbody>
|
76 |
-
|
77 |
-
<?php }
|
78 |
-
|
79 |
-
foreach ( $this->form_data['fields'] as $field_data ) {
|
80 |
-
if ( isset( $field_data['type'] ) && 'hidden' != $field_data['type'] ) {
|
81 |
-
echo $this->render_form_row( $field_data );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
if ( empty( $this->form_data['without_wrapper'] ) ) { ?>
|
86 |
-
|
87 |
-
</tbody>
|
88 |
-
</table>
|
89 |
-
|
90 |
-
<?php }
|
91 |
-
|
92 |
-
if ( $echo ) {
|
93 |
-
ob_get_flush();
|
94 |
-
return '';
|
95 |
-
} else {
|
96 |
-
return ob_get_clean();
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @param array $data
|
103 |
-
*
|
104 |
-
* @return string
|
105 |
-
*/
|
106 |
-
function render_form_row( $data ) {
|
107 |
-
|
108 |
-
if ( empty( $data['type'] ) ) {
|
109 |
-
return '';
|
110 |
-
}
|
111 |
-
|
112 |
-
if ( !empty( $data['value'] ) && $data['type'] != 'email_template' ) {
|
113 |
-
$data['value'] = wp_unslash( $data['value'] );
|
114 |
-
|
115 |
-
/*for multi_text*/
|
116 |
-
if ( ! is_array( $data['value'] ) && $data['type'] != 'wp_editor' ) {
|
117 |
-
$data['value'] = esc_attr( $data['value'] );
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
$conditional = ! empty( $data['conditional'] ) ? 'data-conditional="' . esc_attr( json_encode( $data['conditional'] ) ) . '"' : '';
|
122 |
-
$prefix_attr = ! empty( $this->form_data['prefix_id'] ) ? ' data-prefix="' . esc_attr( $this->form_data['prefix_id'] ) . '" ' : '';
|
123 |
-
|
124 |
-
$type_attr = ' data-field_type="' . esc_attr( $data['type'] ) . '" ';
|
125 |
-
|
126 |
-
$html = '';
|
127 |
-
if ( $data['type'] != 'hidden' ) {
|
128 |
-
|
129 |
-
if ( ! empty( $this->form_data['div_line'] ) ) {
|
130 |
-
|
131 |
-
if ( strpos( $this->form_data['class'], 'um-top-label' ) !== false ) {
|
132 |
-
|
133 |
-
$html .= '<div class="form-field um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>' . $this->render_field_label( $data );
|
134 |
-
|
135 |
-
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
136 |
-
|
137 |
-
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
138 |
-
|
139 |
-
} else {
|
140 |
-
|
141 |
-
$html .= $this->render_field_by_hook( $data );
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
if ( ! empty( $data['description'] ) )
|
146 |
-
$html .= '<p class="description">' . $data['description'] . '</p>';
|
147 |
-
|
148 |
-
$html .= '</div>';
|
149 |
-
|
150 |
-
} else {
|
151 |
-
|
152 |
-
if ( ! empty( $data['without_label'] ) ) {
|
153 |
-
|
154 |
-
$html .= '<div class="form-field um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>';
|
155 |
-
|
156 |
-
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
157 |
-
|
158 |
-
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
159 |
-
|
160 |
-
} else {
|
161 |
-
|
162 |
-
$html .= $this->render_field_by_hook( $data );
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
if ( ! empty( $data['description'] ) )
|
167 |
-
$html .= '<p class="description">' . $data['description'] . '</p>';
|
168 |
-
|
169 |
-
$html .= '</div>';
|
170 |
-
|
171 |
-
} else {
|
172 |
-
|
173 |
-
$html .= '<div class="form-field um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>' . $this->render_field_label( $data );
|
174 |
-
|
175 |
-
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
176 |
-
|
177 |
-
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
178 |
-
|
179 |
-
} else {
|
180 |
-
|
181 |
-
$html .= $this->render_field_by_hook( $data );
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
if ( ! empty( $data['description'] ) )
|
186 |
-
$html .= '<p class="description">' . $data['description'] . '</p>';
|
187 |
-
|
188 |
-
$html .= '</div>';
|
189 |
-
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
} else {
|
194 |
-
if ( strpos( $this->form_data['class'], 'um-top-label' ) !== false ) {
|
195 |
-
|
196 |
-
$html .= '<tr class="um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>
|
197 |
-
<td>' . $this->render_field_label( $data );
|
198 |
-
|
199 |
-
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
200 |
-
|
201 |
-
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
202 |
-
|
203 |
-
} else {
|
204 |
-
|
205 |
-
$html .= $this->render_field_by_hook( $data );
|
206 |
-
|
207 |
-
}
|
208 |
-
|
209 |
-
if ( ! empty( $data['description'] ) )
|
210 |
-
$html .= '<div class="um-admin-clear"></div><p class="description">' . $data['description'] . '</p>';
|
211 |
-
|
212 |
-
$html .= '</td></tr>';
|
213 |
-
|
214 |
-
} else {
|
215 |
-
|
216 |
-
if ( ! empty( $data['without_label'] ) ) {
|
217 |
-
|
218 |
-
$html .= '<tr class="um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>
|
219 |
-
<td colspan="2">';
|
220 |
-
|
221 |
-
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
222 |
-
|
223 |
-
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
224 |
-
|
225 |
-
} else {
|
226 |
-
|
227 |
-
$html .= $this->render_field_by_hook( $data );
|
228 |
-
|
229 |
-
}
|
230 |
-
|
231 |
-
if ( ! empty( $data['description'] ) )
|
232 |
-
$html .= '<div class="um-admin-clear"></div><p class="description">' . $data['description'] . '</p>';
|
233 |
-
|
234 |
-
$html .= '</td></tr>';
|
235 |
-
|
236 |
-
} else {
|
237 |
-
|
238 |
-
$html .= '<tr class="um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>
|
239 |
-
<th>' . $this->render_field_label( $data ) . '</th>
|
240 |
-
<td>';
|
241 |
-
|
242 |
-
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
243 |
-
|
244 |
-
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
245 |
-
|
246 |
-
} else {
|
247 |
-
|
248 |
-
$html .= $this->render_field_by_hook( $data );
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
if ( ! empty( $data['description'] ) )
|
253 |
-
$html .= '<div class="um-admin-clear"></div><p class="description">' . $data['description'] . '</p>';
|
254 |
-
|
255 |
-
$html .= '</td></tr>';
|
256 |
-
|
257 |
-
}
|
258 |
-
}
|
259 |
-
}
|
260 |
-
|
261 |
-
} else {
|
262 |
-
$html .= $this->render_hidden( $data );
|
263 |
-
}
|
264 |
-
|
265 |
-
return $html;
|
266 |
-
}
|
267 |
-
|
268 |
-
|
269 |
-
/**
|
270 |
-
* @param $data
|
271 |
-
*
|
272 |
-
* @return mixed|void
|
273 |
-
*/
|
274 |
-
function render_field_by_hook( $data ) {
|
275 |
-
/**
|
276 |
-
* UM hook
|
277 |
-
*
|
278 |
-
* @type filter
|
279 |
-
* @title um_render_field_type_{$type}
|
280 |
-
* @description Render admin form field by hook
|
281 |
-
* @input_vars
|
282 |
-
* [{"var":"$html","type":"string","desc":"Field's HTML"},
|
283 |
-
* {"var":"$data","type":"array","desc":"Field's data"},
|
284 |
-
* {"var":"$form_data","type":"array","desc":"Form data"},
|
285 |
-
* {"var":"$admin_form","type":"object","desc":"Admin_Forms class object"}]
|
286 |
-
* @change_log
|
287 |
-
* ["Since: 2.0"]
|
288 |
-
* @usage add_filter( 'um_render_field_type_{$type}', 'function_name', 10, 4 );
|
289 |
-
* @example
|
290 |
-
* <?php
|
291 |
-
* add_filter( 'um_render_field_type_{$type}', 'my_render_field_type', 10, 4 );
|
292 |
-
* function my_render_field_type( $html, $data, $form_data, $admin_form ) {
|
293 |
-
* // your code here
|
294 |
-
* return $html;
|
295 |
-
* }
|
296 |
-
* ?>
|
297 |
-
*/
|
298 |
-
return apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data, $this );
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
/**
|
303 |
-
* @param $data
|
304 |
-
*
|
305 |
-
* @return bool|string
|
306 |
-
*/
|
307 |
-
function render_field_label( $data ) {
|
308 |
-
if ( empty( $data['label'] ) ) {
|
309 |
-
return false;
|
310 |
-
}
|
311 |
-
|
312 |
-
$id = ! empty( $data['id1'] ) ? $data['id1'] : $data['id'];
|
313 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $id;
|
314 |
-
$for_attr = ' for="' . esc_attr( $id ) . '" ';
|
315 |
-
|
316 |
-
$label = $data['label'];
|
317 |
-
if ( isset( $data['required'] ) && $data['required'] ) {
|
318 |
-
$label = $label . '<span class="um-req" title="' . esc_attr__( 'Required', 'ultimate-member' ) . '">*</span>';
|
319 |
-
}
|
320 |
-
|
321 |
-
$tooltip = ! empty( $data['tooltip'] ) ? UM()->tooltip( $data['tooltip'], false, false ) : '';
|
322 |
-
|
323 |
-
return "<label $for_attr>$label $tooltip</label>";
|
324 |
-
}
|
325 |
-
|
326 |
-
|
327 |
-
/**
|
328 |
-
* @param $field_data
|
329 |
-
*
|
330 |
-
* @return bool|string
|
331 |
-
*/
|
332 |
-
function render_hidden( $field_data ) {
|
333 |
-
|
334 |
-
if ( empty( $field_data['id'] ) ) {
|
335 |
-
return '';
|
336 |
-
}
|
337 |
-
|
338 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
339 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
340 |
-
|
341 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
342 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
343 |
-
|
344 |
-
$data = array(
|
345 |
-
'field_id' => $field_data['id']
|
346 |
-
);
|
347 |
-
|
348 |
-
$data_attr = '';
|
349 |
-
foreach ( $data as $key => $value ) {
|
350 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
351 |
-
}
|
352 |
-
|
353 |
-
$name = $field_data['id'];
|
354 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
355 |
-
$name_attr = ' name="' . $name . '" ';
|
356 |
-
|
357 |
-
$value = $this->get_field_value( $field_data );
|
358 |
-
$value_attr = ' value="' . $value . '" ';
|
359 |
-
|
360 |
-
$html = "<input type=\"hidden\" $id_attr $class_attr $name_attr $data_attr $value_attr />";
|
361 |
-
|
362 |
-
return $html;
|
363 |
-
}
|
364 |
-
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Render text field
|
368 |
-
*
|
369 |
-
* @param $field_data
|
370 |
-
*
|
371 |
-
* @return bool|string
|
372 |
-
*/
|
373 |
-
function render_text( $field_data ) {
|
374 |
-
|
375 |
-
if ( empty( $field_data['id'] ) ) {
|
376 |
-
return false;
|
377 |
-
}
|
378 |
-
|
379 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
380 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
381 |
-
|
382 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
383 |
-
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
384 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
385 |
-
|
386 |
-
$data = array(
|
387 |
-
'field_id' => $field_data['id']
|
388 |
-
);
|
389 |
-
|
390 |
-
if ( ! empty( $field_data['attr'] ) && is_array( $field_data['attr'] ) ){
|
391 |
-
$data = array_merge( $data, $field_data['attr'] );
|
392 |
-
}
|
393 |
-
|
394 |
-
$data_attr = '';
|
395 |
-
foreach ( $data as $key => $value ) {
|
396 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
397 |
-
}
|
398 |
-
|
399 |
-
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
400 |
-
|
401 |
-
$name = $field_data['id'];
|
402 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
403 |
-
$name_attr = ' name="' . $name . '" ';
|
404 |
-
|
405 |
-
$value = $this->get_field_value( $field_data );
|
406 |
-
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
407 |
-
|
408 |
-
$html = "<input type=\"text\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
409 |
-
|
410 |
-
return $html;
|
411 |
-
}
|
412 |
-
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Render text field
|
416 |
-
*
|
417 |
-
* @param $field_data
|
418 |
-
*
|
419 |
-
* @return bool|string
|
420 |
-
*/
|
421 |
-
function render_number( $field_data ) {
|
422 |
-
|
423 |
-
if ( empty( $field_data['id'] ) ) {
|
424 |
-
return false;
|
425 |
-
}
|
426 |
-
|
427 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
428 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
429 |
-
|
430 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
431 |
-
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
432 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
433 |
-
|
434 |
-
$data = array(
|
435 |
-
'field_id' => $field_data['id']
|
436 |
-
);
|
437 |
-
|
438 |
-
if ( ! empty( $field_data['attr'] ) && is_array( $field_data['attr'] ) ){
|
439 |
-
$data = array_merge( $data, $field_data['attr'] );
|
440 |
-
}
|
441 |
-
|
442 |
-
$data_attr = '';
|
443 |
-
foreach ( $data as $key => $value ) {
|
444 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
445 |
-
}
|
446 |
-
|
447 |
-
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
448 |
-
|
449 |
-
$name = $field_data['id'];
|
450 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
451 |
-
$name_attr = ' name="' . $name . '" ';
|
452 |
-
|
453 |
-
$value = $this->get_field_value( $field_data );
|
454 |
-
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
455 |
-
|
456 |
-
$html = "<input type=\"number\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
457 |
-
|
458 |
-
return $html;
|
459 |
-
}
|
460 |
-
|
461 |
-
|
462 |
-
/**
|
463 |
-
* @param $field_data
|
464 |
-
*
|
465 |
-
* @return bool|string
|
466 |
-
*/
|
467 |
-
function render_color( $field_data ) {
|
468 |
-
|
469 |
-
if ( empty( $field_data['id'] ) ) {
|
470 |
-
return false;
|
471 |
-
}
|
472 |
-
|
473 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
474 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
475 |
-
|
476 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
477 |
-
$class .= ! empty( $field_data['size'] ) ? ' um-' . $field_data['size'] . '-field ' : ' um-long-field ';
|
478 |
-
$class .= ' um-admin-colorpicker ';
|
479 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
480 |
-
|
481 |
-
$data = array(
|
482 |
-
'field_id' => $field_data['id']
|
483 |
-
);
|
484 |
-
|
485 |
-
$data_attr = '';
|
486 |
-
foreach ( $data as $key => $value ) {
|
487 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
488 |
-
}
|
489 |
-
|
490 |
-
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
491 |
-
|
492 |
-
$name = $field_data['id'];
|
493 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
494 |
-
$name_attr = ' name="' . $name . '" ';
|
495 |
-
|
496 |
-
$value = $this->get_field_value( $field_data );
|
497 |
-
$value_attr = ' value="' . $value . '" ';
|
498 |
-
|
499 |
-
$html = "<input type=\"text\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
500 |
-
|
501 |
-
return $html;
|
502 |
-
}
|
503 |
-
|
504 |
-
|
505 |
-
/**
|
506 |
-
* @param $field_data
|
507 |
-
*
|
508 |
-
* @return bool|string
|
509 |
-
*/
|
510 |
-
function render_icon( $field_data ) {
|
511 |
-
|
512 |
-
if ( empty( $field_data['id'] ) ) {
|
513 |
-
return false;
|
514 |
-
}
|
515 |
-
|
516 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
517 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
518 |
-
|
519 |
-
$name = $field_data['id'];
|
520 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
521 |
-
$name_attr = ' name="' . $name . '" ';
|
522 |
-
|
523 |
-
$value = $this->get_field_value( $field_data );
|
524 |
-
$value_attr = ' value="' . $value . '" ';
|
525 |
-
|
526 |
-
$html = '<span class="um_admin_fonticon_wrapper"><a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="">' . __( 'Choose Icon', 'ultimate-member' ) . '</a>
|
527 |
-
<span class="um-admin-icon-value">';
|
528 |
-
|
529 |
-
if ( ! empty( $value ) ) {
|
530 |
-
$html .= '<i class="' . $value . '"></i>';
|
531 |
-
} else {
|
532 |
-
$html .= __( 'No Icon', 'ultimate-member' );
|
533 |
-
}
|
534 |
-
|
535 |
-
$html .= '</span><input type="hidden" ' . $name_attr . ' ' . $id_attr . ' ' . $value_attr . ' />';
|
536 |
-
|
537 |
-
if ( ! empty( $value ) ) {
|
538 |
-
$html .= '<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>';
|
539 |
-
} else {
|
540 |
-
$html .= '<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>';
|
541 |
-
}
|
542 |
-
|
543 |
-
$html .= '</span></span>';
|
544 |
-
|
545 |
-
UM()->metabox()->init_icon = true;
|
546 |
-
|
547 |
-
return $html;
|
548 |
-
}
|
549 |
-
|
550 |
-
|
551 |
-
/**
|
552 |
-
* @param $field_data
|
553 |
-
*
|
554 |
-
* @return bool|string
|
555 |
-
*/
|
556 |
-
function render_users_dropdown( $field_data ) {
|
557 |
-
if ( empty( $field_data['id'] ) ) {
|
558 |
-
return false;
|
559 |
-
}
|
560 |
-
|
561 |
-
$multiple = ! empty( $field_data['multi'] ) ? 'multiple' : '';
|
562 |
-
|
563 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
564 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
565 |
-
|
566 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] . ' ' : ' ';
|
567 |
-
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
568 |
-
$class_attr = ' class="um-forms-field um-user-select-field' . esc_attr( $class ) . '" ';
|
569 |
-
|
570 |
-
$data = array(
|
571 |
-
'field_id' => $field_data['id'],
|
572 |
-
);
|
573 |
-
|
574 |
-
$data_attr = '';
|
575 |
-
foreach ( $data as $key => $value ) {
|
576 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
577 |
-
}
|
578 |
-
|
579 |
-
$name = $field_data['id'];
|
580 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
581 |
-
$hidden_name_attr = ' name="' . $name . '" ';
|
582 |
-
$name = $name . ( ! empty( $field_data['multi'] ) ? '[]' : '' );
|
583 |
-
$name_attr = ' name="' . $name . '" ';
|
584 |
-
|
585 |
-
$value = $this->get_field_value( $field_data );
|
586 |
-
|
587 |
-
$users = array();
|
588 |
-
if ( ! empty( $value ) ) {
|
589 |
-
$users = get_users(
|
590 |
-
array(
|
591 |
-
'include' => $value,
|
592 |
-
'fields' => array( 'ID', 'user_login' ),
|
593 |
-
)
|
594 |
-
);
|
595 |
-
}
|
596 |
-
|
597 |
-
$options = '';
|
598 |
-
if ( ! empty( $users ) ) {
|
599 |
-
foreach ( $users as $user ) {
|
600 |
-
$options .= '<option value="' . esc_attr( $user->ID ) . '" selected>' . esc_html( $user->user_login . ' (#' . $user->ID . ')' ) . '</option>';
|
601 |
-
}
|
602 |
-
}
|
603 |
-
|
604 |
-
$hidden = '';
|
605 |
-
if ( ! empty( $multiple ) ) {
|
606 |
-
$hidden = "<input type=\"hidden\" $hidden_name_attr value=\"\" />";
|
607 |
-
}
|
608 |
-
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr data-placeholder=\"" . esc_attr__( 'Select Users', 'ultimate-member' ) . "\" placeholder=\"" . esc_attr__( 'Select Users', 'ultimate-member' ) . "\"><option>" . esc_html__( 'Select Users', 'ultimate-member' ) . "</option>$options</select>";
|
609 |
-
|
610 |
-
return $html;
|
611 |
-
}
|
612 |
-
|
613 |
-
|
614 |
-
/**
|
615 |
-
* @param $field_data
|
616 |
-
*
|
617 |
-
* @return bool|string
|
618 |
-
*/
|
619 |
-
function render_sortable_items( $field_data ) {
|
620 |
-
if ( empty( $field_data['id'] ) ) {
|
621 |
-
return false;
|
622 |
-
}
|
623 |
-
|
624 |
-
if ( empty( $field_data['items'] ) ) {
|
625 |
-
return false;
|
626 |
-
}
|
627 |
-
|
628 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
629 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
630 |
-
|
631 |
-
$size = ! empty( $field_data['size'] ) ? ' um-' . $field_data['size'] . '-field ' : ' um-long-field';
|
632 |
-
|
633 |
-
$name = $field_data['id'];
|
634 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
635 |
-
$name_attr = ' name="' . $name . '" ';
|
636 |
-
|
637 |
-
$value = $this->get_field_value( $field_data );
|
638 |
-
$value_attr = ' value="' . $value . '" ';
|
639 |
-
|
640 |
-
$data = array(
|
641 |
-
'field_id' => $field_data['id']
|
642 |
-
);
|
643 |
-
|
644 |
-
$data_attr = '';
|
645 |
-
foreach ( $data as $key => $val ) {
|
646 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $val ) . '" ';
|
647 |
-
}
|
648 |
-
|
649 |
-
$html = '<input class="um-sortable-items-value" type="hidden" ' . $name_attr . ' ' . $id_attr . ' ' . $value_attr . ' ' . $data_attr . ' />';
|
650 |
-
$html .= '<ul class="um-sortable-items-field' . esc_attr( $size ) . '">';
|
651 |
-
|
652 |
-
if ( ! empty( $value ) ) {
|
653 |
-
$value_array = explode( ',', $value );
|
654 |
-
uksort( $field_data['items'], function( $a, $b ) use ( $value_array ) {
|
655 |
-
|
656 |
-
$arr_flip = array_flip( $value_array );
|
657 |
-
|
658 |
-
if ( ! isset( $arr_flip[ $b ] ) ) {
|
659 |
-
return 1;
|
660 |
-
}
|
661 |
-
|
662 |
-
if ( ! isset( $arr_flip[ $a ] ) ) {
|
663 |
-
return -1;
|
664 |
-
}
|
665 |
-
|
666 |
-
if ( $arr_flip[ $a ] == $arr_flip[ $b ] ) {
|
667 |
-
return 0;
|
668 |
-
}
|
669 |
-
|
670 |
-
return ( $arr_flip[ $a ] < $arr_flip[ $b ] ) ? -1 : 1;
|
671 |
-
} );
|
672 |
-
}
|
673 |
-
|
674 |
-
foreach ( $field_data['items'] as $tab_id => $tab_name ) {
|
675 |
-
$content = apply_filters( 'um_render_sortable_items_item_html', $tab_name, $tab_id, $field_data );
|
676 |
-
$html .= '<li data-tab-id="' . esc_attr( $tab_id ) . '" class="um-sortable-item"><span class="um-field-icon"><i class="um-faicon-sort"></i></span>' . $content . '</li>';
|
677 |
-
}
|
678 |
-
|
679 |
-
$html .= '</ul>';
|
680 |
-
|
681 |
-
return $html;
|
682 |
-
}
|
683 |
-
|
684 |
-
|
685 |
-
/**
|
686 |
-
* @param $field_data
|
687 |
-
*
|
688 |
-
* @return bool|string
|
689 |
-
*/
|
690 |
-
function render_datepicker( $field_data ) {
|
691 |
-
|
692 |
-
if ( empty( $field_data['id'] ) ) {
|
693 |
-
return false;
|
694 |
-
}
|
695 |
-
|
696 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
697 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
698 |
-
|
699 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
700 |
-
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
701 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
702 |
-
|
703 |
-
$data = array(
|
704 |
-
'field_id' => $field_data['id']
|
705 |
-
);
|
706 |
-
|
707 |
-
$data_attr = '';
|
708 |
-
foreach ( $data as $key => $value ) {
|
709 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
710 |
-
}
|
711 |
-
|
712 |
-
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
713 |
-
|
714 |
-
$name = $field_data['id'];
|
715 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
716 |
-
$name_attr = ' name="' . $name . '" ';
|
717 |
-
|
718 |
-
$value = $this->get_field_value( $field_data );
|
719 |
-
$value_attr = ' value="' . $value . '" ';
|
720 |
-
|
721 |
-
$html = "<input type=\"date\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
722 |
-
|
723 |
-
return $html;
|
724 |
-
}
|
725 |
-
|
726 |
-
|
727 |
-
/**
|
728 |
-
* @param $field_data
|
729 |
-
*
|
730 |
-
* @return bool|string
|
731 |
-
*/
|
732 |
-
function render_inline_texts( $field_data ) {
|
733 |
-
|
734 |
-
if ( empty( $field_data['id1'] ) ) {
|
735 |
-
return false;
|
736 |
-
}
|
737 |
-
|
738 |
-
$i = 1;
|
739 |
-
$fields = array();
|
740 |
-
while( ! empty( $field_data['id' . $i] ) ) {
|
741 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'. $i];
|
742 |
-
$id_attr = ' id="' . $id . '" ';
|
743 |
-
|
744 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
745 |
-
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
746 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
747 |
-
|
748 |
-
$data = array(
|
749 |
-
'field_id' => $field_data[ 'id'. $i ]
|
750 |
-
);
|
751 |
-
|
752 |
-
$data_attr = '';
|
753 |
-
foreach ( $data as $key => $value ) {
|
754 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
755 |
-
}
|
756 |
-
|
757 |
-
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . $field_data['placeholder'] . '"' : '';
|
758 |
-
|
759 |
-
$name = $field_data[ 'id'. $i ];
|
760 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
761 |
-
$name_attr = ' name="' . $name . '" ';
|
762 |
-
|
763 |
-
$value = $this->get_field_value( $field_data, $i );
|
764 |
-
|
765 |
-
$value_attr = ' value="' . $value . '" ';
|
766 |
-
|
767 |
-
$fields[$i] = "<input type=\"text\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr style=\"display:inline;\"/>";
|
768 |
-
|
769 |
-
$i++;
|
770 |
-
}
|
771 |
-
|
772 |
-
$html = vsprintf( $field_data['mask'], $fields );
|
773 |
-
|
774 |
-
return $html;
|
775 |
-
}
|
776 |
-
|
777 |
-
|
778 |
-
/**
|
779 |
-
* @param $field_data
|
780 |
-
*
|
781 |
-
* @return bool|string
|
782 |
-
*/
|
783 |
-
function render_textarea( $field_data ) {
|
784 |
-
|
785 |
-
if ( empty( $field_data['id'] ) ) {
|
786 |
-
return false;
|
787 |
-
}
|
788 |
-
|
789 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
790 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
791 |
-
|
792 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
793 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
794 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
795 |
-
|
796 |
-
$data = array(
|
797 |
-
'field_id' => $field_data['id']
|
798 |
-
);
|
799 |
-
|
800 |
-
$data_attr = '';
|
801 |
-
foreach ( $data as $key => $value ) {
|
802 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
803 |
-
}
|
804 |
-
|
805 |
-
$rows = ! empty( $field_data['args']['textarea_rows'] ) ? ' rows="' . $field_data['args']['textarea_rows'] . '" ' : '';
|
806 |
-
|
807 |
-
$name = $field_data['id'];
|
808 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
809 |
-
$name_attr = ' name="' . $name . '" ';
|
810 |
-
|
811 |
-
$value = $this->get_field_value( $field_data );
|
812 |
-
|
813 |
-
$html = "<textarea $id_attr $class_attr $name_attr $data_attr $rows>$value</textarea>";
|
814 |
-
|
815 |
-
return $html;
|
816 |
-
}
|
817 |
-
|
818 |
-
|
819 |
-
/**
|
820 |
-
* @param $field_data
|
821 |
-
*
|
822 |
-
* @return bool|string
|
823 |
-
*/
|
824 |
-
function render_wp_editor( $field_data ) {
|
825 |
-
|
826 |
-
if ( empty( $field_data['id'] ) ) {
|
827 |
-
return false;
|
828 |
-
}
|
829 |
-
|
830 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
831 |
-
|
832 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
833 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
834 |
-
|
835 |
-
$data = array(
|
836 |
-
'field_id' => $field_data['id']
|
837 |
-
);
|
838 |
-
|
839 |
-
$data_attr = '';
|
840 |
-
foreach ( $data as $key => $value ) {
|
841 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
842 |
-
}
|
843 |
-
|
844 |
-
$name = $field_data['id'];
|
845 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
846 |
-
|
847 |
-
$value = $this->get_field_value( $field_data );
|
848 |
-
|
849 |
-
ob_start();
|
850 |
-
wp_editor( $value,
|
851 |
-
$id,
|
852 |
-
array(
|
853 |
-
'textarea_name' => $name,
|
854 |
-
'textarea_rows' => 20,
|
855 |
-
'editor_height' => 425,
|
856 |
-
'wpautop' => false,
|
857 |
-
'media_buttons' => false,
|
858 |
-
'editor_class' => $class
|
859 |
-
)
|
860 |
-
);
|
861 |
-
|
862 |
-
$html = ob_get_clean();
|
863 |
-
return $html;
|
864 |
-
}
|
865 |
-
|
866 |
-
|
867 |
-
/**
|
868 |
-
* @param $field_data
|
869 |
-
*
|
870 |
-
* @return bool|string
|
871 |
-
*/
|
872 |
-
function render_checkbox( $field_data ) {
|
873 |
-
|
874 |
-
if ( empty( $field_data['id'] ) )
|
875 |
-
return false;
|
876 |
-
|
877 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
878 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
879 |
-
$id_attr_hidden = ' id="' . esc_attr( $id ) . '_hidden" ';
|
880 |
-
|
881 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
882 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
883 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
884 |
-
|
885 |
-
$data = array(
|
886 |
-
'field_id' => $field_data['id']
|
887 |
-
);
|
888 |
-
|
889 |
-
if ( ! empty( $field_data['data'] ) ) {
|
890 |
-
$data = array_merge( $data, $field_data['data'] );
|
891 |
-
}
|
892 |
-
|
893 |
-
$data_attr = '';
|
894 |
-
foreach ( $data as $key => $value ) {
|
895 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
896 |
-
}
|
897 |
-
|
898 |
-
$name = $field_data['id'];
|
899 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
900 |
-
$name_attr = ' name="' . $name . '" ';
|
901 |
-
|
902 |
-
$value = $this->get_field_value( $field_data );
|
903 |
-
|
904 |
-
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" />
|
905 |
-
<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" />";
|
906 |
-
|
907 |
-
|
908 |
-
return $html;
|
909 |
-
}
|
910 |
-
|
911 |
-
|
912 |
-
/**
|
913 |
-
* @param $field_data
|
914 |
-
*
|
915 |
-
* @return bool|string
|
916 |
-
*/
|
917 |
-
function render_same_page_update( $field_data ) {
|
918 |
-
|
919 |
-
if ( empty( $field_data['id'] ) ) {
|
920 |
-
return false;
|
921 |
-
}
|
922 |
-
|
923 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
924 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
925 |
-
$id_attr_hidden = ' id="' . esc_attr( $id ) . '_hidden" ';
|
926 |
-
|
927 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
928 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
929 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
930 |
-
|
931 |
-
$data = array(
|
932 |
-
'field_id' => $field_data['id']
|
933 |
-
);
|
934 |
-
|
935 |
-
if ( ! empty( $field_data['data'] ) ) {
|
936 |
-
$data = array_merge( $data, $field_data['data'] );
|
937 |
-
}
|
938 |
-
|
939 |
-
$data_attr = '';
|
940 |
-
foreach ( $data as $key => $value ) {
|
941 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
942 |
-
}
|
943 |
-
|
944 |
-
if ( ! empty( $field_data['upgrade_cb'] ) ) {
|
945 |
-
$data_attr .= ' data-log-object="' . esc_attr( $field_data['upgrade_cb'] ) . '" ';
|
946 |
-
}
|
947 |
-
|
948 |
-
$name = $field_data['id'];
|
949 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
950 |
-
$name_attr = ' name="' . $name . '" ';
|
951 |
-
|
952 |
-
$value = $this->get_field_value( $field_data );
|
953 |
-
|
954 |
-
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" />
|
955 |
-
<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" />";
|
956 |
-
|
957 |
-
if ( ! empty( $field_data['upgrade_cb'] ) ) {
|
958 |
-
$html .= '<div class="um-same-page-update-wrapper um-same-page-update-' . esc_attr( $field_data['upgrade_cb'] ) . '"><div class="um-same-page-update-description">' . $field_data['upgrade_description'] . '</div><input type="button" data-upgrade_cb="' . $field_data['upgrade_cb'] . '" class="button button-primary um-admin-form-same-page-update" value="' . esc_attr__( 'Run', 'ultimate-member' ) . '"/>
|
959 |
-
<div class="upgrade_log"></div></div>';
|
960 |
-
}
|
961 |
-
|
962 |
-
return $html;
|
963 |
-
}
|
964 |
-
|
965 |
-
|
966 |
-
/**
|
967 |
-
* @param $field_data
|
968 |
-
*
|
969 |
-
* @return bool|string
|
970 |
-
*/
|
971 |
-
function render_select( $field_data ) {
|
972 |
-
|
973 |
-
if ( empty( $field_data['id'] ) ) {
|
974 |
-
return false;
|
975 |
-
}
|
976 |
-
|
977 |
-
$multiple = ! empty( $field_data['multi'] ) ? 'multiple' : '';
|
978 |
-
|
979 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
980 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
981 |
-
|
982 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] . ' ' : ' ';
|
983 |
-
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
984 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
985 |
-
|
986 |
-
$data = array(
|
987 |
-
'field_id' => $field_data['id']
|
988 |
-
);
|
989 |
-
|
990 |
-
$data_attr = '';
|
991 |
-
foreach ( $data as $key => $value ) {
|
992 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
993 |
-
}
|
994 |
-
|
995 |
-
$name = $field_data['id'];
|
996 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
997 |
-
$hidden_name_attr = ' name="' . $name . '" ';
|
998 |
-
$name = $name . ( ! empty( $field_data['multi'] ) ? '[]' : '' );
|
999 |
-
$name_attr = ' name="' . $name . '" ';
|
1000 |
-
|
1001 |
-
$value = $this->get_field_value( $field_data );
|
1002 |
-
|
1003 |
-
$options = '';
|
1004 |
-
if ( ! empty( $field_data['options'] ) ) {
|
1005 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1006 |
-
if ( ! empty( $field_data['multi'] ) ) {
|
1007 |
-
|
1008 |
-
if ( ! is_array( $value ) || empty( $value ) ) {
|
1009 |
-
$value = array();
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
$options .= '<option value="' . $key . '" ' . selected( in_array( $key, $value ), true, false ) . '>' . esc_html( $option ) . '</option>';
|
1013 |
-
} else {
|
1014 |
-
$options .= '<option value="' . $key . '" ' . selected( (string)$key == $value, true, false ) . '>' . esc_html( $option ) . '</option>';
|
1015 |
-
}
|
1016 |
-
}
|
1017 |
-
}
|
1018 |
-
|
1019 |
-
$hidden = '';
|
1020 |
-
if ( ! empty( $multiple ) ) {
|
1021 |
-
$hidden = "<input type=\"hidden\" $hidden_name_attr value=\"\" />";
|
1022 |
-
}
|
1023 |
-
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr>$options</select>";
|
1024 |
-
|
1025 |
-
return $html;
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
|
1029 |
-
/**
|
1030 |
-
* @param $field_data
|
1031 |
-
*
|
1032 |
-
* @return bool|string
|
1033 |
-
*/
|
1034 |
-
function render_multi_selects( $field_data ) {
|
1035 |
-
|
1036 |
-
if ( empty( $field_data['id'] ) ) {
|
1037 |
-
return false;
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1041 |
-
|
1042 |
-
$sorting = ! empty( $field_data['sorting'] ) ? $field_data['sorting'] : false;
|
1043 |
-
|
1044 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1045 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1046 |
-
$class .= ! empty( $sorting ) ? 'um-sorting-enabled' : '';
|
1047 |
-
$class_attr = ' class="um-forms-field ' . $class . '" ';
|
1048 |
-
|
1049 |
-
$data = array(
|
1050 |
-
'field_id' => $field_data['id'],
|
1051 |
-
'id_attr' => $id
|
1052 |
-
);
|
1053 |
-
|
1054 |
-
$data_attr = '';
|
1055 |
-
foreach ( $data as $key => $value ) {
|
1056 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1057 |
-
}
|
1058 |
-
|
1059 |
-
$name = $field_data['id'];
|
1060 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1061 |
-
$name = "{$name}[]";
|
1062 |
-
$name_attr = ' name="' . $name . '" ';
|
1063 |
-
|
1064 |
-
$values = $this->get_field_value( $field_data );
|
1065 |
-
|
1066 |
-
$options = '';
|
1067 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1068 |
-
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
$html = "<select class=\"um-hidden-multi-selects\" $data_attr>$options</select>";
|
1072 |
-
$html .= "<ul class=\"um-multi-selects-list" . ( ! empty( $sorting ) ? ' um-sortable-multi-selects' : '' ) . "\" $data_attr>";
|
1073 |
-
|
1074 |
-
if ( $sorting && is_array( $values ) ) {
|
1075 |
-
ksort( $values );
|
1076 |
-
}
|
1077 |
-
|
1078 |
-
if ( ! empty( $values ) && is_array( $values ) ) {
|
1079 |
-
foreach ( $values as $k => $value ) {
|
1080 |
-
|
1081 |
-
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
|
1082 |
-
continue ;
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1086 |
-
|
1087 |
-
$options = '';
|
1088 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1089 |
-
$options .= '<option value="' . $key . '" ' . selected( $key == $value, true, false ) . '>' . $option . '</option>';
|
1090 |
-
}
|
1091 |
-
|
1092 |
-
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1093 |
-
if ( $sorting ) {
|
1094 |
-
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1095 |
-
}
|
1096 |
-
$html .= "<span class=\"um-field-wrapper\">
|
1097 |
-
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1098 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1099 |
-
}
|
1100 |
-
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1101 |
-
$i = 0;
|
1102 |
-
while ( $i < $field_data['show_default_number'] ) {
|
1103 |
-
$id_attr = ' id="' . $id . '-' . $i . '" ';
|
1104 |
-
|
1105 |
-
$options = '';
|
1106 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1107 |
-
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1111 |
-
if ( $sorting ) {
|
1112 |
-
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1113 |
-
}
|
1114 |
-
|
1115 |
-
$html .= "<span class=\"um-field-wrapper\">
|
1116 |
-
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1117 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1118 |
-
|
1119 |
-
$i++;
|
1120 |
-
}
|
1121 |
-
}
|
1122 |
-
|
1123 |
-
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-multi-selects-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1124 |
-
|
1125 |
-
return $html;
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
|
1129 |
-
/**
|
1130 |
-
* @param $field_data
|
1131 |
-
*
|
1132 |
-
* @return bool|string
|
1133 |
-
*/
|
1134 |
-
function render_multi_checkbox( $field_data ) {
|
1135 |
-
|
1136 |
-
if ( empty( $field_data['id'] ) ) {
|
1137 |
-
return false;
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1141 |
-
|
1142 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1143 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1144 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
1145 |
-
|
1146 |
-
$name = $field_data['id'];
|
1147 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1148 |
-
|
1149 |
-
$values = $this->get_field_value( $field_data );
|
1150 |
-
if ( empty( $values ) ) {
|
1151 |
-
$values = array();
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
$i = 0;
|
1155 |
-
$html = '';
|
1156 |
-
|
1157 |
-
$columns = ( ! empty( $field_data['columns'] ) && is_numeric( $field_data['columns'] ) ) ? $field_data['columns'] : 1;
|
1158 |
-
while ( $i < $columns ) {
|
1159 |
-
$per_page = ceil( count( $field_data['options'] ) / $columns );
|
1160 |
-
$section_fields_per_page = array_slice( $field_data['options'], $i*$per_page, $per_page, true );
|
1161 |
-
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
|
1162 |
-
|
1163 |
-
foreach ( $section_fields_per_page as $k => $title ) {
|
1164 |
-
$id_attr = ' id="' . esc_attr( $id . '_' . $k ) . '" ';
|
1165 |
-
$for_attr = ' for="' . esc_attr( $id . '_' . $k ) . '" ';
|
1166 |
-
$name_attr = ' name="' . $name . '[' . $k . ']" ';
|
1167 |
-
|
1168 |
-
$data = array(
|
1169 |
-
'field_id' => $field_data['id'] . '_' . $k,
|
1170 |
-
);
|
1171 |
-
|
1172 |
-
if ( ! empty( $field_data['data'] ) ) {
|
1173 |
-
$data = array_merge( $data, $field_data['data'] );
|
1174 |
-
}
|
1175 |
-
|
1176 |
-
$data_attr = '';
|
1177 |
-
foreach ( $data as $key => $value ) {
|
1178 |
-
if ( $value == 'checkbox_key' ) {
|
1179 |
-
$value = $k;
|
1180 |
-
}
|
1181 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1182 |
-
}
|
1183 |
-
|
1184 |
-
$html .= "<label $for_attr>
|
1185 |
-
<input type=\"checkbox\" " . checked( in_array( $k, $values ), true, false ) . "$id_attr $name_attr $data_attr value=\"1\" $class_attr>
|
1186 |
-
<span>$title</span>
|
1187 |
-
</label>";
|
1188 |
-
}
|
1189 |
-
|
1190 |
-
$html .= '</span>';
|
1191 |
-
$i++;
|
1192 |
-
}
|
1193 |
-
|
1194 |
-
return $html;
|
1195 |
-
}
|
1196 |
-
|
1197 |
-
|
1198 |
-
/**
|
1199 |
-
* @param $field_data
|
1200 |
-
*
|
1201 |
-
* @return bool|string
|
1202 |
-
*/
|
1203 |
-
function render_multi_text( $field_data ) {
|
1204 |
-
|
1205 |
-
if ( empty( $field_data['id'] ) ) {
|
1206 |
-
return false;
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1210 |
-
|
1211 |
-
$size = ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
1212 |
-
|
1213 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1214 |
-
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
1215 |
-
|
1216 |
-
$data = array(
|
1217 |
-
'field_id' => $field_data['id'],
|
1218 |
-
'id_attr' => $id,
|
1219 |
-
'item_class' => "um-multi-text-option-line {$size}",
|
1220 |
-
);
|
1221 |
-
|
1222 |
-
$data_attr = '';
|
1223 |
-
foreach ( $data as $key => $value ) {
|
1224 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
$name = $field_data['id'];
|
1228 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1229 |
-
$name = "{$name}[]";
|
1230 |
-
$name_attr = ' name="' . $name . '" ';
|
1231 |
-
|
1232 |
-
$values = $this->get_field_value( $field_data );
|
1233 |
-
|
1234 |
-
$html = "<input type=\"text\" class=\"um-hidden-multi-text\" $data_attr />";
|
1235 |
-
$html .= "<ul class=\"um-multi-text-list\" $data_attr>";
|
1236 |
-
|
1237 |
-
if ( ! empty( $values ) ) {
|
1238 |
-
foreach ( $values as $k => $value ) {
|
1239 |
-
$value = esc_attr( $value );
|
1240 |
-
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1241 |
-
|
1242 |
-
$html .= "<li class=\"um-multi-text-option-line {$size}\"><span class=\"um-field-wrapper\">
|
1243 |
-
<input type=\"text\" $id_attr $name_attr $class_attr $data_attr value=\"$value\" /></span>
|
1244 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-text-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1245 |
-
}
|
1246 |
-
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1247 |
-
$i = 0;
|
1248 |
-
while( $i < $field_data['show_default_number'] ) {
|
1249 |
-
$id_attr = ' id="' . esc_attr( $id . '-' . $i ) . '" ';
|
1250 |
-
|
1251 |
-
$html .= "<li class=\"um-multi-text-option-line {$size}\"><span class=\"um-field-wrapper\">
|
1252 |
-
<input type=\"text\" $id_attr $name_attr $class_attr $data_attr value=\"\" /></span>
|
1253 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-text-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1254 |
-
|
1255 |
-
$i++;
|
1256 |
-
}
|
1257 |
-
}
|
1258 |
-
|
1259 |
-
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-multi-text-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1260 |
-
|
1261 |
-
return $html;
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
|
1265 |
-
/**
|
1266 |
-
* @param $field_data
|
1267 |
-
*
|
1268 |
-
* @return bool|string
|
1269 |
-
*/
|
1270 |
-
function render_media( $field_data ) {
|
1271 |
-
|
1272 |
-
if ( empty( $field_data['id'] ) ) {
|
1273 |
-
return false;
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1277 |
-
|
1278 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1279 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1280 |
-
$class_attr = ' class="um-forms-field um-media-upload-data-url ' . $class . '"';
|
1281 |
-
|
1282 |
-
$data = array(
|
1283 |
-
'field_id' => $field_data['id'] . '_url',
|
1284 |
-
);
|
1285 |
-
|
1286 |
-
if ( ! empty( $field_data['default']['url'] ) ) {
|
1287 |
-
$data['default'] = esc_attr( $field_data['default']['url'] );
|
1288 |
-
}
|
1289 |
-
|
1290 |
-
$data_attr = '';
|
1291 |
-
foreach ( $data as $key => $value ) {
|
1292 |
-
$data_attr .= " data-{$key}=\"{$value}\" ";
|
1293 |
-
}
|
1294 |
-
|
1295 |
-
$name = $field_data['id'];
|
1296 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1297 |
-
|
1298 |
-
$value = $this->get_field_value( $field_data );
|
1299 |
-
|
1300 |
-
$upload_frame_title = ! empty( $field_data['upload_frame_title'] ) ? $field_data['upload_frame_title'] : __( 'Select media', 'ultimate-member' );
|
1301 |
-
|
1302 |
-
$image_id = ! empty( $value['id'] ) ? $value['id'] : '';
|
1303 |
-
$image_width = ! empty( $value['width'] ) ? $value['width'] : '';
|
1304 |
-
$image_height = ! empty( $value['height'] ) ? $value['height'] : '';
|
1305 |
-
$image_thumbnail = ! empty( $value['thumbnail'] ) ? $value['thumbnail'] : '';
|
1306 |
-
$image_url = ! empty( $value['url'] ) ? $value['url'] : '';
|
1307 |
-
|
1308 |
-
$html = "<div class=\"um-media-upload\">" .
|
1309 |
-
"<input type=\"hidden\" class=\"um-media-upload-data-id\" name=\"{$name}[id]\" id=\"{$id}_id\" value=\"$image_id\">" .
|
1310 |
-
"<input type=\"hidden\" class=\"um-media-upload-data-width\" name=\"{$name}[width]\" id=\"{$id}_width\" value=\"$image_width\">" .
|
1311 |
-
"<input type=\"hidden\" class=\"um-media-upload-data-height\" name=\"{$name}[height]\" id=\"{$id}_height\" value=\"$image_height\">" .
|
1312 |
-
"<input type=\"hidden\" class=\"um-media-upload-data-thumbnail\" name=\"{$name}[thumbnail]\" id=\"{$id}_thumbnail\" value=\"$image_thumbnail\">" .
|
1313 |
-
"<input type=\"hidden\" $class_attr name=\"{$name}[url]\" id=\"{$id}_url\" value=\"$image_url\" $data_attr>";
|
1314 |
-
|
1315 |
-
if ( ! isset( $field_data['preview'] ) || $field_data['preview'] !== false ) {
|
1316 |
-
$html .= '<img src="' . $image_url . '" alt="" class="icon_preview"><div style="clear:both;"></div>';
|
1317 |
-
}
|
1318 |
-
|
1319 |
-
if ( ! empty( $field_data['url'] ) ) {
|
1320 |
-
$html .= '<input type="text" class="um-media-upload-url" readonly value="' . $image_url . '" /><div style="clear:both;"></div>';
|
1321 |
-
}
|
1322 |
-
|
1323 |
-
$html .= '<input type="button" class="um-set-image button button-primary" value="' . esc_attr__( 'Select', 'ultimate-member' ) . '" data-upload_frame="' . $upload_frame_title . '" />
|
1324 |
-
<input type="button" class="um-clear-image button" value="' . esc_attr__( 'Clear', 'ultimate-member' ) . '" /></div>';
|
1325 |
-
|
1326 |
-
return $html;
|
1327 |
-
}
|
1328 |
-
|
1329 |
-
|
1330 |
-
/**
|
1331 |
-
* @param $field_data
|
1332 |
-
*
|
1333 |
-
* @return bool|string
|
1334 |
-
*/
|
1335 |
-
function render_email_template( $field_data ) {
|
1336 |
-
if ( empty( $field_data['id'] ) ) {
|
1337 |
-
return false;
|
1338 |
-
}
|
1339 |
-
|
1340 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1341 |
-
|
1342 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1343 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1344 |
-
|
1345 |
-
$data = array(
|
1346 |
-
'field_id' => $field_data['id']
|
1347 |
-
);
|
1348 |
-
|
1349 |
-
$data_attr = '';
|
1350 |
-
foreach ( $data as $key => $value ) {
|
1351 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
$name = $field_data['id'];
|
1355 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1356 |
-
|
1357 |
-
$value = $this->get_field_value( $field_data );
|
1358 |
-
|
1359 |
-
ob_start(); ?>
|
1360 |
-
|
1361 |
-
<div class="email_template_wrapper <?php echo $field_data['in_theme'] ? 'in_theme' : '' ?>" data-key="<?php echo $field_data['id'] ?>" style="position: relative;">
|
1362 |
-
|
1363 |
-
<?php wp_editor( $value,
|
1364 |
-
$id,
|
1365 |
-
array(
|
1366 |
-
'textarea_name' => $name,
|
1367 |
-
'textarea_rows' => 20,
|
1368 |
-
'editor_height' => 425,
|
1369 |
-
'wpautop' => false,
|
1370 |
-
'media_buttons' => false,
|
1371 |
-
'editor_class' => $class
|
1372 |
-
)
|
1373 |
-
); ?>
|
1374 |
-
<span class="description">For default text for plain-text emails please see this <a href="https://docs.ultimatemember.com/article/1342-plain-text-email-default-templates#<?php echo $field_data['id'] ?>" target="_blank">doc</a></span>
|
1375 |
-
</div>
|
1376 |
-
|
1377 |
-
<?php $html = ob_get_clean();
|
1378 |
-
|
1379 |
-
return $html;
|
1380 |
-
}
|
1381 |
-
|
1382 |
-
|
1383 |
-
/**
|
1384 |
-
* @param $field_data
|
1385 |
-
*
|
1386 |
-
* @return bool|string
|
1387 |
-
*/
|
1388 |
-
function render_ajax_button( $field_data ) {
|
1389 |
-
|
1390 |
-
if ( empty( $field_data['id'] ) )
|
1391 |
-
return false;
|
1392 |
-
|
1393 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1394 |
-
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
1395 |
-
|
1396 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1397 |
-
$class_attr = ' class="um-forms-field button ' . esc_attr( $class ) . '" ';
|
1398 |
-
|
1399 |
-
$data = array(
|
1400 |
-
'field_id' => $field_data['id']
|
1401 |
-
);
|
1402 |
-
|
1403 |
-
$data_attr = '';
|
1404 |
-
foreach ( $data as $key => $value ) {
|
1405 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1406 |
-
}
|
1407 |
-
|
1408 |
-
$name = $field_data['id'];
|
1409 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1410 |
-
$name_attr = ' name="' . $name . '" ';
|
1411 |
-
|
1412 |
-
$value = $this->get_field_value( $field_data );
|
1413 |
-
$value_attr = ' value="' . $value . '" ';
|
1414 |
-
|
1415 |
-
$html = "<input type=\"button\" $id_attr $class_attr $name_attr $data_attr $value_attr /><div class='clear'></div><div class='um_setting_ajax_button_response'></div>";
|
1416 |
-
|
1417 |
-
return $html;
|
1418 |
-
}
|
1419 |
-
|
1420 |
-
|
1421 |
-
/**
|
1422 |
-
* @param $field_data
|
1423 |
-
*
|
1424 |
-
* @return mixed
|
1425 |
-
*/
|
1426 |
-
function render_info_text( $field_data ) {
|
1427 |
-
return $field_data['value'];
|
1428 |
-
}
|
1429 |
-
|
1430 |
-
|
1431 |
-
/**
|
1432 |
-
* @param $field_data
|
1433 |
-
*
|
1434 |
-
* @return string
|
1435 |
-
*/
|
1436 |
-
function render_md_default_filters( $field_data ) {
|
1437 |
-
if ( empty( $field_data['id'] ) ) {
|
1438 |
-
return false;
|
1439 |
-
}
|
1440 |
-
global $post;
|
1441 |
-
|
1442 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1443 |
-
|
1444 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1445 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1446 |
-
$class_attr = ' class="um-forms-field ' . $class . '" ';
|
1447 |
-
|
1448 |
-
$data = array(
|
1449 |
-
'field_id' => $field_data['id'],
|
1450 |
-
'id_attr' => $id,
|
1451 |
-
'member_directory' => $post->ID
|
1452 |
-
);
|
1453 |
-
|
1454 |
-
$data_attr = '';
|
1455 |
-
foreach ( $data as $key => $value ) {
|
1456 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1457 |
-
}
|
1458 |
-
|
1459 |
-
$name = $field_data['id'];
|
1460 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1461 |
-
$name = "{$name}[]";
|
1462 |
-
$name_attr = ' name="' . $name . '" ';
|
1463 |
-
|
1464 |
-
$values = $this->get_field_value( $field_data );
|
1465 |
-
if ( is_array( $values ) ) {
|
1466 |
-
$filters = array_keys( $values );
|
1467 |
-
}
|
1468 |
-
|
1469 |
-
$options = '';
|
1470 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1471 |
-
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1472 |
-
}
|
1473 |
-
|
1474 |
-
$html = "<input type=\"hidden\" name=\"um-gmt-offset\" /><select class=\"um-hidden-md-default-filters\" $data_attr>$options</select>";
|
1475 |
-
$html .= "<ul class=\"um-md-default-filters-list\" $data_attr>";
|
1476 |
-
|
1477 |
-
if ( ! empty( $filters ) && is_array( $filters ) ) {
|
1478 |
-
foreach ( $filters as $k => $value ) {
|
1479 |
-
|
1480 |
-
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
|
1481 |
-
continue ;
|
1482 |
-
}
|
1483 |
-
|
1484 |
-
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1485 |
-
|
1486 |
-
$options = '';
|
1487 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1488 |
-
$options .= '<option value="' . $key . '" ' . selected( $key == $value, true, false ) . '>' . $option . '</option>';
|
1489 |
-
}
|
1490 |
-
|
1491 |
-
$html .= "<li class=\"um-md-default-filters-option-line\"><span class=\"um-field-wrapper\">
|
1492 |
-
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1493 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span><span class=\"um-field-wrapper2 um\">" . UM()->member_directory()->show_filter( $value, array( 'form_id' => $post->ID ), $values[ $value ], true ) . "</span></li>";
|
1494 |
-
}
|
1495 |
-
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1496 |
-
$i = 0;
|
1497 |
-
while ( $i < $field_data['show_default_number'] ) {
|
1498 |
-
$id_attr = ' id="' . $id . '-' . $i . '" ';
|
1499 |
-
|
1500 |
-
$options = '';
|
1501 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1502 |
-
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1503 |
-
}
|
1504 |
-
|
1505 |
-
$html .= "<li class=\"um-md-default-filters-option-line\"><span class=\"um-field-wrapper\">
|
1506 |
-
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1507 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1508 |
-
|
1509 |
-
$i++;
|
1510 |
-
}
|
1511 |
-
}
|
1512 |
-
|
1513 |
-
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-md-default-filters-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1514 |
-
|
1515 |
-
return $html;
|
1516 |
-
}
|
1517 |
-
|
1518 |
-
|
1519 |
-
/**
|
1520 |
-
* @param $field_data
|
1521 |
-
*
|
1522 |
-
* @return string
|
1523 |
-
*/
|
1524 |
-
function render_md_sorting_fields( $field_data ) {
|
1525 |
-
if ( empty( $field_data['id'] ) ) {
|
1526 |
-
return false;
|
1527 |
-
}
|
1528 |
-
|
1529 |
-
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1530 |
-
|
1531 |
-
$sorting = ! empty( $field_data['sorting'] ) ? $field_data['sorting'] : false;
|
1532 |
-
|
1533 |
-
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1534 |
-
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1535 |
-
$class .= ! empty( $sorting ) ? 'um-sorting-enabled' : '';
|
1536 |
-
$class_attr = ' class="um-forms-field ' . $class . '" ';
|
1537 |
-
|
1538 |
-
$data = array(
|
1539 |
-
'field_id' => $field_data['id'],
|
1540 |
-
'id_attr' => $id
|
1541 |
-
);
|
1542 |
-
|
1543 |
-
$data_attr = '';
|
1544 |
-
foreach ( $data as $key => $value ) {
|
1545 |
-
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1546 |
-
}
|
1547 |
-
|
1548 |
-
$name = $field_data['id'];
|
1549 |
-
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1550 |
-
$name = "{$name}[]";
|
1551 |
-
$name_attr = ' name="' . $name . '" ';
|
1552 |
-
|
1553 |
-
$values = $this->get_field_value( $field_data );
|
1554 |
-
|
1555 |
-
$options = '';
|
1556 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1557 |
-
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1558 |
-
}
|
1559 |
-
|
1560 |
-
$html = "<select class=\"um-hidden-multi-selects\" $data_attr>$options</select>";
|
1561 |
-
$html .= "<ul class=\"um-multi-selects-list" . ( ! empty( $sorting ) ? ' um-sortable-multi-selects' : '' ) . "\" $data_attr>";
|
1562 |
-
|
1563 |
-
if ( $sorting && is_array( $values ) ) {
|
1564 |
-
ksort( $values );
|
1565 |
-
}
|
1566 |
-
|
1567 |
-
if ( ! empty( $values ) && is_array( $values ) ) {
|
1568 |
-
foreach ( $values as $k => $value ) {
|
1569 |
-
|
1570 |
-
$other_key = '';
|
1571 |
-
$other_label = '';
|
1572 |
-
if ( is_array( $value ) ) {
|
1573 |
-
$keys = array_keys( $value );
|
1574 |
-
$other_key = $keys[0];
|
1575 |
-
|
1576 |
-
$labels = array_values( $value );
|
1577 |
-
$other_label = $labels[0];
|
1578 |
-
} else {
|
1579 |
-
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
|
1580 |
-
continue;
|
1581 |
-
}
|
1582 |
-
}
|
1583 |
-
|
1584 |
-
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1585 |
-
|
1586 |
-
$options = '';
|
1587 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1588 |
-
if ( is_array( $value ) ) {
|
1589 |
-
$selected = selected( $key == 'other', true, false );
|
1590 |
-
} else {
|
1591 |
-
$selected = selected( $key == $value, true, false );
|
1592 |
-
}
|
1593 |
-
|
1594 |
-
$options .= '<option value="' . $key . '" ' . $selected . '>' . $option . '</option>';
|
1595 |
-
}
|
1596 |
-
|
1597 |
-
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1598 |
-
if ( $sorting ) {
|
1599 |
-
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1600 |
-
}
|
1601 |
-
$html .= "<span class=\"um-field-wrapper\">
|
1602 |
-
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1603 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span>
|
1604 |
-
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Meta key', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $k . "][meta_key]\" value=\"" . esc_attr( $other_key ) . "\" /></label></span>
|
1605 |
-
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Label', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $k . "][label]\" value=\"" . esc_attr( $other_label ) . "\" /></label></span>
|
1606 |
-
</li>";
|
1607 |
-
}
|
1608 |
-
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1609 |
-
$i = 0;
|
1610 |
-
while ( $i < $field_data['show_default_number'] ) {
|
1611 |
-
$id_attr = ' id="' . $id . '-' . $i . '" ';
|
1612 |
-
|
1613 |
-
$options = '';
|
1614 |
-
foreach ( $field_data['options'] as $key => $option ) {
|
1615 |
-
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1616 |
-
}
|
1617 |
-
|
1618 |
-
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1619 |
-
if ( $sorting ) {
|
1620 |
-
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1621 |
-
}
|
1622 |
-
|
1623 |
-
$html .= "<span class=\"um-field-wrapper\">
|
1624 |
-
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1625 |
-
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span>
|
1626 |
-
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Meta key', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $i . "][meta_key]\" value=\"\" /></label></span>
|
1627 |
-
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Label', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $i . "][label]\" value=\"\" /></label></span>
|
1628 |
-
</li>";
|
1629 |
-
|
1630 |
-
$i++;
|
1631 |
-
}
|
1632 |
-
}
|
1633 |
-
|
1634 |
-
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-multi-selects-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1635 |
-
|
1636 |
-
return $html;
|
1637 |
-
}
|
1638 |
-
|
1639 |
-
|
1640 |
-
/**
|
1641 |
-
* Get field value
|
1642 |
-
*
|
1643 |
-
* @param array $field_data
|
1644 |
-
* @param string $i
|
1645 |
-
* @return string|array
|
1646 |
-
*/
|
1647 |
-
function get_field_value( $field_data, $i = '' ) {
|
1648 |
-
|
1649 |
-
$default = '';
|
1650 |
-
if ( $field_data['type'] === 'multi_checkbox' ) {
|
1651 |
-
$default = array();
|
1652 |
-
if ( isset( $field_data['default'] ) ) {
|
1653 |
-
$default = is_array( $field_data['default'] ) ? $field_data['default'] : array( $field_data['default'] );
|
1654 |
-
}
|
1655 |
-
}
|
1656 |
-
if ( isset( $field_data[ 'default' . $i ] ) ) {
|
1657 |
-
$default = $field_data[ 'default' . $i ];
|
1658 |
-
}
|
1659 |
-
|
1660 |
-
if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) {
|
1661 |
-
$value = ( isset( $field_data[ 'value' . $i ] ) && '' !== $field_data[ 'value' . $i ] ) ? $field_data[ 'value' . $i ] : $default;
|
1662 |
-
} else {
|
1663 |
-
$value = isset( $field_data[ 'value' . $i ] ) ? $field_data[ 'value' . $i ] : $default;
|
1664 |
-
}
|
1665 |
-
|
1666 |
-
$value = is_string( $value ) ? stripslashes( $value ) : $value;
|
1667 |
-
|
1668 |
-
return $value;
|
1669 |
-
}
|
1670 |
-
}
|
1671 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Forms
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Forms {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var bool
|
20 |
+
*/
|
21 |
+
var $form_data;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Admin_Forms constructor.
|
26 |
+
* @param bool $form_data
|
27 |
+
*/
|
28 |
+
function __construct( $form_data = false ) {
|
29 |
+
if ( $form_data ) {
|
30 |
+
$this->form_data = $form_data;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Set Form Data
|
37 |
+
*
|
38 |
+
* @param $data
|
39 |
+
*
|
40 |
+
* @return $this
|
41 |
+
*/
|
42 |
+
function set_data( $data ) {
|
43 |
+
$this->form_data = $data;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Render form
|
50 |
+
*
|
51 |
+
*
|
52 |
+
* @param bool $echo
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
function render_form( $echo = true ) {
|
56 |
+
|
57 |
+
if ( empty( $this->form_data['fields'] ) ) {
|
58 |
+
return '';
|
59 |
+
}
|
60 |
+
|
61 |
+
$class = 'form-table um-form-table ' . ( ! empty( $this->form_data['class'] ) ? $this->form_data['class'] : '' );
|
62 |
+
$class_attr = ' class="' . $class . '" ';
|
63 |
+
|
64 |
+
ob_start();
|
65 |
+
|
66 |
+
foreach ( $this->form_data['fields'] as $field_data ) {
|
67 |
+
if ( isset( $field_data['type'] ) && 'hidden' == $field_data['type'] ) {
|
68 |
+
echo $this->render_form_row( $field_data );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( empty( $this->form_data['without_wrapper'] ) ) { ?>
|
73 |
+
|
74 |
+
<table <?php echo $class_attr ?>>
|
75 |
+
<tbody>
|
76 |
+
|
77 |
+
<?php }
|
78 |
+
|
79 |
+
foreach ( $this->form_data['fields'] as $field_data ) {
|
80 |
+
if ( isset( $field_data['type'] ) && 'hidden' != $field_data['type'] ) {
|
81 |
+
echo $this->render_form_row( $field_data );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
if ( empty( $this->form_data['without_wrapper'] ) ) { ?>
|
86 |
+
|
87 |
+
</tbody>
|
88 |
+
</table>
|
89 |
+
|
90 |
+
<?php }
|
91 |
+
|
92 |
+
if ( $echo ) {
|
93 |
+
ob_get_flush();
|
94 |
+
return '';
|
95 |
+
} else {
|
96 |
+
return ob_get_clean();
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param array $data
|
103 |
+
*
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
function render_form_row( $data ) {
|
107 |
+
|
108 |
+
if ( empty( $data['type'] ) ) {
|
109 |
+
return '';
|
110 |
+
}
|
111 |
+
|
112 |
+
if ( !empty( $data['value'] ) && $data['type'] != 'email_template' ) {
|
113 |
+
$data['value'] = wp_unslash( $data['value'] );
|
114 |
+
|
115 |
+
/*for multi_text*/
|
116 |
+
if ( ! is_array( $data['value'] ) && $data['type'] != 'wp_editor' ) {
|
117 |
+
$data['value'] = esc_attr( $data['value'] );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
$conditional = ! empty( $data['conditional'] ) ? 'data-conditional="' . esc_attr( json_encode( $data['conditional'] ) ) . '"' : '';
|
122 |
+
$prefix_attr = ! empty( $this->form_data['prefix_id'] ) ? ' data-prefix="' . esc_attr( $this->form_data['prefix_id'] ) . '" ' : '';
|
123 |
+
|
124 |
+
$type_attr = ' data-field_type="' . esc_attr( $data['type'] ) . '" ';
|
125 |
+
|
126 |
+
$html = '';
|
127 |
+
if ( $data['type'] != 'hidden' ) {
|
128 |
+
|
129 |
+
if ( ! empty( $this->form_data['div_line'] ) ) {
|
130 |
+
|
131 |
+
if ( strpos( $this->form_data['class'], 'um-top-label' ) !== false ) {
|
132 |
+
|
133 |
+
$html .= '<div class="form-field um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>' . $this->render_field_label( $data );
|
134 |
+
|
135 |
+
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
136 |
+
|
137 |
+
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
138 |
+
|
139 |
+
} else {
|
140 |
+
|
141 |
+
$html .= $this->render_field_by_hook( $data );
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
if ( ! empty( $data['description'] ) )
|
146 |
+
$html .= '<p class="description">' . $data['description'] . '</p>';
|
147 |
+
|
148 |
+
$html .= '</div>';
|
149 |
+
|
150 |
+
} else {
|
151 |
+
|
152 |
+
if ( ! empty( $data['without_label'] ) ) {
|
153 |
+
|
154 |
+
$html .= '<div class="form-field um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>';
|
155 |
+
|
156 |
+
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
157 |
+
|
158 |
+
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
159 |
+
|
160 |
+
} else {
|
161 |
+
|
162 |
+
$html .= $this->render_field_by_hook( $data );
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( ! empty( $data['description'] ) )
|
167 |
+
$html .= '<p class="description">' . $data['description'] . '</p>';
|
168 |
+
|
169 |
+
$html .= '</div>';
|
170 |
+
|
171 |
+
} else {
|
172 |
+
|
173 |
+
$html .= '<div class="form-field um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>' . $this->render_field_label( $data );
|
174 |
+
|
175 |
+
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
176 |
+
|
177 |
+
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
178 |
+
|
179 |
+
} else {
|
180 |
+
|
181 |
+
$html .= $this->render_field_by_hook( $data );
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
if ( ! empty( $data['description'] ) )
|
186 |
+
$html .= '<p class="description">' . $data['description'] . '</p>';
|
187 |
+
|
188 |
+
$html .= '</div>';
|
189 |
+
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
} else {
|
194 |
+
if ( strpos( $this->form_data['class'], 'um-top-label' ) !== false ) {
|
195 |
+
|
196 |
+
$html .= '<tr class="um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>
|
197 |
+
<td>' . $this->render_field_label( $data );
|
198 |
+
|
199 |
+
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
200 |
+
|
201 |
+
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
202 |
+
|
203 |
+
} else {
|
204 |
+
|
205 |
+
$html .= $this->render_field_by_hook( $data );
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( ! empty( $data['description'] ) )
|
210 |
+
$html .= '<div class="um-admin-clear"></div><p class="description">' . $data['description'] . '</p>';
|
211 |
+
|
212 |
+
$html .= '</td></tr>';
|
213 |
+
|
214 |
+
} else {
|
215 |
+
|
216 |
+
if ( ! empty( $data['without_label'] ) ) {
|
217 |
+
|
218 |
+
$html .= '<tr class="um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>
|
219 |
+
<td colspan="2">';
|
220 |
+
|
221 |
+
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
222 |
+
|
223 |
+
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
224 |
+
|
225 |
+
} else {
|
226 |
+
|
227 |
+
$html .= $this->render_field_by_hook( $data );
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
if ( ! empty( $data['description'] ) )
|
232 |
+
$html .= '<div class="um-admin-clear"></div><p class="description">' . $data['description'] . '</p>';
|
233 |
+
|
234 |
+
$html .= '</td></tr>';
|
235 |
+
|
236 |
+
} else {
|
237 |
+
|
238 |
+
$html .= '<tr class="um-forms-line" ' . $conditional . $prefix_attr . $type_attr . '>
|
239 |
+
<th>' . $this->render_field_label( $data ) . '</th>
|
240 |
+
<td>';
|
241 |
+
|
242 |
+
if ( method_exists( $this, 'render_' . $data['type'] ) ) {
|
243 |
+
|
244 |
+
$html .= call_user_func( array( &$this, 'render_' . $data['type'] ), $data );
|
245 |
+
|
246 |
+
} else {
|
247 |
+
|
248 |
+
$html .= $this->render_field_by_hook( $data );
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
if ( ! empty( $data['description'] ) )
|
253 |
+
$html .= '<div class="um-admin-clear"></div><p class="description">' . $data['description'] . '</p>';
|
254 |
+
|
255 |
+
$html .= '</td></tr>';
|
256 |
+
|
257 |
+
}
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
} else {
|
262 |
+
$html .= $this->render_hidden( $data );
|
263 |
+
}
|
264 |
+
|
265 |
+
return $html;
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
/**
|
270 |
+
* @param $data
|
271 |
+
*
|
272 |
+
* @return mixed|void
|
273 |
+
*/
|
274 |
+
function render_field_by_hook( $data ) {
|
275 |
+
/**
|
276 |
+
* UM hook
|
277 |
+
*
|
278 |
+
* @type filter
|
279 |
+
* @title um_render_field_type_{$type}
|
280 |
+
* @description Render admin form field by hook
|
281 |
+
* @input_vars
|
282 |
+
* [{"var":"$html","type":"string","desc":"Field's HTML"},
|
283 |
+
* {"var":"$data","type":"array","desc":"Field's data"},
|
284 |
+
* {"var":"$form_data","type":"array","desc":"Form data"},
|
285 |
+
* {"var":"$admin_form","type":"object","desc":"Admin_Forms class object"}]
|
286 |
+
* @change_log
|
287 |
+
* ["Since: 2.0"]
|
288 |
+
* @usage add_filter( 'um_render_field_type_{$type}', 'function_name', 10, 4 );
|
289 |
+
* @example
|
290 |
+
* <?php
|
291 |
+
* add_filter( 'um_render_field_type_{$type}', 'my_render_field_type', 10, 4 );
|
292 |
+
* function my_render_field_type( $html, $data, $form_data, $admin_form ) {
|
293 |
+
* // your code here
|
294 |
+
* return $html;
|
295 |
+
* }
|
296 |
+
* ?>
|
297 |
+
*/
|
298 |
+
return apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data, $this );
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
/**
|
303 |
+
* @param $data
|
304 |
+
*
|
305 |
+
* @return bool|string
|
306 |
+
*/
|
307 |
+
function render_field_label( $data ) {
|
308 |
+
if ( empty( $data['label'] ) ) {
|
309 |
+
return false;
|
310 |
+
}
|
311 |
+
|
312 |
+
$id = ! empty( $data['id1'] ) ? $data['id1'] : $data['id'];
|
313 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $id;
|
314 |
+
$for_attr = ' for="' . esc_attr( $id ) . '" ';
|
315 |
+
|
316 |
+
$label = $data['label'];
|
317 |
+
if ( isset( $data['required'] ) && $data['required'] ) {
|
318 |
+
$label = $label . '<span class="um-req" title="' . esc_attr__( 'Required', 'ultimate-member' ) . '">*</span>';
|
319 |
+
}
|
320 |
+
|
321 |
+
$tooltip = ! empty( $data['tooltip'] ) ? UM()->tooltip( $data['tooltip'], false, false ) : '';
|
322 |
+
|
323 |
+
return "<label $for_attr>$label $tooltip</label>";
|
324 |
+
}
|
325 |
+
|
326 |
+
|
327 |
+
/**
|
328 |
+
* @param $field_data
|
329 |
+
*
|
330 |
+
* @return bool|string
|
331 |
+
*/
|
332 |
+
function render_hidden( $field_data ) {
|
333 |
+
|
334 |
+
if ( empty( $field_data['id'] ) ) {
|
335 |
+
return '';
|
336 |
+
}
|
337 |
+
|
338 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
339 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
340 |
+
|
341 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
342 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
343 |
+
|
344 |
+
$data = array(
|
345 |
+
'field_id' => $field_data['id']
|
346 |
+
);
|
347 |
+
|
348 |
+
$data_attr = '';
|
349 |
+
foreach ( $data as $key => $value ) {
|
350 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
351 |
+
}
|
352 |
+
|
353 |
+
$name = $field_data['id'];
|
354 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
355 |
+
$name_attr = ' name="' . $name . '" ';
|
356 |
+
|
357 |
+
$value = $this->get_field_value( $field_data );
|
358 |
+
$value_attr = ' value="' . $value . '" ';
|
359 |
+
|
360 |
+
$html = "<input type=\"hidden\" $id_attr $class_attr $name_attr $data_attr $value_attr />";
|
361 |
+
|
362 |
+
return $html;
|
363 |
+
}
|
364 |
+
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Render text field
|
368 |
+
*
|
369 |
+
* @param $field_data
|
370 |
+
*
|
371 |
+
* @return bool|string
|
372 |
+
*/
|
373 |
+
function render_text( $field_data ) {
|
374 |
+
|
375 |
+
if ( empty( $field_data['id'] ) ) {
|
376 |
+
return false;
|
377 |
+
}
|
378 |
+
|
379 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
380 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
381 |
+
|
382 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
383 |
+
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
384 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
385 |
+
|
386 |
+
$data = array(
|
387 |
+
'field_id' => $field_data['id']
|
388 |
+
);
|
389 |
+
|
390 |
+
if ( ! empty( $field_data['attr'] ) && is_array( $field_data['attr'] ) ){
|
391 |
+
$data = array_merge( $data, $field_data['attr'] );
|
392 |
+
}
|
393 |
+
|
394 |
+
$data_attr = '';
|
395 |
+
foreach ( $data as $key => $value ) {
|
396 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
397 |
+
}
|
398 |
+
|
399 |
+
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
400 |
+
|
401 |
+
$name = $field_data['id'];
|
402 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
403 |
+
$name_attr = ' name="' . $name . '" ';
|
404 |
+
|
405 |
+
$value = $this->get_field_value( $field_data );
|
406 |
+
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
407 |
+
|
408 |
+
$html = "<input type=\"text\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
409 |
+
|
410 |
+
return $html;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Render text field
|
416 |
+
*
|
417 |
+
* @param $field_data
|
418 |
+
*
|
419 |
+
* @return bool|string
|
420 |
+
*/
|
421 |
+
function render_number( $field_data ) {
|
422 |
+
|
423 |
+
if ( empty( $field_data['id'] ) ) {
|
424 |
+
return false;
|
425 |
+
}
|
426 |
+
|
427 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
428 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
429 |
+
|
430 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
431 |
+
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
432 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
433 |
+
|
434 |
+
$data = array(
|
435 |
+
'field_id' => $field_data['id']
|
436 |
+
);
|
437 |
+
|
438 |
+
if ( ! empty( $field_data['attr'] ) && is_array( $field_data['attr'] ) ){
|
439 |
+
$data = array_merge( $data, $field_data['attr'] );
|
440 |
+
}
|
441 |
+
|
442 |
+
$data_attr = '';
|
443 |
+
foreach ( $data as $key => $value ) {
|
444 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
445 |
+
}
|
446 |
+
|
447 |
+
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
448 |
+
|
449 |
+
$name = $field_data['id'];
|
450 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
451 |
+
$name_attr = ' name="' . $name . '" ';
|
452 |
+
|
453 |
+
$value = $this->get_field_value( $field_data );
|
454 |
+
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
455 |
+
|
456 |
+
$html = "<input type=\"number\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
457 |
+
|
458 |
+
return $html;
|
459 |
+
}
|
460 |
+
|
461 |
+
|
462 |
+
/**
|
463 |
+
* @param $field_data
|
464 |
+
*
|
465 |
+
* @return bool|string
|
466 |
+
*/
|
467 |
+
function render_color( $field_data ) {
|
468 |
+
|
469 |
+
if ( empty( $field_data['id'] ) ) {
|
470 |
+
return false;
|
471 |
+
}
|
472 |
+
|
473 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
474 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
475 |
+
|
476 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
477 |
+
$class .= ! empty( $field_data['size'] ) ? ' um-' . $field_data['size'] . '-field ' : ' um-long-field ';
|
478 |
+
$class .= ' um-admin-colorpicker ';
|
479 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
480 |
+
|
481 |
+
$data = array(
|
482 |
+
'field_id' => $field_data['id']
|
483 |
+
);
|
484 |
+
|
485 |
+
$data_attr = '';
|
486 |
+
foreach ( $data as $key => $value ) {
|
487 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
488 |
+
}
|
489 |
+
|
490 |
+
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
491 |
+
|
492 |
+
$name = $field_data['id'];
|
493 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
494 |
+
$name_attr = ' name="' . $name . '" ';
|
495 |
+
|
496 |
+
$value = $this->get_field_value( $field_data );
|
497 |
+
$value_attr = ' value="' . $value . '" ';
|
498 |
+
|
499 |
+
$html = "<input type=\"text\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
500 |
+
|
501 |
+
return $html;
|
502 |
+
}
|
503 |
+
|
504 |
+
|
505 |
+
/**
|
506 |
+
* @param $field_data
|
507 |
+
*
|
508 |
+
* @return bool|string
|
509 |
+
*/
|
510 |
+
function render_icon( $field_data ) {
|
511 |
+
|
512 |
+
if ( empty( $field_data['id'] ) ) {
|
513 |
+
return false;
|
514 |
+
}
|
515 |
+
|
516 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
517 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
518 |
+
|
519 |
+
$name = $field_data['id'];
|
520 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
521 |
+
$name_attr = ' name="' . $name . '" ';
|
522 |
+
|
523 |
+
$value = $this->get_field_value( $field_data );
|
524 |
+
$value_attr = ' value="' . $value . '" ';
|
525 |
+
|
526 |
+
$html = '<span class="um_admin_fonticon_wrapper"><a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="">' . __( 'Choose Icon', 'ultimate-member' ) . '</a>
|
527 |
+
<span class="um-admin-icon-value">';
|
528 |
+
|
529 |
+
if ( ! empty( $value ) ) {
|
530 |
+
$html .= '<i class="' . $value . '"></i>';
|
531 |
+
} else {
|
532 |
+
$html .= __( 'No Icon', 'ultimate-member' );
|
533 |
+
}
|
534 |
+
|
535 |
+
$html .= '</span><input type="hidden" ' . $name_attr . ' ' . $id_attr . ' ' . $value_attr . ' />';
|
536 |
+
|
537 |
+
if ( ! empty( $value ) ) {
|
538 |
+
$html .= '<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>';
|
539 |
+
} else {
|
540 |
+
$html .= '<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>';
|
541 |
+
}
|
542 |
+
|
543 |
+
$html .= '</span></span>';
|
544 |
+
|
545 |
+
UM()->metabox()->init_icon = true;
|
546 |
+
|
547 |
+
return $html;
|
548 |
+
}
|
549 |
+
|
550 |
+
|
551 |
+
/**
|
552 |
+
* @param $field_data
|
553 |
+
*
|
554 |
+
* @return bool|string
|
555 |
+
*/
|
556 |
+
function render_users_dropdown( $field_data ) {
|
557 |
+
if ( empty( $field_data['id'] ) ) {
|
558 |
+
return false;
|
559 |
+
}
|
560 |
+
|
561 |
+
$multiple = ! empty( $field_data['multi'] ) ? 'multiple' : '';
|
562 |
+
|
563 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
564 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
565 |
+
|
566 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] . ' ' : ' ';
|
567 |
+
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
568 |
+
$class_attr = ' class="um-forms-field um-user-select-field' . esc_attr( $class ) . '" ';
|
569 |
+
|
570 |
+
$data = array(
|
571 |
+
'field_id' => $field_data['id'],
|
572 |
+
);
|
573 |
+
|
574 |
+
$data_attr = '';
|
575 |
+
foreach ( $data as $key => $value ) {
|
576 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
577 |
+
}
|
578 |
+
|
579 |
+
$name = $field_data['id'];
|
580 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
581 |
+
$hidden_name_attr = ' name="' . $name . '" ';
|
582 |
+
$name = $name . ( ! empty( $field_data['multi'] ) ? '[]' : '' );
|
583 |
+
$name_attr = ' name="' . $name . '" ';
|
584 |
+
|
585 |
+
$value = $this->get_field_value( $field_data );
|
586 |
+
|
587 |
+
$users = array();
|
588 |
+
if ( ! empty( $value ) ) {
|
589 |
+
$users = get_users(
|
590 |
+
array(
|
591 |
+
'include' => $value,
|
592 |
+
'fields' => array( 'ID', 'user_login' ),
|
593 |
+
)
|
594 |
+
);
|
595 |
+
}
|
596 |
+
|
597 |
+
$options = '';
|
598 |
+
if ( ! empty( $users ) ) {
|
599 |
+
foreach ( $users as $user ) {
|
600 |
+
$options .= '<option value="' . esc_attr( $user->ID ) . '" selected>' . esc_html( $user->user_login . ' (#' . $user->ID . ')' ) . '</option>';
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
$hidden = '';
|
605 |
+
if ( ! empty( $multiple ) ) {
|
606 |
+
$hidden = "<input type=\"hidden\" $hidden_name_attr value=\"\" />";
|
607 |
+
}
|
608 |
+
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr data-placeholder=\"" . esc_attr__( 'Select Users', 'ultimate-member' ) . "\" placeholder=\"" . esc_attr__( 'Select Users', 'ultimate-member' ) . "\"><option>" . esc_html__( 'Select Users', 'ultimate-member' ) . "</option>$options</select>";
|
609 |
+
|
610 |
+
return $html;
|
611 |
+
}
|
612 |
+
|
613 |
+
|
614 |
+
/**
|
615 |
+
* @param $field_data
|
616 |
+
*
|
617 |
+
* @return bool|string
|
618 |
+
*/
|
619 |
+
function render_sortable_items( $field_data ) {
|
620 |
+
if ( empty( $field_data['id'] ) ) {
|
621 |
+
return false;
|
622 |
+
}
|
623 |
+
|
624 |
+
if ( empty( $field_data['items'] ) ) {
|
625 |
+
return false;
|
626 |
+
}
|
627 |
+
|
628 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
629 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
630 |
+
|
631 |
+
$size = ! empty( $field_data['size'] ) ? ' um-' . $field_data['size'] . '-field ' : ' um-long-field';
|
632 |
+
|
633 |
+
$name = $field_data['id'];
|
634 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
635 |
+
$name_attr = ' name="' . $name . '" ';
|
636 |
+
|
637 |
+
$value = $this->get_field_value( $field_data );
|
638 |
+
$value_attr = ' value="' . $value . '" ';
|
639 |
+
|
640 |
+
$data = array(
|
641 |
+
'field_id' => $field_data['id']
|
642 |
+
);
|
643 |
+
|
644 |
+
$data_attr = '';
|
645 |
+
foreach ( $data as $key => $val ) {
|
646 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $val ) . '" ';
|
647 |
+
}
|
648 |
+
|
649 |
+
$html = '<input class="um-sortable-items-value" type="hidden" ' . $name_attr . ' ' . $id_attr . ' ' . $value_attr . ' ' . $data_attr . ' />';
|
650 |
+
$html .= '<ul class="um-sortable-items-field' . esc_attr( $size ) . '">';
|
651 |
+
|
652 |
+
if ( ! empty( $value ) ) {
|
653 |
+
$value_array = explode( ',', $value );
|
654 |
+
uksort( $field_data['items'], function( $a, $b ) use ( $value_array ) {
|
655 |
+
|
656 |
+
$arr_flip = array_flip( $value_array );
|
657 |
+
|
658 |
+
if ( ! isset( $arr_flip[ $b ] ) ) {
|
659 |
+
return 1;
|
660 |
+
}
|
661 |
+
|
662 |
+
if ( ! isset( $arr_flip[ $a ] ) ) {
|
663 |
+
return -1;
|
664 |
+
}
|
665 |
+
|
666 |
+
if ( $arr_flip[ $a ] == $arr_flip[ $b ] ) {
|
667 |
+
return 0;
|
668 |
+
}
|
669 |
+
|
670 |
+
return ( $arr_flip[ $a ] < $arr_flip[ $b ] ) ? -1 : 1;
|
671 |
+
} );
|
672 |
+
}
|
673 |
+
|
674 |
+
foreach ( $field_data['items'] as $tab_id => $tab_name ) {
|
675 |
+
$content = apply_filters( 'um_render_sortable_items_item_html', $tab_name, $tab_id, $field_data );
|
676 |
+
$html .= '<li data-tab-id="' . esc_attr( $tab_id ) . '" class="um-sortable-item"><span class="um-field-icon"><i class="um-faicon-sort"></i></span>' . $content . '</li>';
|
677 |
+
}
|
678 |
+
|
679 |
+
$html .= '</ul>';
|
680 |
+
|
681 |
+
return $html;
|
682 |
+
}
|
683 |
+
|
684 |
+
|
685 |
+
/**
|
686 |
+
* @param $field_data
|
687 |
+
*
|
688 |
+
* @return bool|string
|
689 |
+
*/
|
690 |
+
function render_datepicker( $field_data ) {
|
691 |
+
|
692 |
+
if ( empty( $field_data['id'] ) ) {
|
693 |
+
return false;
|
694 |
+
}
|
695 |
+
|
696 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
697 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
698 |
+
|
699 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
700 |
+
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
701 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
702 |
+
|
703 |
+
$data = array(
|
704 |
+
'field_id' => $field_data['id']
|
705 |
+
);
|
706 |
+
|
707 |
+
$data_attr = '';
|
708 |
+
foreach ( $data as $key => $value ) {
|
709 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
710 |
+
}
|
711 |
+
|
712 |
+
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
713 |
+
|
714 |
+
$name = $field_data['id'];
|
715 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
716 |
+
$name_attr = ' name="' . $name . '" ';
|
717 |
+
|
718 |
+
$value = $this->get_field_value( $field_data );
|
719 |
+
$value_attr = ' value="' . $value . '" ';
|
720 |
+
|
721 |
+
$html = "<input type=\"date\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
722 |
+
|
723 |
+
return $html;
|
724 |
+
}
|
725 |
+
|
726 |
+
|
727 |
+
/**
|
728 |
+
* @param $field_data
|
729 |
+
*
|
730 |
+
* @return bool|string
|
731 |
+
*/
|
732 |
+
function render_inline_texts( $field_data ) {
|
733 |
+
|
734 |
+
if ( empty( $field_data['id1'] ) ) {
|
735 |
+
return false;
|
736 |
+
}
|
737 |
+
|
738 |
+
$i = 1;
|
739 |
+
$fields = array();
|
740 |
+
while( ! empty( $field_data['id' . $i] ) ) {
|
741 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'. $i];
|
742 |
+
$id_attr = ' id="' . $id . '" ';
|
743 |
+
|
744 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
745 |
+
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
746 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
747 |
+
|
748 |
+
$data = array(
|
749 |
+
'field_id' => $field_data[ 'id'. $i ]
|
750 |
+
);
|
751 |
+
|
752 |
+
$data_attr = '';
|
753 |
+
foreach ( $data as $key => $value ) {
|
754 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
755 |
+
}
|
756 |
+
|
757 |
+
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . $field_data['placeholder'] . '"' : '';
|
758 |
+
|
759 |
+
$name = $field_data[ 'id'. $i ];
|
760 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
761 |
+
$name_attr = ' name="' . $name . '" ';
|
762 |
+
|
763 |
+
$value = $this->get_field_value( $field_data, $i );
|
764 |
+
|
765 |
+
$value_attr = ' value="' . $value . '" ';
|
766 |
+
|
767 |
+
$fields[$i] = "<input type=\"text\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr style=\"display:inline;\"/>";
|
768 |
+
|
769 |
+
$i++;
|
770 |
+
}
|
771 |
+
|
772 |
+
$html = vsprintf( $field_data['mask'], $fields );
|
773 |
+
|
774 |
+
return $html;
|
775 |
+
}
|
776 |
+
|
777 |
+
|
778 |
+
/**
|
779 |
+
* @param $field_data
|
780 |
+
*
|
781 |
+
* @return bool|string
|
782 |
+
*/
|
783 |
+
function render_textarea( $field_data ) {
|
784 |
+
|
785 |
+
if ( empty( $field_data['id'] ) ) {
|
786 |
+
return false;
|
787 |
+
}
|
788 |
+
|
789 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
790 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
791 |
+
|
792 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
793 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
794 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
795 |
+
|
796 |
+
$data = array(
|
797 |
+
'field_id' => $field_data['id']
|
798 |
+
);
|
799 |
+
|
800 |
+
$data_attr = '';
|
801 |
+
foreach ( $data as $key => $value ) {
|
802 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
803 |
+
}
|
804 |
+
|
805 |
+
$rows = ! empty( $field_data['args']['textarea_rows'] ) ? ' rows="' . $field_data['args']['textarea_rows'] . '" ' : '';
|
806 |
+
|
807 |
+
$name = $field_data['id'];
|
808 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
809 |
+
$name_attr = ' name="' . $name . '" ';
|
810 |
+
|
811 |
+
$value = $this->get_field_value( $field_data );
|
812 |
+
|
813 |
+
$html = "<textarea $id_attr $class_attr $name_attr $data_attr $rows>$value</textarea>";
|
814 |
+
|
815 |
+
return $html;
|
816 |
+
}
|
817 |
+
|
818 |
+
|
819 |
+
/**
|
820 |
+
* @param $field_data
|
821 |
+
*
|
822 |
+
* @return bool|string
|
823 |
+
*/
|
824 |
+
function render_wp_editor( $field_data ) {
|
825 |
+
|
826 |
+
if ( empty( $field_data['id'] ) ) {
|
827 |
+
return false;
|
828 |
+
}
|
829 |
+
|
830 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
831 |
+
|
832 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
833 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
834 |
+
|
835 |
+
$data = array(
|
836 |
+
'field_id' => $field_data['id']
|
837 |
+
);
|
838 |
+
|
839 |
+
$data_attr = '';
|
840 |
+
foreach ( $data as $key => $value ) {
|
841 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
842 |
+
}
|
843 |
+
|
844 |
+
$name = $field_data['id'];
|
845 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
846 |
+
|
847 |
+
$value = $this->get_field_value( $field_data );
|
848 |
+
|
849 |
+
ob_start();
|
850 |
+
wp_editor( $value,
|
851 |
+
$id,
|
852 |
+
array(
|
853 |
+
'textarea_name' => $name,
|
854 |
+
'textarea_rows' => 20,
|
855 |
+
'editor_height' => 425,
|
856 |
+
'wpautop' => false,
|
857 |
+
'media_buttons' => false,
|
858 |
+
'editor_class' => $class
|
859 |
+
)
|
860 |
+
);
|
861 |
+
|
862 |
+
$html = ob_get_clean();
|
863 |
+
return $html;
|
864 |
+
}
|
865 |
+
|
866 |
+
|
867 |
+
/**
|
868 |
+
* @param $field_data
|
869 |
+
*
|
870 |
+
* @return bool|string
|
871 |
+
*/
|
872 |
+
function render_checkbox( $field_data ) {
|
873 |
+
|
874 |
+
if ( empty( $field_data['id'] ) )
|
875 |
+
return false;
|
876 |
+
|
877 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
878 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
879 |
+
$id_attr_hidden = ' id="' . esc_attr( $id ) . '_hidden" ';
|
880 |
+
|
881 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
882 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
883 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
884 |
+
|
885 |
+
$data = array(
|
886 |
+
'field_id' => $field_data['id']
|
887 |
+
);
|
888 |
+
|
889 |
+
if ( ! empty( $field_data['data'] ) ) {
|
890 |
+
$data = array_merge( $data, $field_data['data'] );
|
891 |
+
}
|
892 |
+
|
893 |
+
$data_attr = '';
|
894 |
+
foreach ( $data as $key => $value ) {
|
895 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
896 |
+
}
|
897 |
+
|
898 |
+
$name = $field_data['id'];
|
899 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
900 |
+
$name_attr = ' name="' . $name . '" ';
|
901 |
+
|
902 |
+
$value = $this->get_field_value( $field_data );
|
903 |
+
|
904 |
+
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" />
|
905 |
+
<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" />";
|
906 |
+
|
907 |
+
|
908 |
+
return $html;
|
909 |
+
}
|
910 |
+
|
911 |
+
|
912 |
+
/**
|
913 |
+
* @param $field_data
|
914 |
+
*
|
915 |
+
* @return bool|string
|
916 |
+
*/
|
917 |
+
function render_same_page_update( $field_data ) {
|
918 |
+
|
919 |
+
if ( empty( $field_data['id'] ) ) {
|
920 |
+
return false;
|
921 |
+
}
|
922 |
+
|
923 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
924 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
925 |
+
$id_attr_hidden = ' id="' . esc_attr( $id ) . '_hidden" ';
|
926 |
+
|
927 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
928 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
929 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
930 |
+
|
931 |
+
$data = array(
|
932 |
+
'field_id' => $field_data['id']
|
933 |
+
);
|
934 |
+
|
935 |
+
if ( ! empty( $field_data['data'] ) ) {
|
936 |
+
$data = array_merge( $data, $field_data['data'] );
|
937 |
+
}
|
938 |
+
|
939 |
+
$data_attr = '';
|
940 |
+
foreach ( $data as $key => $value ) {
|
941 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
942 |
+
}
|
943 |
+
|
944 |
+
if ( ! empty( $field_data['upgrade_cb'] ) ) {
|
945 |
+
$data_attr .= ' data-log-object="' . esc_attr( $field_data['upgrade_cb'] ) . '" ';
|
946 |
+
}
|
947 |
+
|
948 |
+
$name = $field_data['id'];
|
949 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
950 |
+
$name_attr = ' name="' . $name . '" ';
|
951 |
+
|
952 |
+
$value = $this->get_field_value( $field_data );
|
953 |
+
|
954 |
+
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" />
|
955 |
+
<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" />";
|
956 |
+
|
957 |
+
if ( ! empty( $field_data['upgrade_cb'] ) ) {
|
958 |
+
$html .= '<div class="um-same-page-update-wrapper um-same-page-update-' . esc_attr( $field_data['upgrade_cb'] ) . '"><div class="um-same-page-update-description">' . $field_data['upgrade_description'] . '</div><input type="button" data-upgrade_cb="' . $field_data['upgrade_cb'] . '" class="button button-primary um-admin-form-same-page-update" value="' . esc_attr__( 'Run', 'ultimate-member' ) . '"/>
|
959 |
+
<div class="upgrade_log"></div></div>';
|
960 |
+
}
|
961 |
+
|
962 |
+
return $html;
|
963 |
+
}
|
964 |
+
|
965 |
+
|
966 |
+
/**
|
967 |
+
* @param $field_data
|
968 |
+
*
|
969 |
+
* @return bool|string
|
970 |
+
*/
|
971 |
+
function render_select( $field_data ) {
|
972 |
+
|
973 |
+
if ( empty( $field_data['id'] ) ) {
|
974 |
+
return false;
|
975 |
+
}
|
976 |
+
|
977 |
+
$multiple = ! empty( $field_data['multi'] ) ? 'multiple' : '';
|
978 |
+
|
979 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
980 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
981 |
+
|
982 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] . ' ' : ' ';
|
983 |
+
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
984 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
985 |
+
|
986 |
+
$data = array(
|
987 |
+
'field_id' => $field_data['id']
|
988 |
+
);
|
989 |
+
|
990 |
+
$data_attr = '';
|
991 |
+
foreach ( $data as $key => $value ) {
|
992 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
993 |
+
}
|
994 |
+
|
995 |
+
$name = $field_data['id'];
|
996 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
997 |
+
$hidden_name_attr = ' name="' . $name . '" ';
|
998 |
+
$name = $name . ( ! empty( $field_data['multi'] ) ? '[]' : '' );
|
999 |
+
$name_attr = ' name="' . $name . '" ';
|
1000 |
+
|
1001 |
+
$value = $this->get_field_value( $field_data );
|
1002 |
+
|
1003 |
+
$options = '';
|
1004 |
+
if ( ! empty( $field_data['options'] ) ) {
|
1005 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1006 |
+
if ( ! empty( $field_data['multi'] ) ) {
|
1007 |
+
|
1008 |
+
if ( ! is_array( $value ) || empty( $value ) ) {
|
1009 |
+
$value = array();
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
$options .= '<option value="' . $key . '" ' . selected( in_array( $key, $value ), true, false ) . '>' . esc_html( $option ) . '</option>';
|
1013 |
+
} else {
|
1014 |
+
$options .= '<option value="' . $key . '" ' . selected( (string)$key == $value, true, false ) . '>' . esc_html( $option ) . '</option>';
|
1015 |
+
}
|
1016 |
+
}
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
$hidden = '';
|
1020 |
+
if ( ! empty( $multiple ) ) {
|
1021 |
+
$hidden = "<input type=\"hidden\" $hidden_name_attr value=\"\" />";
|
1022 |
+
}
|
1023 |
+
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr>$options</select>";
|
1024 |
+
|
1025 |
+
return $html;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
|
1029 |
+
/**
|
1030 |
+
* @param $field_data
|
1031 |
+
*
|
1032 |
+
* @return bool|string
|
1033 |
+
*/
|
1034 |
+
function render_multi_selects( $field_data ) {
|
1035 |
+
|
1036 |
+
if ( empty( $field_data['id'] ) ) {
|
1037 |
+
return false;
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1041 |
+
|
1042 |
+
$sorting = ! empty( $field_data['sorting'] ) ? $field_data['sorting'] : false;
|
1043 |
+
|
1044 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1045 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1046 |
+
$class .= ! empty( $sorting ) ? 'um-sorting-enabled' : '';
|
1047 |
+
$class_attr = ' class="um-forms-field ' . $class . '" ';
|
1048 |
+
|
1049 |
+
$data = array(
|
1050 |
+
'field_id' => $field_data['id'],
|
1051 |
+
'id_attr' => $id
|
1052 |
+
);
|
1053 |
+
|
1054 |
+
$data_attr = '';
|
1055 |
+
foreach ( $data as $key => $value ) {
|
1056 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
$name = $field_data['id'];
|
1060 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1061 |
+
$name = "{$name}[]";
|
1062 |
+
$name_attr = ' name="' . $name . '" ';
|
1063 |
+
|
1064 |
+
$values = $this->get_field_value( $field_data );
|
1065 |
+
|
1066 |
+
$options = '';
|
1067 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1068 |
+
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
$html = "<select class=\"um-hidden-multi-selects\" $data_attr>$options</select>";
|
1072 |
+
$html .= "<ul class=\"um-multi-selects-list" . ( ! empty( $sorting ) ? ' um-sortable-multi-selects' : '' ) . "\" $data_attr>";
|
1073 |
+
|
1074 |
+
if ( $sorting && is_array( $values ) ) {
|
1075 |
+
ksort( $values );
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
if ( ! empty( $values ) && is_array( $values ) ) {
|
1079 |
+
foreach ( $values as $k => $value ) {
|
1080 |
+
|
1081 |
+
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
|
1082 |
+
continue ;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1086 |
+
|
1087 |
+
$options = '';
|
1088 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1089 |
+
$options .= '<option value="' . $key . '" ' . selected( $key == $value, true, false ) . '>' . $option . '</option>';
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1093 |
+
if ( $sorting ) {
|
1094 |
+
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1095 |
+
}
|
1096 |
+
$html .= "<span class=\"um-field-wrapper\">
|
1097 |
+
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1098 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1099 |
+
}
|
1100 |
+
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1101 |
+
$i = 0;
|
1102 |
+
while ( $i < $field_data['show_default_number'] ) {
|
1103 |
+
$id_attr = ' id="' . $id . '-' . $i . '" ';
|
1104 |
+
|
1105 |
+
$options = '';
|
1106 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1107 |
+
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1111 |
+
if ( $sorting ) {
|
1112 |
+
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
$html .= "<span class=\"um-field-wrapper\">
|
1116 |
+
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1117 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1118 |
+
|
1119 |
+
$i++;
|
1120 |
+
}
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-multi-selects-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1124 |
+
|
1125 |
+
return $html;
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
|
1129 |
+
/**
|
1130 |
+
* @param $field_data
|
1131 |
+
*
|
1132 |
+
* @return bool|string
|
1133 |
+
*/
|
1134 |
+
function render_multi_checkbox( $field_data ) {
|
1135 |
+
|
1136 |
+
if ( empty( $field_data['id'] ) ) {
|
1137 |
+
return false;
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1141 |
+
|
1142 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1143 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1144 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
1145 |
+
|
1146 |
+
$name = $field_data['id'];
|
1147 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1148 |
+
|
1149 |
+
$values = $this->get_field_value( $field_data );
|
1150 |
+
if ( empty( $values ) ) {
|
1151 |
+
$values = array();
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
$i = 0;
|
1155 |
+
$html = '';
|
1156 |
+
|
1157 |
+
$columns = ( ! empty( $field_data['columns'] ) && is_numeric( $field_data['columns'] ) ) ? $field_data['columns'] : 1;
|
1158 |
+
while ( $i < $columns ) {
|
1159 |
+
$per_page = ceil( count( $field_data['options'] ) / $columns );
|
1160 |
+
$section_fields_per_page = array_slice( $field_data['options'], $i*$per_page, $per_page, true );
|
1161 |
+
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
|
1162 |
+
|
1163 |
+
foreach ( $section_fields_per_page as $k => $title ) {
|
1164 |
+
$id_attr = ' id="' . esc_attr( $id . '_' . $k ) . '" ';
|
1165 |
+
$for_attr = ' for="' . esc_attr( $id . '_' . $k ) . '" ';
|
1166 |
+
$name_attr = ' name="' . $name . '[' . $k . ']" ';
|
1167 |
+
|
1168 |
+
$data = array(
|
1169 |
+
'field_id' => $field_data['id'] . '_' . $k,
|
1170 |
+
);
|
1171 |
+
|
1172 |
+
if ( ! empty( $field_data['data'] ) ) {
|
1173 |
+
$data = array_merge( $data, $field_data['data'] );
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
$data_attr = '';
|
1177 |
+
foreach ( $data as $key => $value ) {
|
1178 |
+
if ( $value == 'checkbox_key' ) {
|
1179 |
+
$value = $k;
|
1180 |
+
}
|
1181 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
$html .= "<label $for_attr>
|
1185 |
+
<input type=\"checkbox\" " . checked( in_array( $k, $values ), true, false ) . "$id_attr $name_attr $data_attr value=\"1\" $class_attr>
|
1186 |
+
<span>$title</span>
|
1187 |
+
</label>";
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
$html .= '</span>';
|
1191 |
+
$i++;
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
return $html;
|
1195 |
+
}
|
1196 |
+
|
1197 |
+
|
1198 |
+
/**
|
1199 |
+
* @param $field_data
|
1200 |
+
*
|
1201 |
+
* @return bool|string
|
1202 |
+
*/
|
1203 |
+
function render_multi_text( $field_data ) {
|
1204 |
+
|
1205 |
+
if ( empty( $field_data['id'] ) ) {
|
1206 |
+
return false;
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1210 |
+
|
1211 |
+
$size = ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
|
1212 |
+
|
1213 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1214 |
+
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
1215 |
+
|
1216 |
+
$data = array(
|
1217 |
+
'field_id' => $field_data['id'],
|
1218 |
+
'id_attr' => $id,
|
1219 |
+
'item_class' => "um-multi-text-option-line {$size}",
|
1220 |
+
);
|
1221 |
+
|
1222 |
+
$data_attr = '';
|
1223 |
+
foreach ( $data as $key => $value ) {
|
1224 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
$name = $field_data['id'];
|
1228 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1229 |
+
$name = "{$name}[]";
|
1230 |
+
$name_attr = ' name="' . $name . '" ';
|
1231 |
+
|
1232 |
+
$values = $this->get_field_value( $field_data );
|
1233 |
+
|
1234 |
+
$html = "<input type=\"text\" class=\"um-hidden-multi-text\" $data_attr />";
|
1235 |
+
$html .= "<ul class=\"um-multi-text-list\" $data_attr>";
|
1236 |
+
|
1237 |
+
if ( ! empty( $values ) ) {
|
1238 |
+
foreach ( $values as $k => $value ) {
|
1239 |
+
$value = esc_attr( $value );
|
1240 |
+
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1241 |
+
|
1242 |
+
$html .= "<li class=\"um-multi-text-option-line {$size}\"><span class=\"um-field-wrapper\">
|
1243 |
+
<input type=\"text\" $id_attr $name_attr $class_attr $data_attr value=\"$value\" /></span>
|
1244 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-text-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1245 |
+
}
|
1246 |
+
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1247 |
+
$i = 0;
|
1248 |
+
while( $i < $field_data['show_default_number'] ) {
|
1249 |
+
$id_attr = ' id="' . esc_attr( $id . '-' . $i ) . '" ';
|
1250 |
+
|
1251 |
+
$html .= "<li class=\"um-multi-text-option-line {$size}\"><span class=\"um-field-wrapper\">
|
1252 |
+
<input type=\"text\" $id_attr $name_attr $class_attr $data_attr value=\"\" /></span>
|
1253 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-text-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1254 |
+
|
1255 |
+
$i++;
|
1256 |
+
}
|
1257 |
+
}
|
1258 |
+
|
1259 |
+
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-multi-text-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1260 |
+
|
1261 |
+
return $html;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
|
1265 |
+
/**
|
1266 |
+
* @param $field_data
|
1267 |
+
*
|
1268 |
+
* @return bool|string
|
1269 |
+
*/
|
1270 |
+
function render_media( $field_data ) {
|
1271 |
+
|
1272 |
+
if ( empty( $field_data['id'] ) ) {
|
1273 |
+
return false;
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1277 |
+
|
1278 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1279 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1280 |
+
$class_attr = ' class="um-forms-field um-media-upload-data-url ' . $class . '"';
|
1281 |
+
|
1282 |
+
$data = array(
|
1283 |
+
'field_id' => $field_data['id'] . '_url',
|
1284 |
+
);
|
1285 |
+
|
1286 |
+
if ( ! empty( $field_data['default']['url'] ) ) {
|
1287 |
+
$data['default'] = esc_attr( $field_data['default']['url'] );
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
$data_attr = '';
|
1291 |
+
foreach ( $data as $key => $value ) {
|
1292 |
+
$data_attr .= " data-{$key}=\"{$value}\" ";
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
$name = $field_data['id'];
|
1296 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1297 |
+
|
1298 |
+
$value = $this->get_field_value( $field_data );
|
1299 |
+
|
1300 |
+
$upload_frame_title = ! empty( $field_data['upload_frame_title'] ) ? $field_data['upload_frame_title'] : __( 'Select media', 'ultimate-member' );
|
1301 |
+
|
1302 |
+
$image_id = ! empty( $value['id'] ) ? $value['id'] : '';
|
1303 |
+
$image_width = ! empty( $value['width'] ) ? $value['width'] : '';
|
1304 |
+
$image_height = ! empty( $value['height'] ) ? $value['height'] : '';
|
1305 |
+
$image_thumbnail = ! empty( $value['thumbnail'] ) ? $value['thumbnail'] : '';
|
1306 |
+
$image_url = ! empty( $value['url'] ) ? $value['url'] : '';
|
1307 |
+
|
1308 |
+
$html = "<div class=\"um-media-upload\">" .
|
1309 |
+
"<input type=\"hidden\" class=\"um-media-upload-data-id\" name=\"{$name}[id]\" id=\"{$id}_id\" value=\"$image_id\">" .
|
1310 |
+
"<input type=\"hidden\" class=\"um-media-upload-data-width\" name=\"{$name}[width]\" id=\"{$id}_width\" value=\"$image_width\">" .
|
1311 |
+
"<input type=\"hidden\" class=\"um-media-upload-data-height\" name=\"{$name}[height]\" id=\"{$id}_height\" value=\"$image_height\">" .
|
1312 |
+
"<input type=\"hidden\" class=\"um-media-upload-data-thumbnail\" name=\"{$name}[thumbnail]\" id=\"{$id}_thumbnail\" value=\"$image_thumbnail\">" .
|
1313 |
+
"<input type=\"hidden\" $class_attr name=\"{$name}[url]\" id=\"{$id}_url\" value=\"$image_url\" $data_attr>";
|
1314 |
+
|
1315 |
+
if ( ! isset( $field_data['preview'] ) || $field_data['preview'] !== false ) {
|
1316 |
+
$html .= '<img src="' . $image_url . '" alt="" class="icon_preview"><div style="clear:both;"></div>';
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
if ( ! empty( $field_data['url'] ) ) {
|
1320 |
+
$html .= '<input type="text" class="um-media-upload-url" readonly value="' . $image_url . '" /><div style="clear:both;"></div>';
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
$html .= '<input type="button" class="um-set-image button button-primary" value="' . esc_attr__( 'Select', 'ultimate-member' ) . '" data-upload_frame="' . $upload_frame_title . '" />
|
1324 |
+
<input type="button" class="um-clear-image button" value="' . esc_attr__( 'Clear', 'ultimate-member' ) . '" /></div>';
|
1325 |
+
|
1326 |
+
return $html;
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
|
1330 |
+
/**
|
1331 |
+
* @param $field_data
|
1332 |
+
*
|
1333 |
+
* @return bool|string
|
1334 |
+
*/
|
1335 |
+
function render_email_template( $field_data ) {
|
1336 |
+
if ( empty( $field_data['id'] ) ) {
|
1337 |
+
return false;
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1341 |
+
|
1342 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1343 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1344 |
+
|
1345 |
+
$data = array(
|
1346 |
+
'field_id' => $field_data['id']
|
1347 |
+
);
|
1348 |
+
|
1349 |
+
$data_attr = '';
|
1350 |
+
foreach ( $data as $key => $value ) {
|
1351 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
$name = $field_data['id'];
|
1355 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1356 |
+
|
1357 |
+
$value = $this->get_field_value( $field_data );
|
1358 |
+
|
1359 |
+
ob_start(); ?>
|
1360 |
+
|
1361 |
+
<div class="email_template_wrapper <?php echo $field_data['in_theme'] ? 'in_theme' : '' ?>" data-key="<?php echo $field_data['id'] ?>" style="position: relative;">
|
1362 |
+
|
1363 |
+
<?php wp_editor( $value,
|
1364 |
+
$id,
|
1365 |
+
array(
|
1366 |
+
'textarea_name' => $name,
|
1367 |
+
'textarea_rows' => 20,
|
1368 |
+
'editor_height' => 425,
|
1369 |
+
'wpautop' => false,
|
1370 |
+
'media_buttons' => false,
|
1371 |
+
'editor_class' => $class
|
1372 |
+
)
|
1373 |
+
); ?>
|
1374 |
+
<span class="description">For default text for plain-text emails please see this <a href="https://docs.ultimatemember.com/article/1342-plain-text-email-default-templates#<?php echo $field_data['id'] ?>" target="_blank">doc</a></span>
|
1375 |
+
</div>
|
1376 |
+
|
1377 |
+
<?php $html = ob_get_clean();
|
1378 |
+
|
1379 |
+
return $html;
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
|
1383 |
+
/**
|
1384 |
+
* @param $field_data
|
1385 |
+
*
|
1386 |
+
* @return bool|string
|
1387 |
+
*/
|
1388 |
+
function render_ajax_button( $field_data ) {
|
1389 |
+
|
1390 |
+
if ( empty( $field_data['id'] ) )
|
1391 |
+
return false;
|
1392 |
+
|
1393 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1394 |
+
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
1395 |
+
|
1396 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1397 |
+
$class_attr = ' class="um-forms-field button ' . esc_attr( $class ) . '" ';
|
1398 |
+
|
1399 |
+
$data = array(
|
1400 |
+
'field_id' => $field_data['id']
|
1401 |
+
);
|
1402 |
+
|
1403 |
+
$data_attr = '';
|
1404 |
+
foreach ( $data as $key => $value ) {
|
1405 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1406 |
+
}
|
1407 |
+
|
1408 |
+
$name = $field_data['id'];
|
1409 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1410 |
+
$name_attr = ' name="' . $name . '" ';
|
1411 |
+
|
1412 |
+
$value = $this->get_field_value( $field_data );
|
1413 |
+
$value_attr = ' value="' . $value . '" ';
|
1414 |
+
|
1415 |
+
$html = "<input type=\"button\" $id_attr $class_attr $name_attr $data_attr $value_attr /><div class='clear'></div><div class='um_setting_ajax_button_response'></div>";
|
1416 |
+
|
1417 |
+
return $html;
|
1418 |
+
}
|
1419 |
+
|
1420 |
+
|
1421 |
+
/**
|
1422 |
+
* @param $field_data
|
1423 |
+
*
|
1424 |
+
* @return mixed
|
1425 |
+
*/
|
1426 |
+
function render_info_text( $field_data ) {
|
1427 |
+
return $field_data['value'];
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
|
1431 |
+
/**
|
1432 |
+
* @param $field_data
|
1433 |
+
*
|
1434 |
+
* @return string
|
1435 |
+
*/
|
1436 |
+
function render_md_default_filters( $field_data ) {
|
1437 |
+
if ( empty( $field_data['id'] ) ) {
|
1438 |
+
return false;
|
1439 |
+
}
|
1440 |
+
global $post;
|
1441 |
+
|
1442 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1443 |
+
|
1444 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1445 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1446 |
+
$class_attr = ' class="um-forms-field ' . $class . '" ';
|
1447 |
+
|
1448 |
+
$data = array(
|
1449 |
+
'field_id' => $field_data['id'],
|
1450 |
+
'id_attr' => $id,
|
1451 |
+
'member_directory' => $post->ID
|
1452 |
+
);
|
1453 |
+
|
1454 |
+
$data_attr = '';
|
1455 |
+
foreach ( $data as $key => $value ) {
|
1456 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
$name = $field_data['id'];
|
1460 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1461 |
+
$name = "{$name}[]";
|
1462 |
+
$name_attr = ' name="' . $name . '" ';
|
1463 |
+
|
1464 |
+
$values = $this->get_field_value( $field_data );
|
1465 |
+
if ( is_array( $values ) ) {
|
1466 |
+
$filters = array_keys( $values );
|
1467 |
+
}
|
1468 |
+
|
1469 |
+
$options = '';
|
1470 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1471 |
+
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
$html = "<input type=\"hidden\" name=\"um-gmt-offset\" /><select class=\"um-hidden-md-default-filters\" $data_attr>$options</select>";
|
1475 |
+
$html .= "<ul class=\"um-md-default-filters-list\" $data_attr>";
|
1476 |
+
|
1477 |
+
if ( ! empty( $filters ) && is_array( $filters ) ) {
|
1478 |
+
foreach ( $filters as $k => $value ) {
|
1479 |
+
|
1480 |
+
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
|
1481 |
+
continue ;
|
1482 |
+
}
|
1483 |
+
|
1484 |
+
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1485 |
+
|
1486 |
+
$options = '';
|
1487 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1488 |
+
$options .= '<option value="' . $key . '" ' . selected( $key == $value, true, false ) . '>' . $option . '</option>';
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
$html .= "<li class=\"um-md-default-filters-option-line\"><span class=\"um-field-wrapper\">
|
1492 |
+
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1493 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span><span class=\"um-field-wrapper2 um\">" . UM()->member_directory()->show_filter( $value, array( 'form_id' => $post->ID ), $values[ $value ], true ) . "</span></li>";
|
1494 |
+
}
|
1495 |
+
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1496 |
+
$i = 0;
|
1497 |
+
while ( $i < $field_data['show_default_number'] ) {
|
1498 |
+
$id_attr = ' id="' . $id . '-' . $i . '" ';
|
1499 |
+
|
1500 |
+
$options = '';
|
1501 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1502 |
+
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1503 |
+
}
|
1504 |
+
|
1505 |
+
$html .= "<li class=\"um-md-default-filters-option-line\"><span class=\"um-field-wrapper\">
|
1506 |
+
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1507 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span></li>";
|
1508 |
+
|
1509 |
+
$i++;
|
1510 |
+
}
|
1511 |
+
}
|
1512 |
+
|
1513 |
+
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-md-default-filters-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1514 |
+
|
1515 |
+
return $html;
|
1516 |
+
}
|
1517 |
+
|
1518 |
+
|
1519 |
+
/**
|
1520 |
+
* @param $field_data
|
1521 |
+
*
|
1522 |
+
* @return string
|
1523 |
+
*/
|
1524 |
+
function render_md_sorting_fields( $field_data ) {
|
1525 |
+
if ( empty( $field_data['id'] ) ) {
|
1526 |
+
return false;
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
1530 |
+
|
1531 |
+
$sorting = ! empty( $field_data['sorting'] ) ? $field_data['sorting'] : false;
|
1532 |
+
|
1533 |
+
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
1534 |
+
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
1535 |
+
$class .= ! empty( $sorting ) ? 'um-sorting-enabled' : '';
|
1536 |
+
$class_attr = ' class="um-forms-field ' . $class . '" ';
|
1537 |
+
|
1538 |
+
$data = array(
|
1539 |
+
'field_id' => $field_data['id'],
|
1540 |
+
'id_attr' => $id
|
1541 |
+
);
|
1542 |
+
|
1543 |
+
$data_attr = '';
|
1544 |
+
foreach ( $data as $key => $value ) {
|
1545 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
$name = $field_data['id'];
|
1549 |
+
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
1550 |
+
$name = "{$name}[]";
|
1551 |
+
$name_attr = ' name="' . $name . '" ';
|
1552 |
+
|
1553 |
+
$values = $this->get_field_value( $field_data );
|
1554 |
+
|
1555 |
+
$options = '';
|
1556 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1557 |
+
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1558 |
+
}
|
1559 |
+
|
1560 |
+
$html = "<select class=\"um-hidden-multi-selects\" $data_attr>$options</select>";
|
1561 |
+
$html .= "<ul class=\"um-multi-selects-list" . ( ! empty( $sorting ) ? ' um-sortable-multi-selects' : '' ) . "\" $data_attr>";
|
1562 |
+
|
1563 |
+
if ( $sorting && is_array( $values ) ) {
|
1564 |
+
ksort( $values );
|
1565 |
+
}
|
1566 |
+
|
1567 |
+
if ( ! empty( $values ) && is_array( $values ) ) {
|
1568 |
+
foreach ( $values as $k => $value ) {
|
1569 |
+
|
1570 |
+
$other_key = '';
|
1571 |
+
$other_label = '';
|
1572 |
+
if ( is_array( $value ) ) {
|
1573 |
+
$keys = array_keys( $value );
|
1574 |
+
$other_key = $keys[0];
|
1575 |
+
|
1576 |
+
$labels = array_values( $value );
|
1577 |
+
$other_label = $labels[0];
|
1578 |
+
} else {
|
1579 |
+
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
|
1580 |
+
continue;
|
1581 |
+
}
|
1582 |
+
}
|
1583 |
+
|
1584 |
+
$id_attr = ' id="' . esc_attr( $id . '-' . $k ) . '" ';
|
1585 |
+
|
1586 |
+
$options = '';
|
1587 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1588 |
+
if ( is_array( $value ) ) {
|
1589 |
+
$selected = selected( $key == 'other', true, false );
|
1590 |
+
} else {
|
1591 |
+
$selected = selected( $key == $value, true, false );
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
$options .= '<option value="' . $key . '" ' . $selected . '>' . $option . '</option>';
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1598 |
+
if ( $sorting ) {
|
1599 |
+
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1600 |
+
}
|
1601 |
+
$html .= "<span class=\"um-field-wrapper\">
|
1602 |
+
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1603 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span>
|
1604 |
+
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Meta key', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $k . "][meta_key]\" value=\"" . esc_attr( $other_key ) . "\" /></label></span>
|
1605 |
+
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Label', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $k . "][label]\" value=\"" . esc_attr( $other_label ) . "\" /></label></span>
|
1606 |
+
</li>";
|
1607 |
+
}
|
1608 |
+
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
|
1609 |
+
$i = 0;
|
1610 |
+
while ( $i < $field_data['show_default_number'] ) {
|
1611 |
+
$id_attr = ' id="' . $id . '-' . $i . '" ';
|
1612 |
+
|
1613 |
+
$options = '';
|
1614 |
+
foreach ( $field_data['options'] as $key => $option ) {
|
1615 |
+
$options .= '<option value="' . $key . '">' . $option . '</option>';
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
$html .= '<li class="um-multi-selects-option-line' . ( ! empty( $sorting ) ? ' um-admin-drag-fld' : '' ) . '">';
|
1619 |
+
if ( $sorting ) {
|
1620 |
+
$html .= '<span class="um-field-icon"><i class="um-faicon-sort"></i></span>';
|
1621 |
+
}
|
1622 |
+
|
1623 |
+
$html .= "<span class=\"um-field-wrapper\">
|
1624 |
+
<select $id_attr $name_attr $class_attr $data_attr>$options</select></span>
|
1625 |
+
<span class=\"um-field-control\"><a href=\"javascript:void(0);\" class=\"um-select-delete\">" . __( 'Remove', 'ultimate-member' ) . "</a></span>
|
1626 |
+
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Meta key', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $i . "][meta_key]\" value=\"\" /></label></span>
|
1627 |
+
<span class=\"um-field-wrapper um-custom-order-fields\"><label>" . __( 'Label', 'ultimate-member' ) . ": <input type=\"text\" name=\"um_metadata[_um_sorting_fields][other_data][" . $i . "][label]\" value=\"\" /></label></span>
|
1628 |
+
</li>";
|
1629 |
+
|
1630 |
+
$i++;
|
1631 |
+
}
|
1632 |
+
}
|
1633 |
+
|
1634 |
+
$html .= "</ul><a href=\"javascript:void(0);\" class=\"button button-primary um-multi-selects-add-option\" data-name=\"$name\">{$field_data['add_text']}</a>";
|
1635 |
+
|
1636 |
+
return $html;
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
|
1640 |
+
/**
|
1641 |
+
* Get field value
|
1642 |
+
*
|
1643 |
+
* @param array $field_data
|
1644 |
+
* @param string $i
|
1645 |
+
* @return string|array
|
1646 |
+
*/
|
1647 |
+
function get_field_value( $field_data, $i = '' ) {
|
1648 |
+
|
1649 |
+
$default = '';
|
1650 |
+
if ( $field_data['type'] === 'multi_checkbox' ) {
|
1651 |
+
$default = array();
|
1652 |
+
if ( isset( $field_data['default'] ) ) {
|
1653 |
+
$default = is_array( $field_data['default'] ) ? $field_data['default'] : array( $field_data['default'] );
|
1654 |
+
}
|
1655 |
+
}
|
1656 |
+
if ( isset( $field_data[ 'default' . $i ] ) ) {
|
1657 |
+
$default = $field_data[ 'default' . $i ];
|
1658 |
+
}
|
1659 |
+
|
1660 |
+
if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) {
|
1661 |
+
$value = ( isset( $field_data[ 'value' . $i ] ) && '' !== $field_data[ 'value' . $i ] ) ? $field_data[ 'value' . $i ] : $default;
|
1662 |
+
} else {
|
1663 |
+
$value = isset( $field_data[ 'value' . $i ] ) ? $field_data[ 'value' . $i ] : $default;
|
1664 |
+
}
|
1665 |
+
|
1666 |
+
$value = is_string( $value ) ? stripslashes( $value ) : $value;
|
1667 |
+
|
1668 |
+
return $value;
|
1669 |
+
}
|
1670 |
+
}
|
1671 |
+
}
|
includes/admin/core/class-admin-notices.php
CHANGED
@@ -1,715 +1,715 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Notices
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Notices {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Notices list
|
19 |
-
*
|
20 |
-
* @var array
|
21 |
-
*/
|
22 |
-
var $list = array();
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Admin_Notices constructor.
|
27 |
-
*/
|
28 |
-
function __construct() {
|
29 |
-
add_action( 'admin_init', array( &$this, 'create_languages_folder' ) );
|
30 |
-
|
31 |
-
add_action( 'admin_init', array( &$this, 'create_list' ), 10 );
|
32 |
-
add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 );
|
33 |
-
|
34 |
-
add_action( 'wp_ajax_um_dismiss_notice', array( &$this, 'dismiss_notice' ) );
|
35 |
-
add_action( 'admin_init', array( &$this, 'force_dismiss_notice' ) );
|
36 |
-
}
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
*
|
41 |
-
*/
|
42 |
-
function create_list() {
|
43 |
-
$this->old_extensions_notice();
|
44 |
-
$this->install_core_page_notice();
|
45 |
-
$this->exif_extension_notice();
|
46 |
-
$this->show_update_messages();
|
47 |
-
$this->check_wrong_install_folder();
|
48 |
-
$this->need_upgrade();
|
49 |
-
$this->check_wrong_licenses();
|
50 |
-
|
51 |
-
$this->lock_registration();
|
52 |
-
|
53 |
-
// removed for now to avoid the bad reviews
|
54 |
-
//$this->reviews_notice();
|
55 |
-
|
56 |
-
//$this->future_changed();
|
57 |
-
|
58 |
-
/**
|
59 |
-
* UM hook
|
60 |
-
*
|
61 |
-
* @type action
|
62 |
-
* @title um_admin_create_notices
|
63 |
-
* @description Add notices to wp-admin
|
64 |
-
* @change_log
|
65 |
-
* ["Since: 2.0"]
|
66 |
-
* @usage add_action( 'um_admin_create_notices', 'function_name', 10 );
|
67 |
-
* @example
|
68 |
-
* <?php
|
69 |
-
* add_action( 'um_admin_create_notices', 'my_admin_create_notices', 10 );
|
70 |
-
* function my_admin_create_notices() {
|
71 |
-
* // your code here
|
72 |
-
* }
|
73 |
-
* ?>
|
74 |
-
*/
|
75 |
-
do_action( 'um_admin_create_notices' );
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
/**
|
80 |
-
* @return array
|
81 |
-
*/
|
82 |
-
function get_admin_notices() {
|
83 |
-
return $this->list;
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @param $admin_notices
|
89 |
-
*/
|
90 |
-
function set_admin_notices( $admin_notices ) {
|
91 |
-
$this->list = $admin_notices;
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
/**
|
96 |
-
* @param $a
|
97 |
-
* @param $b
|
98 |
-
*
|
99 |
-
* @return mixed
|
100 |
-
*/
|
101 |
-
function notice_priority_sort( $a, $b ) {
|
102 |
-
if ( $a['priority'] == $b['priority'] ) {
|
103 |
-
return 0;
|
104 |
-
}
|
105 |
-
return ( $a['priority'] < $b['priority'] ) ? -1 : 1;
|
106 |
-
}
|
107 |
-
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Add notice to UM notices array
|
111 |
-
*
|
112 |
-
* @param string $key
|
113 |
-
* @param array $data
|
114 |
-
* @param int $priority
|
115 |
-
*/
|
116 |
-
function add_notice( $key, $data, $priority = 10 ) {
|
117 |
-
$admin_notices = $this->get_admin_notices();
|
118 |
-
|
119 |
-
if ( empty( $admin_notices[ $key ] ) ) {
|
120 |
-
$admin_notices[ $key ] = array_merge( $data, array( 'priority' => $priority ) );
|
121 |
-
$this->set_admin_notices( $admin_notices );
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Remove notice from UM notices array
|
128 |
-
*
|
129 |
-
* @param string $key
|
130 |
-
*/
|
131 |
-
function remove_notice( $key ) {
|
132 |
-
$admin_notices = $this->get_admin_notices();
|
133 |
-
|
134 |
-
if ( ! empty( $admin_notices[ $key ] ) ) {
|
135 |
-
unset( $admin_notices[ $key ] );
|
136 |
-
$this->set_admin_notices( $admin_notices );
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Render all admin notices
|
143 |
-
*/
|
144 |
-
function render_notices() {
|
145 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
146 |
-
return;
|
147 |
-
}
|
148 |
-
|
149 |
-
$admin_notices = $this->get_admin_notices();
|
150 |
-
|
151 |
-
$hidden = get_option( 'um_hidden_admin_notices', array() );
|
152 |
-
|
153 |
-
uasort( $admin_notices, array( &$this, 'notice_priority_sort' ) );
|
154 |
-
|
155 |
-
foreach ( $admin_notices as $key => $admin_notice ) {
|
156 |
-
if ( empty( $hidden ) || ! in_array( $key, $hidden ) ) {
|
157 |
-
$this->display_notice( $key );
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* UM hook
|
163 |
-
*
|
164 |
-
* @type action
|
165 |
-
* @title um_admin_after_main_notices
|
166 |
-
* @description Insert some content after main admin notices
|
167 |
-
* @change_log
|
168 |
-
* ["Since: 2.0"]
|
169 |
-
* @usage add_action( 'um_admin_after_main_notices', 'function_name', 10 );
|
170 |
-
* @example
|
171 |
-
* <?php
|
172 |
-
* add_action( 'um_admin_after_main_notices', 'my_admin_after_main_notices', 10 );
|
173 |
-
* function my_admin_after_main_notices() {
|
174 |
-
* // your code here
|
175 |
-
* }
|
176 |
-
* ?>
|
177 |
-
*/
|
178 |
-
do_action( 'um_admin_after_main_notices' );
|
179 |
-
}
|
180 |
-
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Display single admin notice
|
184 |
-
*
|
185 |
-
* @param string $key
|
186 |
-
* @param bool $echo
|
187 |
-
*
|
188 |
-
* @return void|string
|
189 |
-
*/
|
190 |
-
function display_notice( $key, $echo = true ) {
|
191 |
-
$admin_notices = $this->get_admin_notices();
|
192 |
-
|
193 |
-
if ( empty( $admin_notices[ $key ] ) ) {
|
194 |
-
return;
|
195 |
-
}
|
196 |
-
|
197 |
-
$notice_data = $admin_notices[ $key ];
|
198 |
-
|
199 |
-
$class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated';
|
200 |
-
|
201 |
-
$dismissible = ! empty( $admin_notices[ $key ]['dismissible'] );
|
202 |
-
|
203 |
-
ob_start(); ?>
|
204 |
-
|
205 |
-
<div class="<?php echo esc_attr( $class ) ?> um-admin-notice notice <?php echo $dismissible ? 'is-dismissible' : '' ?>" data-key="<?php echo esc_attr( $key ) ?>">
|
206 |
-
<?php echo ! empty( $notice_data['message'] ) ? $notice_data['message'] : '' ?>
|
207 |
-
</div>
|
208 |
-
|
209 |
-
<?php $notice = ob_get_clean();
|
210 |
-
if ( $echo ) {
|
211 |
-
echo $notice;
|
212 |
-
return;
|
213 |
-
} else {
|
214 |
-
return $notice;
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Checking if the "Membership - Anyone can register" WordPress general setting is active
|
221 |
-
*/
|
222 |
-
public function lock_registration() {
|
223 |
-
$users_can_register = get_option( 'users_can_register' );
|
224 |
-
if ( ! $users_can_register ) {
|
225 |
-
return;
|
226 |
-
}
|
227 |
-
|
228 |
-
$allowed_html = array(
|
229 |
-
'a' => array(
|
230 |
-
'href' => array(),
|
231 |
-
),
|
232 |
-
'strong' => array(),
|
233 |
-
);
|
234 |
-
|
235 |
-
$this->add_notice( 'lock_registration', array(
|
236 |
-
'class' => 'info',
|
237 |
-
'message' => '<p>' . wp_kses( sprintf( __( 'The <strong>"Membership - Anyone can register"</strong> option on the general settings <a href="%s">page</a> is enabled. This means users can register via the standard WordPress wp-login.php page. If you do not want users to be able to register via this page and only register via the Ultimate Member registration form, you should deactivate this option. You can dismiss this notice if you wish to keep the wp-login.php registration page open.', 'ultimate-member' ), admin_url( 'options-general.php' ) . '#users_can_register' ), $allowed_html ) . '</p>',
|
238 |
-
'dismissible' => true,
|
239 |
-
), 10 );
|
240 |
-
}
|
241 |
-
|
242 |
-
|
243 |
-
/**
|
244 |
-
* To store plugin languages
|
245 |
-
*/
|
246 |
-
function create_languages_folder() {
|
247 |
-
$path = UM()->files()->upload_basedir;
|
248 |
-
$path = str_replace( '/uploads/ultimatemember', '', $path );
|
249 |
-
$path = $path . '/languages/plugins/';
|
250 |
-
$path = str_replace( '//', '/', $path );
|
251 |
-
|
252 |
-
if ( ! file_exists( $path ) ) {
|
253 |
-
$old = umask(0);
|
254 |
-
@mkdir( $path, 0777, true );
|
255 |
-
umask( $old );
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
|
260 |
-
/**
|
261 |
-
* Show notice for customers with old extension's versions
|
262 |
-
*/
|
263 |
-
function old_extensions_notice() {
|
264 |
-
$show = false;
|
265 |
-
|
266 |
-
$old_extensions = array(
|
267 |
-
'bbpress',
|
268 |
-
'followers',
|
269 |
-
'friends',
|
270 |
-
'instagram',
|
271 |
-
'mailchimp',
|
272 |
-
'messaging',
|
273 |
-
'mycred',
|
274 |
-
'notices',
|
275 |
-
'notifications',
|
276 |
-
'online',
|
277 |
-
'private-content',
|
278 |
-
'profile-completeness',
|
279 |
-
'recaptcha',
|
280 |
-
'reviews',
|
281 |
-
'social-activity',
|
282 |
-
'social-login',
|
283 |
-
'terms-conditions',
|
284 |
-
'user-tags',
|
285 |
-
'verified-users',
|
286 |
-
'woocommerce',
|
287 |
-
);
|
288 |
-
|
289 |
-
$slugs = array_map( function( $item ) {
|
290 |
-
return 'um-' . $item . '/um-' . $item . '.php';
|
291 |
-
}, $old_extensions );
|
292 |
-
|
293 |
-
$active_plugins = UM()->dependencies()->get_active_plugins();
|
294 |
-
foreach ( $slugs as $slug ) {
|
295 |
-
if ( in_array( $slug, $active_plugins ) ) {
|
296 |
-
$path = wp_normalize_path( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $slug );
|
297 |
-
if ( ! file_exists( $path ) ) {
|
298 |
-
continue;
|
299 |
-
}
|
300 |
-
$plugin_data = get_plugin_data( $path );
|
301 |
-
if ( version_compare( '2.0', $plugin_data['Version'], '>' ) ) {
|
302 |
-
$show = true;
|
303 |
-
break;
|
304 |
-
}
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
if ( ! $show ) {
|
309 |
-
return;
|
310 |
-
}
|
311 |
-
|
312 |
-
$this->add_notice( 'old_extensions', array(
|
313 |
-
'class' => 'error',
|
314 |
-
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'https://docs.ultimatemember.com/article/201-how-to-update-your-site' ) . '</p>',
|
315 |
-
), 0 );
|
316 |
-
}
|
317 |
-
|
318 |
-
|
319 |
-
/**
|
320 |
-
* Regarding page setup
|
321 |
-
*/
|
322 |
-
function install_core_page_notice() {
|
323 |
-
$pages = UM()->config()->permalinks;
|
324 |
-
|
325 |
-
if ( $pages && is_array( $pages ) ) {
|
326 |
-
|
327 |
-
foreach ( $pages as $slug => $page_id ) {
|
328 |
-
$page = get_post( $page_id );
|
329 |
-
|
330 |
-
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
331 |
-
|
332 |
-
ob_start(); ?>
|
333 |
-
|
334 |
-
<p>
|
335 |
-
<?php printf( __( '%s needs to create several pages (User Profiles, Account, Registration, Login, Password Reset, Logout, Member Directory) to function correctly.', 'ultimate-member' ), ultimatemember_plugin_name ); ?>
|
336 |
-
</p>
|
337 |
-
|
338 |
-
<p>
|
339 |
-
<a href="<?php echo esc_url( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Create Pages', 'ultimate-member' ) ?></a>
|
340 |
-
|
341 |
-
<a href="javascript:void(0);" class="button-secondary um_secondary_dimiss"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
|
342 |
-
</p>
|
343 |
-
|
344 |
-
<?php $message = ob_get_clean();
|
345 |
-
|
346 |
-
$this->add_notice( 'wrong_pages', array(
|
347 |
-
'class' => 'updated',
|
348 |
-
'message' => $message,
|
349 |
-
'dismissible' => true
|
350 |
-
), 20 );
|
351 |
-
|
352 |
-
break;
|
353 |
-
}
|
354 |
-
}
|
355 |
-
|
356 |
-
if ( isset( $pages['user'] ) ) {
|
357 |
-
$test = get_post( $pages['user'] );
|
358 |
-
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
|
359 |
-
$this->add_notice( 'wrong_user_page', array(
|
360 |
-
'class' => 'updated',
|
361 |
-
'message' => '<p>' . __( 'Ultimate Member Setup Error: User page can not be a child page.', 'ultimate-member' ) . '</p>',
|
362 |
-
), 25 );
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
if ( isset( $pages['account'] ) ) {
|
367 |
-
$test = get_post( $pages['account'] );
|
368 |
-
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
|
369 |
-
$this->add_notice( 'wrong_account_page', array(
|
370 |
-
'class' => 'updated',
|
371 |
-
'message' => '<p>' . __( 'Ultimate Member Setup Error: Account page can not be a child page.', 'ultimate-member' ) . '</p>',
|
372 |
-
), 30 );
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
}
|
377 |
-
}
|
378 |
-
|
379 |
-
|
380 |
-
/**
|
381 |
-
* EXIF library notice
|
382 |
-
*/
|
383 |
-
function exif_extension_notice() {
|
384 |
-
$hide_exif_notice = get_option( 'um_hide_exif_notice' );
|
385 |
-
|
386 |
-
if ( ! extension_loaded( 'exif' ) && ! $hide_exif_notice ) {
|
387 |
-
$this->add_notice( 'exif_disabled', array(
|
388 |
-
'class' => 'updated',
|
389 |
-
'message' => '<p>' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '</p>',
|
390 |
-
), 10 );
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
|
395 |
-
/**
|
396 |
-
* Updating users
|
397 |
-
*/
|
398 |
-
function show_update_messages() {
|
399 |
-
|
400 |
-
if ( ! isset( $_REQUEST['update'] ) ) {
|
401 |
-
return;
|
402 |
-
}
|
403 |
-
|
404 |
-
$update = sanitize_key( $_REQUEST['update'] );
|
405 |
-
switch( $update ) {
|
406 |
-
|
407 |
-
case 'confirm_delete':
|
408 |
-
$request_users = array_map( 'absint', (array) $_REQUEST['user'] );
|
409 |
-
|
410 |
-
$confirm_uri = admin_url( 'users.php?' . http_build_query( array(
|
411 |
-
'um_adm_action' => 'delete_users',
|
412 |
-
'user' => $request_users,
|
413 |
-
'confirm' => 1
|
414 |
-
) ) );
|
415 |
-
$users = '';
|
416 |
-
|
417 |
-
if ( isset( $request_users ) ) {
|
418 |
-
foreach ( $request_users as $user_id ) {
|
419 |
-
$user = get_userdata( $user_id );
|
420 |
-
$users .= '#' . $user_id . ': ' . $user->user_login . '<br />';
|
421 |
-
}
|
422 |
-
}
|
423 |
-
|
424 |
-
$ignore = admin_url( 'users.php' );
|
425 |
-
|
426 |
-
$messages[0]['err_content'] = sprintf( __( 'Are you sure you want to delete the selected user(s)? The following users will be deleted: <p>%s</p> <strong>This cannot be undone!</strong>', 'ultimate-member' ), $users );
|
427 |
-
$messages[0]['err_content'] .= '<p><a href="'. esc_url( $confirm_uri ) .'" class="button-primary">' . __( 'Remove', 'ultimate-member' ) . '</a> <a href="' . esc_url( $ignore ) . '" class="button">' . __( 'Undo', 'ultimate-member' ) . '</a></p>';
|
428 |
-
|
429 |
-
break;
|
430 |
-
|
431 |
-
case 'language_updated':
|
432 |
-
$messages[0]['content'] = __( 'Your translation files have been updated successfully.', 'ultimate-member' );
|
433 |
-
break;
|
434 |
-
|
435 |
-
case 'purged_temp':
|
436 |
-
$messages[0]['content'] = __( 'Your temp uploads directory is now clean.', 'ultimate-member' );
|
437 |
-
break;
|
438 |
-
|
439 |
-
case 'cleared_cache':
|
440 |
-
$messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' );
|
441 |
-
break;
|
442 |
-
|
443 |
-
case 'got_updates':
|
444 |
-
$messages[0]['content'] = __( 'You have the latest updates.', 'ultimate-member' );
|
445 |
-
break;
|
446 |
-
|
447 |
-
case 'often_updates':
|
448 |
-
$messages[0]['err_content'] = __( 'Try again later. You can run this action once daily.', 'ultimate-member' );
|
449 |
-
break;
|
450 |
-
|
451 |
-
case 'form_duplicated':
|
452 |
-
$messages[0]['content'] = __( 'The form has been duplicated successfully.', 'ultimate-member' );
|
453 |
-
break;
|
454 |
-
|
455 |
-
case 'settings_updated':
|
456 |
-
$messages[0]['content'] = __( 'Settings have been saved successfully.', 'ultimate-member' );
|
457 |
-
break;
|
458 |
-
|
459 |
-
case 'user_updated':
|
460 |
-
$messages[0]['content'] = __( 'User has been updated.', 'ultimate-member' );
|
461 |
-
break;
|
462 |
-
|
463 |
-
case 'users_updated':
|
464 |
-
$messages[0]['content'] = __( 'Users have been updated.', 'ultimate-member' );
|
465 |
-
break;
|
466 |
-
|
467 |
-
case 'users_role_updated':
|
468 |
-
$messages[0]['content'] = __( 'Changed roles.', 'ultimate-member' );
|
469 |
-
break;
|
470 |
-
|
471 |
-
case 'err_users_updated':
|
472 |
-
$messages[0]['err_content'] = __( 'Super administrators cannot be modified.', 'ultimate-member' );
|
473 |
-
$messages[1]['content'] = __( 'Other users have been updated.', 'ultimate-member' );
|
474 |
-
|
475 |
-
}
|
476 |
-
|
477 |
-
if ( ! empty( $messages ) ) {
|
478 |
-
foreach ( $messages as $message ) {
|
479 |
-
if ( isset( $message['err_content'] ) ) {
|
480 |
-
$this->add_notice( 'actions', array(
|
481 |
-
'class' => 'error',
|
482 |
-
'message' => '<p>' . $message['err_content'] . '</p>',
|
483 |
-
), 50 );
|
484 |
-
} else {
|
485 |
-
$this->add_notice( 'actions', array(
|
486 |
-
'class' => 'updated',
|
487 |
-
'message' => '<p>' . $message['content'] . '</p>',
|
488 |
-
), 50 );
|
489 |
-
}
|
490 |
-
}
|
491 |
-
}
|
492 |
-
|
493 |
-
}
|
494 |
-
|
495 |
-
|
496 |
-
/**
|
497 |
-
* Check if plugin is installed with correct folder
|
498 |
-
*/
|
499 |
-
function check_wrong_install_folder() {
|
500 |
-
$invalid_folder = false;
|
501 |
-
|
502 |
-
$slug_array = explode( '/', um_plugin );
|
503 |
-
if ( $slug_array[0] != 'ultimate-member' ) {
|
504 |
-
$invalid_folder = true;
|
505 |
-
}
|
506 |
-
|
507 |
-
if ( $invalid_folder ) {
|
508 |
-
$this->add_notice( 'invalid_dir', array(
|
509 |
-
'class' => 'error',
|
510 |
-
'message' => '<p>' . sprintf( __( 'You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>"ultimate-member"</strong>.', 'ultimate-member' ), ultimatemember_plugin_name ) . '</p>',
|
511 |
-
), 1 );
|
512 |
-
}
|
513 |
-
}
|
514 |
-
|
515 |
-
|
516 |
-
function check_wrong_licenses() {
|
517 |
-
$invalid_license = 0;
|
518 |
-
$arr_inactive_license_keys = array();
|
519 |
-
|
520 |
-
if ( empty( UM()->admin_settings()->settings_structure['licenses']['fields'] ) ) {
|
521 |
-
return;
|
522 |
-
}
|
523 |
-
|
524 |
-
foreach ( UM()->admin_settings()->settings_structure['licenses']['fields'] as $field_data ) {
|
525 |
-
$license = get_option( "{$field_data['id']}_edd_answer" );
|
526 |
-
|
527 |
-
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license )
|
528 |
-
continue;
|
529 |
-
|
530 |
-
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) {
|
531 |
-
$arr_inactive_license_keys[ ] = $license->item_name;
|
532 |
-
}
|
533 |
-
|
534 |
-
$invalid_license++;
|
535 |
-
}
|
536 |
-
|
537 |
-
if ( ! empty( $arr_inactive_license_keys ) ) {
|
538 |
-
$this->add_notice( 'license_key', array(
|
539 |
-
'class' => 'error',
|
540 |
-
'message' => '<p>' . sprintf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%s">www.ultimatemember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, UM()->store_url ) . '</p>',
|
541 |
-
), 3 );
|
542 |
-
}
|
543 |
-
|
544 |
-
if ( $invalid_license ) {
|
545 |
-
$this->add_notice( 'license_key', array(
|
546 |
-
'class' => 'error',
|
547 |
-
'message' => '<p>' . sprintf( __( 'You have %d invalid or expired license keys for %s. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) . '</p>',
|
548 |
-
), 3 );
|
549 |
-
}
|
550 |
-
}
|
551 |
-
|
552 |
-
|
553 |
-
function need_upgrade() {
|
554 |
-
if ( ! empty( UM()->admin_upgrade()->necessary_packages ) ) {
|
555 |
-
|
556 |
-
$url = add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) );
|
557 |
-
|
558 |
-
ob_start(); ?>
|
559 |
-
|
560 |
-
<p>
|
561 |
-
<?php printf( __( '<strong>%s version %s</strong> needs to be updated to work correctly.<br />It is necessary to update the structure of the database and options that are associated with <strong>%s %s</strong>.<br />Please visit <a href="%s">"Upgrade"</a> page and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, ultimatemember_version, $url ); ?>
|
562 |
-
</p>
|
563 |
-
|
564 |
-
<p>
|
565 |
-
<a href="<?php echo esc_url( $url ) ?>" class="button button-primary"><?php _e( 'Visit Upgrade Page', 'ultimate-member' ) ?></a>
|
566 |
-
|
567 |
-
</p>
|
568 |
-
|
569 |
-
<?php $message = ob_get_clean();
|
570 |
-
|
571 |
-
$this->add_notice( 'upgrade', array(
|
572 |
-
'class' => 'error',
|
573 |
-
'message' => $message,
|
574 |
-
), 4 );
|
575 |
-
} else {
|
576 |
-
if ( isset( $_GET['msg'] ) && 'updated' === sanitize_key( $_GET['msg'] ) ) {
|
577 |
-
if ( isset( $_GET['page'] ) && 'um_options' === sanitize_key( $_GET['page'] ) ) {
|
578 |
-
$this->add_notice( 'settings_upgrade', array(
|
579 |
-
'class' => 'updated',
|
580 |
-
'message' => '<p>' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '</p>',
|
581 |
-
), 4 );
|
582 |
-
} else {
|
583 |
-
$this->add_notice( 'upgrade', array(
|
584 |
-
'class' => 'updated',
|
585 |
-
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> Successfully Upgraded', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version ) . '</p>',
|
586 |
-
), 4 );
|
587 |
-
}
|
588 |
-
}
|
589 |
-
}
|
590 |
-
}
|
591 |
-
|
592 |
-
|
593 |
-
/**
|
594 |
-
*
|
595 |
-
*/
|
596 |
-
function reviews_notice() {
|
597 |
-
|
598 |
-
$first_activation_date = get_option( 'um_first_activation_date', false );
|
599 |
-
|
600 |
-
if ( empty( $first_activation_date ) ) {
|
601 |
-
return;
|
602 |
-
}
|
603 |
-
|
604 |
-
if ( $first_activation_date + 2*WEEK_IN_SECONDS > time() ) {
|
605 |
-
return;
|
606 |
-
}
|
607 |
-
|
608 |
-
ob_start(); ?>
|
609 |
-
|
610 |
-
<div id="um_start_review_notice">
|
611 |
-
<p>
|
612 |
-
<?php printf( __( 'Hey there! It\'s been one month since you installed %s. How have you found the plugin so far?', 'ultimate-member' ), ultimatemember_plugin_name ) ?>
|
613 |
-
</p>
|
614 |
-
<p>
|
615 |
-
<a href="javascript:void(0);" id="um_add_review_love"><?php _e( 'I love it!', 'ultimate-member' ) ?></a> |
|
616 |
-
<a href="javascript:void(0);" id="um_add_review_good"><?php _e('It\'s good but could be better', 'ultimate-member' ) ?></a> |
|
617 |
-
<a href="javascript:void(0);" id="um_add_review_bad"><?php _e('I don\'t like the plugin', 'ultimate-member' ) ?></a>
|
618 |
-
</p>
|
619 |
-
</div>
|
620 |
-
<div class="um_hidden_notice" data-key="love">
|
621 |
-
<p>
|
622 |
-
<?php printf( __( 'Great! We\'re happy to hear that you love the plugin. It would be amazing if you could let others know why you like %s by leaving a review of the plugin. This will help %s to grow and become more popular and would be massively appreciated by us!' ), ultimatemember_plugin_name, ultimatemember_plugin_name ); ?>
|
623 |
-
</p>
|
624 |
-
|
625 |
-
<p>
|
626 |
-
<a href="https://wordpress.org/support/plugin/ultimate-member/reviews/?rate=5#new-post" target="_blank" class="button button-primary um_review_link"><?php _e( 'Leave Review', 'ultimate-member' ) ?></a>
|
627 |
-
</p>
|
628 |
-
</div>
|
629 |
-
<div class="um_hidden_notice" data-key="good">
|
630 |
-
<p>
|
631 |
-
<?php _e( 'We\'re glad to hear that you like the plugin but we would love to get your feedback so we can make the plugin better.' ); ?>
|
632 |
-
</p>
|
633 |
-
|
634 |
-
<p>
|
635 |
-
<a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
|
636 |
-
</p>
|
637 |
-
</div>
|
638 |
-
<div class="um_hidden_notice" data-key="bad">
|
639 |
-
<p>
|
640 |
-
<?php printf( __( 'We\'re sorry to hear that. If you\'re having the issue with the plugin you can create a topic on our <a href="%s" target="_blank">support forum</a> and we will try and help you out with the issue. Alternatively if you have an idea on how we can make the plugin better or want to tell us what you don\'t like about the plugin you can tell us know by giving us feedback.' ), 'https://wordpress.org/support/plugin/ultimate-member' ); ?>
|
641 |
-
</p>
|
642 |
-
|
643 |
-
<p>
|
644 |
-
<a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
|
645 |
-
</p>
|
646 |
-
</div>
|
647 |
-
|
648 |
-
<?php $message = ob_get_clean();
|
649 |
-
|
650 |
-
$this->add_notice( 'reviews_notice', array(
|
651 |
-
'class' => 'updated',
|
652 |
-
'message' => $message,
|
653 |
-
'dismissible' => true
|
654 |
-
), 1 );
|
655 |
-
}
|
656 |
-
|
657 |
-
|
658 |
-
/**
|
659 |
-
* Check Future Changes notice
|
660 |
-
*/
|
661 |
-
function future_changed() {
|
662 |
-
|
663 |
-
ob_start(); ?>
|
664 |
-
|
665 |
-
<p>
|
666 |
-
<?php printf( __( '<strong>%s</strong> future plans! Detailed future list is <a href="%s" target="_blank">here</a>', 'ultimate-member' ), ultimatemember_plugin_name, '#' ); ?>
|
667 |
-
</p>
|
668 |
-
|
669 |
-
<?php $message = ob_get_clean();
|
670 |
-
|
671 |
-
$this->add_notice( 'future_changes', array(
|
672 |
-
'class' => 'updated',
|
673 |
-
'message' => $message,
|
674 |
-
), 2 );
|
675 |
-
}
|
676 |
-
|
677 |
-
|
678 |
-
function dismiss_notice() {
|
679 |
-
UM()->admin()->check_ajax_nonce();
|
680 |
-
|
681 |
-
if ( empty( $_POST['key'] ) ) {
|
682 |
-
wp_send_json_error( __( 'Wrong Data', 'ultimate-member' ) );
|
683 |
-
}
|
684 |
-
|
685 |
-
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
686 |
-
if ( ! is_array( $hidden_notices ) ) {
|
687 |
-
$hidden_notices = array();
|
688 |
-
}
|
689 |
-
|
690 |
-
$hidden_notices[] = sanitize_key( $_POST['key'] );
|
691 |
-
|
692 |
-
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
693 |
-
|
694 |
-
wp_send_json_success();
|
695 |
-
}
|
696 |
-
|
697 |
-
|
698 |
-
function force_dismiss_notice() {
|
699 |
-
if ( ! empty( $_REQUEST['um_dismiss_notice'] ) && ! empty( $_REQUEST['um_admin_nonce'] ) ) {
|
700 |
-
if ( wp_verify_nonce( $_REQUEST['um_admin_nonce'], 'um-admin-nonce' ) ) {
|
701 |
-
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
702 |
-
if ( ! is_array( $hidden_notices ) ) {
|
703 |
-
$hidden_notices = array();
|
704 |
-
}
|
705 |
-
|
706 |
-
$hidden_notices[] = sanitize_key( $_REQUEST['um_dismiss_notice'] );
|
707 |
-
|
708 |
-
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
709 |
-
} else {
|
710 |
-
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
711 |
-
}
|
712 |
-
}
|
713 |
-
}
|
714 |
-
}
|
715 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Notices
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Notices {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Notices list
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
var $list = array();
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Admin_Notices constructor.
|
27 |
+
*/
|
28 |
+
function __construct() {
|
29 |
+
add_action( 'admin_init', array( &$this, 'create_languages_folder' ) );
|
30 |
+
|
31 |
+
add_action( 'admin_init', array( &$this, 'create_list' ), 10 );
|
32 |
+
add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 );
|
33 |
+
|
34 |
+
add_action( 'wp_ajax_um_dismiss_notice', array( &$this, 'dismiss_notice' ) );
|
35 |
+
add_action( 'admin_init', array( &$this, 'force_dismiss_notice' ) );
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
*
|
41 |
+
*/
|
42 |
+
function create_list() {
|
43 |
+
$this->old_extensions_notice();
|
44 |
+
$this->install_core_page_notice();
|
45 |
+
$this->exif_extension_notice();
|
46 |
+
$this->show_update_messages();
|
47 |
+
$this->check_wrong_install_folder();
|
48 |
+
$this->need_upgrade();
|
49 |
+
$this->check_wrong_licenses();
|
50 |
+
|
51 |
+
$this->lock_registration();
|
52 |
+
|
53 |
+
// removed for now to avoid the bad reviews
|
54 |
+
//$this->reviews_notice();
|
55 |
+
|
56 |
+
//$this->future_changed();
|
57 |
+
|
58 |
+
/**
|
59 |
+
* UM hook
|
60 |
+
*
|
61 |
+
* @type action
|
62 |
+
* @title um_admin_create_notices
|
63 |
+
* @description Add notices to wp-admin
|
64 |
+
* @change_log
|
65 |
+
* ["Since: 2.0"]
|
66 |
+
* @usage add_action( 'um_admin_create_notices', 'function_name', 10 );
|
67 |
+
* @example
|
68 |
+
* <?php
|
69 |
+
* add_action( 'um_admin_create_notices', 'my_admin_create_notices', 10 );
|
70 |
+
* function my_admin_create_notices() {
|
71 |
+
* // your code here
|
72 |
+
* }
|
73 |
+
* ?>
|
74 |
+
*/
|
75 |
+
do_action( 'um_admin_create_notices' );
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return array
|
81 |
+
*/
|
82 |
+
function get_admin_notices() {
|
83 |
+
return $this->list;
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param $admin_notices
|
89 |
+
*/
|
90 |
+
function set_admin_notices( $admin_notices ) {
|
91 |
+
$this->list = $admin_notices;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @param $a
|
97 |
+
* @param $b
|
98 |
+
*
|
99 |
+
* @return mixed
|
100 |
+
*/
|
101 |
+
function notice_priority_sort( $a, $b ) {
|
102 |
+
if ( $a['priority'] == $b['priority'] ) {
|
103 |
+
return 0;
|
104 |
+
}
|
105 |
+
return ( $a['priority'] < $b['priority'] ) ? -1 : 1;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Add notice to UM notices array
|
111 |
+
*
|
112 |
+
* @param string $key
|
113 |
+
* @param array $data
|
114 |
+
* @param int $priority
|
115 |
+
*/
|
116 |
+
function add_notice( $key, $data, $priority = 10 ) {
|
117 |
+
$admin_notices = $this->get_admin_notices();
|
118 |
+
|
119 |
+
if ( empty( $admin_notices[ $key ] ) ) {
|
120 |
+
$admin_notices[ $key ] = array_merge( $data, array( 'priority' => $priority ) );
|
121 |
+
$this->set_admin_notices( $admin_notices );
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Remove notice from UM notices array
|
128 |
+
*
|
129 |
+
* @param string $key
|
130 |
+
*/
|
131 |
+
function remove_notice( $key ) {
|
132 |
+
$admin_notices = $this->get_admin_notices();
|
133 |
+
|
134 |
+
if ( ! empty( $admin_notices[ $key ] ) ) {
|
135 |
+
unset( $admin_notices[ $key ] );
|
136 |
+
$this->set_admin_notices( $admin_notices );
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Render all admin notices
|
143 |
+
*/
|
144 |
+
function render_notices() {
|
145 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
|
149 |
+
$admin_notices = $this->get_admin_notices();
|
150 |
+
|
151 |
+
$hidden = get_option( 'um_hidden_admin_notices', array() );
|
152 |
+
|
153 |
+
uasort( $admin_notices, array( &$this, 'notice_priority_sort' ) );
|
154 |
+
|
155 |
+
foreach ( $admin_notices as $key => $admin_notice ) {
|
156 |
+
if ( empty( $hidden ) || ! in_array( $key, $hidden ) ) {
|
157 |
+
$this->display_notice( $key );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* UM hook
|
163 |
+
*
|
164 |
+
* @type action
|
165 |
+
* @title um_admin_after_main_notices
|
166 |
+
* @description Insert some content after main admin notices
|
167 |
+
* @change_log
|
168 |
+
* ["Since: 2.0"]
|
169 |
+
* @usage add_action( 'um_admin_after_main_notices', 'function_name', 10 );
|
170 |
+
* @example
|
171 |
+
* <?php
|
172 |
+
* add_action( 'um_admin_after_main_notices', 'my_admin_after_main_notices', 10 );
|
173 |
+
* function my_admin_after_main_notices() {
|
174 |
+
* // your code here
|
175 |
+
* }
|
176 |
+
* ?>
|
177 |
+
*/
|
178 |
+
do_action( 'um_admin_after_main_notices' );
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Display single admin notice
|
184 |
+
*
|
185 |
+
* @param string $key
|
186 |
+
* @param bool $echo
|
187 |
+
*
|
188 |
+
* @return void|string
|
189 |
+
*/
|
190 |
+
function display_notice( $key, $echo = true ) {
|
191 |
+
$admin_notices = $this->get_admin_notices();
|
192 |
+
|
193 |
+
if ( empty( $admin_notices[ $key ] ) ) {
|
194 |
+
return;
|
195 |
+
}
|
196 |
+
|
197 |
+
$notice_data = $admin_notices[ $key ];
|
198 |
+
|
199 |
+
$class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated';
|
200 |
+
|
201 |
+
$dismissible = ! empty( $admin_notices[ $key ]['dismissible'] );
|
202 |
+
|
203 |
+
ob_start(); ?>
|
204 |
+
|
205 |
+
<div class="<?php echo esc_attr( $class ) ?> um-admin-notice notice <?php echo $dismissible ? 'is-dismissible' : '' ?>" data-key="<?php echo esc_attr( $key ) ?>">
|
206 |
+
<?php echo ! empty( $notice_data['message'] ) ? $notice_data['message'] : '' ?>
|
207 |
+
</div>
|
208 |
+
|
209 |
+
<?php $notice = ob_get_clean();
|
210 |
+
if ( $echo ) {
|
211 |
+
echo $notice;
|
212 |
+
return;
|
213 |
+
} else {
|
214 |
+
return $notice;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Checking if the "Membership - Anyone can register" WordPress general setting is active
|
221 |
+
*/
|
222 |
+
public function lock_registration() {
|
223 |
+
$users_can_register = get_option( 'users_can_register' );
|
224 |
+
if ( ! $users_can_register ) {
|
225 |
+
return;
|
226 |
+
}
|
227 |
+
|
228 |
+
$allowed_html = array(
|
229 |
+
'a' => array(
|
230 |
+
'href' => array(),
|
231 |
+
),
|
232 |
+
'strong' => array(),
|
233 |
+
);
|
234 |
+
|
235 |
+
$this->add_notice( 'lock_registration', array(
|
236 |
+
'class' => 'info',
|
237 |
+
'message' => '<p>' . wp_kses( sprintf( __( 'The <strong>"Membership - Anyone can register"</strong> option on the general settings <a href="%s">page</a> is enabled. This means users can register via the standard WordPress wp-login.php page. If you do not want users to be able to register via this page and only register via the Ultimate Member registration form, you should deactivate this option. You can dismiss this notice if you wish to keep the wp-login.php registration page open.', 'ultimate-member' ), admin_url( 'options-general.php' ) . '#users_can_register' ), $allowed_html ) . '</p>',
|
238 |
+
'dismissible' => true,
|
239 |
+
), 10 );
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
/**
|
244 |
+
* To store plugin languages
|
245 |
+
*/
|
246 |
+
function create_languages_folder() {
|
247 |
+
$path = UM()->files()->upload_basedir;
|
248 |
+
$path = str_replace( '/uploads/ultimatemember', '', $path );
|
249 |
+
$path = $path . '/languages/plugins/';
|
250 |
+
$path = str_replace( '//', '/', $path );
|
251 |
+
|
252 |
+
if ( ! file_exists( $path ) ) {
|
253 |
+
$old = umask(0);
|
254 |
+
@mkdir( $path, 0777, true );
|
255 |
+
umask( $old );
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Show notice for customers with old extension's versions
|
262 |
+
*/
|
263 |
+
function old_extensions_notice() {
|
264 |
+
$show = false;
|
265 |
+
|
266 |
+
$old_extensions = array(
|
267 |
+
'bbpress',
|
268 |
+
'followers',
|
269 |
+
'friends',
|
270 |
+
'instagram',
|
271 |
+
'mailchimp',
|
272 |
+
'messaging',
|
273 |
+
'mycred',
|
274 |
+
'notices',
|
275 |
+
'notifications',
|
276 |
+
'online',
|
277 |
+
'private-content',
|
278 |
+
'profile-completeness',
|
279 |
+
'recaptcha',
|
280 |
+
'reviews',
|
281 |
+
'social-activity',
|
282 |
+
'social-login',
|
283 |
+
'terms-conditions',
|
284 |
+
'user-tags',
|
285 |
+
'verified-users',
|
286 |
+
'woocommerce',
|
287 |
+
);
|
288 |
+
|
289 |
+
$slugs = array_map( function( $item ) {
|
290 |
+
return 'um-' . $item . '/um-' . $item . '.php';
|
291 |
+
}, $old_extensions );
|
292 |
+
|
293 |
+
$active_plugins = UM()->dependencies()->get_active_plugins();
|
294 |
+
foreach ( $slugs as $slug ) {
|
295 |
+
if ( in_array( $slug, $active_plugins ) ) {
|
296 |
+
$path = wp_normalize_path( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $slug );
|
297 |
+
if ( ! file_exists( $path ) ) {
|
298 |
+
continue;
|
299 |
+
}
|
300 |
+
$plugin_data = get_plugin_data( $path );
|
301 |
+
if ( version_compare( '2.0', $plugin_data['Version'], '>' ) ) {
|
302 |
+
$show = true;
|
303 |
+
break;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
if ( ! $show ) {
|
309 |
+
return;
|
310 |
+
}
|
311 |
+
|
312 |
+
$this->add_notice( 'old_extensions', array(
|
313 |
+
'class' => 'error',
|
314 |
+
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'https://docs.ultimatemember.com/article/201-how-to-update-your-site' ) . '</p>',
|
315 |
+
), 0 );
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Regarding page setup
|
321 |
+
*/
|
322 |
+
function install_core_page_notice() {
|
323 |
+
$pages = UM()->config()->permalinks;
|
324 |
+
|
325 |
+
if ( $pages && is_array( $pages ) ) {
|
326 |
+
|
327 |
+
foreach ( $pages as $slug => $page_id ) {
|
328 |
+
$page = get_post( $page_id );
|
329 |
+
|
330 |
+
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
331 |
+
|
332 |
+
ob_start(); ?>
|
333 |
+
|
334 |
+
<p>
|
335 |
+
<?php printf( __( '%s needs to create several pages (User Profiles, Account, Registration, Login, Password Reset, Logout, Member Directory) to function correctly.', 'ultimate-member' ), ultimatemember_plugin_name ); ?>
|
336 |
+
</p>
|
337 |
+
|
338 |
+
<p>
|
339 |
+
<a href="<?php echo esc_url( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Create Pages', 'ultimate-member' ) ?></a>
|
340 |
+
|
341 |
+
<a href="javascript:void(0);" class="button-secondary um_secondary_dimiss"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
|
342 |
+
</p>
|
343 |
+
|
344 |
+
<?php $message = ob_get_clean();
|
345 |
+
|
346 |
+
$this->add_notice( 'wrong_pages', array(
|
347 |
+
'class' => 'updated',
|
348 |
+
'message' => $message,
|
349 |
+
'dismissible' => true
|
350 |
+
), 20 );
|
351 |
+
|
352 |
+
break;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
if ( isset( $pages['user'] ) ) {
|
357 |
+
$test = get_post( $pages['user'] );
|
358 |
+
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
|
359 |
+
$this->add_notice( 'wrong_user_page', array(
|
360 |
+
'class' => 'updated',
|
361 |
+
'message' => '<p>' . __( 'Ultimate Member Setup Error: User page can not be a child page.', 'ultimate-member' ) . '</p>',
|
362 |
+
), 25 );
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
if ( isset( $pages['account'] ) ) {
|
367 |
+
$test = get_post( $pages['account'] );
|
368 |
+
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
|
369 |
+
$this->add_notice( 'wrong_account_page', array(
|
370 |
+
'class' => 'updated',
|
371 |
+
'message' => '<p>' . __( 'Ultimate Member Setup Error: Account page can not be a child page.', 'ultimate-member' ) . '</p>',
|
372 |
+
), 30 );
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* EXIF library notice
|
382 |
+
*/
|
383 |
+
function exif_extension_notice() {
|
384 |
+
$hide_exif_notice = get_option( 'um_hide_exif_notice' );
|
385 |
+
|
386 |
+
if ( ! extension_loaded( 'exif' ) && ! $hide_exif_notice ) {
|
387 |
+
$this->add_notice( 'exif_disabled', array(
|
388 |
+
'class' => 'updated',
|
389 |
+
'message' => '<p>' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '</p>',
|
390 |
+
), 10 );
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Updating users
|
397 |
+
*/
|
398 |
+
function show_update_messages() {
|
399 |
+
|
400 |
+
if ( ! isset( $_REQUEST['update'] ) ) {
|
401 |
+
return;
|
402 |
+
}
|
403 |
+
|
404 |
+
$update = sanitize_key( $_REQUEST['update'] );
|
405 |
+
switch( $update ) {
|
406 |
+
|
407 |
+
case 'confirm_delete':
|
408 |
+
$request_users = array_map( 'absint', (array) $_REQUEST['user'] );
|
409 |
+
|
410 |
+
$confirm_uri = admin_url( 'users.php?' . http_build_query( array(
|
411 |
+
'um_adm_action' => 'delete_users',
|
412 |
+
'user' => $request_users,
|
413 |
+
'confirm' => 1
|
414 |
+
) ) );
|
415 |
+
$users = '';
|
416 |
+
|
417 |
+
if ( isset( $request_users ) ) {
|
418 |
+
foreach ( $request_users as $user_id ) {
|
419 |
+
$user = get_userdata( $user_id );
|
420 |
+
$users .= '#' . $user_id . ': ' . $user->user_login . '<br />';
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
$ignore = admin_url( 'users.php' );
|
425 |
+
|
426 |
+
$messages[0]['err_content'] = sprintf( __( 'Are you sure you want to delete the selected user(s)? The following users will be deleted: <p>%s</p> <strong>This cannot be undone!</strong>', 'ultimate-member' ), $users );
|
427 |
+
$messages[0]['err_content'] .= '<p><a href="'. esc_url( $confirm_uri ) .'" class="button-primary">' . __( 'Remove', 'ultimate-member' ) . '</a> <a href="' . esc_url( $ignore ) . '" class="button">' . __( 'Undo', 'ultimate-member' ) . '</a></p>';
|
428 |
+
|
429 |
+
break;
|
430 |
+
|
431 |
+
case 'language_updated':
|
432 |
+
$messages[0]['content'] = __( 'Your translation files have been updated successfully.', 'ultimate-member' );
|
433 |
+
break;
|
434 |
+
|
435 |
+
case 'purged_temp':
|
436 |
+
$messages[0]['content'] = __( 'Your temp uploads directory is now clean.', 'ultimate-member' );
|
437 |
+
break;
|
438 |
+
|
439 |
+
case 'cleared_cache':
|
440 |
+
$messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' );
|
441 |
+
break;
|
442 |
+
|
443 |
+
case 'got_updates':
|
444 |
+
$messages[0]['content'] = __( 'You have the latest updates.', 'ultimate-member' );
|
445 |
+
break;
|
446 |
+
|
447 |
+
case 'often_updates':
|
448 |
+
$messages[0]['err_content'] = __( 'Try again later. You can run this action once daily.', 'ultimate-member' );
|
449 |
+
break;
|
450 |
+
|
451 |
+
case 'form_duplicated':
|
452 |
+
$messages[0]['content'] = __( 'The form has been duplicated successfully.', 'ultimate-member' );
|
453 |
+
break;
|
454 |
+
|
455 |
+
case 'settings_updated':
|
456 |
+
$messages[0]['content'] = __( 'Settings have been saved successfully.', 'ultimate-member' );
|
457 |
+
break;
|
458 |
+
|
459 |
+
case 'user_updated':
|
460 |
+
$messages[0]['content'] = __( 'User has been updated.', 'ultimate-member' );
|
461 |
+
break;
|
462 |
+
|
463 |
+
case 'users_updated':
|
464 |
+
$messages[0]['content'] = __( 'Users have been updated.', 'ultimate-member' );
|
465 |
+
break;
|
466 |
+
|
467 |
+
case 'users_role_updated':
|
468 |
+
$messages[0]['content'] = __( 'Changed roles.', 'ultimate-member' );
|
469 |
+
break;
|
470 |
+
|
471 |
+
case 'err_users_updated':
|
472 |
+
$messages[0]['err_content'] = __( 'Super administrators cannot be modified.', 'ultimate-member' );
|
473 |
+
$messages[1]['content'] = __( 'Other users have been updated.', 'ultimate-member' );
|
474 |
+
|
475 |
+
}
|
476 |
+
|
477 |
+
if ( ! empty( $messages ) ) {
|
478 |
+
foreach ( $messages as $message ) {
|
479 |
+
if ( isset( $message['err_content'] ) ) {
|
480 |
+
$this->add_notice( 'actions', array(
|
481 |
+
'class' => 'error',
|
482 |
+
'message' => '<p>' . $message['err_content'] . '</p>',
|
483 |
+
), 50 );
|
484 |
+
} else {
|
485 |
+
$this->add_notice( 'actions', array(
|
486 |
+
'class' => 'updated',
|
487 |
+
'message' => '<p>' . $message['content'] . '</p>',
|
488 |
+
), 50 );
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Check if plugin is installed with correct folder
|
498 |
+
*/
|
499 |
+
function check_wrong_install_folder() {
|
500 |
+
$invalid_folder = false;
|
501 |
+
|
502 |
+
$slug_array = explode( '/', um_plugin );
|
503 |
+
if ( $slug_array[0] != 'ultimate-member' ) {
|
504 |
+
$invalid_folder = true;
|
505 |
+
}
|
506 |
+
|
507 |
+
if ( $invalid_folder ) {
|
508 |
+
$this->add_notice( 'invalid_dir', array(
|
509 |
+
'class' => 'error',
|
510 |
+
'message' => '<p>' . sprintf( __( 'You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>"ultimate-member"</strong>.', 'ultimate-member' ), ultimatemember_plugin_name ) . '</p>',
|
511 |
+
), 1 );
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
|
516 |
+
function check_wrong_licenses() {
|
517 |
+
$invalid_license = 0;
|
518 |
+
$arr_inactive_license_keys = array();
|
519 |
+
|
520 |
+
if ( empty( UM()->admin_settings()->settings_structure['licenses']['fields'] ) ) {
|
521 |
+
return;
|
522 |
+
}
|
523 |
+
|
524 |
+
foreach ( UM()->admin_settings()->settings_structure['licenses']['fields'] as $field_data ) {
|
525 |
+
$license = get_option( "{$field_data['id']}_edd_answer" );
|
526 |
+
|
527 |
+
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license )
|
528 |
+
continue;
|
529 |
+
|
530 |
+
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) {
|
531 |
+
$arr_inactive_license_keys[ ] = $license->item_name;
|
532 |
+
}
|
533 |
+
|
534 |
+
$invalid_license++;
|
535 |
+
}
|
536 |
+
|
537 |
+
if ( ! empty( $arr_inactive_license_keys ) ) {
|
538 |
+
$this->add_notice( 'license_key', array(
|
539 |
+
'class' => 'error',
|
540 |
+
'message' => '<p>' . sprintf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%s">www.ultimatemember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, UM()->store_url ) . '</p>',
|
541 |
+
), 3 );
|
542 |
+
}
|
543 |
+
|
544 |
+
if ( $invalid_license ) {
|
545 |
+
$this->add_notice( 'license_key', array(
|
546 |
+
'class' => 'error',
|
547 |
+
'message' => '<p>' . sprintf( __( 'You have %d invalid or expired license keys for %s. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) . '</p>',
|
548 |
+
), 3 );
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
|
553 |
+
function need_upgrade() {
|
554 |
+
if ( ! empty( UM()->admin_upgrade()->necessary_packages ) ) {
|
555 |
+
|
556 |
+
$url = add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) );
|
557 |
+
|
558 |
+
ob_start(); ?>
|
559 |
+
|
560 |
+
<p>
|
561 |
+
<?php printf( __( '<strong>%s version %s</strong> needs to be updated to work correctly.<br />It is necessary to update the structure of the database and options that are associated with <strong>%s %s</strong>.<br />Please visit <a href="%s">"Upgrade"</a> page and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, ultimatemember_version, $url ); ?>
|
562 |
+
</p>
|
563 |
+
|
564 |
+
<p>
|
565 |
+
<a href="<?php echo esc_url( $url ) ?>" class="button button-primary"><?php _e( 'Visit Upgrade Page', 'ultimate-member' ) ?></a>
|
566 |
+
|
567 |
+
</p>
|
568 |
+
|
569 |
+
<?php $message = ob_get_clean();
|
570 |
+
|
571 |
+
$this->add_notice( 'upgrade', array(
|
572 |
+
'class' => 'error',
|
573 |
+
'message' => $message,
|
574 |
+
), 4 );
|
575 |
+
} else {
|
576 |
+
if ( isset( $_GET['msg'] ) && 'updated' === sanitize_key( $_GET['msg'] ) ) {
|
577 |
+
if ( isset( $_GET['page'] ) && 'um_options' === sanitize_key( $_GET['page'] ) ) {
|
578 |
+
$this->add_notice( 'settings_upgrade', array(
|
579 |
+
'class' => 'updated',
|
580 |
+
'message' => '<p>' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '</p>',
|
581 |
+
), 4 );
|
582 |
+
} else {
|
583 |
+
$this->add_notice( 'upgrade', array(
|
584 |
+
'class' => 'updated',
|
585 |
+
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> Successfully Upgraded', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version ) . '</p>',
|
586 |
+
), 4 );
|
587 |
+
}
|
588 |
+
}
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
/**
|
594 |
+
*
|
595 |
+
*/
|
596 |
+
function reviews_notice() {
|
597 |
+
|
598 |
+
$first_activation_date = get_option( 'um_first_activation_date', false );
|
599 |
+
|
600 |
+
if ( empty( $first_activation_date ) ) {
|
601 |
+
return;
|
602 |
+
}
|
603 |
+
|
604 |
+
if ( $first_activation_date + 2*WEEK_IN_SECONDS > time() ) {
|
605 |
+
return;
|
606 |
+
}
|
607 |
+
|
608 |
+
ob_start(); ?>
|
609 |
+
|
610 |
+
<div id="um_start_review_notice">
|
611 |
+
<p>
|
612 |
+
<?php printf( __( 'Hey there! It\'s been one month since you installed %s. How have you found the plugin so far?', 'ultimate-member' ), ultimatemember_plugin_name ) ?>
|
613 |
+
</p>
|
614 |
+
<p>
|
615 |
+
<a href="javascript:void(0);" id="um_add_review_love"><?php _e( 'I love it!', 'ultimate-member' ) ?></a> |
|
616 |
+
<a href="javascript:void(0);" id="um_add_review_good"><?php _e('It\'s good but could be better', 'ultimate-member' ) ?></a> |
|
617 |
+
<a href="javascript:void(0);" id="um_add_review_bad"><?php _e('I don\'t like the plugin', 'ultimate-member' ) ?></a>
|
618 |
+
</p>
|
619 |
+
</div>
|
620 |
+
<div class="um_hidden_notice" data-key="love">
|
621 |
+
<p>
|
622 |
+
<?php printf( __( 'Great! We\'re happy to hear that you love the plugin. It would be amazing if you could let others know why you like %s by leaving a review of the plugin. This will help %s to grow and become more popular and would be massively appreciated by us!' ), ultimatemember_plugin_name, ultimatemember_plugin_name ); ?>
|
623 |
+
</p>
|
624 |
+
|
625 |
+
<p>
|
626 |
+
<a href="https://wordpress.org/support/plugin/ultimate-member/reviews/?rate=5#new-post" target="_blank" class="button button-primary um_review_link"><?php _e( 'Leave Review', 'ultimate-member' ) ?></a>
|
627 |
+
</p>
|
628 |
+
</div>
|
629 |
+
<div class="um_hidden_notice" data-key="good">
|
630 |
+
<p>
|
631 |
+
<?php _e( 'We\'re glad to hear that you like the plugin but we would love to get your feedback so we can make the plugin better.' ); ?>
|
632 |
+
</p>
|
633 |
+
|
634 |
+
<p>
|
635 |
+
<a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
|
636 |
+
</p>
|
637 |
+
</div>
|
638 |
+
<div class="um_hidden_notice" data-key="bad">
|
639 |
+
<p>
|
640 |
+
<?php printf( __( 'We\'re sorry to hear that. If you\'re having the issue with the plugin you can create a topic on our <a href="%s" target="_blank">support forum</a> and we will try and help you out with the issue. Alternatively if you have an idea on how we can make the plugin better or want to tell us what you don\'t like about the plugin you can tell us know by giving us feedback.' ), 'https://wordpress.org/support/plugin/ultimate-member' ); ?>
|
641 |
+
</p>
|
642 |
+
|
643 |
+
<p>
|
644 |
+
<a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
|
645 |
+
</p>
|
646 |
+
</div>
|
647 |
+
|
648 |
+
<?php $message = ob_get_clean();
|
649 |
+
|
650 |
+
$this->add_notice( 'reviews_notice', array(
|
651 |
+
'class' => 'updated',
|
652 |
+
'message' => $message,
|
653 |
+
'dismissible' => true
|
654 |
+
), 1 );
|
655 |
+
}
|
656 |
+
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Check Future Changes notice
|
660 |
+
*/
|
661 |
+
function future_changed() {
|
662 |
+
|
663 |
+
ob_start(); ?>
|
664 |
+
|
665 |
+
<p>
|
666 |
+
<?php printf( __( '<strong>%s</strong> future plans! Detailed future list is <a href="%s" target="_blank">here</a>', 'ultimate-member' ), ultimatemember_plugin_name, '#' ); ?>
|
667 |
+
</p>
|
668 |
+
|
669 |
+
<?php $message = ob_get_clean();
|
670 |
+
|
671 |
+
$this->add_notice( 'future_changes', array(
|
672 |
+
'class' => 'updated',
|
673 |
+
'message' => $message,
|
674 |
+
), 2 );
|
675 |
+
}
|
676 |
+
|
677 |
+
|
678 |
+
function dismiss_notice() {
|
679 |
+
UM()->admin()->check_ajax_nonce();
|
680 |
+
|
681 |
+
if ( empty( $_POST['key'] ) ) {
|
682 |
+
wp_send_json_error( __( 'Wrong Data', 'ultimate-member' ) );
|
683 |
+
}
|
684 |
+
|
685 |
+
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
686 |
+
if ( ! is_array( $hidden_notices ) ) {
|
687 |
+
$hidden_notices = array();
|
688 |
+
}
|
689 |
+
|
690 |
+
$hidden_notices[] = sanitize_key( $_POST['key'] );
|
691 |
+
|
692 |
+
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
693 |
+
|
694 |
+
wp_send_json_success();
|
695 |
+
}
|
696 |
+
|
697 |
+
|
698 |
+
function force_dismiss_notice() {
|
699 |
+
if ( ! empty( $_REQUEST['um_dismiss_notice'] ) && ! empty( $_REQUEST['um_admin_nonce'] ) ) {
|
700 |
+
if ( wp_verify_nonce( $_REQUEST['um_admin_nonce'], 'um-admin-nonce' ) ) {
|
701 |
+
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
702 |
+
if ( ! is_array( $hidden_notices ) ) {
|
703 |
+
$hidden_notices = array();
|
704 |
+
}
|
705 |
+
|
706 |
+
$hidden_notices[] = sanitize_key( $_REQUEST['um_dismiss_notice'] );
|
707 |
+
|
708 |
+
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
709 |
+
} else {
|
710 |
+
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
711 |
+
}
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
}
|
includes/admin/core/class-admin-settings.php
CHANGED
@@ -1,3458 +1,3458 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
exit;
|
6 |
-
}
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Settings
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Settings {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var array
|
20 |
-
*/
|
21 |
-
public $settings_map;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var array
|
26 |
-
*/
|
27 |
-
public $settings_structure;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var
|
32 |
-
*/
|
33 |
-
private $previous_licenses;
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var
|
38 |
-
*/
|
39 |
-
private $need_change_permalinks;
|
40 |
-
|
41 |
-
|
42 |
-
private $gravatar_changed = false;
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Admin_Settings constructor.
|
47 |
-
*/
|
48 |
-
public function __construct() {
|
49 |
-
//init settings structure
|
50 |
-
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
-
|
52 |
-
//admin menu
|
53 |
-
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
-
|
55 |
-
//settings structure handlers
|
56 |
-
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
-
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
-
|
59 |
-
//enqueue wp_media for profiles tab
|
60 |
-
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
-
|
62 |
-
//custom content for licenses tab
|
63 |
-
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
-
|
65 |
-
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
-
|
67 |
-
|
68 |
-
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
-
|
70 |
-
|
71 |
-
//save handlers
|
72 |
-
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
-
|
74 |
-
//save pages options
|
75 |
-
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
-
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
-
|
78 |
-
|
79 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
-
|
81 |
-
|
82 |
-
//save licenses options
|
83 |
-
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
-
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
-
|
86 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
-
|
89 |
-
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
public function same_page_update_ajax() {
|
95 |
-
UM()->admin()->check_ajax_nonce();
|
96 |
-
|
97 |
-
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
-
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
-
}
|
100 |
-
|
101 |
-
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
-
|
103 |
-
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
-
//first install metatable
|
105 |
-
global $wpdb;
|
106 |
-
|
107 |
-
$metakeys = array();
|
108 |
-
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
-
$metakeys[] = $all_user_field['metakey'];
|
110 |
-
}
|
111 |
-
|
112 |
-
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
-
|
114 |
-
if ( is_multisite() ) {
|
115 |
-
|
116 |
-
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
-
foreach ( $sites as $blog_id ) {
|
118 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
-
}
|
120 |
-
} else {
|
121 |
-
$blog_id = get_current_blog_id();
|
122 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
-
}
|
124 |
-
|
125 |
-
//member directory data
|
126 |
-
$metakeys[] = 'um_member_directory_data';
|
127 |
-
$metakeys[] = '_um_verified';
|
128 |
-
$metakeys[] = '_money_spent';
|
129 |
-
$metakeys[] = '_completed';
|
130 |
-
$metakeys[] = '_reviews_avg';
|
131 |
-
|
132 |
-
//myCred meta
|
133 |
-
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
-
$mycred_types = mycred_get_types();
|
135 |
-
if ( ! empty( $mycred_types ) ) {
|
136 |
-
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
-
$metakeys[] = $point_type;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
-
if ( empty( $sortby_custom_keys ) ) {
|
144 |
-
$sortby_custom_keys = array();
|
145 |
-
}
|
146 |
-
|
147 |
-
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
-
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
-
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
-
$custom_val = maybe_unserialize( $custom_val );
|
151 |
-
|
152 |
-
foreach ( $custom_val as $sort_value ) {
|
153 |
-
if ( is_array( $sort_value ) ) {
|
154 |
-
$field_keys = array_keys( $sort_value );
|
155 |
-
$sortby_custom_keys[] = $field_keys[0];
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
-
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
-
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
-
}
|
165 |
-
|
166 |
-
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
-
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
-
|
169 |
-
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
-
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
-
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
-
|
173 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
-
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
-
}
|
176 |
-
|
177 |
-
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
-
|
179 |
-
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
-
|
181 |
-
update_option( 'um_member_directory_update_meta', time() );
|
182 |
-
|
183 |
-
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
-
|
185 |
-
wp_send_json_success();
|
186 |
-
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
-
global $wpdb;
|
188 |
-
|
189 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
-
|
191 |
-
$count = $wpdb->get_var(
|
192 |
-
"SELECT COUNT(*)
|
193 |
-
FROM {$wpdb->usermeta}
|
194 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
-
);
|
196 |
-
|
197 |
-
wp_send_json_success( array( 'count' => $count ) );
|
198 |
-
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
-
|
200 |
-
if ( empty( $_POST['page'] ) ) {
|
201 |
-
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
-
}
|
203 |
-
|
204 |
-
$per_page = 500;
|
205 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
-
|
207 |
-
global $wpdb;
|
208 |
-
$metadata = $wpdb->get_results(
|
209 |
-
$wpdb->prepare(
|
210 |
-
"SELECT *
|
211 |
-
FROM {$wpdb->usermeta}
|
212 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
-
LIMIT %d, %d",
|
214 |
-
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
-
$per_page
|
216 |
-
),
|
217 |
-
ARRAY_A
|
218 |
-
);
|
219 |
-
|
220 |
-
$values = array();
|
221 |
-
foreach ( $metadata as $metarow ) {
|
222 |
-
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( ! empty( $values ) ) {
|
226 |
-
$wpdb->query(
|
227 |
-
"INSERT INTO
|
228 |
-
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
-
VALUES " . implode( ',', $values )
|
230 |
-
);
|
231 |
-
}
|
232 |
-
|
233 |
-
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
-
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
-
|
236 |
-
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
*
|
243 |
-
*/
|
244 |
-
public function init_variables() {
|
245 |
-
|
246 |
-
$settings_map = array();
|
247 |
-
|
248 |
-
$general_pages_fields = array(
|
249 |
-
array(
|
250 |
-
'id' => 'pages_settings',
|
251 |
-
'type' => 'hidden',
|
252 |
-
'value' => true,
|
253 |
-
'is_option' => false,
|
254 |
-
),
|
255 |
-
);
|
256 |
-
|
257 |
-
$core_pages = UM()->config()->core_pages;
|
258 |
-
|
259 |
-
foreach ( $core_pages as $page_s => $page ) {
|
260 |
-
$have_pages = UM()->query()->wp_pages();
|
261 |
-
$page_id = UM()->options()->get_core_page_id( $page_s );
|
262 |
-
|
263 |
-
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
264 |
-
|
265 |
-
if ( 'reached_maximum_limit' === $have_pages ) {
|
266 |
-
$general_pages_fields[] = array(
|
267 |
-
'id' => $page_id,
|
268 |
-
'type' => 'text',
|
269 |
-
// translators: %s: Page title
|
270 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
271 |
-
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
272 |
-
'compiler' => true,
|
273 |
-
'size' => 'small',
|
274 |
-
);
|
275 |
-
} else {
|
276 |
-
$general_pages_fields[] = array(
|
277 |
-
'id' => $page_id,
|
278 |
-
'type' => 'select',
|
279 |
-
// translators: %s: Page title
|
280 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
281 |
-
'options' => UM()->query()->wp_pages(),
|
282 |
-
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
283 |
-
'compiler' => true,
|
284 |
-
'size' => 'small',
|
285 |
-
);
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
$settings_map[ $page_id ] = array(
|
290 |
-
'sanitize' => 'absint',
|
291 |
-
);
|
292 |
-
}
|
293 |
-
|
294 |
-
$appearances_profile_menu_fields = array(
|
295 |
-
array(
|
296 |
-
'id' => 'profile_menu',
|
297 |
-
'type' => 'checkbox',
|
298 |
-
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
299 |
-
),
|
300 |
-
);
|
301 |
-
|
302 |
-
$settings_map['profile_menu'] = array(
|
303 |
-
'sanitize' => 'bool',
|
304 |
-
);
|
305 |
-
|
306 |
-
$tabs = UM()->profile()->tabs();
|
307 |
-
|
308 |
-
$tabs_options = array();
|
309 |
-
$tabs_condition = array();
|
310 |
-
foreach ( $tabs as $id => $tab ) {
|
311 |
-
|
312 |
-
if ( ! empty( $tab['hidden'] ) ) {
|
313 |
-
continue;
|
314 |
-
}
|
315 |
-
|
316 |
-
if ( isset( $tab['name'] ) ) {
|
317 |
-
$tabs_options[ $id ] = $tab['name'];
|
318 |
-
$tabs_condition[] = 'profile_tab_' . $id;
|
319 |
-
}
|
320 |
-
|
321 |
-
if ( isset( $tab['default_privacy'] ) ) {
|
322 |
-
$fields = array(
|
323 |
-
array(
|
324 |
-
'id' => 'profile_tab_' . $id,
|
325 |
-
'type' => 'checkbox',
|
326 |
-
// translators: %s: Tab title
|
327 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
328 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
329 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
330 |
-
),
|
331 |
-
);
|
332 |
-
|
333 |
-
$settings_map[ 'profile_tab_' . $id ] = array(
|
334 |
-
'sanitize' => 'bool',
|
335 |
-
);
|
336 |
-
} else {
|
337 |
-
|
338 |
-
$fields = array(
|
339 |
-
array(
|
340 |
-
'id' => 'profile_tab_' . $id,
|
341 |
-
'type' => 'checkbox',
|
342 |
-
// translators: %s: Tab title
|
343 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
344 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
345 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
346 |
-
),
|
347 |
-
array(
|
348 |
-
'id' => 'profile_tab_' . $id . '_privacy',
|
349 |
-
'type' => 'select',
|
350 |
-
// translators: %s: Tab title
|
351 |
-
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
352 |
-
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
353 |
-
'options' => UM()->profile()->tabs_privacy(),
|
354 |
-
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
355 |
-
'size' => 'small',
|
356 |
-
),
|
357 |
-
array(
|
358 |
-
'id' => 'profile_tab_' . $id . '_roles',
|
359 |
-
'type' => 'select',
|
360 |
-
'multi' => true,
|
361 |
-
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
362 |
-
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
363 |
-
'options' => UM()->roles()->get_roles(),
|
364 |
-
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
365 |
-
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
366 |
-
'size' => 'small',
|
367 |
-
),
|
368 |
-
);
|
369 |
-
|
370 |
-
$settings_map = array_merge(
|
371 |
-
$settings_map,
|
372 |
-
array(
|
373 |
-
"profile_tab_{$id}" => array(
|
374 |
-
'sanitize' => 'bool',
|
375 |
-
),
|
376 |
-
"profile_tab_{$id}_privacy" => array(
|
377 |
-
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
378 |
-
),
|
379 |
-
"profile_tab_{$id}_roles" => array(
|
380 |
-
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
381 |
-
),
|
382 |
-
)
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
387 |
-
}
|
388 |
-
|
389 |
-
$appearances_profile_menu_fields[] = array(
|
390 |
-
'id' => 'profile_menu_default_tab',
|
391 |
-
'type' => 'select',
|
392 |
-
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
393 |
-
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
394 |
-
'options' => $tabs_options,
|
395 |
-
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
396 |
-
'size' => 'small',
|
397 |
-
);
|
398 |
-
|
399 |
-
$settings_map['profile_menu_default_tab'] = array(
|
400 |
-
'sanitize' => 'key',
|
401 |
-
);
|
402 |
-
|
403 |
-
$appearances_profile_menu_fields = array_merge(
|
404 |
-
$appearances_profile_menu_fields,
|
405 |
-
array(
|
406 |
-
array(
|
407 |
-
'id' => 'profile_menu_icons',
|
408 |
-
'type' => 'checkbox',
|
409 |
-
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
410 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
411 |
-
),
|
412 |
-
)
|
413 |
-
);
|
414 |
-
|
415 |
-
$settings_map['profile_menu_icons'] = array(
|
416 |
-
'sanitize' => 'bool',
|
417 |
-
);
|
418 |
-
|
419 |
-
$post_types_options = array();
|
420 |
-
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
421 |
-
foreach ( $all_post_types as $key => $post_type_data ) {
|
422 |
-
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
423 |
-
}
|
424 |
-
|
425 |
-
$duplicates = array();
|
426 |
-
$taxonomies_options = array();
|
427 |
-
$exclude_taxonomies = UM()->excluded_taxonomies();
|
428 |
-
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
429 |
-
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
430 |
-
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
431 |
-
continue;
|
432 |
-
}
|
433 |
-
|
434 |
-
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
435 |
-
$duplicates[] = $taxonomy->labels->singular_name;
|
436 |
-
$label = $taxonomy->labels->singular_name;
|
437 |
-
} else {
|
438 |
-
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
439 |
-
}
|
440 |
-
|
441 |
-
$taxonomies_options[ $key ] = $label;
|
442 |
-
}
|
443 |
-
|
444 |
-
$restricted_access_post_metabox_value = array();
|
445 |
-
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
446 |
-
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
447 |
-
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
448 |
-
if ( $value ) {
|
449 |
-
$restricted_access_post_metabox_value[] = $key;
|
450 |
-
}
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
|
455 |
-
$restricted_access_taxonomy_metabox_value = array();
|
456 |
-
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
457 |
-
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
458 |
-
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
459 |
-
if ( $value ) {
|
460 |
-
$restricted_access_taxonomy_metabox_value[] = $key;
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
$access_fields = array(
|
466 |
-
array(
|
467 |
-
'id' => 'accessible',
|
468 |
-
'type' => 'select',
|
469 |
-
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
470 |
-
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
471 |
-
'options' => array(
|
472 |
-
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
473 |
-
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
474 |
-
),
|
475 |
-
'size' => 'medium',
|
476 |
-
),
|
477 |
-
array(
|
478 |
-
'id' => 'access_redirect',
|
479 |
-
'type' => 'text',
|
480 |
-
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
481 |
-
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
482 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
483 |
-
),
|
484 |
-
array(
|
485 |
-
'id' => 'access_exclude_uris',
|
486 |
-
'type' => 'multi_text',
|
487 |
-
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
488 |
-
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
489 |
-
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
490 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
491 |
-
'show_default_number' => 0,
|
492 |
-
),
|
493 |
-
array(
|
494 |
-
'id' => 'home_page_accessible',
|
495 |
-
'type' => 'checkbox',
|
496 |
-
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
497 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
498 |
-
),
|
499 |
-
array(
|
500 |
-
'id' => 'category_page_accessible',
|
501 |
-
'type' => 'checkbox',
|
502 |
-
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
503 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
504 |
-
),
|
505 |
-
array(
|
506 |
-
'id' => 'restricted_post_title_replace',
|
507 |
-
'type' => 'checkbox',
|
508 |
-
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
509 |
-
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
510 |
-
),
|
511 |
-
array(
|
512 |
-
'id' => 'restricted_access_post_title',
|
513 |
-
'type' => 'text',
|
514 |
-
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
515 |
-
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
516 |
-
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
517 |
-
),
|
518 |
-
array(
|
519 |
-
'id' => 'restricted_access_message',
|
520 |
-
'type' => 'wp_editor',
|
521 |
-
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
522 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
523 |
-
),
|
524 |
-
);
|
525 |
-
|
526 |
-
$settings_map = array_merge(
|
527 |
-
$settings_map,
|
528 |
-
array(
|
529 |
-
'accessible' => array(
|
530 |
-
'sanitize' => 'int',
|
531 |
-
),
|
532 |
-
'access_redirect' => array(
|
533 |
-
'sanitize' => 'url',
|
534 |
-
),
|
535 |
-
'access_exclude_uris' => array(
|
536 |
-
'sanitize' => 'url',
|
537 |
-
),
|
538 |
-
'home_page_accessible' => array(
|
539 |
-
'sanitize' => 'bool',
|
540 |
-
),
|
541 |
-
'category_page_accessible' => array(
|
542 |
-
'sanitize' => 'bool',
|
543 |
-
),
|
544 |
-
'restricted_post_title_replace' => array(
|
545 |
-
'sanitize' => 'bool',
|
546 |
-
),
|
547 |
-
'restricted_access_post_title' => array(
|
548 |
-
'sanitize' => 'text',
|
549 |
-
),
|
550 |
-
'restricted_access_message' => array(
|
551 |
-
'sanitize' => 'wp_kses',
|
552 |
-
),
|
553 |
-
)
|
554 |
-
);
|
555 |
-
|
556 |
-
global $wp_version;
|
557 |
-
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
558 |
-
$access_fields = array_merge(
|
559 |
-
$access_fields,
|
560 |
-
array(
|
561 |
-
array(
|
562 |
-
'id' => 'restricted_blocks',
|
563 |
-
'type' => 'checkbox',
|
564 |
-
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
565 |
-
),
|
566 |
-
array(
|
567 |
-
'id' => 'restricted_block_message',
|
568 |
-
'type' => 'textarea',
|
569 |
-
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
570 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
571 |
-
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
572 |
-
),
|
573 |
-
)
|
574 |
-
);
|
575 |
-
|
576 |
-
$settings_map['restricted_blocks'] = array(
|
577 |
-
'sanitize' => 'bool',
|
578 |
-
);
|
579 |
-
$settings_map['restricted_block_message'] = array(
|
580 |
-
'sanitize' => 'textarea',
|
581 |
-
);
|
582 |
-
}
|
583 |
-
|
584 |
-
$access_fields = array_merge(
|
585 |
-
$access_fields,
|
586 |
-
array(
|
587 |
-
array(
|
588 |
-
'id' => 'restricted_access_post_metabox',
|
589 |
-
'type' => 'hidden',
|
590 |
-
'value' => '',
|
591 |
-
),
|
592 |
-
array(
|
593 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
594 |
-
'type' => 'hidden',
|
595 |
-
'value' => '',
|
596 |
-
),
|
597 |
-
array(
|
598 |
-
'id' => 'restricted_access_post_metabox',
|
599 |
-
'type' => 'multi_checkbox',
|
600 |
-
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
601 |
-
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
602 |
-
'options' => $post_types_options,
|
603 |
-
'columns' => 3,
|
604 |
-
'value' => $restricted_access_post_metabox_value,
|
605 |
-
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
606 |
-
),
|
607 |
-
array(
|
608 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
609 |
-
'type' => 'multi_checkbox',
|
610 |
-
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
611 |
-
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
612 |
-
'options' => $taxonomies_options,
|
613 |
-
'columns' => 3,
|
614 |
-
'value' => $restricted_access_taxonomy_metabox_value,
|
615 |
-
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
616 |
-
),
|
617 |
-
)
|
618 |
-
);
|
619 |
-
|
620 |
-
$settings_map = array_merge(
|
621 |
-
$settings_map,
|
622 |
-
array(
|
623 |
-
'restricted_access_post_metabox' => array(
|
624 |
-
'sanitize' => 'key',
|
625 |
-
),
|
626 |
-
'restricted_access_taxonomy_metabox' => array(
|
627 |
-
'sanitize' => 'key',
|
628 |
-
),
|
629 |
-
)
|
630 |
-
);
|
631 |
-
|
632 |
-
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
633 |
-
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
634 |
-
|
635 |
-
$same_page_update = array(
|
636 |
-
'id' => 'member_directory_own_table',
|
637 |
-
'type' => 'same_page_update',
|
638 |
-
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
639 |
-
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
640 |
-
);
|
641 |
-
|
642 |
-
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
643 |
-
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
644 |
-
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
645 |
-
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
646 |
-
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
647 |
-
}
|
648 |
-
|
649 |
-
$settings_map = array_merge(
|
650 |
-
$settings_map,
|
651 |
-
array(
|
652 |
-
'permalink_base' => array(
|
653 |
-
'sanitize' => 'key',
|
654 |
-
),
|
655 |
-
'display_name' => array(
|
656 |
-
'sanitize' => 'key',
|
657 |
-
),
|
658 |
-
'display_name_field' => array(
|
659 |
-
'sanitize' => 'text',
|
660 |
-
),
|
661 |
-
'author_redirect' => array(
|
662 |
-
'sanitize' => 'bool',
|
663 |
-
),
|
664 |
-
'members_page' => array(
|
665 |
-
'sanitize' => 'bool',
|
666 |
-
),
|
667 |
-
'use_gravatars' => array(
|
668 |
-
'sanitize' => 'bool',
|
669 |
-
),
|
670 |
-
'use_um_gravatar_default_builtin_image' => array(
|
671 |
-
'sanitize' => 'key',
|
672 |
-
),
|
673 |
-
'use_um_gravatar_default_image' => array(
|
674 |
-
'sanitize' => 'bool',
|
675 |
-
),
|
676 |
-
'require_strongpass' => array(
|
677 |
-
'sanitize' => 'bool',
|
678 |
-
),
|
679 |
-
'password_min_chars' => array(
|
680 |
-
'sanitize' => 'absint',
|
681 |
-
),
|
682 |
-
'password_max_chars' => array(
|
683 |
-
'sanitize' => 'absint',
|
684 |
-
),
|
685 |
-
'profile_noindex' => array(
|
686 |
-
'sanitize' => 'bool',
|
687 |
-
),
|
688 |
-
'activation_link_expiry_time' => array(
|
689 |
-
'sanitize' => 'absint',
|
690 |
-
),
|
691 |
-
'account_tab_password' => array(
|
692 |
-
'sanitize' => 'bool',
|
693 |
-
),
|
694 |
-
'account_tab_privacy' => array(
|
695 |
-
'sanitize' => 'bool',
|
696 |
-
),
|
697 |
-
'account_tab_notifications' => array(
|
698 |
-
'sanitize' => 'bool',
|
699 |
-
),
|
700 |
-
'account_tab_delete' => array(
|
701 |
-
'sanitize' => 'bool',
|
702 |
-
),
|
703 |
-
'delete_account_text' => array(
|
704 |
-
'sanitize' => 'textarea',
|
705 |
-
),
|
706 |
-
'delete_account_no_pass_required_text' => array(
|
707 |
-
'sanitize' => 'textarea',
|
708 |
-
),
|
709 |
-
'account_name' => array(
|
710 |
-
'sanitize' => 'bool',
|
711 |
-
),
|
712 |
-
'account_name_disable' => array(
|
713 |
-
'sanitize' => 'bool',
|
714 |
-
),
|
715 |
-
'account_name_require' => array(
|
716 |
-
'sanitize' => 'bool',
|
717 |
-
),
|
718 |
-
'account_email' => array(
|
719 |
-
'sanitize' => 'bool',
|
720 |
-
),
|
721 |
-
'account_general_password' => array(
|
722 |
-
'sanitize' => 'bool',
|
723 |
-
),
|
724 |
-
'account_hide_in_directory' => array(
|
725 |
-
'sanitize' => 'bool',
|
726 |
-
),
|
727 |
-
'account_hide_in_directory_default' => array(
|
728 |
-
'sanitize' => 'text',
|
729 |
-
),
|
730 |
-
'profile_photo_max_size' => array(
|
731 |
-
'sanitize' => 'absint',
|
732 |
-
),
|
733 |
-
'cover_photo_max_size' => array(
|
734 |
-
'sanitize' => 'absint',
|
735 |
-
),
|
736 |
-
'photo_thumb_sizes' => array(
|
737 |
-
'sanitize' => 'absint',
|
738 |
-
),
|
739 |
-
'cover_thumb_sizes' => array(
|
740 |
-
'sanitize' => 'absint',
|
741 |
-
),
|
742 |
-
'image_orientation_by_exif' => array(
|
743 |
-
'sanitize' => 'bool',
|
744 |
-
),
|
745 |
-
'image_compression' => array(
|
746 |
-
'sanitize' => 'absint',
|
747 |
-
),
|
748 |
-
'image_max_width' => array(
|
749 |
-
'sanitize' => 'absint',
|
750 |
-
),
|
751 |
-
'cover_min_width' => array(
|
752 |
-
'sanitize' => 'absint',
|
753 |
-
),
|
754 |
-
'enable_reset_password_limit' => array(
|
755 |
-
'sanitize' => 'bool',
|
756 |
-
),
|
757 |
-
'reset_password_limit_number' => array(
|
758 |
-
'sanitize' => 'absint',
|
759 |
-
),
|
760 |
-
'blocked_emails' => array(
|
761 |
-
'sanitize' => 'textarea',
|
762 |
-
),
|
763 |
-
'blocked_words' => array(
|
764 |
-
'sanitize' => 'textarea',
|
765 |
-
),
|
766 |
-
'admin_email' => array(
|
767 |
-
'sanitize' => 'text',
|
768 |
-
),
|
769 |
-
'mail_from' => array(
|
770 |
-
'sanitize' => 'text',
|
771 |
-
),
|
772 |
-
'mail_from_addr' => array(
|
773 |
-
'sanitize' => 'text',
|
774 |
-
),
|
775 |
-
'email_html' => array(
|
776 |
-
'sanitize' => 'bool',
|
777 |
-
),
|
778 |
-
'profile_template' => array(
|
779 |
-
'sanitize' => 'text',
|
780 |
-
),
|
781 |
-
'profile_max_width' => array(
|
782 |
-
'sanitize' => 'text',
|
783 |
-
),
|
784 |
-
'profile_area_max_width' => array(
|
785 |
-
'sanitize' => 'text',
|
786 |
-
),
|
787 |
-
'profile_icons' => array(
|
788 |
-
'sanitize' => 'key',
|
789 |
-
),
|
790 |
-
'profile_primary_btn_word' => array(
|
791 |
-
'sanitize' => 'text',
|
792 |
-
),
|
793 |
-
'profile_secondary_btn' => array(
|
794 |
-
'sanitize' => 'bool',
|
795 |
-
),
|
796 |
-
'profile_secondary_btn_word' => array(
|
797 |
-
'sanitize' => 'text',
|
798 |
-
),
|
799 |
-
'default_avatar' => array(
|
800 |
-
'sanitize' => 'url',
|
801 |
-
),
|
802 |
-
'default_cover' => array(
|
803 |
-
'sanitize' => 'url',
|
804 |
-
),
|
805 |
-
'disable_profile_photo_upload' => array(
|
806 |
-
'sanitize' => 'bool',
|
807 |
-
),
|
808 |
-
'profile_photosize' => array(
|
809 |
-
'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
|
810 |
-
),
|
811 |
-
'profile_cover_enabled' => array(
|
812 |
-
'sanitize' => 'bool',
|
813 |
-
),
|
814 |
-
'profile_coversize' => array(
|
815 |
-
'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
|
816 |
-
),
|
817 |
-
'profile_cover_ratio' => array(
|
818 |
-
'sanitize' => 'text',
|
819 |
-
),
|
820 |
-
'profile_show_metaicon' => array(
|
821 |
-
'sanitize' => 'bool',
|
822 |
-
),
|
823 |
-
'profile_show_name' => array(
|
824 |
-
'sanitize' => 'bool',
|
825 |
-
),
|
826 |
-
'profile_show_social_links' => array(
|
827 |
-
'sanitize' => 'bool',
|
828 |
-
),
|
829 |
-
'profile_show_bio' => array(
|
830 |
-
'sanitize' => 'bool',
|
831 |
-
),
|
832 |
-
'profile_show_html_bio' => array(
|
833 |
-
'sanitize' => 'bool',
|
834 |
-
),
|
835 |
-
'profile_bio_maxchars' => array(
|
836 |
-
'sanitize' => 'absint',
|
837 |
-
),
|
838 |
-
'profile_header_menu' => array(
|
839 |
-
'sanitize' => 'key',
|
840 |
-
),
|
841 |
-
'profile_empty_text' => array(
|
842 |
-
'sanitize' => 'bool',
|
843 |
-
),
|
844 |
-
'profile_empty_text_emo' => array(
|
845 |
-
'sanitize' => 'bool',
|
846 |
-
),
|
847 |
-
'register_template' => array(
|
848 |
-
'sanitize' => 'text',
|
849 |
-
),
|
850 |
-
'register_max_width' => array(
|
851 |
-
'sanitize' => 'text',
|
852 |
-
),
|
853 |
-
'register_align' => array(
|
854 |
-
'sanitize' => 'key',
|
855 |
-
),
|
856 |
-
'register_icons' => array(
|
857 |
-
'sanitize' => 'key',
|
858 |
-
),
|
859 |
-
'register_primary_btn_word' => array(
|
860 |
-
'sanitize' => 'text',
|
861 |
-
),
|
862 |
-
'register_secondary_btn' => array(
|
863 |
-
'sanitize' => 'bool',
|
864 |
-
),
|
865 |
-
'register_secondary_btn_word' => array(
|
866 |
-
'sanitize' => 'text',
|
867 |
-
),
|
868 |
-
'register_secondary_btn_url' => array(
|
869 |
-
'sanitize' => 'url',
|
870 |
-
),
|
871 |
-
'register_role' => array(
|
872 |
-
'sanitize' => 'key',
|
873 |
-
),
|
874 |
-
'login_template' => array(
|
875 |
-
'sanitize' => 'text',
|
876 |
-
),
|
877 |
-
'login_max_width' => array(
|
878 |
-
'sanitize' => 'text',
|
879 |
-
),
|
880 |
-
'login_align' => array(
|
881 |
-
'sanitize' => 'key',
|
882 |
-
),
|
883 |
-
'login_icons' => array(
|
884 |
-
'sanitize' => 'key',
|
885 |
-
),
|
886 |
-
'login_primary_btn_word' => array(
|
887 |
-
'sanitize' => 'text',
|
888 |
-
),
|
889 |
-
'login_secondary_btn' => array(
|
890 |
-
'sanitize' => 'bool',
|
891 |
-
),
|
892 |
-
'login_secondary_btn_word' => array(
|
893 |
-
'sanitize' => 'text',
|
894 |
-
),
|
895 |
-
'login_secondary_btn_url' => array(
|
896 |
-
'sanitize' => 'url',
|
897 |
-
),
|
898 |
-
'login_forgot_pass_link' => array(
|
899 |
-
'sanitize' => 'bool',
|
900 |
-
),
|
901 |
-
'login_show_rememberme' => array(
|
902 |
-
'sanitize' => 'bool',
|
903 |
-
),
|
904 |
-
'form_asterisk' => array(
|
905 |
-
'sanitize' => 'bool',
|
906 |
-
),
|
907 |
-
'profile_title' => array(
|
908 |
-
'sanitize' => 'text',
|
909 |
-
),
|
910 |
-
'profile_desc' => array(
|
911 |
-
'sanitize' => 'textarea',
|
912 |
-
),
|
913 |
-
'um_profile_object_cache_stop' => array(
|
914 |
-
'sanitize' => 'bool',
|
915 |
-
),
|
916 |
-
'enable_blocks' => array(
|
917 |
-
'sanitize' => 'bool',
|
918 |
-
),
|
919 |
-
'rest_api_version' => array(
|
920 |
-
'sanitize' => 'text',
|
921 |
-
),
|
922 |
-
'uninstall_on_delete' => array(
|
923 |
-
'sanitize' => 'bool',
|
924 |
-
),
|
925 |
-
)
|
926 |
-
);
|
927 |
-
|
928 |
-
$this->settings_map = apply_filters( 'um_settings_map', $settings_map );
|
929 |
-
|
930 |
-
/**
|
931 |
-
* UM hook
|
932 |
-
*
|
933 |
-
* @type filter
|
934 |
-
* @title um_settings_structure
|
935 |
-
* @description Extend UM Settings
|
936 |
-
* @input_vars
|
937 |
-
* [{"var":"$settings","type":"array","desc":"UM Settings"}]
|
938 |
-
* @change_log
|
939 |
-
* ["Since: 2.0"]
|
940 |
-
* @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
|
941 |
-
* @example
|
942 |
-
* <?php
|
943 |
-
* add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
|
944 |
-
* function my_settings_structure( $settings ) {
|
945 |
-
* // your code here
|
946 |
-
* return $settings;
|
947 |
-
* }
|
948 |
-
* ?>
|
949 |
-
*/
|
950 |
-
$this->settings_structure = apply_filters(
|
951 |
-
'um_settings_structure',
|
952 |
-
array(
|
953 |
-
'' => array(
|
954 |
-
'title' => __( 'General', 'ultimate-member' ),
|
955 |
-
'sections' => array(
|
956 |
-
'' => array(
|
957 |
-
'title' => __( 'Pages', 'ultimate-member' ),
|
958 |
-
'fields' => $general_pages_fields,
|
959 |
-
),
|
960 |
-
'users' => array(
|
961 |
-
'title' => __( 'Users', 'ultimate-member' ),
|
962 |
-
'fields' => array(
|
963 |
-
array(
|
964 |
-
'id' => 'permalink_base',
|
965 |
-
'type' => 'select',
|
966 |
-
'size' => 'small',
|
967 |
-
'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
|
968 |
-
// translators: %s: Profile page URL
|
969 |
-
'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ),
|
970 |
-
'options' => array(
|
971 |
-
'user_login' => __( 'Username', 'ultimate-member' ),
|
972 |
-
'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
|
973 |
-
'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
|
974 |
-
'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
|
975 |
-
'user_id' => __( 'User ID', 'ultimate-member' ),
|
976 |
-
),
|
977 |
-
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
978 |
-
),
|
979 |
-
array(
|
980 |
-
'id' => 'display_name',
|
981 |
-
'type' => 'select',
|
982 |
-
'size' => 'medium',
|
983 |
-
'label' => __( 'User Display Name', 'ultimate-member' ),
|
984 |
-
'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ),
|
985 |
-
'options' => array(
|
986 |
-
'default' => __( 'Default WP Display Name', 'ultimate-member' ),
|
987 |
-
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
988 |
-
'username' => __( 'Username', 'ultimate-member' ),
|
989 |
-
'full_name' => __( 'First name & last name', 'ultimate-member' ),
|
990 |
-
'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
|
991 |
-
'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
|
992 |
-
'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
|
993 |
-
'first_name' => __( 'First name only', 'ultimate-member' ),
|
994 |
-
'field' => __( 'Custom field(s)', 'ultimate-member' ),
|
995 |
-
),
|
996 |
-
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
997 |
-
),
|
998 |
-
array(
|
999 |
-
'id' => 'display_name_field',
|
1000 |
-
'type' => 'text',
|
1001 |
-
'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
|
1002 |
-
'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ),
|
1003 |
-
'conditional' => array( 'display_name', '=', 'field' ),
|
1004 |
-
),
|
1005 |
-
array(
|
1006 |
-
'id' => 'author_redirect',
|
1007 |
-
'type' => 'checkbox',
|
1008 |
-
'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
|
1009 |
-
'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
|
1010 |
-
),
|
1011 |
-
array(
|
1012 |
-
'id' => 'members_page',
|
1013 |
-
'type' => 'checkbox',
|
1014 |
-
'label' => __( 'Enable Members Directory', 'ultimate-member' ),
|
1015 |
-
'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
|
1016 |
-
),
|
1017 |
-
array(
|
1018 |
-
'id' => 'use_gravatars',
|
1019 |
-
'type' => 'checkbox',
|
1020 |
-
'label' => __( 'Use Gravatars?', 'ultimate-member' ),
|
1021 |
-
'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1022 |
-
),
|
1023 |
-
array(
|
1024 |
-
'id' => 'use_um_gravatar_default_builtin_image',
|
1025 |
-
'type' => 'select',
|
1026 |
-
'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
|
1027 |
-
'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
|
1028 |
-
'options' => array(
|
1029 |
-
'default' => __( 'Default', 'ultimate-member' ),
|
1030 |
-
'404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
|
1031 |
-
'mm' => __( 'Mystery Man', 'ultimate-member' ),
|
1032 |
-
'identicon' => __( 'Identicon', 'ultimate-member' ),
|
1033 |
-
'monsterid' => __( 'Monsterid', 'ultimate-member' ),
|
1034 |
-
'wavatar' => __( 'Wavatar', 'ultimate-member' ),
|
1035 |
-
'retro' => __( 'Retro', 'ultimate-member' ),
|
1036 |
-
'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
|
1037 |
-
),
|
1038 |
-
'conditional' => array( 'use_gravatars', '=', 1 ),
|
1039 |
-
'size' => 'medium',
|
1040 |
-
),
|
1041 |
-
array(
|
1042 |
-
'id' => 'use_um_gravatar_default_image',
|
1043 |
-
'type' => 'checkbox',
|
1044 |
-
'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
|
1045 |
-
'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1046 |
-
'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
|
1047 |
-
),
|
1048 |
-
array(
|
1049 |
-
'id' => 'require_strongpass',
|
1050 |
-
'type' => 'checkbox',
|
1051 |
-
'label' => __( 'Require a strong password?', 'ultimate-member' ),
|
1052 |
-
'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms.', 'ultimate-member' ),
|
1053 |
-
),
|
1054 |
-
array(
|
1055 |
-
'id' => 'password_min_chars',
|
1056 |
-
'type' => 'number',
|
1057 |
-
'label' => __( 'Password minimum length', 'ultimate-member' ),
|
1058 |
-
'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ),
|
1059 |
-
'size' => 'small',
|
1060 |
-
),
|
1061 |
-
array(
|
1062 |
-
'id' => 'password_max_chars',
|
1063 |
-
'type' => 'number',
|
1064 |
-
'label' => __( 'Password maximum length', 'ultimate-member' ),
|
1065 |
-
'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ),
|
1066 |
-
'size' => 'small',
|
1067 |
-
),
|
1068 |
-
array(
|
1069 |
-
'id' => 'profile_noindex',
|
1070 |
-
'type' => 'select',
|
1071 |
-
'size' => 'small',
|
1072 |
-
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
1073 |
-
'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
|
1074 |
-
'options' => array(
|
1075 |
-
'0' => __( 'No', 'ultimate-member' ),
|
1076 |
-
'1' => __( 'Yes', 'ultimate-member' ),
|
1077 |
-
),
|
1078 |
-
),
|
1079 |
-
array(
|
1080 |
-
'id' => 'activation_link_expiry_time',
|
1081 |
-
'type' => 'number',
|
1082 |
-
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
1083 |
-
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
|
1084 |
-
'size' => 'small',
|
1085 |
-
),
|
1086 |
-
),
|
1087 |
-
),
|
1088 |
-
'account' => array(
|
1089 |
-
'title' => __( 'Account', 'ultimate-member' ),
|
1090 |
-
'fields' => array(
|
1091 |
-
array(
|
1092 |
-
'id' => 'account_tab_password',
|
1093 |
-
'type' => 'checkbox',
|
1094 |
-
'label' => __( 'Password Account Tab', 'ultimate-member' ),
|
1095 |
-
'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
|
1096 |
-
),
|
1097 |
-
array(
|
1098 |
-
'id' => 'account_tab_privacy',
|
1099 |
-
'type' => 'checkbox',
|
1100 |
-
'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
|
1101 |
-
'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
|
1102 |
-
),
|
1103 |
-
array(
|
1104 |
-
'id' => 'account_tab_notifications',
|
1105 |
-
'type' => 'checkbox',
|
1106 |
-
'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
|
1107 |
-
'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
|
1108 |
-
),
|
1109 |
-
array(
|
1110 |
-
'id' => 'account_tab_delete',
|
1111 |
-
'type' => 'checkbox',
|
1112 |
-
'label' => __( 'Delete Account Tab', 'ultimate-member' ),
|
1113 |
-
'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
|
1114 |
-
),
|
1115 |
-
array(
|
1116 |
-
'id' => 'delete_account_text',
|
1117 |
-
'type' => 'textarea', // bug with wp 4.4? should be editor
|
1118 |
-
'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
|
1119 |
-
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ),
|
1120 |
-
'args' => array(
|
1121 |
-
'textarea_rows' => 6,
|
1122 |
-
),
|
1123 |
-
),
|
1124 |
-
array(
|
1125 |
-
'id' => 'delete_account_no_pass_required_text',
|
1126 |
-
'type' => 'textarea',
|
1127 |
-
'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
|
1128 |
-
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ),
|
1129 |
-
'args' => array(
|
1130 |
-
'textarea_rows' => 6,
|
1131 |
-
),
|
1132 |
-
),
|
1133 |
-
array(
|
1134 |
-
'id' => 'account_name',
|
1135 |
-
'type' => 'checkbox',
|
1136 |
-
'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
|
1137 |
-
'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
|
1138 |
-
),
|
1139 |
-
array(
|
1140 |
-
'id' => 'account_name_disable',
|
1141 |
-
'type' => 'checkbox',
|
1142 |
-
'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
|
1143 |
-
'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
|
1144 |
-
'conditional' => array( 'account_name', '=', '1' ),
|
1145 |
-
),
|
1146 |
-
array(
|
1147 |
-
'id' => 'account_name_require',
|
1148 |
-
'type' => 'checkbox',
|
1149 |
-
'label' => __( 'Require First & Last Name', 'ultimate-member' ),
|
1150 |
-
'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
|
1151 |
-
'conditional' => array( 'account_name', '=', '1' ),
|
1152 |
-
),
|
1153 |
-
array(
|
1154 |
-
'id' => 'account_email',
|
1155 |
-
'type' => 'checkbox',
|
1156 |
-
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
|
1157 |
-
'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
|
1158 |
-
),
|
1159 |
-
array(
|
1160 |
-
'id' => 'account_general_password',
|
1161 |
-
'type' => 'checkbox',
|
1162 |
-
'label' => __( 'Password is required?', 'ultimate-member' ),
|
1163 |
-
'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
|
1164 |
-
),
|
1165 |
-
array(
|
1166 |
-
'id' => 'account_hide_in_directory',
|
1167 |
-
'type' => 'checkbox',
|
1168 |
-
'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
|
1169 |
-
'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
|
1170 |
-
'conditional' => array( 'account_tab_privacy', '=', '1' ),
|
1171 |
-
),
|
1172 |
-
array(
|
1173 |
-
'id' => 'account_hide_in_directory_default',
|
1174 |
-
'type' => 'select',
|
1175 |
-
'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
|
1176 |
-
'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
|
1177 |
-
'options' => array(
|
1178 |
-
'No' => __( 'No', 'ultimate-member' ),
|
1179 |
-
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1180 |
-
),
|
1181 |
-
'size' => 'small',
|
1182 |
-
'conditional' => array( 'account_hide_in_directory', '=', '1' ),
|
1183 |
-
),
|
1184 |
-
),
|
1185 |
-
),
|
1186 |
-
'uploads' => array(
|
1187 |
-
'title' => __( 'Uploads', 'ultimate-member' ),
|
1188 |
-
'fields' => array(
|
1189 |
-
array(
|
1190 |
-
'id' => 'profile_photo_max_size',
|
1191 |
-
'type' => 'text',
|
1192 |
-
'size' => 'small',
|
1193 |
-
'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1194 |
-
'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
|
1195 |
-
),
|
1196 |
-
array(
|
1197 |
-
'id' => 'cover_photo_max_size',
|
1198 |
-
'type' => 'text',
|
1199 |
-
'size' => 'small',
|
1200 |
-
'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1201 |
-
'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
|
1202 |
-
),
|
1203 |
-
array(
|
1204 |
-
'id' => 'photo_thumb_sizes',
|
1205 |
-
'type' => 'multi_text',
|
1206 |
-
'size' => 'small',
|
1207 |
-
'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1208 |
-
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
|
1209 |
-
'validate' => 'numeric',
|
1210 |
-
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1211 |
-
'show_default_number' => 1,
|
1212 |
-
),
|
1213 |
-
array(
|
1214 |
-
'id' => 'cover_thumb_sizes',
|
1215 |
-
'type' => 'multi_text',
|
1216 |
-
'size' => 'small',
|
1217 |
-
'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1218 |
-
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
|
1219 |
-
'validate' => 'numeric',
|
1220 |
-
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1221 |
-
'show_default_number' => 1,
|
1222 |
-
),
|
1223 |
-
array(
|
1224 |
-
'id' => 'image_orientation_by_exif',
|
1225 |
-
'type' => 'checkbox',
|
1226 |
-
'label' => __( 'Change image orientation', 'ultimate-member' ),
|
1227 |
-
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
|
1228 |
-
),
|
1229 |
-
array(
|
1230 |
-
'id' => 'image_compression',
|
1231 |
-
'type' => 'text',
|
1232 |
-
'size' => 'small',
|
1233 |
-
'label' => __( 'Image Quality', 'ultimate-member' ),
|
1234 |
-
'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' ),
|
1235 |
-
),
|
1236 |
-
|
1237 |
-
array(
|
1238 |
-
'id' => 'image_max_width',
|
1239 |
-
'type' => 'text',
|
1240 |
-
'size' => 'small',
|
1241 |
-
'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
|
1242 |
-
'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
|
1243 |
-
),
|
1244 |
-
|
1245 |
-
array(
|
1246 |
-
'id' => 'cover_min_width',
|
1247 |
-
'type' => 'text',
|
1248 |
-
'size' => 'small',
|
1249 |
-
'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
|
1250 |
-
'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
|
1251 |
-
),
|
1252 |
-
),
|
1253 |
-
),
|
1254 |
-
),
|
1255 |
-
),
|
1256 |
-
'access' => array(
|
1257 |
-
'title' => __( 'Access', 'ultimate-member' ),
|
1258 |
-
'sections' => array(
|
1259 |
-
'' => array(
|
1260 |
-
'title' => __( 'Restriction Content', 'ultimate-member' ),
|
1261 |
-
'fields' => $access_fields,
|
1262 |
-
),
|
1263 |
-
'other' => array(
|
1264 |
-
'title' => __( 'Other', 'ultimate-member' ),
|
1265 |
-
'fields' => array(
|
1266 |
-
array(
|
1267 |
-
'id' => 'enable_reset_password_limit',
|
1268 |
-
'type' => 'checkbox',
|
1269 |
-
'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
|
1270 |
-
),
|
1271 |
-
array(
|
1272 |
-
'id' => 'reset_password_limit_number',
|
1273 |
-
'type' => 'text',
|
1274 |
-
'label' => __( 'Reset Password Limit', 'ultimate-member' ),
|
1275 |
-
'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
|
1276 |
-
'validate' => 'numeric',
|
1277 |
-
'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
|
1278 |
-
'size' => 'small',
|
1279 |
-
),
|
1280 |
-
array(
|
1281 |
-
'id' => 'blocked_emails',
|
1282 |
-
'type' => 'textarea',
|
1283 |
-
'label' => __( 'Blocked Email Addresses (Enter one email per line)', 'ultimate-member' ),
|
1284 |
-
'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ),
|
1285 |
-
),
|
1286 |
-
array(
|
1287 |
-
'id' => 'blocked_words',
|
1288 |
-
'type' => 'textarea',
|
1289 |
-
'label' => __( 'Blacklist Words (Enter one word per line)', 'ultimate-member' ),
|
1290 |
-
'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
|
1291 |
-
),
|
1292 |
-
),
|
1293 |
-
),
|
1294 |
-
),
|
1295 |
-
),
|
1296 |
-
'email' => array(
|
1297 |
-
'title' => __( 'Email', 'ultimate-member' ),
|
1298 |
-
'fields' => array(
|
1299 |
-
array(
|
1300 |
-
'id' => 'admin_email',
|
1301 |
-
'type' => 'text',
|
1302 |
-
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
|
1303 |
-
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1304 |
-
),
|
1305 |
-
array(
|
1306 |
-
'id' => 'mail_from',
|
1307 |
-
'type' => 'text',
|
1308 |
-
'label' => __( 'Mail appears from', 'ultimate-member' ),
|
1309 |
-
'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
|
1310 |
-
),
|
1311 |
-
array(
|
1312 |
-
'id' => 'mail_from_addr',
|
1313 |
-
'type' => 'text',
|
1314 |
-
'label' => __( 'Mail appears from address', 'ultimate-member' ),
|
1315 |
-
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1316 |
-
),
|
1317 |
-
array(
|
1318 |
-
'id' => 'email_html',
|
1319 |
-
'type' => 'checkbox',
|
1320 |
-
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
|
1321 |
-
'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ),
|
1322 |
-
),
|
1323 |
-
),
|
1324 |
-
),
|
1325 |
-
'appearance' => array(
|
1326 |
-
'title' => __( 'Appearance', 'ultimate-member' ),
|
1327 |
-
'sections' => array(
|
1328 |
-
'' => array(
|
1329 |
-
'title' => __( 'Profile', 'ultimate-member' ),
|
1330 |
-
'fields' => array(
|
1331 |
-
array(
|
1332 |
-
'id' => 'profile_template',
|
1333 |
-
'type' => 'select',
|
1334 |
-
'label' => __( 'Profile Default Template', 'ultimate-member' ),
|
1335 |
-
'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
|
1336 |
-
'default' => um_get_metadefault( 'profile_template' ),
|
1337 |
-
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
1338 |
-
'size' => 'small',
|
1339 |
-
),
|
1340 |
-
array(
|
1341 |
-
'id' => 'profile_max_width',
|
1342 |
-
'type' => 'text',
|
1343 |
-
'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
|
1344 |
-
'default' => um_get_metadefault( 'profile_max_width' ),
|
1345 |
-
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1346 |
-
'size' => 'small',
|
1347 |
-
),
|
1348 |
-
array(
|
1349 |
-
'id' => 'profile_area_max_width',
|
1350 |
-
'type' => 'text',
|
1351 |
-
'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
|
1352 |
-
'default' => um_get_metadefault( 'profile_area_max_width' ),
|
1353 |
-
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
1354 |
-
'size' => 'small',
|
1355 |
-
),
|
1356 |
-
array(
|
1357 |
-
'id' => 'profile_icons',
|
1358 |
-
'type' => 'select',
|
1359 |
-
'label' => __( 'Profile Field Icons', 'ultimate-member' ),
|
1360 |
-
'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
|
1361 |
-
'default' => um_get_metadefault( 'profile_icons' ),
|
1362 |
-
'options' => array(
|
1363 |
-
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1364 |
-
'label' => __( 'Show with label', 'ultimate-member' ),
|
1365 |
-
'off' => __( 'Turn off', 'ultimate-member' ),
|
1366 |
-
),
|
1367 |
-
'size' => 'small',
|
1368 |
-
),
|
1369 |
-
array(
|
1370 |
-
'id' => 'profile_primary_btn_word',
|
1371 |
-
'type' => 'text',
|
1372 |
-
'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
|
1373 |
-
'default' => um_get_metadefault( 'profile_primary_btn_word' ),
|
1374 |
-
'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
|
1375 |
-
'size' => 'medium',
|
1376 |
-
),
|
1377 |
-
array(
|
1378 |
-
'id' => 'profile_secondary_btn',
|
1379 |
-
'type' => 'checkbox',
|
1380 |
-
'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
|
1381 |
-
'default' => um_get_metadefault( 'profile_secondary_btn' ),
|
1382 |
-
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1383 |
-
),
|
1384 |
-
array(
|
1385 |
-
'id' => 'profile_secondary_btn_word',
|
1386 |
-
'type' => 'text',
|
1387 |
-
'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
|
1388 |
-
'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
|
1389 |
-
'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
|
1390 |
-
'conditional' => array( 'profile_secondary_btn', '=', 1 ),
|
1391 |
-
'size' => 'medium',
|
1392 |
-
),
|
1393 |
-
array(
|
1394 |
-
'id' => 'default_avatar',
|
1395 |
-
'type' => 'media',
|
1396 |
-
'label' => __( 'Default Profile Photo', 'ultimate-member' ),
|
1397 |
-
'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
|
1398 |
-
'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
|
1399 |
-
'default' => array(
|
1400 |
-
'url' => um_url . 'assets/img/default_avatar.jpg',
|
1401 |
-
),
|
1402 |
-
),
|
1403 |
-
array(
|
1404 |
-
'id' => 'default_cover',
|
1405 |
-
'type' => 'media',
|
1406 |
-
'url' => true,
|
1407 |
-
'preview' => false,
|
1408 |
-
'label' => __( 'Default Cover Photo', 'ultimate-member' ),
|
1409 |
-
'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ),
|
1410 |
-
'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
|
1411 |
-
),
|
1412 |
-
array(
|
1413 |
-
'id' => 'disable_profile_photo_upload',
|
1414 |
-
'type' => 'checkbox',
|
1415 |
-
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
1416 |
-
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
1417 |
-
'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
|
1418 |
-
),
|
1419 |
-
array(
|
1420 |
-
'id' => 'profile_photosize',
|
1421 |
-
'type' => 'select',
|
1422 |
-
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
1423 |
-
'default' => um_get_metadefault( 'profile_photosize' ),
|
1424 |
-
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
1425 |
-
'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1426 |
-
'size' => 'small',
|
1427 |
-
),
|
1428 |
-
array(
|
1429 |
-
'id' => 'profile_cover_enabled',
|
1430 |
-
'type' => 'checkbox',
|
1431 |
-
'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
|
1432 |
-
'default' => um_get_metadefault( 'profile_cover_enabled' ),
|
1433 |
-
'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
|
1434 |
-
),
|
1435 |
-
array(
|
1436 |
-
'id' => 'profile_coversize',
|
1437 |
-
'type' => 'select',
|
1438 |
-
'label' => __( 'Profile Cover Size', 'ultimate-member' ),
|
1439 |
-
'default' => um_get_metadefault( 'profile_coversize' ),
|
1440 |
-
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
1441 |
-
'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1442 |
-
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1443 |
-
'size' => 'small',
|
1444 |
-
),
|
1445 |
-
array(
|
1446 |
-
'id' => 'profile_cover_ratio',
|
1447 |
-
'type' => 'select',
|
1448 |
-
'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
|
1449 |
-
'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
|
1450 |
-
'default' => um_get_metadefault( 'profile_cover_ratio' ),
|
1451 |
-
'options' => array(
|
1452 |
-
'1.6:1' => '1.6:1',
|
1453 |
-
'2.7:1' => '2.7:1',
|
1454 |
-
'2.2:1' => '2.2:1',
|
1455 |
-
'3.2:1' => '3.2:1',
|
1456 |
-
),
|
1457 |
-
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1458 |
-
'size' => 'small',
|
1459 |
-
),
|
1460 |
-
array(
|
1461 |
-
'id' => 'profile_show_metaicon',
|
1462 |
-
'type' => 'checkbox',
|
1463 |
-
'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
|
1464 |
-
'default' => 0,
|
1465 |
-
'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
|
1466 |
-
),
|
1467 |
-
array(
|
1468 |
-
'id' => 'profile_show_name',
|
1469 |
-
'type' => 'checkbox',
|
1470 |
-
'label' => __( 'Show display name in profile header', 'ultimate-member' ),
|
1471 |
-
'default' => um_get_metadefault( 'profile_show_name' ),
|
1472 |
-
'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
|
1473 |
-
),
|
1474 |
-
array(
|
1475 |
-
'id' => 'profile_show_social_links',
|
1476 |
-
'type' => 'checkbox',
|
1477 |
-
'label' => __( 'Show social links in profile header', 'ultimate-member' ),
|
1478 |
-
'default' => um_get_metadefault( 'profile_show_social_links' ),
|
1479 |
-
'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
|
1480 |
-
),
|
1481 |
-
array(
|
1482 |
-
'id' => 'profile_show_bio',
|
1483 |
-
'type' => 'checkbox',
|
1484 |
-
'label' => __( 'Show user description in header', 'ultimate-member' ),
|
1485 |
-
'default' => um_get_metadefault( 'profile_show_bio' ),
|
1486 |
-
'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
|
1487 |
-
),
|
1488 |
-
array(
|
1489 |
-
'id' => 'profile_show_html_bio',
|
1490 |
-
'type' => 'checkbox',
|
1491 |
-
'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
|
1492 |
-
'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
|
1493 |
-
),
|
1494 |
-
array(
|
1495 |
-
'id' => 'profile_bio_maxchars',
|
1496 |
-
'type' => 'text',
|
1497 |
-
'label' => __( 'User description maximum chars', 'ultimate-member' ),
|
1498 |
-
'default' => um_get_metadefault( 'profile_bio_maxchars' ),
|
1499 |
-
'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
|
1500 |
-
'conditional' => array( 'profile_show_bio', '=', 1 ),
|
1501 |
-
'size' => 'small',
|
1502 |
-
),
|
1503 |
-
array(
|
1504 |
-
'id' => 'profile_header_menu',
|
1505 |
-
'type' => 'select',
|
1506 |
-
'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
|
1507 |
-
'default' => um_get_metadefault( 'profile_header_menu' ),
|
1508 |
-
'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
|
1509 |
-
'options' => array(
|
1510 |
-
'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
|
1511 |
-
'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
|
1512 |
-
),
|
1513 |
-
'size' => 'small',
|
1514 |
-
),
|
1515 |
-
array(
|
1516 |
-
'id' => 'profile_empty_text',
|
1517 |
-
'type' => 'checkbox',
|
1518 |
-
'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
|
1519 |
-
'default' => um_get_metadefault( 'profile_empty_text' ),
|
1520 |
-
'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
|
1521 |
-
),
|
1522 |
-
array(
|
1523 |
-
'id' => 'profile_empty_text_emo',
|
1524 |
-
'type' => 'checkbox',
|
1525 |
-
'label' => __( 'Show the emoticon', 'ultimate-member' ),
|
1526 |
-
'default' => um_get_metadefault( 'profile_empty_text_emo' ),
|
1527 |
-
'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
|
1528 |
-
'conditional' => array( 'profile_empty_text', '=', 1 ),
|
1529 |
-
),
|
1530 |
-
),
|
1531 |
-
),
|
1532 |
-
'profile_menu' => array(
|
1533 |
-
'title' => __( 'Profile Menu', 'ultimate-member' ),
|
1534 |
-
'fields' => $appearances_profile_menu_fields,
|
1535 |
-
),
|
1536 |
-
'registration_form' => array(
|
1537 |
-
'title' => __( 'Registration Form', 'ultimate-member' ),
|
1538 |
-
'fields' => array(
|
1539 |
-
array(
|
1540 |
-
'id' => 'register_template',
|
1541 |
-
'type' => 'select',
|
1542 |
-
'label' => __( 'Registration Default Template', 'ultimate-member' ),
|
1543 |
-
'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
|
1544 |
-
'default' => um_get_metadefault( 'register_template' ),
|
1545 |
-
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
1546 |
-
'size' => 'small',
|
1547 |
-
),
|
1548 |
-
array(
|
1549 |
-
'id' => 'register_max_width',
|
1550 |
-
'type' => 'text',
|
1551 |
-
'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
|
1552 |
-
'default' => um_get_metadefault( 'register_max_width' ),
|
1553 |
-
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1554 |
-
'size' => 'small',
|
1555 |
-
),
|
1556 |
-
array(
|
1557 |
-
'id' => 'register_align',
|
1558 |
-
'type' => 'select',
|
1559 |
-
'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
|
1560 |
-
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1561 |
-
'default' => um_get_metadefault( 'register_align' ),
|
1562 |
-
'options' => array(
|
1563 |
-
'center' => __( 'Centered', 'ultimate-member' ),
|
1564 |
-
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1565 |
-
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1566 |
-
),
|
1567 |
-
'size' => 'small',
|
1568 |
-
),
|
1569 |
-
array(
|
1570 |
-
'id' => 'register_icons',
|
1571 |
-
'type' => 'select',
|
1572 |
-
'label' => __( 'Registration Field Icons', 'ultimate-member' ),
|
1573 |
-
'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
|
1574 |
-
'default' => um_get_metadefault( 'register_icons' ),
|
1575 |
-
'options' => array(
|
1576 |
-
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1577 |
-
'label' => __( 'Show with label', 'ultimate-member' ),
|
1578 |
-
'off' => __( 'Turn off', 'ultimate-member' ),
|
1579 |
-
),
|
1580 |
-
'size' => 'small',
|
1581 |
-
),
|
1582 |
-
array(
|
1583 |
-
'id' => 'register_primary_btn_word',
|
1584 |
-
'type' => 'text',
|
1585 |
-
'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
|
1586 |
-
'default' => um_get_metadefault( 'register_primary_btn_word' ),
|
1587 |
-
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1588 |
-
'size' => 'medium',
|
1589 |
-
),
|
1590 |
-
array(
|
1591 |
-
'id' => 'register_secondary_btn',
|
1592 |
-
'type' => 'checkbox',
|
1593 |
-
'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
|
1594 |
-
'default' => 1,
|
1595 |
-
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1596 |
-
),
|
1597 |
-
array(
|
1598 |
-
'id' => 'register_secondary_btn_word',
|
1599 |
-
'type' => 'text',
|
1600 |
-
'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
|
1601 |
-
'default' => um_get_metadefault( 'register_secondary_btn_word' ),
|
1602 |
-
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1603 |
-
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1604 |
-
'size' => 'medium',
|
1605 |
-
),
|
1606 |
-
array(
|
1607 |
-
'id' => 'register_secondary_btn_url',
|
1608 |
-
'type' => 'text',
|
1609 |
-
'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
|
1610 |
-
'default' => um_get_metadefault( 'register_secondary_btn_url' ),
|
1611 |
-
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1612 |
-
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1613 |
-
'size' => 'medium',
|
1614 |
-
),
|
1615 |
-
array(
|
1616 |
-
'id' => 'register_role',
|
1617 |
-
'type' => 'select',
|
1618 |
-
'label' => __( 'Registration Default Role', 'ultimate-member' ),
|
1619 |
-
'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
|
1620 |
-
'default' => um_get_metadefault( 'register_role' ),
|
1621 |
-
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
1622 |
-
'size' => 'small',
|
1623 |
-
),
|
1624 |
-
),
|
1625 |
-
),
|
1626 |
-
'login_form' => array(
|
1627 |
-
'title' => __( 'Login Form', 'ultimate-member' ),
|
1628 |
-
'fields' => array(
|
1629 |
-
array(
|
1630 |
-
'id' => 'login_template',
|
1631 |
-
'type' => 'select',
|
1632 |
-
'label' => __( 'Login Default Template', 'ultimate-member' ),
|
1633 |
-
'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
|
1634 |
-
'default' => um_get_metadefault( 'login_template' ),
|
1635 |
-
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
1636 |
-
'size' => 'small',
|
1637 |
-
),
|
1638 |
-
array(
|
1639 |
-
'id' => 'login_max_width',
|
1640 |
-
'type' => 'text',
|
1641 |
-
'label' => __( 'Login Maximum Width', 'ultimate-member' ),
|
1642 |
-
'default' => um_get_metadefault( 'login_max_width' ),
|
1643 |
-
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1644 |
-
'size' => 'small',
|
1645 |
-
),
|
1646 |
-
array(
|
1647 |
-
'id' => 'login_align',
|
1648 |
-
'type' => 'select',
|
1649 |
-
'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
|
1650 |
-
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1651 |
-
'default' => um_get_metadefault( 'login_align' ),
|
1652 |
-
'options' => array(
|
1653 |
-
'center' => __( 'Centered', 'ultimate-member' ),
|
1654 |
-
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1655 |
-
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1656 |
-
),
|
1657 |
-
'size' => 'small',
|
1658 |
-
),
|
1659 |
-
array(
|
1660 |
-
'id' => 'login_icons',
|
1661 |
-
'type' => 'select',
|
1662 |
-
'label' => __( 'Login Field Icons', 'ultimate-member' ),
|
1663 |
-
'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
|
1664 |
-
'default' => um_get_metadefault( 'login_icons' ),
|
1665 |
-
'options' => array(
|
1666 |
-
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1667 |
-
'label' => __( 'Show with label', 'ultimate-member' ),
|
1668 |
-
'off' => __( 'Turn off', 'ultimate-member' ),
|
1669 |
-
),
|
1670 |
-
'size' => 'small',
|
1671 |
-
),
|
1672 |
-
array(
|
1673 |
-
'id' => 'login_primary_btn_word',
|
1674 |
-
'type' => 'text',
|
1675 |
-
'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
|
1676 |
-
'default' => um_get_metadefault( 'login_primary_btn_word' ),
|
1677 |
-
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1678 |
-
'size' => 'medium',
|
1679 |
-
),
|
1680 |
-
array(
|
1681 |
-
'id' => 'login_secondary_btn',
|
1682 |
-
'type' => 'checkbox',
|
1683 |
-
'label' => __( 'Login Secondary Button', 'ultimate-member' ),
|
1684 |
-
'default' => 1,
|
1685 |
-
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1686 |
-
),
|
1687 |
-
array(
|
1688 |
-
'id' => 'login_secondary_btn_word',
|
1689 |
-
'type' => 'text',
|
1690 |
-
'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
|
1691 |
-
'default' => um_get_metadefault( 'login_secondary_btn_word' ),
|
1692 |
-
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1693 |
-
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1694 |
-
'size' => 'medium',
|
1695 |
-
),
|
1696 |
-
array(
|
1697 |
-
'id' => 'login_secondary_btn_url',
|
1698 |
-
'type' => 'text',
|
1699 |
-
'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
|
1700 |
-
'default' => um_get_metadefault( 'login_secondary_btn_url' ),
|
1701 |
-
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1702 |
-
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1703 |
-
'size' => 'medium',
|
1704 |
-
),
|
1705 |
-
array(
|
1706 |
-
'id' => 'login_forgot_pass_link',
|
1707 |
-
'type' => 'checkbox',
|
1708 |
-
'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
|
1709 |
-
'default' => 1,
|
1710 |
-
'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
|
1711 |
-
),
|
1712 |
-
array(
|
1713 |
-
'id' => 'login_show_rememberme',
|
1714 |
-
'type' => 'checkbox',
|
1715 |
-
'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
|
1716 |
-
'default' => 1,
|
1717 |
-
'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ),
|
1718 |
-
),
|
1719 |
-
),
|
1720 |
-
),
|
1721 |
-
),
|
1722 |
-
),
|
1723 |
-
'extensions' => array(
|
1724 |
-
'title' => __( 'Extensions', 'ultimate-member' ),
|
1725 |
-
),
|
1726 |
-
'licenses' => array(
|
1727 |
-
'title' => __( 'Licenses', 'ultimate-member' ),
|
1728 |
-
),
|
1729 |
-
'misc' => array(
|
1730 |
-
'title' => __( 'Misc', 'ultimate-member' ),
|
1731 |
-
'fields' => array(
|
1732 |
-
array(
|
1733 |
-
'id' => 'form_asterisk',
|
1734 |
-
'type' => 'checkbox',
|
1735 |
-
'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
|
1736 |
-
),
|
1737 |
-
array(
|
1738 |
-
'id' => 'profile_title',
|
1739 |
-
'type' => 'text',
|
1740 |
-
'label' => __( 'User Profile Title', 'ultimate-member' ),
|
1741 |
-
'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
|
1742 |
-
'size' => 'medium',
|
1743 |
-
),
|
1744 |
-
array(
|
1745 |
-
'id' => 'profile_desc',
|
1746 |
-
'type' => 'textarea',
|
1747 |
-
'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
|
1748 |
-
'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
|
1749 |
-
'args' => array(
|
1750 |
-
'textarea_rows' => 6,
|
1751 |
-
),
|
1752 |
-
),
|
1753 |
-
array(
|
1754 |
-
'id' => 'um_profile_object_cache_stop',
|
1755 |
-
'type' => 'checkbox',
|
1756 |
-
'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
|
1757 |
-
'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
|
1758 |
-
),
|
1759 |
-
array(
|
1760 |
-
'id' => 'enable_blocks',
|
1761 |
-
'type' => 'checkbox',
|
1762 |
-
'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
|
1763 |
-
'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ),
|
1764 |
-
),
|
1765 |
-
array(
|
1766 |
-
'id' => 'rest_api_version',
|
1767 |
-
'type' => 'select',
|
1768 |
-
'label' => __( 'REST API version', 'ultimate-member' ),
|
1769 |
-
'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
|
1770 |
-
'options' => array(
|
1771 |
-
'1.0' => __( '1.0 version', 'ultimate-member' ),
|
1772 |
-
'2.0' => __( '2.0 version', 'ultimate-member' ),
|
1773 |
-
),
|
1774 |
-
),
|
1775 |
-
// backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
|
1776 |
-
// otherwise we filtering only results and restricted posts/terms can be visible
|
1777 |
-
array(
|
1778 |
-
'id' => 'disable_restriction_pre_queries',
|
1779 |
-
'type' => 'checkbox',
|
1780 |
-
'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
|
1781 |
-
'tooltip' => __( 'Please enable this option only in the cases when you have big or unnecessary queries on your site with active restriction logic. If you want to exclude posts only from the results queries instead of pre_get_posts and fully-hidden post logic also please enable this option. It activates the restriction content logic until 2.2.x version without latest security enhancements', 'ultimate-member' ),
|
1782 |
-
),
|
1783 |
-
$same_page_update,
|
1784 |
-
array(
|
1785 |
-
'id' => 'uninstall_on_delete',
|
1786 |
-
'type' => 'checkbox',
|
1787 |
-
'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
|
1788 |
-
'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ),
|
1789 |
-
),
|
1790 |
-
),
|
1791 |
-
),
|
1792 |
-
'install_info' => array(
|
1793 |
-
'title' => __( 'Install Info', 'ultimate-member' ),
|
1794 |
-
'fields' => array(
|
1795 |
-
array(
|
1796 |
-
'type' => 'install_info',
|
1797 |
-
),
|
1798 |
-
),
|
1799 |
-
),
|
1800 |
-
)
|
1801 |
-
);
|
1802 |
-
|
1803 |
-
}
|
1804 |
-
|
1805 |
-
|
1806 |
-
/**
|
1807 |
-
* @param array $settings
|
1808 |
-
*
|
1809 |
-
* @return array
|
1810 |
-
*/
|
1811 |
-
public function sorting_licenses_options( $settings ) {
|
1812 |
-
//sorting licenses
|
1813 |
-
if ( ! empty( $settings['licenses']['fields'] ) ) {
|
1814 |
-
$licenses = $settings['licenses']['fields'];
|
1815 |
-
@uasort( $licenses, function( $a, $b ) {
|
1816 |
-
return strnatcasecmp( $a['label'], $b['label'] );
|
1817 |
-
} );
|
1818 |
-
$settings['licenses']['fields'] = $licenses;
|
1819 |
-
}
|
1820 |
-
|
1821 |
-
//sorting extensions by the title
|
1822 |
-
if ( ! empty( $settings['extensions']['sections'] ) ) {
|
1823 |
-
$extensions = $settings['extensions']['sections'];
|
1824 |
-
|
1825 |
-
@uasort( $extensions, function( $a, $b ) {
|
1826 |
-
return strnatcasecmp( $a['title'], $b['title'] );
|
1827 |
-
} );
|
1828 |
-
|
1829 |
-
$keys = array_keys( $extensions );
|
1830 |
-
$temp = array(
|
1831 |
-
'' => $extensions[ $keys[0] ],
|
1832 |
-
);
|
1833 |
-
|
1834 |
-
unset( $extensions[ $keys[0] ] );
|
1835 |
-
$extensions = $temp + $extensions;
|
1836 |
-
|
1837 |
-
$settings['extensions']['sections'] = $extensions;
|
1838 |
-
}
|
1839 |
-
|
1840 |
-
return $settings;
|
1841 |
-
}
|
1842 |
-
|
1843 |
-
|
1844 |
-
/**
|
1845 |
-
* @param $tab
|
1846 |
-
* @param $section
|
1847 |
-
*
|
1848 |
-
* @return array
|
1849 |
-
*/
|
1850 |
-
function get_section_fields( $tab, $section ) {
|
1851 |
-
|
1852 |
-
if ( empty( $this->settings_structure[ $tab ] ) ) {
|
1853 |
-
return array();
|
1854 |
-
}
|
1855 |
-
|
1856 |
-
if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
1857 |
-
return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
1858 |
-
} elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
|
1859 |
-
return $this->settings_structure[ $tab ]['fields'];
|
1860 |
-
}
|
1861 |
-
|
1862 |
-
return array();
|
1863 |
-
}
|
1864 |
-
|
1865 |
-
|
1866 |
-
/**
|
1867 |
-
* Setup admin menu
|
1868 |
-
*/
|
1869 |
-
function primary_admin_menu() {
|
1870 |
-
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
|
1871 |
-
}
|
1872 |
-
|
1873 |
-
|
1874 |
-
/**
|
1875 |
-
* Settings page callback
|
1876 |
-
*/
|
1877 |
-
function settings_page() {
|
1878 |
-
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
1879 |
-
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
1880 |
-
|
1881 |
-
$settings_struct = $this->settings_structure[ $current_tab ];
|
1882 |
-
|
1883 |
-
//remove not option hidden fields
|
1884 |
-
if ( ! empty( $settings_struct['fields'] ) ) {
|
1885 |
-
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
|
1886 |
-
|
1887 |
-
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
1888 |
-
unset( $settings_struct['fields'][ $field_key ] );
|
1889 |
-
}
|
1890 |
-
|
1891 |
-
}
|
1892 |
-
}
|
1893 |
-
|
1894 |
-
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
|
1895 |
-
um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
|
1896 |
-
}
|
1897 |
-
|
1898 |
-
if ( ! empty( $settings_struct['sections'] ) ) {
|
1899 |
-
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
|
1900 |
-
um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
|
1901 |
-
}
|
1902 |
-
}
|
1903 |
-
|
1904 |
-
echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
|
1905 |
-
|
1906 |
-
echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
|
1907 |
-
|
1908 |
-
/**
|
1909 |
-
* UM hook
|
1910 |
-
*
|
1911 |
-
* @type action
|
1912 |
-
* @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
|
1913 |
-
* @description Show some content before settings page content
|
1914 |
-
* @change_log
|
1915 |
-
* ["Since: 2.0"]
|
1916 |
-
* @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
|
1917 |
-
* @example
|
1918 |
-
* <?php
|
1919 |
-
* add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
|
1920 |
-
* function my_settings_page_before() {
|
1921 |
-
* // your code here
|
1922 |
-
* }
|
1923 |
-
* ?>
|
1924 |
-
*/
|
1925 |
-
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
1926 |
-
|
1927 |
-
if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) {
|
1928 |
-
|
1929 |
-
/**
|
1930 |
-
* UM hook
|
1931 |
-
*
|
1932 |
-
* @type action
|
1933 |
-
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1934 |
-
* @description Show some content before section content at settings page
|
1935 |
-
* @change_log
|
1936 |
-
* ["Since: 2.0"]
|
1937 |
-
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1938 |
-
* @example
|
1939 |
-
* <?php
|
1940 |
-
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1941 |
-
* function my_settings_page_before_section() {
|
1942 |
-
* // your code here
|
1943 |
-
* }
|
1944 |
-
* ?>
|
1945 |
-
*/
|
1946 |
-
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
1947 |
-
|
1948 |
-
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
1949 |
-
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
1950 |
-
|
1951 |
-
/**
|
1952 |
-
* UM hook
|
1953 |
-
*
|
1954 |
-
* @type filter
|
1955 |
-
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
1956 |
-
*
|
1957 |
-
* @description Render settings section
|
1958 |
-
* @input_vars
|
1959 |
-
* [{"var":"$content","type":"string","desc":"Section content"},
|
1960 |
-
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
1961 |
-
* @change_log
|
1962 |
-
* ["Since: 2.0"]
|
1963 |
-
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
1964 |
-
* @example
|
1965 |
-
* <?php
|
1966 |
-
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
1967 |
-
* function my_settings_section( $content ) {
|
1968 |
-
* // your code here
|
1969 |
-
* return $content;
|
1970 |
-
* }
|
1971 |
-
* ?>
|
1972 |
-
*/
|
1973 |
-
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
1974 |
-
$settings_section,
|
1975 |
-
$section_fields
|
1976 |
-
);
|
1977 |
-
|
1978 |
-
} else { ?>
|
1979 |
-
|
1980 |
-
<form method="post" action="" name="um-settings-form" id="um-settings-form">
|
1981 |
-
<input type="hidden" value="save" name="um-settings-action" />
|
1982 |
-
|
1983 |
-
<?php
|
1984 |
-
/**
|
1985 |
-
* UM hook
|
1986 |
-
*
|
1987 |
-
* @type action
|
1988 |
-
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1989 |
-
* @description Show some content before section content at settings page
|
1990 |
-
* @change_log
|
1991 |
-
* ["Since: 2.0"]
|
1992 |
-
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1993 |
-
* @example
|
1994 |
-
* <?php
|
1995 |
-
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1996 |
-
* function my_settings_page_before_section() {
|
1997 |
-
* // your code here
|
1998 |
-
* }
|
1999 |
-
* ?>
|
2000 |
-
*/
|
2001 |
-
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
2002 |
-
|
2003 |
-
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
2004 |
-
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
2005 |
-
|
2006 |
-
/**
|
2007 |
-
* UM hook
|
2008 |
-
*
|
2009 |
-
* @type filter
|
2010 |
-
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
2011 |
-
* @description Render settings section
|
2012 |
-
* @input_vars
|
2013 |
-
* [{"var":"$content","type":"string","desc":"Section content"},
|
2014 |
-
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
2015 |
-
* @change_log
|
2016 |
-
* ["Since: 2.0"]
|
2017 |
-
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
2018 |
-
* @example
|
2019 |
-
* <?php
|
2020 |
-
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
2021 |
-
* function my_settings_section( $content ) {
|
2022 |
-
* // your code here
|
2023 |
-
* return $content;
|
2024 |
-
* }
|
2025 |
-
* ?>
|
2026 |
-
*/
|
2027 |
-
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
2028 |
-
$settings_section,
|
2029 |
-
$section_fields
|
2030 |
-
); ?>
|
2031 |
-
|
2032 |
-
|
2033 |
-
<p class="submit">
|
2034 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
|
2035 |
-
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2036 |
-
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2037 |
-
</p>
|
2038 |
-
</form>
|
2039 |
-
|
2040 |
-
<?php }
|
2041 |
-
}
|
2042 |
-
|
2043 |
-
|
2044 |
-
/**
|
2045 |
-
* Generate pages tabs
|
2046 |
-
*
|
2047 |
-
* @param string $page
|
2048 |
-
* @return string
|
2049 |
-
*/
|
2050 |
-
function generate_tabs_menu( $page = 'settings' ) {
|
2051 |
-
|
2052 |
-
$tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
|
2053 |
-
|
2054 |
-
switch( $page ) {
|
2055 |
-
case 'settings':
|
2056 |
-
$menu_tabs = array();
|
2057 |
-
foreach ( $this->settings_structure as $slug => $tab ) {
|
2058 |
-
if ( ! empty( $tab['fields'] ) ) {
|
2059 |
-
foreach ( $tab['fields'] as $field_key => $field_options ) {
|
2060 |
-
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
2061 |
-
unset( $tab['fields'][ $field_key ] );
|
2062 |
-
}
|
2063 |
-
}
|
2064 |
-
}
|
2065 |
-
|
2066 |
-
if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
|
2067 |
-
$menu_tabs[ $slug ] = $tab['title'];
|
2068 |
-
}
|
2069 |
-
}
|
2070 |
-
|
2071 |
-
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2072 |
-
foreach ( $menu_tabs as $name => $label ) {
|
2073 |
-
$active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
|
2074 |
-
$tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
|
2075 |
-
$label .
|
2076 |
-
'</a>';
|
2077 |
-
}
|
2078 |
-
|
2079 |
-
break;
|
2080 |
-
default:
|
2081 |
-
/**
|
2082 |
-
* UM hook
|
2083 |
-
*
|
2084 |
-
* @type filter
|
2085 |
-
* @title um_generate_tabs_menu_{$page}
|
2086 |
-
* @description Generate tabs menu
|
2087 |
-
* @input_vars
|
2088 |
-
* [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
|
2089 |
-
* @change_log
|
2090 |
-
* ["Since: 2.0"]
|
2091 |
-
* @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
|
2092 |
-
* @example
|
2093 |
-
* <?php
|
2094 |
-
* add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
|
2095 |
-
* function my_tabs_menu( $tabs ) {
|
2096 |
-
* // your code here
|
2097 |
-
* return $tabs;
|
2098 |
-
* }
|
2099 |
-
* ?>
|
2100 |
-
*/
|
2101 |
-
$tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
|
2102 |
-
break;
|
2103 |
-
}
|
2104 |
-
|
2105 |
-
return $tabs . '</h2>';
|
2106 |
-
}
|
2107 |
-
|
2108 |
-
|
2109 |
-
/**
|
2110 |
-
* @param string $tab
|
2111 |
-
*
|
2112 |
-
* @return string
|
2113 |
-
*/
|
2114 |
-
function generate_subtabs_menu( $tab = '' ) {
|
2115 |
-
if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
|
2116 |
-
return '';
|
2117 |
-
}
|
2118 |
-
|
2119 |
-
$menu_subtabs = array();
|
2120 |
-
foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
|
2121 |
-
$menu_subtabs[ $slug ] = $subtab['title'];
|
2122 |
-
}
|
2123 |
-
|
2124 |
-
$subtabs = '<div><ul class="subsubsub">';
|
2125 |
-
|
2126 |
-
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2127 |
-
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
2128 |
-
foreach ( $menu_subtabs as $name => $label ) {
|
2129 |
-
$active = ( $current_subtab == $name ) ? 'current' : '';
|
2130 |
-
$subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '§ion=' . $name ) ) ) . '" class="' . $active . '">'
|
2131 |
-
. $label .
|
2132 |
-
'</a> | ';
|
2133 |
-
}
|
2134 |
-
|
2135 |
-
return substr( $subtabs, 0, -3 ) . '</ul></div>';
|
2136 |
-
}
|
2137 |
-
|
2138 |
-
|
2139 |
-
/**
|
2140 |
-
* Handler for settings forms
|
2141 |
-
* when "Save Settings" button click
|
2142 |
-
*
|
2143 |
-
*/
|
2144 |
-
function save_settings_handler() {
|
2145 |
-
|
2146 |
-
if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
|
2147 |
-
|
2148 |
-
$nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
|
2149 |
-
|
2150 |
-
if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
|
2151 |
-
// This nonce is not valid.
|
2152 |
-
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
2153 |
-
}
|
2154 |
-
|
2155 |
-
/**
|
2156 |
-
* UM hook
|
2157 |
-
*
|
2158 |
-
* @type action
|
2159 |
-
* @title um_settings_before_save
|
2160 |
-
* @description Before settings save action
|
2161 |
-
* @change_log
|
2162 |
-
* ["Since: 2.0"]
|
2163 |
-
* @usage add_action( 'um_settings_before_save', 'function_name', 10 );
|
2164 |
-
* @example
|
2165 |
-
* <?php
|
2166 |
-
* add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
|
2167 |
-
* function my_settings_before_save() {
|
2168 |
-
* // your code here
|
2169 |
-
* }
|
2170 |
-
* ?>
|
2171 |
-
*/
|
2172 |
-
do_action( "um_settings_before_save" );
|
2173 |
-
|
2174 |
-
/**
|
2175 |
-
* UM hook
|
2176 |
-
*
|
2177 |
-
* @type filter
|
2178 |
-
* @title um_change_settings_before_save
|
2179 |
-
* @description Change settings before save
|
2180 |
-
* @input_vars
|
2181 |
-
* [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
|
2182 |
-
* @change_log
|
2183 |
-
* ["Since: 2.0"]
|
2184 |
-
* @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
|
2185 |
-
* @example
|
2186 |
-
* <?php
|
2187 |
-
* add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
|
2188 |
-
* function my_change_settings_before_save( $settings ) {
|
2189 |
-
* // your code here
|
2190 |
-
* return $settings;
|
2191 |
-
* }
|
2192 |
-
* ?>
|
2193 |
-
*/
|
2194 |
-
$settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
|
2195 |
-
|
2196 |
-
$settings = UM()->admin()->sanitize_options( $settings );
|
2197 |
-
|
2198 |
-
foreach ( $settings as $key => $value ) {
|
2199 |
-
UM()->options()->update( $key, $value );
|
2200 |
-
}
|
2201 |
-
|
2202 |
-
/**
|
2203 |
-
* UM hook
|
2204 |
-
*
|
2205 |
-
* @type action
|
2206 |
-
* @title um_settings_save
|
2207 |
-
* @description After settings save action
|
2208 |
-
* @change_log
|
2209 |
-
* ["Since: 2.0"]
|
2210 |
-
* @usage add_action( 'um_settings_save', 'function_name', 10 );
|
2211 |
-
* @example
|
2212 |
-
* <?php
|
2213 |
-
* add_action( 'um_settings_save', 'my_settings_save', 10 );
|
2214 |
-
* function my_settings_save() {
|
2215 |
-
* // your code here
|
2216 |
-
* }
|
2217 |
-
* ?>
|
2218 |
-
*/
|
2219 |
-
do_action( 'um_settings_save' );
|
2220 |
-
|
2221 |
-
//redirect after save settings
|
2222 |
-
$arg = array(
|
2223 |
-
'page' => 'um_options',
|
2224 |
-
'update' => 'settings_updated',
|
2225 |
-
);
|
2226 |
-
|
2227 |
-
if ( ! empty( $_GET['tab'] ) ) {
|
2228 |
-
$arg['tab'] = sanitize_key( $_GET['tab'] );
|
2229 |
-
}
|
2230 |
-
|
2231 |
-
if ( ! empty( $_GET['section'] ) ) {
|
2232 |
-
$arg['section'] = sanitize_key( $_GET['section'] );
|
2233 |
-
}
|
2234 |
-
|
2235 |
-
um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
|
2236 |
-
}
|
2237 |
-
}
|
2238 |
-
|
2239 |
-
|
2240 |
-
function set_default_if_empty( $settings ) {
|
2241 |
-
$tab = '';
|
2242 |
-
if ( ! empty( $_GET['tab'] ) ) {
|
2243 |
-
$tab = sanitize_key( $_GET['tab'] );
|
2244 |
-
}
|
2245 |
-
|
2246 |
-
$section = '';
|
2247 |
-
if ( ! empty( $_GET['section'] ) ) {
|
2248 |
-
$section = sanitize_key( $_GET['section'] );
|
2249 |
-
}
|
2250 |
-
|
2251 |
-
|
2252 |
-
if ( 'access' === $tab && empty( $section ) ) {
|
2253 |
-
if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
|
2254 |
-
$settings['access_exclude_uris'] = array();
|
2255 |
-
}
|
2256 |
-
}
|
2257 |
-
|
2258 |
-
return $settings;
|
2259 |
-
}
|
2260 |
-
|
2261 |
-
|
2262 |
-
/**
|
2263 |
-
* Remove empty values from multi text fields
|
2264 |
-
*
|
2265 |
-
* @param $settings
|
2266 |
-
* @return array
|
2267 |
-
*/
|
2268 |
-
function remove_empty_values( $settings ) {
|
2269 |
-
$tab = '';
|
2270 |
-
if ( ! empty( $_GET['tab'] ) ) {
|
2271 |
-
$tab = sanitize_key( $_GET['tab'] );
|
2272 |
-
}
|
2273 |
-
|
2274 |
-
$section = '';
|
2275 |
-
if ( ! empty( $_GET['section'] ) ) {
|
2276 |
-
$section = sanitize_key( $_GET['section'] );
|
2277 |
-
}
|
2278 |
-
|
2279 |
-
if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
2280 |
-
$fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
2281 |
-
} else {
|
2282 |
-
$fields = $this->settings_structure[ $tab ]['fields'];
|
2283 |
-
}
|
2284 |
-
|
2285 |
-
if ( empty( $fields ) ) {
|
2286 |
-
return $settings;
|
2287 |
-
}
|
2288 |
-
|
2289 |
-
|
2290 |
-
$filtered_settings = array();
|
2291 |
-
foreach ( $settings as $key => $value ) {
|
2292 |
-
|
2293 |
-
$filtered_settings[ $key ] = $value;
|
2294 |
-
|
2295 |
-
foreach ( $fields as $field ) {
|
2296 |
-
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
|
2297 |
-
$filtered_settings[ $key ] = array_filter( $settings[ $key ] );
|
2298 |
-
}
|
2299 |
-
}
|
2300 |
-
}
|
2301 |
-
|
2302 |
-
return $filtered_settings;
|
2303 |
-
}
|
2304 |
-
|
2305 |
-
|
2306 |
-
/**
|
2307 |
-
*
|
2308 |
-
*/
|
2309 |
-
function check_permalinks_changes() {
|
2310 |
-
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2311 |
-
if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
|
2312 |
-
$this->need_change_permalinks = true;
|
2313 |
-
}
|
2314 |
-
}
|
2315 |
-
|
2316 |
-
// set variable if gravatar settings were changed
|
2317 |
-
// update for um_member_directory_data metakey
|
2318 |
-
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2319 |
-
$use_gravatar = UM()->options()->get( 'use_gravatars' );
|
2320 |
-
if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
|
2321 |
-
$this->gravatar_changed = true;
|
2322 |
-
}
|
2323 |
-
}
|
2324 |
-
}
|
2325 |
-
|
2326 |
-
|
2327 |
-
/**
|
2328 |
-
*
|
2329 |
-
*/
|
2330 |
-
function on_settings_save() {
|
2331 |
-
if ( ! empty( $_POST['um_options'] ) ) {
|
2332 |
-
|
2333 |
-
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
2334 |
-
$post_ids = new \WP_Query( array(
|
2335 |
-
'post_type' => 'page',
|
2336 |
-
'meta_query' => array(
|
2337 |
-
array(
|
2338 |
-
'key' => '_um_core',
|
2339 |
-
'compare' => 'EXISTS'
|
2340 |
-
)
|
2341 |
-
),
|
2342 |
-
'posts_per_page' => -1,
|
2343 |
-
'fields' => 'ids'
|
2344 |
-
) );
|
2345 |
-
|
2346 |
-
$post_ids = $post_ids->get_posts();
|
2347 |
-
|
2348 |
-
if ( ! empty( $post_ids ) ) {
|
2349 |
-
foreach ( $post_ids as $post_id ) {
|
2350 |
-
delete_post_meta( $post_id, '_um_core' );
|
2351 |
-
}
|
2352 |
-
}
|
2353 |
-
|
2354 |
-
foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
|
2355 |
-
$slug = str_replace( 'core_', '', $option_slug );
|
2356 |
-
update_post_meta( $post_id, '_um_core', $slug );
|
2357 |
-
}
|
2358 |
-
|
2359 |
-
// reset rewrite rules after re-save pages
|
2360 |
-
UM()->rewrite()->reset_rules();
|
2361 |
-
|
2362 |
-
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2363 |
-
if ( ! empty( $this->need_change_permalinks ) ) {
|
2364 |
-
$users = get_users( array(
|
2365 |
-
'fields' => 'ids',
|
2366 |
-
) );
|
2367 |
-
if ( ! empty( $users ) ) {
|
2368 |
-
foreach ( $users as $user_id ) {
|
2369 |
-
UM()->user()->generate_profile_slug( $user_id );
|
2370 |
-
}
|
2371 |
-
}
|
2372 |
-
}
|
2373 |
-
|
2374 |
-
|
2375 |
-
// update for um_member_directory_data metakey
|
2376 |
-
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2377 |
-
if ( $this->gravatar_changed ) {
|
2378 |
-
global $wpdb;
|
2379 |
-
|
2380 |
-
if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
|
2381 |
-
|
2382 |
-
$results = $wpdb->get_col(
|
2383 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2384 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
|
2385 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2386 |
-
WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
|
2387 |
-
um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
|
2388 |
-
);
|
2389 |
-
|
2390 |
-
} else {
|
2391 |
-
|
2392 |
-
$results = $wpdb->get_col(
|
2393 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2394 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
|
2395 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2396 |
-
WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
|
2397 |
-
um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
|
2398 |
-
);
|
2399 |
-
|
2400 |
-
}
|
2401 |
-
|
2402 |
-
if ( ! empty( $results ) ) {
|
2403 |
-
foreach ( $results as $user_id ) {
|
2404 |
-
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2405 |
-
if ( ! empty( $md_data ) ) {
|
2406 |
-
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
2407 |
-
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2408 |
-
}
|
2409 |
-
}
|
2410 |
-
}
|
2411 |
-
}
|
2412 |
-
}
|
2413 |
-
|
2414 |
-
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2415 |
-
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2416 |
-
global $wpdb;
|
2417 |
-
|
2418 |
-
$results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
|
2419 |
-
|
2420 |
-
if ( ! empty( $results ) ) {
|
2421 |
-
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
|
2422 |
-
}
|
2423 |
-
|
2424 |
-
update_option( 'um_member_directory_truncated', time() );
|
2425 |
-
}
|
2426 |
-
} elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
|
2427 |
-
|
2428 |
-
global $wpdb;
|
2429 |
-
|
2430 |
-
if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
|
2431 |
-
|
2432 |
-
$results = $wpdb->get_col(
|
2433 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2434 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2435 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2436 |
-
WHERE um.meta_value IS NULL AND
|
2437 |
-
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
|
2438 |
-
);
|
2439 |
-
|
2440 |
-
} else {
|
2441 |
-
|
2442 |
-
$results = $wpdb->get_col(
|
2443 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2444 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2445 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2446 |
-
WHERE um.meta_value IS NULL AND
|
2447 |
-
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
|
2448 |
-
);
|
2449 |
-
|
2450 |
-
}
|
2451 |
-
|
2452 |
-
if ( ! empty( $results ) ) {
|
2453 |
-
foreach ( $results as $user_id ) {
|
2454 |
-
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2455 |
-
if ( ! empty( $md_data ) ) {
|
2456 |
-
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
2457 |
-
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2458 |
-
}
|
2459 |
-
}
|
2460 |
-
}
|
2461 |
-
|
2462 |
-
}
|
2463 |
-
}
|
2464 |
-
}
|
2465 |
-
|
2466 |
-
|
2467 |
-
/**
|
2468 |
-
*
|
2469 |
-
*/
|
2470 |
-
function before_licenses_save() {
|
2471 |
-
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2472 |
-
return;
|
2473 |
-
}
|
2474 |
-
|
2475 |
-
foreach ( $_POST['um_options'] as $key => $value ) {
|
2476 |
-
$this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
|
2477 |
-
}
|
2478 |
-
}
|
2479 |
-
|
2480 |
-
|
2481 |
-
/**
|
2482 |
-
*
|
2483 |
-
*/
|
2484 |
-
function licenses_save() {
|
2485 |
-
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2486 |
-
return;
|
2487 |
-
}
|
2488 |
-
|
2489 |
-
foreach ( $_POST['um_options'] as $key => $value ) {
|
2490 |
-
$key = sanitize_key( $key );
|
2491 |
-
$value = sanitize_text_field( $value );
|
2492 |
-
|
2493 |
-
$edd_action = '';
|
2494 |
-
$license_key = '';
|
2495 |
-
if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
|
2496 |
-
$edd_action = 'activate_license';
|
2497 |
-
$license_key = $value;
|
2498 |
-
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
|
2499 |
-
$edd_action = 'deactivate_license';
|
2500 |
-
$license_key = $this->previous_licenses[ $key ];
|
2501 |
-
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
|
2502 |
-
$edd_action = 'check_license';
|
2503 |
-
$license_key = $value;
|
2504 |
-
}
|
2505 |
-
|
2506 |
-
if ( empty( $edd_action ) ) {
|
2507 |
-
continue;
|
2508 |
-
}
|
2509 |
-
|
2510 |
-
$item_name = false;
|
2511 |
-
$version = false;
|
2512 |
-
$author = false;
|
2513 |
-
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
2514 |
-
if ( $field_data['id'] == $key ) {
|
2515 |
-
$item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
|
2516 |
-
$version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
|
2517 |
-
$author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
|
2518 |
-
}
|
2519 |
-
}
|
2520 |
-
|
2521 |
-
$api_params = array(
|
2522 |
-
'edd_action' => $edd_action,
|
2523 |
-
'license' => $license_key,
|
2524 |
-
'item_name' => $item_name,
|
2525 |
-
'version' => $version,
|
2526 |
-
'author' => $author,
|
2527 |
-
'url' => home_url(),
|
2528 |
-
);
|
2529 |
-
|
2530 |
-
$request = wp_remote_post(
|
2531 |
-
UM()->store_url,
|
2532 |
-
array(
|
2533 |
-
'timeout' => UM()->request_timeout,
|
2534 |
-
'sslverify' => false,
|
2535 |
-
'body' => $api_params
|
2536 |
-
)
|
2537 |
-
);
|
2538 |
-
|
2539 |
-
if ( ! is_wp_error( $request ) ) {
|
2540 |
-
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2541 |
-
} else {
|
2542 |
-
$request = wp_remote_post(
|
2543 |
-
UM()->store_url,
|
2544 |
-
array(
|
2545 |
-
'timeout' => UM()->request_timeout,
|
2546 |
-
'sslverify' => true,
|
2547 |
-
'body' => $api_params
|
2548 |
-
)
|
2549 |
-
);
|
2550 |
-
|
2551 |
-
if ( ! is_wp_error( $request ) ) {
|
2552 |
-
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2553 |
-
}
|
2554 |
-
}
|
2555 |
-
|
2556 |
-
$request = ( $request ) ? maybe_unserialize( $request ) : false;
|
2557 |
-
|
2558 |
-
if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
|
2559 |
-
update_option( "{$key}_edd_answer", $request );
|
2560 |
-
} else {
|
2561 |
-
delete_option( "{$key}_edd_answer" );
|
2562 |
-
}
|
2563 |
-
|
2564 |
-
}
|
2565 |
-
}
|
2566 |
-
|
2567 |
-
|
2568 |
-
/**
|
2569 |
-
*
|
2570 |
-
*/
|
2571 |
-
function settings_before_email_tab() {
|
2572 |
-
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2573 |
-
$emails = UM()->config()->email_notifications;
|
2574 |
-
|
2575 |
-
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2576 |
-
include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
|
2577 |
-
}
|
2578 |
-
}
|
2579 |
-
|
2580 |
-
|
2581 |
-
/**
|
2582 |
-
* @param $section
|
2583 |
-
*
|
2584 |
-
* @return string
|
2585 |
-
*/
|
2586 |
-
function settings_email_tab( $section ) {
|
2587 |
-
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2588 |
-
$emails = UM()->config()->email_notifications;
|
2589 |
-
|
2590 |
-
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2591 |
-
return $section;
|
2592 |
-
}
|
2593 |
-
|
2594 |
-
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
2595 |
-
|
2596 |
-
/**
|
2597 |
-
* UM hook
|
2598 |
-
*
|
2599 |
-
* @type filter
|
2600 |
-
* @title um_admin_settings_email_section_fields
|
2601 |
-
* @description Extend UM Email Settings
|
2602 |
-
* @input_vars
|
2603 |
-
* [{"var":"$settings","type":"array","desc":"UM Email Settings"},
|
2604 |
-
* {"var":"$email_key","type":"string","desc":"Email Key"}]
|
2605 |
-
* @change_log
|
2606 |
-
* ["Since: 2.0"]
|
2607 |
-
* @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
|
2608 |
-
* @example
|
2609 |
-
* <?php
|
2610 |
-
* add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
|
2611 |
-
* function my_admin_settings_email_section( $settings, $email_key ) {
|
2612 |
-
* // your code here
|
2613 |
-
* return $settings;
|
2614 |
-
* }
|
2615 |
-
* ?>
|
2616 |
-
*/
|
2617 |
-
$section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
|
2618 |
-
array(
|
2619 |
-
'id' => 'um_email_template',
|
2620 |
-
'type' => 'hidden',
|
2621 |
-
'value' => $email_key,
|
2622 |
-
),
|
2623 |
-
array(
|
2624 |
-
'id' => $email_key . '_on',
|
2625 |
-
'type' => 'checkbox',
|
2626 |
-
'label' => $emails[ $email_key ]['title'],
|
2627 |
-
'tooltip' => $emails[ $email_key ]['description'],
|
2628 |
-
),
|
2629 |
-
array(
|
2630 |
-
'id' => $email_key . '_sub',
|
2631 |
-
'type' => 'text',
|
2632 |
-
'label' => __( 'Subject Line', 'ultimate-member' ),
|
2633 |
-
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2634 |
-
'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
|
2635 |
-
),
|
2636 |
-
array(
|
2637 |
-
'id' => $email_key,
|
2638 |
-
'type' => 'email_template',
|
2639 |
-
'label' => __( 'Message Body', 'ultimate-member' ),
|
2640 |
-
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2641 |
-
'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
|
2642 |
-
'value' => UM()->mail()->get_email_template( $email_key ),
|
2643 |
-
'in_theme' => $in_theme
|
2644 |
-
),
|
2645 |
-
), $email_key );
|
2646 |
-
|
2647 |
-
return $this->render_settings_section( $section_fields, 'email', $email_key );
|
2648 |
-
}
|
2649 |
-
|
2650 |
-
|
2651 |
-
/**
|
2652 |
-
*
|
2653 |
-
*/
|
2654 |
-
function settings_appearance_profile_tab() {
|
2655 |
-
wp_enqueue_media();
|
2656 |
-
}
|
2657 |
-
|
2658 |
-
|
2659 |
-
/**
|
2660 |
-
* @param $html
|
2661 |
-
* @param $section_fields
|
2662 |
-
*
|
2663 |
-
* @return string
|
2664 |
-
*/
|
2665 |
-
function settings_licenses_tab( $html, $section_fields ) {
|
2666 |
-
ob_start(); ?>
|
2667 |
-
|
2668 |
-
<div class="wrap-licenses">
|
2669 |
-
<input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
|
2670 |
-
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2671 |
-
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2672 |
-
<table class="form-table um-settings-section">
|
2673 |
-
<tbody>
|
2674 |
-
<?php foreach ( $section_fields as $field_data ) {
|
2675 |
-
$option_value = UM()->options()->get( $field_data['id'] );
|
2676 |
-
$value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
|
2677 |
-
|
2678 |
-
$license = get_option( "{$field_data['id']}_edd_answer" );
|
2679 |
-
|
2680 |
-
if ( is_object( $license ) && ! empty( $value ) ) {
|
2681 |
-
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
2682 |
-
if ( empty( $license->success ) ) {
|
2683 |
-
|
2684 |
-
if ( ! empty( $license->error ) ) {
|
2685 |
-
switch ( $license->error ) {
|
2686 |
-
|
2687 |
-
case 'expired' :
|
2688 |
-
|
2689 |
-
$class = 'expired';
|
2690 |
-
$messages[] = sprintf(
|
2691 |
-
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2692 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2693 |
-
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2694 |
-
);
|
2695 |
-
|
2696 |
-
$license_status = 'license-' . $class . '-notice';
|
2697 |
-
|
2698 |
-
break;
|
2699 |
-
|
2700 |
-
case 'revoked' :
|
2701 |
-
|
2702 |
-
$class = 'error';
|
2703 |
-
$messages[] = sprintf(
|
2704 |
-
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2705 |
-
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2706 |
-
);
|
2707 |
-
|
2708 |
-
$license_status = 'license-' . $class . '-notice';
|
2709 |
-
|
2710 |
-
break;
|
2711 |
-
|
2712 |
-
case 'missing' :
|
2713 |
-
|
2714 |
-
$class = 'error';
|
2715 |
-
$messages[] = sprintf(
|
2716 |
-
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2717 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2718 |
-
);
|
2719 |
-
|
2720 |
-
$license_status = 'license-' . $class . '-notice';
|
2721 |
-
|
2722 |
-
break;
|
2723 |
-
|
2724 |
-
case 'invalid' :
|
2725 |
-
case 'site_inactive' :
|
2726 |
-
|
2727 |
-
$class = 'error';
|
2728 |
-
$messages[] = sprintf(
|
2729 |
-
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2730 |
-
$field_data['item_name'],
|
2731 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2732 |
-
);
|
2733 |
-
|
2734 |
-
$license_status = 'license-' . $class . '-notice';
|
2735 |
-
|
2736 |
-
break;
|
2737 |
-
|
2738 |
-
case 'item_name_mismatch' :
|
2739 |
-
|
2740 |
-
$class = 'error';
|
2741 |
-
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2742 |
-
|
2743 |
-
$license_status = 'license-' . $class . '-notice';
|
2744 |
-
|
2745 |
-
break;
|
2746 |
-
|
2747 |
-
case 'no_activations_left':
|
2748 |
-
|
2749 |
-
$class = 'error';
|
2750 |
-
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2751 |
-
|
2752 |
-
$license_status = 'license-' . $class . '-notice';
|
2753 |
-
|
2754 |
-
break;
|
2755 |
-
|
2756 |
-
case 'license_not_activable':
|
2757 |
-
|
2758 |
-
$class = 'error';
|
2759 |
-
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2760 |
-
|
2761 |
-
$license_status = 'license-' . $class . '-notice';
|
2762 |
-
break;
|
2763 |
-
|
2764 |
-
default :
|
2765 |
-
|
2766 |
-
$class = 'error';
|
2767 |
-
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2768 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2769 |
-
|
2770 |
-
$license_status = 'license-' . $class . '-notice';
|
2771 |
-
break;
|
2772 |
-
}
|
2773 |
-
} else {
|
2774 |
-
$class = 'error';
|
2775 |
-
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2776 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2777 |
-
|
2778 |
-
$license_status = 'license-' . $class . '-notice';
|
2779 |
-
}
|
2780 |
-
|
2781 |
-
} elseif ( ! empty( $license->errors ) ) {
|
2782 |
-
|
2783 |
-
$errors = array_keys( $license->errors );
|
2784 |
-
$errors_data = array_values( $license->errors );
|
2785 |
-
|
2786 |
-
$class = 'error';
|
2787 |
-
$error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
|
2788 |
-
$errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
|
2789 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s%s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, $errors_data, 'https://ultimatemember.com/support' );
|
2790 |
-
|
2791 |
-
$license_status = 'license-' . $class . '-notice';
|
2792 |
-
|
2793 |
-
} else {
|
2794 |
-
|
2795 |
-
switch( $license->license ) {
|
2796 |
-
|
2797 |
-
case 'expired' :
|
2798 |
-
|
2799 |
-
$class = 'expired';
|
2800 |
-
$messages[] = sprintf(
|
2801 |
-
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2802 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2803 |
-
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2804 |
-
);
|
2805 |
-
|
2806 |
-
$license_status = 'license-' . $class . '-notice';
|
2807 |
-
|
2808 |
-
break;
|
2809 |
-
|
2810 |
-
case 'revoked' :
|
2811 |
-
|
2812 |
-
$class = 'error';
|
2813 |
-
$messages[] = sprintf(
|
2814 |
-
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2815 |
-
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2816 |
-
);
|
2817 |
-
|
2818 |
-
$license_status = 'license-' . $class . '-notice';
|
2819 |
-
|
2820 |
-
break;
|
2821 |
-
|
2822 |
-
case 'missing' :
|
2823 |
-
|
2824 |
-
$class = 'error';
|
2825 |
-
$messages[] = sprintf(
|
2826 |
-
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2827 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2828 |
-
);
|
2829 |
-
|
2830 |
-
$license_status = 'license-' . $class . '-notice';
|
2831 |
-
|
2832 |
-
break;
|
2833 |
-
|
2834 |
-
case 'invalid' :
|
2835 |
-
case 'site_inactive' :
|
2836 |
-
|
2837 |
-
$class = 'error';
|
2838 |
-
$messages[] = sprintf(
|
2839 |
-
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2840 |
-
$field_data['item_name'],
|
2841 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2842 |
-
);
|
2843 |
-
|
2844 |
-
$license_status = 'license-' . $class . '-notice';
|
2845 |
-
|
2846 |
-
break;
|
2847 |
-
|
2848 |
-
case 'item_name_mismatch' :
|
2849 |
-
|
2850 |
-
$class = 'error';
|
2851 |
-
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2852 |
-
|
2853 |
-
$license_status = 'license-' . $class . '-notice';
|
2854 |
-
|
2855 |
-
break;
|
2856 |
-
|
2857 |
-
case 'no_activations_left':
|
2858 |
-
|
2859 |
-
$class = 'error';
|
2860 |
-
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2861 |
-
|
2862 |
-
$license_status = 'license-' . $class . '-notice';
|
2863 |
-
|
2864 |
-
break;
|
2865 |
-
|
2866 |
-
case 'license_not_activable':
|
2867 |
-
|
2868 |
-
$class = 'error';
|
2869 |
-
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2870 |
-
|
2871 |
-
$license_status = 'license-' . $class . '-notice';
|
2872 |
-
break;
|
2873 |
-
|
2874 |
-
case 'valid' :
|
2875 |
-
default:
|
2876 |
-
|
2877 |
-
$class = 'valid';
|
2878 |
-
|
2879 |
-
$now = current_time( 'timestamp' );
|
2880 |
-
$expiration = strtotime( $license->expires, $now );
|
2881 |
-
|
2882 |
-
if( 'lifetime' === $license->expires ) {
|
2883 |
-
|
2884 |
-
$messages[] = __( 'License key never expires.', 'ultimate-member' );
|
2885 |
-
|
2886 |
-
$license_status = 'license-lifetime-notice';
|
2887 |
-
|
2888 |
-
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
2889 |
-
|
2890 |
-
$messages[] = sprintf(
|
2891 |
-
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
|
2892 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2893 |
-
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
|
2894 |
-
);
|
2895 |
-
|
2896 |
-
$license_status = 'license-expires-soon-notice';
|
2897 |
-
|
2898 |
-
} else {
|
2899 |
-
|
2900 |
-
$messages[] = sprintf(
|
2901 |
-
__( 'Your license key expires on %s.', 'ultimate-member' ),
|
2902 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
2903 |
-
);
|
2904 |
-
|
2905 |
-
$license_status = 'license-expiration-date-notice';
|
2906 |
-
|
2907 |
-
}
|
2908 |
-
|
2909 |
-
break;
|
2910 |
-
|
2911 |
-
}
|
2912 |
-
|
2913 |
-
}
|
2914 |
-
|
2915 |
-
} else {
|
2916 |
-
$class = 'empty';
|
2917 |
-
|
2918 |
-
$messages[] = sprintf(
|
2919 |
-
__( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
|
2920 |
-
$field_data['item_name']
|
2921 |
-
);
|
2922 |
-
|
2923 |
-
$license_status = null;
|
2924 |
-
|
2925 |
-
} ?>
|
2926 |
-
|
2927 |
-
<tr class="um-settings-line">
|
2928 |
-
<th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
|
2929 |
-
<td>
|
2930 |
-
<form method="post" action="" name="um-settings-form" class="um-settings-form">
|
2931 |
-
<input type="hidden" value="save" name="um-settings-action" />
|
2932 |
-
<input type="hidden" name="licenses_settings" value="1" />
|
2933 |
-
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2934 |
-
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2935 |
-
<input type="text" id="um_options_<?php echo esc_attr( $field_data['id'] ) ?>" name="um_options[<?php echo esc_attr( $field_data['id'] ) ?>]" value="<?php echo $value ?>" class="um-option-field um-long-field" data-field_id="<?php echo esc_attr( $field_data['id'] ) ?>" />
|
2936 |
-
<?php if ( ! empty( $field_data['description'] ) ) { ?>
|
2937 |
-
<div class="description"><?php echo $field_data['description'] ?></div>
|
2938 |
-
<?php } ?>
|
2939 |
-
|
2940 |
-
<?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
|
2941 |
-
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2942 |
-
<?php } elseif ( empty( $value ) ) { ?>
|
2943 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
|
2944 |
-
<?php } else { ?>
|
2945 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
|
2946 |
-
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2947 |
-
<?php }
|
2948 |
-
|
2949 |
-
if ( ! empty( $messages ) ) {
|
2950 |
-
foreach ( $messages as $message ) { ?>
|
2951 |
-
<div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
|
2952 |
-
<p><?php echo $message ?></p>
|
2953 |
-
</div>
|
2954 |
-
<?php }
|
2955 |
-
} ?>
|
2956 |
-
</form>
|
2957 |
-
</td>
|
2958 |
-
</tr>
|
2959 |
-
<?php } ?>
|
2960 |
-
</tbody>
|
2961 |
-
</table>
|
2962 |
-
</div>
|
2963 |
-
<?php $section = ob_get_clean();
|
2964 |
-
|
2965 |
-
return $section;
|
2966 |
-
}
|
2967 |
-
|
2968 |
-
|
2969 |
-
/**
|
2970 |
-
* @param $html
|
2971 |
-
* @param $section_fields
|
2972 |
-
*/
|
2973 |
-
function settings_install_info_tab( $html, $section_fields ) {
|
2974 |
-
global $wpdb;
|
2975 |
-
|
2976 |
-
if ( ! class_exists( '\Browser' ) )
|
2977 |
-
require_once um_path . 'includes/lib/browser.php';
|
2978 |
-
|
2979 |
-
// Detect browser
|
2980 |
-
$browser = new \Browser();
|
2981 |
-
|
2982 |
-
// Get theme info
|
2983 |
-
$theme_data = wp_get_theme();
|
2984 |
-
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
2985 |
-
|
2986 |
-
// Identify Hosting Provider
|
2987 |
-
$host = um_get_host();
|
2988 |
-
|
2989 |
-
um_fetch_user( get_current_user_id() );
|
2990 |
-
|
2991 |
-
if ( isset( $this->content ) ) {
|
2992 |
-
echo $this->content;
|
2993 |
-
} else { ?>
|
2994 |
-
|
2995 |
-
<h3>Install Info</h3>
|
2996 |
-
|
2997 |
-
<form action="" method="post" dir="ltr">
|
2998 |
-
<textarea style="width:70%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="install-info-textarea" name="um-install-info" title="<?php _e( 'To copy the Install info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'ultimate-member' ); ?>">
|
2999 |
-
### Begin Install Info ###
|
3000 |
-
|
3001 |
-
## Please include this information when posting support requests ##
|
3002 |
-
|
3003 |
-
<?php
|
3004 |
-
/**
|
3005 |
-
* UM hook
|
3006 |
-
*
|
3007 |
-
* @type action
|
3008 |
-
* @title um_install_info_before
|
3009 |
-
* @description Before install info settings
|
3010 |
-
* @change_log
|
3011 |
-
* ["Since: 2.0"]
|
3012 |
-
* @usage add_action( 'um_install_info_before', 'function_name', 10 );
|
3013 |
-
* @example
|
3014 |
-
* <?php
|
3015 |
-
* add_action( 'um_install_info_before', 'my_install_info_before', 10 );
|
3016 |
-
* function my_install_info_before() {
|
3017 |
-
* // your code here
|
3018 |
-
* }
|
3019 |
-
* ?>
|
3020 |
-
*/
|
3021 |
-
do_action( 'um_install_info_before' ); ?>
|
3022 |
-
|
3023 |
-
--- Site Info ---
|
3024 |
-
|
3025 |
-
Site URL: <?php echo site_url() . "\n"; ?>
|
3026 |
-
Home URL: <?php echo home_url() . "\n"; ?>
|
3027 |
-
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
3028 |
-
|
3029 |
-
--- Hosting Provider ---
|
3030 |
-
|
3031 |
-
<?php if( $host ) : ?>
|
3032 |
-
Host: <?php echo $host . "\n"; ?>
|
3033 |
-
<?php endif; ?>
|
3034 |
-
|
3035 |
-
--- User Browser ---
|
3036 |
-
|
3037 |
-
<?php echo $browser ; ?>
|
3038 |
-
|
3039 |
-
---- Current User Details --
|
3040 |
-
|
3041 |
-
<?php $user = wp_get_current_user(); ?>
|
3042 |
-
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
3043 |
-
|
3044 |
-
|
3045 |
-
--- WordPress Configurations ---
|
3046 |
-
|
3047 |
-
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
3048 |
-
Language: <?php echo get_locale()."\n"; ?>
|
3049 |
-
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
3050 |
-
Active Theme: <?php echo $theme . "\n"; ?>
|
3051 |
-
<?php $show_on_front = get_option( 'show_on_front' ); ?>
|
3052 |
-
<?php if( $show_on_front == "posts" ): ?>
|
3053 |
-
Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
|
3054 |
-
<?php elseif( $show_on_front == "page" ): ?>
|
3055 |
-
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3056 |
-
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3057 |
-
<?php endif; ?>
|
3058 |
-
ABSPATH: <?php echo ABSPATH."\n"; ?>
|
3059 |
-
<?php $wp_count_posts = wp_count_posts(); ?>
|
3060 |
-
All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
|
3061 |
-
<?php
|
3062 |
-
$request['cmd'] = '_notify-validate';
|
3063 |
-
|
3064 |
-
$params = array(
|
3065 |
-
'sslverify' => false,
|
3066 |
-
'timeout' => 60,
|
3067 |
-
'user-agent' => 'UltimateMember/' . ultimatemember_version,
|
3068 |
-
'body' => $request
|
3069 |
-
);
|
3070 |
-
|
3071 |
-
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
3072 |
-
|
3073 |
-
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
3074 |
-
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
|
3075 |
-
} else {
|
3076 |
-
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
|
3077 |
-
}
|
3078 |
-
?>
|
3079 |
-
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
|
3080 |
-
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
3081 |
-
WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
|
3082 |
-
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
3083 |
-
|
3084 |
-
|
3085 |
-
--- UM Configurations ---
|
3086 |
-
|
3087 |
-
Version: <?php echo ultimatemember_version . "\n"; ?>
|
3088 |
-
Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
|
3089 |
-
Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
|
3090 |
-
Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3091 |
-
Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3092 |
-
Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3093 |
-
JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3094 |
-
<?php if( is_multisite() ): ?>
|
3095 |
-
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
3096 |
-
<?php endif; ?>
|
3097 |
-
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3098 |
-
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3099 |
-
|
3100 |
-
|
3101 |
-
--- UM Pages Configuration ---
|
3102 |
-
|
3103 |
-
<?php
|
3104 |
-
/**
|
3105 |
-
* UM hook
|
3106 |
-
*
|
3107 |
-
* @type action
|
3108 |
-
* @title um_install_info_before_page_config
|
3109 |
-
* @description Before page config install info
|
3110 |
-
* @change_log
|
3111 |
-
* ["Since: 2.0"]
|
3112 |
-
* @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
|
3113 |
-
* @example
|
3114 |
-
* <?php
|
3115 |
-
* add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
|
3116 |
-
* function my_install_info_before_page_config() {
|
3117 |
-
* // your code here
|
3118 |
-
* }
|
3119 |
-
* ?>
|
3120 |
-
*/
|
3121 |
-
do_action( "um_install_info_before_page_config" ); ?>
|
3122 |
-
User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
|
3123 |
-
Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
|
3124 |
-
Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
|
3125 |
-
Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
|
3126 |
-
Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
|
3127 |
-
Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
|
3128 |
-
Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
|
3129 |
-
<?php
|
3130 |
-
/**
|
3131 |
-
* UM hook
|
3132 |
-
*
|
3133 |
-
* @type action
|
3134 |
-
* @title um_install_info_after_page_config
|
3135 |
-
* @description After page config install info
|
3136 |
-
* @change_log
|
3137 |
-
* ["Since: 2.0"]
|
3138 |
-
* @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
|
3139 |
-
* @example
|
3140 |
-
* <?php
|
3141 |
-
* add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
|
3142 |
-
* function my_install_info_after_page_config() {
|
3143 |
-
* // your code here
|
3144 |
-
* }
|
3145 |
-
* ?>
|
3146 |
-
*/
|
3147 |
-
do_action( "um_install_info_after_page_config" ); ?>
|
3148 |
-
|
3149 |
-
|
3150 |
-
--- UM Users Configuration ---
|
3151 |
-
|
3152 |
-
Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
|
3153 |
-
Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
|
3154 |
-
User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
|
3155 |
-
Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
|
3156 |
-
Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
|
3157 |
-
Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
|
3158 |
-
Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
|
3159 |
-
<?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
|
3160 |
-
UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
|
3161 |
-
Require a strong password: <?php echo $this->info_value( UM()->options()->get('require_strongpass'), 'onoff', true ); ?>
|
3162 |
-
|
3163 |
-
|
3164 |
-
--- UM Access Configuration ---
|
3165 |
-
|
3166 |
-
Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
|
3167 |
-
Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
|
3168 |
-
<?php if( UM()->options()->get('accessible') == 2 ) { ?>
|
3169 |
-
Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
|
3170 |
-
Exclude the following URLs:<?php echo "\t\t\t\t".implode("\t\n\t\t\t\t\t\t\t\t\t\t",UM()->options()->get('access_exclude_uris') )."\n";?>
|
3171 |
-
<?php } ?>
|
3172 |
-
Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
|
3173 |
-
<?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
|
3174 |
-
Redirect to alternative login page: <?php if( UM()->options()->get('wpadmin_login_redirect') == 'um_login_page' ){ echo um_get_core_page('login')."\n"; }else{ echo UM()->options()->get('wpadmin_login_redirect_url')."\n"; }?>
|
3175 |
-
<?php } ?>
|
3176 |
-
Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
|
3177 |
-
<?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
|
3178 |
-
Redirect to alternative register page: <?php if( UM()->options()->get('wpadmin_register_redirect') == 'um_register_page' ){ echo um_get_core_page('register')."\n"; }else{ echo UM()->options()->get('wpadmin_register_redirect_url')."\n"; }?>
|
3179 |
-
<?php } ?>
|
3180 |
-
Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
|
3181 |
-
Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
|
3182 |
-
<?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
|
3183 |
-
Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
|
3184 |
-
Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
|
3185 |
-
<?php } ?>
|
3186 |
-
<?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
|
3187 |
-
Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
|
3188 |
-
<?php } ?>
|
3189 |
-
<?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
|
3190 |
-
Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
|
3191 |
-
<?php } ?>
|
3192 |
-
<?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
|
3193 |
-
Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
|
3194 |
-
<?php } ?>
|
3195 |
-
|
3196 |
-
|
3197 |
-
--- UM Email Configurations ---
|
3198 |
-
|
3199 |
-
Mail appears from: <?php $mail_from = UM()->options()->get('mail_from'); if( ! empty( $mail_from ) ){echo UM()->options()->get('mail_from');}else{echo "-";}; echo "\n";?>
|
3200 |
-
Mail appears from address: <?php $mail_from_addr = UM()->options()->get('mail_from_addr'); if( ! empty( $mail_from_addr ) ){echo UM()->options()->get('mail_from_addr');}else{echo "-";}; echo "\n";?>
|
3201 |
-
Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
|
3202 |
-
Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
|
3203 |
-
Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
|
3204 |
-
Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
|
3205 |
-
Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
|
3206 |
-
Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
|
3207 |
-
Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
|
3208 |
-
Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
|
3209 |
-
Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
|
3210 |
-
Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
|
3211 |
-
|
3212 |
-
|
3213 |
-
--- UM Total Users ---
|
3214 |
-
|
3215 |
-
<?php $result = count_users();
|
3216 |
-
echo 'All Users('.$result['total_users'].")\n";
|
3217 |
-
foreach( $result['avail_roles'] as $role => $count ) {
|
3218 |
-
echo $role."(".$count.")\n";
|
3219 |
-
} ?>
|
3220 |
-
|
3221 |
-
|
3222 |
-
--- UM Roles ---
|
3223 |
-
|
3224 |
-
<?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
|
3225 |
-
echo $role." ({$role_id})\n";
|
3226 |
-
} ?>
|
3227 |
-
|
3228 |
-
|
3229 |
-
--- UM Custom Templates ---
|
3230 |
-
|
3231 |
-
<?php // Show templates that have been copied to the theme's edd_templates dir
|
3232 |
-
$dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
|
3233 |
-
if ( ! empty( $dir ) ) {
|
3234 |
-
$found = glob( $dir );
|
3235 |
-
if ( ! empty( $found ) ) {
|
3236 |
-
foreach ( glob( $dir ) as $file ) {
|
3237 |
-
echo "File: " . $file . "\n";
|
3238 |
-
}
|
3239 |
-
} else {
|
3240 |
-
echo 'N/A'."\n";
|
3241 |
-
}
|
3242 |
-
} ?>
|
3243 |
-
|
3244 |
-
|
3245 |
-
--- UM Email HTML Templates ---
|
3246 |
-
|
3247 |
-
<?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
|
3248 |
-
|
3249 |
-
if ( ! empty( $dir ) ) {
|
3250 |
-
$found = glob( $dir );
|
3251 |
-
if ( ! empty( $found ) ){
|
3252 |
-
foreach ( glob( $dir ) as $file ) {
|
3253 |
-
echo "File: ". $file . "\n";
|
3254 |
-
}
|
3255 |
-
} else {
|
3256 |
-
echo 'N/A'."\n";
|
3257 |
-
}
|
3258 |
-
} ?>
|
3259 |
-
|
3260 |
-
|
3261 |
-
--- Web Server Configurations ---
|
3262 |
-
|
3263 |
-
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
|
3264 |
-
MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
|
3265 |
-
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
|
3266 |
-
|
3267 |
-
|
3268 |
-
--- PHP Configurations ---
|
3269 |
-
|
3270 |
-
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
|
3271 |
-
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3272 |
-
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
|
3273 |
-
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3274 |
-
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
|
3275 |
-
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
|
3276 |
-
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
|
3277 |
-
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
|
3278 |
-
|
3279 |
-
|
3280 |
-
--- Web Server Extensions/Modules ---
|
3281 |
-
|
3282 |
-
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
|
3283 |
-
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
|
3284 |
-
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
|
3285 |
-
SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
|
3286 |
-
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
|
3287 |
-
GD Library: <?php echo ( extension_loaded( 'gd' ) && function_exists('gd_info') ) ? 'PHP GD library is installed on your web server.' : 'PHP GD library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3288 |
-
Mail: <?php echo ( function_exists('mail') ) ? 'PHP mail function exist on your web server.' : 'PHP mail function doesn\'t exist on your web server.'; ?><?php echo "\n"; ?>
|
3289 |
-
Exif: <?php echo ( extension_loaded( 'exif' ) && function_exists('exif_imagetype') ) ? 'PHP Exif library is installed on your web server.' : 'PHP Exif library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3290 |
-
|
3291 |
-
|
3292 |
-
--- Session Configurations ---
|
3293 |
-
|
3294 |
-
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
|
3295 |
-
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
|
3296 |
-
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
|
3297 |
-
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
|
3298 |
-
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3299 |
-
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3300 |
-
|
3301 |
-
|
3302 |
-
--- WordPress Active Plugins ---
|
3303 |
-
|
3304 |
-
<?php $plugins = get_plugins();
|
3305 |
-
$active_plugins = get_option( 'active_plugins', array() );
|
3306 |
-
|
3307 |
-
foreach ( $plugins as $plugin_path => $plugin ) {
|
3308 |
-
// If the plugin isn't active, don't show it.
|
3309 |
-
if ( ! in_array( $plugin_path, $active_plugins ) )
|
3310 |
-
continue;
|
3311 |
-
|
3312 |
-
echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
|
3313 |
-
}
|
3314 |
-
|
3315 |
-
if ( is_multisite() ) { ?>
|
3316 |
-
|
3317 |
-
--- WordPress Network Active Plugins ---
|
3318 |
-
|
3319 |
-
<?php $plugins = wp_get_active_network_plugins();
|
3320 |
-
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
3321 |
-
|
3322 |
-
foreach ( $plugins as $plugin_path ) {
|
3323 |
-
$plugin_base = plugin_basename( $plugin_path );
|
3324 |
-
|
3325 |
-
// If the plugin isn't active, don't show it.
|
3326 |
-
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
|
3327 |
-
continue;
|
3328 |
-
|
3329 |
-
$plugin = get_plugin_data( $plugin_path );
|
3330 |
-
|
3331 |
-
echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
|
3332 |
-
}
|
3333 |
-
|
3334 |
-
}
|
3335 |
-
|
3336 |
-
/**
|
3337 |
-
* UM hook
|
3338 |
-
*
|
3339 |
-
* @type action
|
3340 |
-
* @title um_install_info_after
|
3341 |
-
* @description After install info
|
3342 |
-
* @change_log
|
3343 |
-
* ["Since: 2.0"]
|
3344 |
-
* @usage add_action( 'um_install_info_after', 'function_name', 10 );
|
3345 |
-
* @example
|
3346 |
-
* <?php
|
3347 |
-
* add_action( 'um_install_info_after', 'my_install_info_after', 10 );
|
3348 |
-
* function my_install_info_after() {
|
3349 |
-
* // your code here
|
3350 |
-
* }
|
3351 |
-
* ?>
|
3352 |
-
*/
|
3353 |
-
do_action( 'um_install_info_after' ); ?>
|
3354 |
-
|
3355 |
-
### End Install Info ###
|
3356 |
-
</textarea>
|
3357 |
-
<p class="submit">
|
3358 |
-
<input type="hidden" name="um-addon-hook" value="download_install_info" />
|
3359 |
-
<?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
|
3360 |
-
</p>
|
3361 |
-
</form>
|
3362 |
-
|
3363 |
-
<?php }
|
3364 |
-
}
|
3365 |
-
|
3366 |
-
|
3367 |
-
/**
|
3368 |
-
*
|
3369 |
-
*/
|
3370 |
-
function um_download_install_info() {
|
3371 |
-
if ( ! empty( $_POST['download_install_info'] ) ) {
|
3372 |
-
nocache_headers();
|
3373 |
-
|
3374 |
-
header( "Content-type: text/plain" );
|
3375 |
-
header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
|
3376 |
-
|
3377 |
-
echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
|
3378 |
-
exit;
|
3379 |
-
}
|
3380 |
-
}
|
3381 |
-
|
3382 |
-
|
3383 |
-
/**
|
3384 |
-
* @param string $raw_value
|
3385 |
-
* @param string $type
|
3386 |
-
* @param string $default
|
3387 |
-
*
|
3388 |
-
* @return string
|
3389 |
-
*/
|
3390 |
-
function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
|
3391 |
-
|
3392 |
-
if ( $type == 'yesno' ) {
|
3393 |
-
$raw_value = ( $default == $raw_value ) ? "Yes" : "No";
|
3394 |
-
} elseif( $type == 'onoff' ) {
|
3395 |
-
$raw_value = ( $default == $raw_value ) ? "On" : "Off";
|
3396 |
-
}
|
3397 |
-
|
3398 |
-
return $raw_value."\n";
|
3399 |
-
}
|
3400 |
-
|
3401 |
-
|
3402 |
-
/**
|
3403 |
-
* Render settings section
|
3404 |
-
*
|
3405 |
-
* @param array $section_fields
|
3406 |
-
* @param string $current_tab
|
3407 |
-
* @param string $current_subtab
|
3408 |
-
*
|
3409 |
-
* @return string
|
3410 |
-
*/
|
3411 |
-
function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
|
3412 |
-
ob_start();
|
3413 |
-
|
3414 |
-
UM()->admin_forms_settings( array(
|
3415 |
-
'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
|
3416 |
-
'prefix_id' => 'um_options',
|
3417 |
-
'fields' => $section_fields
|
3418 |
-
) )->render_form(); ?>
|
3419 |
-
|
3420 |
-
<?php $section = ob_get_clean();
|
3421 |
-
|
3422 |
-
return $section;
|
3423 |
-
}
|
3424 |
-
|
3425 |
-
|
3426 |
-
/**
|
3427 |
-
* @param array $settings
|
3428 |
-
*
|
3429 |
-
* @return array
|
3430 |
-
*/
|
3431 |
-
function save_email_templates( $settings ) {
|
3432 |
-
|
3433 |
-
if ( empty( $settings['um_email_template'] ) ) {
|
3434 |
-
return $settings;
|
3435 |
-
}
|
3436 |
-
|
3437 |
-
$template = $settings['um_email_template'];
|
3438 |
-
$content = wp_kses_post( stripslashes( $settings[ $template ] ) );
|
3439 |
-
|
3440 |
-
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
|
3441 |
-
|
3442 |
-
if ( ! file_exists( $theme_template_path ) ) {
|
3443 |
-
UM()->mail()->copy_email_template( $template );
|
3444 |
-
}
|
3445 |
-
|
3446 |
-
$fp = fopen( $theme_template_path, "w" );
|
3447 |
-
$result = fputs( $fp, $content );
|
3448 |
-
fclose( $fp );
|
3449 |
-
|
3450 |
-
if ( $result !== false ) {
|
3451 |
-
unset( $settings['um_email_template'] );
|
3452 |
-
unset( $settings[ $template ] );
|
3453 |
-
}
|
3454 |
-
|
3455 |
-
return $settings;
|
3456 |
-
}
|
3457 |
-
}
|
3458 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Settings
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Settings {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
public $settings_map;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
public $settings_structure;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var
|
32 |
+
*/
|
33 |
+
private $previous_licenses;
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var
|
38 |
+
*/
|
39 |
+
private $need_change_permalinks;
|
40 |
+
|
41 |
+
|
42 |
+
private $gravatar_changed = false;
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Admin_Settings constructor.
|
47 |
+
*/
|
48 |
+
public function __construct() {
|
49 |
+
//init settings structure
|
50 |
+
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
+
|
52 |
+
//admin menu
|
53 |
+
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
+
|
55 |
+
//settings structure handlers
|
56 |
+
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
+
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
+
|
59 |
+
//enqueue wp_media for profiles tab
|
60 |
+
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
+
|
62 |
+
//custom content for licenses tab
|
63 |
+
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
+
|
65 |
+
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
+
|
67 |
+
|
68 |
+
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
+
|
70 |
+
|
71 |
+
//save handlers
|
72 |
+
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
+
|
74 |
+
//save pages options
|
75 |
+
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
+
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
+
|
78 |
+
|
79 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
+
|
81 |
+
|
82 |
+
//save licenses options
|
83 |
+
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
+
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
+
|
86 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
+
|
89 |
+
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
public function same_page_update_ajax() {
|
95 |
+
UM()->admin()->check_ajax_nonce();
|
96 |
+
|
97 |
+
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
+
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
+
}
|
100 |
+
|
101 |
+
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
+
|
103 |
+
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
+
//first install metatable
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
$metakeys = array();
|
108 |
+
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
+
$metakeys[] = $all_user_field['metakey'];
|
110 |
+
}
|
111 |
+
|
112 |
+
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
+
|
114 |
+
if ( is_multisite() ) {
|
115 |
+
|
116 |
+
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
+
foreach ( $sites as $blog_id ) {
|
118 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
$blog_id = get_current_blog_id();
|
122 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
+
}
|
124 |
+
|
125 |
+
//member directory data
|
126 |
+
$metakeys[] = 'um_member_directory_data';
|
127 |
+
$metakeys[] = '_um_verified';
|
128 |
+
$metakeys[] = '_money_spent';
|
129 |
+
$metakeys[] = '_completed';
|
130 |
+
$metakeys[] = '_reviews_avg';
|
131 |
+
|
132 |
+
//myCred meta
|
133 |
+
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
+
$mycred_types = mycred_get_types();
|
135 |
+
if ( ! empty( $mycred_types ) ) {
|
136 |
+
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
+
$metakeys[] = $point_type;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
+
if ( empty( $sortby_custom_keys ) ) {
|
144 |
+
$sortby_custom_keys = array();
|
145 |
+
}
|
146 |
+
|
147 |
+
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
+
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
+
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
+
$custom_val = maybe_unserialize( $custom_val );
|
151 |
+
|
152 |
+
foreach ( $custom_val as $sort_value ) {
|
153 |
+
if ( is_array( $sort_value ) ) {
|
154 |
+
$field_keys = array_keys( $sort_value );
|
155 |
+
$sortby_custom_keys[] = $field_keys[0];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
+
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
+
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
+
}
|
165 |
+
|
166 |
+
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
+
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
+
|
169 |
+
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
+
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
+
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
+
|
173 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
+
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
+
}
|
176 |
+
|
177 |
+
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
+
|
179 |
+
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
+
|
181 |
+
update_option( 'um_member_directory_update_meta', time() );
|
182 |
+
|
183 |
+
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
+
|
185 |
+
wp_send_json_success();
|
186 |
+
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
+
global $wpdb;
|
188 |
+
|
189 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
+
|
191 |
+
$count = $wpdb->get_var(
|
192 |
+
"SELECT COUNT(*)
|
193 |
+
FROM {$wpdb->usermeta}
|
194 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
+
);
|
196 |
+
|
197 |
+
wp_send_json_success( array( 'count' => $count ) );
|
198 |
+
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
+
|
200 |
+
if ( empty( $_POST['page'] ) ) {
|
201 |
+
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
+
}
|
203 |
+
|
204 |
+
$per_page = 500;
|
205 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
$metadata = $wpdb->get_results(
|
209 |
+
$wpdb->prepare(
|
210 |
+
"SELECT *
|
211 |
+
FROM {$wpdb->usermeta}
|
212 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
+
LIMIT %d, %d",
|
214 |
+
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
+
$per_page
|
216 |
+
),
|
217 |
+
ARRAY_A
|
218 |
+
);
|
219 |
+
|
220 |
+
$values = array();
|
221 |
+
foreach ( $metadata as $metarow ) {
|
222 |
+
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
+
}
|
224 |
+
|
225 |
+
if ( ! empty( $values ) ) {
|
226 |
+
$wpdb->query(
|
227 |
+
"INSERT INTO
|
228 |
+
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
+
VALUES " . implode( ',', $values )
|
230 |
+
);
|
231 |
+
}
|
232 |
+
|
233 |
+
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
+
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
+
|
236 |
+
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
*
|
243 |
+
*/
|
244 |
+
public function init_variables() {
|
245 |
+
|
246 |
+
$settings_map = array();
|
247 |
+
|
248 |
+
$general_pages_fields = array(
|
249 |
+
array(
|
250 |
+
'id' => 'pages_settings',
|
251 |
+
'type' => 'hidden',
|
252 |
+
'value' => true,
|
253 |
+
'is_option' => false,
|
254 |
+
),
|
255 |
+
);
|
256 |
+
|
257 |
+
$core_pages = UM()->config()->core_pages;
|
258 |
+
|
259 |
+
foreach ( $core_pages as $page_s => $page ) {
|
260 |
+
$have_pages = UM()->query()->wp_pages();
|
261 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
262 |
+
|
263 |
+
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
264 |
+
|
265 |
+
if ( 'reached_maximum_limit' === $have_pages ) {
|
266 |
+
$general_pages_fields[] = array(
|
267 |
+
'id' => $page_id,
|
268 |
+
'type' => 'text',
|
269 |
+
// translators: %s: Page title
|
270 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
271 |
+
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
272 |
+
'compiler' => true,
|
273 |
+
'size' => 'small',
|
274 |
+
);
|
275 |
+
} else {
|
276 |
+
$general_pages_fields[] = array(
|
277 |
+
'id' => $page_id,
|
278 |
+
'type' => 'select',
|
279 |
+
// translators: %s: Page title
|
280 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
281 |
+
'options' => UM()->query()->wp_pages(),
|
282 |
+
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
283 |
+
'compiler' => true,
|
284 |
+
'size' => 'small',
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
$settings_map[ $page_id ] = array(
|
290 |
+
'sanitize' => 'absint',
|
291 |
+
);
|
292 |
+
}
|
293 |
+
|
294 |
+
$appearances_profile_menu_fields = array(
|
295 |
+
array(
|
296 |
+
'id' => 'profile_menu',
|
297 |
+
'type' => 'checkbox',
|
298 |
+
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
299 |
+
),
|
300 |
+
);
|
301 |
+
|
302 |
+
$settings_map['profile_menu'] = array(
|
303 |
+
'sanitize' => 'bool',
|
304 |
+
);
|
305 |
+
|
306 |
+
$tabs = UM()->profile()->tabs();
|
307 |
+
|
308 |
+
$tabs_options = array();
|
309 |
+
$tabs_condition = array();
|
310 |
+
foreach ( $tabs as $id => $tab ) {
|
311 |
+
|
312 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
313 |
+
continue;
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( isset( $tab['name'] ) ) {
|
317 |
+
$tabs_options[ $id ] = $tab['name'];
|
318 |
+
$tabs_condition[] = 'profile_tab_' . $id;
|
319 |
+
}
|
320 |
+
|
321 |
+
if ( isset( $tab['default_privacy'] ) ) {
|
322 |
+
$fields = array(
|
323 |
+
array(
|
324 |
+
'id' => 'profile_tab_' . $id,
|
325 |
+
'type' => 'checkbox',
|
326 |
+
// translators: %s: Tab title
|
327 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
328 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
329 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
330 |
+
),
|
331 |
+
);
|
332 |
+
|
333 |
+
$settings_map[ 'profile_tab_' . $id ] = array(
|
334 |
+
'sanitize' => 'bool',
|
335 |
+
);
|
336 |
+
} else {
|
337 |
+
|
338 |
+
$fields = array(
|
339 |
+
array(
|
340 |
+
'id' => 'profile_tab_' . $id,
|
341 |
+
'type' => 'checkbox',
|
342 |
+
// translators: %s: Tab title
|
343 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
344 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
345 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'id' => 'profile_tab_' . $id . '_privacy',
|
349 |
+
'type' => 'select',
|
350 |
+
// translators: %s: Tab title
|
351 |
+
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
352 |
+
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
353 |
+
'options' => UM()->profile()->tabs_privacy(),
|
354 |
+
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
355 |
+
'size' => 'small',
|
356 |
+
),
|
357 |
+
array(
|
358 |
+
'id' => 'profile_tab_' . $id . '_roles',
|
359 |
+
'type' => 'select',
|
360 |
+
'multi' => true,
|
361 |
+
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
362 |
+
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
363 |
+
'options' => UM()->roles()->get_roles(),
|
364 |
+
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
365 |
+
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
366 |
+
'size' => 'small',
|
367 |
+
),
|
368 |
+
);
|
369 |
+
|
370 |
+
$settings_map = array_merge(
|
371 |
+
$settings_map,
|
372 |
+
array(
|
373 |
+
"profile_tab_{$id}" => array(
|
374 |
+
'sanitize' => 'bool',
|
375 |
+
),
|
376 |
+
"profile_tab_{$id}_privacy" => array(
|
377 |
+
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
378 |
+
),
|
379 |
+
"profile_tab_{$id}_roles" => array(
|
380 |
+
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
381 |
+
),
|
382 |
+
)
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
387 |
+
}
|
388 |
+
|
389 |
+
$appearances_profile_menu_fields[] = array(
|
390 |
+
'id' => 'profile_menu_default_tab',
|
391 |
+
'type' => 'select',
|
392 |
+
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
393 |
+
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
394 |
+
'options' => $tabs_options,
|
395 |
+
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
396 |
+
'size' => 'small',
|
397 |
+
);
|
398 |
+
|
399 |
+
$settings_map['profile_menu_default_tab'] = array(
|
400 |
+
'sanitize' => 'key',
|
401 |
+
);
|
402 |
+
|
403 |
+
$appearances_profile_menu_fields = array_merge(
|
404 |
+
$appearances_profile_menu_fields,
|
405 |
+
array(
|
406 |
+
array(
|
407 |
+
'id' => 'profile_menu_icons',
|
408 |
+
'type' => 'checkbox',
|
409 |
+
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
410 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
411 |
+
),
|
412 |
+
)
|
413 |
+
);
|
414 |
+
|
415 |
+
$settings_map['profile_menu_icons'] = array(
|
416 |
+
'sanitize' => 'bool',
|
417 |
+
);
|
418 |
+
|
419 |
+
$post_types_options = array();
|
420 |
+
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
421 |
+
foreach ( $all_post_types as $key => $post_type_data ) {
|
422 |
+
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
423 |
+
}
|
424 |
+
|
425 |
+
$duplicates = array();
|
426 |
+
$taxonomies_options = array();
|
427 |
+
$exclude_taxonomies = UM()->excluded_taxonomies();
|
428 |
+
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
429 |
+
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
430 |
+
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
431 |
+
continue;
|
432 |
+
}
|
433 |
+
|
434 |
+
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
435 |
+
$duplicates[] = $taxonomy->labels->singular_name;
|
436 |
+
$label = $taxonomy->labels->singular_name;
|
437 |
+
} else {
|
438 |
+
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
439 |
+
}
|
440 |
+
|
441 |
+
$taxonomies_options[ $key ] = $label;
|
442 |
+
}
|
443 |
+
|
444 |
+
$restricted_access_post_metabox_value = array();
|
445 |
+
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
446 |
+
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
447 |
+
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
448 |
+
if ( $value ) {
|
449 |
+
$restricted_access_post_metabox_value[] = $key;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
|
455 |
+
$restricted_access_taxonomy_metabox_value = array();
|
456 |
+
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
457 |
+
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
458 |
+
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
459 |
+
if ( $value ) {
|
460 |
+
$restricted_access_taxonomy_metabox_value[] = $key;
|
461 |
+
}
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
$access_fields = array(
|
466 |
+
array(
|
467 |
+
'id' => 'accessible',
|
468 |
+
'type' => 'select',
|
469 |
+
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
470 |
+
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
471 |
+
'options' => array(
|
472 |
+
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
473 |
+
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
474 |
+
),
|
475 |
+
'size' => 'medium',
|
476 |
+
),
|
477 |
+
array(
|
478 |
+
'id' => 'access_redirect',
|
479 |
+
'type' => 'text',
|
480 |
+
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
481 |
+
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
482 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
483 |
+
),
|
484 |
+
array(
|
485 |
+
'id' => 'access_exclude_uris',
|
486 |
+
'type' => 'multi_text',
|
487 |
+
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
488 |
+
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
489 |
+
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
490 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
491 |
+
'show_default_number' => 0,
|
492 |
+
),
|
493 |
+
array(
|
494 |
+
'id' => 'home_page_accessible',
|
495 |
+
'type' => 'checkbox',
|
496 |
+
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
497 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
498 |
+
),
|
499 |
+
array(
|
500 |
+
'id' => 'category_page_accessible',
|
501 |
+
'type' => 'checkbox',
|
502 |
+
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
503 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
504 |
+
),
|
505 |
+
array(
|
506 |
+
'id' => 'restricted_post_title_replace',
|
507 |
+
'type' => 'checkbox',
|
508 |
+
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
509 |
+
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
510 |
+
),
|
511 |
+
array(
|
512 |
+
'id' => 'restricted_access_post_title',
|
513 |
+
'type' => 'text',
|
514 |
+
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
515 |
+
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
516 |
+
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
517 |
+
),
|
518 |
+
array(
|
519 |
+
'id' => 'restricted_access_message',
|
520 |
+
'type' => 'wp_editor',
|
521 |
+
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
522 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
523 |
+
),
|
524 |
+
);
|
525 |
+
|
526 |
+
$settings_map = array_merge(
|
527 |
+
$settings_map,
|
528 |
+
array(
|
529 |
+
'accessible' => array(
|
530 |
+
'sanitize' => 'int',
|
531 |
+
),
|
532 |
+
'access_redirect' => array(
|
533 |
+
'sanitize' => 'url',
|
534 |
+
),
|
535 |
+
'access_exclude_uris' => array(
|
536 |
+
'sanitize' => 'url',
|
537 |
+
),
|
538 |
+
'home_page_accessible' => array(
|
539 |
+
'sanitize' => 'bool',
|
540 |
+
),
|
541 |
+
'category_page_accessible' => array(
|
542 |
+
'sanitize' => 'bool',
|
543 |
+
),
|
544 |
+
'restricted_post_title_replace' => array(
|
545 |
+
'sanitize' => 'bool',
|
546 |
+
),
|
547 |
+
'restricted_access_post_title' => array(
|
548 |
+
'sanitize' => 'text',
|
549 |
+
),
|
550 |
+
'restricted_access_message' => array(
|
551 |
+
'sanitize' => 'wp_kses',
|
552 |
+
),
|
553 |
+
)
|
554 |
+
);
|
555 |
+
|
556 |
+
global $wp_version;
|
557 |
+
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
558 |
+
$access_fields = array_merge(
|
559 |
+
$access_fields,
|
560 |
+
array(
|
561 |
+
array(
|
562 |
+
'id' => 'restricted_blocks',
|
563 |
+
'type' => 'checkbox',
|
564 |
+
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
565 |
+
),
|
566 |
+
array(
|
567 |
+
'id' => 'restricted_block_message',
|
568 |
+
'type' => 'textarea',
|
569 |
+
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
570 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
571 |
+
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
572 |
+
),
|
573 |
+
)
|
574 |
+
);
|
575 |
+
|
576 |
+
$settings_map['restricted_blocks'] = array(
|
577 |
+
'sanitize' => 'bool',
|
578 |
+
);
|
579 |
+
$settings_map['restricted_block_message'] = array(
|
580 |
+
'sanitize' => 'textarea',
|
581 |
+
);
|
582 |
+
}
|
583 |
+
|
584 |
+
$access_fields = array_merge(
|
585 |
+
$access_fields,
|
586 |
+
array(
|
587 |
+
array(
|
588 |
+
'id' => 'restricted_access_post_metabox',
|
589 |
+
'type' => 'hidden',
|
590 |
+
'value' => '',
|
591 |
+
),
|
592 |
+
array(
|
593 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
594 |
+
'type' => 'hidden',
|
595 |
+
'value' => '',
|
596 |
+
),
|
597 |
+
array(
|
598 |
+
'id' => 'restricted_access_post_metabox',
|
599 |
+
'type' => 'multi_checkbox',
|
600 |
+
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
601 |
+
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
602 |
+
'options' => $post_types_options,
|
603 |
+
'columns' => 3,
|
604 |
+
'value' => $restricted_access_post_metabox_value,
|
605 |
+
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
606 |
+
),
|
607 |
+
array(
|
608 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
609 |
+
'type' => 'multi_checkbox',
|
610 |
+
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
611 |
+
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
612 |
+
'options' => $taxonomies_options,
|
613 |
+
'columns' => 3,
|
614 |
+
'value' => $restricted_access_taxonomy_metabox_value,
|
615 |
+
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
616 |
+
),
|
617 |
+
)
|
618 |
+
);
|
619 |
+
|
620 |
+
$settings_map = array_merge(
|
621 |
+
$settings_map,
|
622 |
+
array(
|
623 |
+
'restricted_access_post_metabox' => array(
|
624 |
+
'sanitize' => 'key',
|
625 |
+
),
|
626 |
+
'restricted_access_taxonomy_metabox' => array(
|
627 |
+
'sanitize' => 'key',
|
628 |
+
),
|
629 |
+
)
|
630 |
+
);
|
631 |
+
|
632 |
+
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
633 |
+
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
634 |
+
|
635 |
+
$same_page_update = array(
|
636 |
+
'id' => 'member_directory_own_table',
|
637 |
+
'type' => 'same_page_update',
|
638 |
+
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
639 |
+
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
640 |
+
);
|
641 |
+
|
642 |
+
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
643 |
+
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
644 |
+
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
645 |
+
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
646 |
+
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
647 |
+
}
|
648 |
+
|
649 |
+
$settings_map = array_merge(
|
650 |
+
$settings_map,
|
651 |
+
array(
|
652 |
+
'permalink_base' => array(
|
653 |
+
'sanitize' => 'key',
|
654 |
+
),
|
655 |
+
'display_name' => array(
|
656 |
+
'sanitize' => 'key',
|
657 |
+
),
|
658 |
+
'display_name_field' => array(
|
659 |
+
'sanitize' => 'text',
|
660 |
+
),
|
661 |
+
'author_redirect' => array(
|
662 |
+
'sanitize' => 'bool',
|
663 |
+
),
|
664 |
+
'members_page' => array(
|
665 |
+
'sanitize' => 'bool',
|
666 |
+
),
|
667 |
+
'use_gravatars' => array(
|
668 |
+
'sanitize' => 'bool',
|
669 |
+
),
|
670 |
+
'use_um_gravatar_default_builtin_image' => array(
|
671 |
+
'sanitize' => 'key',
|
672 |
+
),
|
673 |
+
'use_um_gravatar_default_image' => array(
|
674 |
+
'sanitize' => 'bool',
|
675 |
+
),
|
676 |
+
'require_strongpass' => array(
|
677 |
+
'sanitize' => 'bool',
|
678 |
+
),
|
679 |
+
'password_min_chars' => array(
|
680 |
+
'sanitize' => 'absint',
|
681 |
+
),
|
682 |
+
'password_max_chars' => array(
|
683 |
+
'sanitize' => 'absint',
|
684 |
+
),
|
685 |
+
'profile_noindex' => array(
|
686 |
+
'sanitize' => 'bool',
|
687 |
+
),
|
688 |
+
'activation_link_expiry_time' => array(
|
689 |
+
'sanitize' => 'absint',
|
690 |
+
),
|
691 |
+
'account_tab_password' => array(
|
692 |
+
'sanitize' => 'bool',
|
693 |
+
),
|
694 |
+
'account_tab_privacy' => array(
|
695 |
+
'sanitize' => 'bool',
|
696 |
+
),
|
697 |
+
'account_tab_notifications' => array(
|
698 |
+
'sanitize' => 'bool',
|
699 |
+
),
|
700 |
+
'account_tab_delete' => array(
|
701 |
+
'sanitize' => 'bool',
|
702 |
+
),
|
703 |
+
'delete_account_text' => array(
|
704 |
+
'sanitize' => 'textarea',
|
705 |
+
),
|
706 |
+
'delete_account_no_pass_required_text' => array(
|
707 |
+
'sanitize' => 'textarea',
|
708 |
+
),
|
709 |
+
'account_name' => array(
|
710 |
+
'sanitize' => 'bool',
|
711 |
+
),
|
712 |
+
'account_name_disable' => array(
|
713 |
+
'sanitize' => 'bool',
|
714 |
+
),
|
715 |
+
'account_name_require' => array(
|
716 |
+
'sanitize' => 'bool',
|
717 |
+
),
|
718 |
+
'account_email' => array(
|
719 |
+
'sanitize' => 'bool',
|
720 |
+
),
|
721 |
+
'account_general_password' => array(
|
722 |
+
'sanitize' => 'bool',
|
723 |
+
),
|
724 |
+
'account_hide_in_directory' => array(
|
725 |
+
'sanitize' => 'bool',
|
726 |
+
),
|
727 |
+
'account_hide_in_directory_default' => array(
|
728 |
+
'sanitize' => 'text',
|
729 |
+
),
|
730 |
+
'profile_photo_max_size' => array(
|
731 |
+
'sanitize' => 'absint',
|
732 |
+
),
|
733 |
+
'cover_photo_max_size' => array(
|
734 |
+
'sanitize' => 'absint',
|
735 |
+
),
|
736 |
+
'photo_thumb_sizes' => array(
|
737 |
+
'sanitize' => 'absint',
|
738 |
+
),
|
739 |
+
'cover_thumb_sizes' => array(
|
740 |
+
'sanitize' => 'absint',
|
741 |
+
),
|
742 |
+
'image_orientation_by_exif' => array(
|
743 |
+
'sanitize' => 'bool',
|
744 |
+
),
|
745 |
+
'image_compression' => array(
|
746 |
+
'sanitize' => 'absint',
|
747 |
+
),
|
748 |
+
'image_max_width' => array(
|
749 |
+
'sanitize' => 'absint',
|
750 |
+
),
|
751 |
+
'cover_min_width' => array(
|
752 |
+
'sanitize' => 'absint',
|
753 |
+
),
|
754 |
+
'enable_reset_password_limit' => array(
|
755 |
+
'sanitize' => 'bool',
|
756 |
+
),
|
757 |
+
'reset_password_limit_number' => array(
|
758 |
+
'sanitize' => 'absint',
|
759 |
+
),
|
760 |
+
'blocked_emails' => array(
|
761 |
+
'sanitize' => 'textarea',
|
762 |
+
),
|
763 |
+
'blocked_words' => array(
|
764 |
+
'sanitize' => 'textarea',
|
765 |
+
),
|
766 |
+
'admin_email' => array(
|
767 |
+
'sanitize' => 'text',
|
768 |
+
),
|
769 |
+
'mail_from' => array(
|
770 |
+
'sanitize' => 'text',
|
771 |
+
),
|
772 |
+
'mail_from_addr' => array(
|
773 |
+
'sanitize' => 'text',
|
774 |
+
),
|
775 |
+
'email_html' => array(
|
776 |
+
'sanitize' => 'bool',
|
777 |
+
),
|
778 |
+
'profile_template' => array(
|
779 |
+
'sanitize' => 'text',
|
780 |
+
),
|
781 |
+
'profile_max_width' => array(
|
782 |
+
'sanitize' => 'text',
|
783 |
+
),
|
784 |
+
'profile_area_max_width' => array(
|
785 |
+
'sanitize' => 'text',
|
786 |
+
),
|
787 |
+
'profile_icons' => array(
|
788 |
+
'sanitize' => 'key',
|
789 |
+
),
|
790 |
+
'profile_primary_btn_word' => array(
|
791 |
+
'sanitize' => 'text',
|
792 |
+
),
|
793 |
+
'profile_secondary_btn' => array(
|
794 |
+
'sanitize' => 'bool',
|
795 |
+
),
|
796 |
+
'profile_secondary_btn_word' => array(
|
797 |
+
'sanitize' => 'text',
|
798 |
+
),
|
799 |
+
'default_avatar' => array(
|
800 |
+
'sanitize' => 'url',
|
801 |
+
),
|
802 |
+
'default_cover' => array(
|
803 |
+
'sanitize' => 'url',
|
804 |
+
),
|
805 |
+
'disable_profile_photo_upload' => array(
|
806 |
+
'sanitize' => 'bool',
|
807 |
+
),
|
808 |
+
'profile_photosize' => array(
|
809 |
+
'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
|
810 |
+
),
|
811 |
+
'profile_cover_enabled' => array(
|
812 |
+
'sanitize' => 'bool',
|
813 |
+
),
|
814 |
+
'profile_coversize' => array(
|
815 |
+
'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
|
816 |
+
),
|
817 |
+
'profile_cover_ratio' => array(
|
818 |
+
'sanitize' => 'text',
|
819 |
+
),
|
820 |
+
'profile_show_metaicon' => array(
|
821 |
+
'sanitize' => 'bool',
|
822 |
+
),
|
823 |
+
'profile_show_name' => array(
|
824 |
+
'sanitize' => 'bool',
|
825 |
+
),
|
826 |
+
'profile_show_social_links' => array(
|
827 |
+
'sanitize' => 'bool',
|
828 |
+
),
|
829 |
+
'profile_show_bio' => array(
|
830 |
+
'sanitize' => 'bool',
|
831 |
+
),
|
832 |
+
'profile_show_html_bio' => array(
|
833 |
+
'sanitize' => 'bool',
|
834 |
+
),
|
835 |
+
'profile_bio_maxchars' => array(
|
836 |
+
'sanitize' => 'absint',
|
837 |
+
),
|
838 |
+
'profile_header_menu' => array(
|
839 |
+
'sanitize' => 'key',
|
840 |
+
),
|
841 |
+
'profile_empty_text' => array(
|
842 |
+
'sanitize' => 'bool',
|
843 |
+
),
|
844 |
+
'profile_empty_text_emo' => array(
|
845 |
+
'sanitize' => 'bool',
|
846 |
+
),
|
847 |
+
'register_template' => array(
|
848 |
+
'sanitize' => 'text',
|
849 |
+
),
|
850 |
+
'register_max_width' => array(
|
851 |
+
'sanitize' => 'text',
|
852 |
+
),
|
853 |
+
'register_align' => array(
|
854 |
+
'sanitize' => 'key',
|
855 |
+
),
|
856 |
+
'register_icons' => array(
|
857 |
+
'sanitize' => 'key',
|
858 |
+
),
|
859 |
+
'register_primary_btn_word' => array(
|
860 |
+
'sanitize' => 'text',
|
861 |
+
),
|
862 |
+
'register_secondary_btn' => array(
|
863 |
+
'sanitize' => 'bool',
|
864 |
+
),
|
865 |
+
'register_secondary_btn_word' => array(
|
866 |
+
'sanitize' => 'text',
|
867 |
+
),
|
868 |
+
'register_secondary_btn_url' => array(
|
869 |
+
'sanitize' => 'url',
|
870 |
+
),
|
871 |
+
'register_role' => array(
|
872 |
+
'sanitize' => 'key',
|
873 |
+
),
|
874 |
+
'login_template' => array(
|
875 |
+
'sanitize' => 'text',
|
876 |
+
),
|
877 |
+
'login_max_width' => array(
|
878 |
+
'sanitize' => 'text',
|
879 |
+
),
|
880 |
+
'login_align' => array(
|
881 |
+
'sanitize' => 'key',
|
882 |
+
),
|
883 |
+
'login_icons' => array(
|
884 |
+
'sanitize' => 'key',
|
885 |
+
),
|
886 |
+
'login_primary_btn_word' => array(
|
887 |
+
'sanitize' => 'text',
|
888 |
+
),
|
889 |
+
'login_secondary_btn' => array(
|
890 |
+
'sanitize' => 'bool',
|
891 |
+
),
|
892 |
+
'login_secondary_btn_word' => array(
|
893 |
+
'sanitize' => 'text',
|
894 |
+
),
|
895 |
+
'login_secondary_btn_url' => array(
|
896 |
+
'sanitize' => 'url',
|
897 |
+
),
|
898 |
+
'login_forgot_pass_link' => array(
|
899 |
+
'sanitize' => 'bool',
|
900 |
+
),
|
901 |
+
'login_show_rememberme' => array(
|
902 |
+
'sanitize' => 'bool',
|
903 |
+
),
|
904 |
+
'form_asterisk' => array(
|
905 |
+
'sanitize' => 'bool',
|
906 |
+
),
|
907 |
+
'profile_title' => array(
|
908 |
+
'sanitize' => 'text',
|
909 |
+
),
|
910 |
+
'profile_desc' => array(
|
911 |
+
'sanitize' => 'textarea',
|
912 |
+
),
|
913 |
+
'um_profile_object_cache_stop' => array(
|
914 |
+
'sanitize' => 'bool',
|
915 |
+
),
|
916 |
+
'enable_blocks' => array(
|
917 |
+
'sanitize' => 'bool',
|
918 |
+
),
|
919 |
+
'rest_api_version' => array(
|
920 |
+
'sanitize' => 'text',
|
921 |
+
),
|
922 |
+
'uninstall_on_delete' => array(
|
923 |
+
'sanitize' => 'bool',
|
924 |
+
),
|
925 |
+
)
|
926 |
+
);
|
927 |
+
|
928 |
+
$this->settings_map = apply_filters( 'um_settings_map', $settings_map );
|
929 |
+
|
930 |
+
/**
|
931 |
+
* UM hook
|
932 |
+
*
|
933 |
+
* @type filter
|
934 |
+
* @title um_settings_structure
|
935 |
+
* @description Extend UM Settings
|
936 |
+
* @input_vars
|
937 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings"}]
|
938 |
+
* @change_log
|
939 |
+
* ["Since: 2.0"]
|
940 |
+
* @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
|
941 |
+
* @example
|
942 |
+
* <?php
|
943 |
+
* add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
|
944 |
+
* function my_settings_structure( $settings ) {
|
945 |
+
* // your code here
|
946 |
+
* return $settings;
|
947 |
+
* }
|
948 |
+
* ?>
|
949 |
+
*/
|
950 |
+
$this->settings_structure = apply_filters(
|
951 |
+
'um_settings_structure',
|
952 |
+
array(
|
953 |
+
'' => array(
|
954 |
+
'title' => __( 'General', 'ultimate-member' ),
|
955 |
+
'sections' => array(
|
956 |
+
'' => array(
|
957 |
+
'title' => __( 'Pages', 'ultimate-member' ),
|
958 |
+
'fields' => $general_pages_fields,
|
959 |
+
),
|
960 |
+
'users' => array(
|
961 |
+
'title' => __( 'Users', 'ultimate-member' ),
|
962 |
+
'fields' => array(
|
963 |
+
array(
|
964 |
+
'id' => 'permalink_base',
|
965 |
+
'type' => 'select',
|
966 |
+
'size' => 'small',
|
967 |
+
'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
|
968 |
+
// translators: %s: Profile page URL
|
969 |
+
'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ),
|
970 |
+
'options' => array(
|
971 |
+
'user_login' => __( 'Username', 'ultimate-member' ),
|
972 |
+
'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
|
973 |
+
'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
|
974 |
+
'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
|
975 |
+
'user_id' => __( 'User ID', 'ultimate-member' ),
|
976 |
+
),
|
977 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
978 |
+
),
|
979 |
+
array(
|
980 |
+
'id' => 'display_name',
|
981 |
+
'type' => 'select',
|
982 |
+
'size' => 'medium',
|
983 |
+
'label' => __( 'User Display Name', 'ultimate-member' ),
|
984 |
+
'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ),
|
985 |
+
'options' => array(
|
986 |
+
'default' => __( 'Default WP Display Name', 'ultimate-member' ),
|
987 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
988 |
+
'username' => __( 'Username', 'ultimate-member' ),
|
989 |
+
'full_name' => __( 'First name & last name', 'ultimate-member' ),
|
990 |
+
'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
|
991 |
+
'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
|
992 |
+
'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
|
993 |
+
'first_name' => __( 'First name only', 'ultimate-member' ),
|
994 |
+
'field' => __( 'Custom field(s)', 'ultimate-member' ),
|
995 |
+
),
|
996 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
997 |
+
),
|
998 |
+
array(
|
999 |
+
'id' => 'display_name_field',
|
1000 |
+
'type' => 'text',
|
1001 |
+
'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
|
1002 |
+
'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ),
|
1003 |
+
'conditional' => array( 'display_name', '=', 'field' ),
|
1004 |
+
),
|
1005 |
+
array(
|
1006 |
+
'id' => 'author_redirect',
|
1007 |
+
'type' => 'checkbox',
|
1008 |
+
'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
|
1009 |
+
'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
|
1010 |
+
),
|
1011 |
+
array(
|
1012 |
+
'id' => 'members_page',
|
1013 |
+
'type' => 'checkbox',
|
1014 |
+
'label' => __( 'Enable Members Directory', 'ultimate-member' ),
|
1015 |
+
'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
|
1016 |
+
),
|
1017 |
+
array(
|
1018 |
+
'id' => 'use_gravatars',
|
1019 |
+
'type' => 'checkbox',
|
1020 |
+
'label' => __( 'Use Gravatars?', 'ultimate-member' ),
|
1021 |
+
'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1022 |
+
),
|
1023 |
+
array(
|
1024 |
+
'id' => 'use_um_gravatar_default_builtin_image',
|
1025 |
+
'type' => 'select',
|
1026 |
+
'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
|
1027 |
+
'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
|
1028 |
+
'options' => array(
|
1029 |
+
'default' => __( 'Default', 'ultimate-member' ),
|
1030 |
+
'404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
|
1031 |
+
'mm' => __( 'Mystery Man', 'ultimate-member' ),
|
1032 |
+
'identicon' => __( 'Identicon', 'ultimate-member' ),
|
1033 |
+
'monsterid' => __( 'Monsterid', 'ultimate-member' ),
|
1034 |
+
'wavatar' => __( 'Wavatar', 'ultimate-member' ),
|
1035 |
+
'retro' => __( 'Retro', 'ultimate-member' ),
|
1036 |
+
'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
|
1037 |
+
),
|
1038 |
+
'conditional' => array( 'use_gravatars', '=', 1 ),
|
1039 |
+
'size' => 'medium',
|
1040 |
+
),
|
1041 |
+
array(
|
1042 |
+
'id' => 'use_um_gravatar_default_image',
|
1043 |
+
'type' => 'checkbox',
|
1044 |
+
'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
|
1045 |
+
'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1046 |
+
'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
|
1047 |
+
),
|
1048 |
+
array(
|
1049 |
+
'id' => 'require_strongpass',
|
1050 |
+
'type' => 'checkbox',
|
1051 |
+
'label' => __( 'Require a strong password?', 'ultimate-member' ),
|
1052 |
+
'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms.', 'ultimate-member' ),
|
1053 |
+
),
|
1054 |
+
array(
|
1055 |
+
'id' => 'password_min_chars',
|
1056 |
+
'type' => 'number',
|
1057 |
+
'label' => __( 'Password minimum length', 'ultimate-member' ),
|
1058 |
+
'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ),
|
1059 |
+
'size' => 'small',
|
1060 |
+
),
|
1061 |
+
array(
|
1062 |
+
'id' => 'password_max_chars',
|
1063 |
+
'type' => 'number',
|
1064 |
+
'label' => __( 'Password maximum length', 'ultimate-member' ),
|
1065 |
+
'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ),
|
1066 |
+
'size' => 'small',
|
1067 |
+
),
|
1068 |
+
array(
|
1069 |
+
'id' => 'profile_noindex',
|
1070 |
+
'type' => 'select',
|
1071 |
+
'size' => 'small',
|
1072 |
+
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
1073 |
+
'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
|
1074 |
+
'options' => array(
|
1075 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1076 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1077 |
+
),
|
1078 |
+
),
|
1079 |
+
array(
|
1080 |
+
'id' => 'activation_link_expiry_time',
|
1081 |
+
'type' => 'number',
|
1082 |
+
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
1083 |
+
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
|
1084 |
+
'size' => 'small',
|
1085 |
+
),
|
1086 |
+
),
|
1087 |
+
),
|
1088 |
+
'account' => array(
|
1089 |
+
'title' => __( 'Account', 'ultimate-member' ),
|
1090 |
+
'fields' => array(
|
1091 |
+
array(
|
1092 |
+
'id' => 'account_tab_password',
|
1093 |
+
'type' => 'checkbox',
|
1094 |
+
'label' => __( 'Password Account Tab', 'ultimate-member' ),
|
1095 |
+
'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
|
1096 |
+
),
|
1097 |
+
array(
|
1098 |
+
'id' => 'account_tab_privacy',
|
1099 |
+
'type' => 'checkbox',
|
1100 |
+
'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
|
1101 |
+
'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
|
1102 |
+
),
|
1103 |
+
array(
|
1104 |
+
'id' => 'account_tab_notifications',
|
1105 |
+
'type' => 'checkbox',
|
1106 |
+
'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
|
1107 |
+
'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
|
1108 |
+
),
|
1109 |
+
array(
|
1110 |
+
'id' => 'account_tab_delete',
|
1111 |
+
'type' => 'checkbox',
|
1112 |
+
'label' => __( 'Delete Account Tab', 'ultimate-member' ),
|
1113 |
+
'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
|
1114 |
+
),
|
1115 |
+
array(
|
1116 |
+
'id' => 'delete_account_text',
|
1117 |
+
'type' => 'textarea', // bug with wp 4.4? should be editor
|
1118 |
+
'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
|
1119 |
+
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ),
|
1120 |
+
'args' => array(
|
1121 |
+
'textarea_rows' => 6,
|
1122 |
+
),
|
1123 |
+
),
|
1124 |
+
array(
|
1125 |
+
'id' => 'delete_account_no_pass_required_text',
|
1126 |
+
'type' => 'textarea',
|
1127 |
+
'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
|
1128 |
+
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ),
|
1129 |
+
'args' => array(
|
1130 |
+
'textarea_rows' => 6,
|
1131 |
+
),
|
1132 |
+
),
|
1133 |
+
array(
|
1134 |
+
'id' => 'account_name',
|
1135 |
+
'type' => 'checkbox',
|
1136 |
+
'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
|
1137 |
+
'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
|
1138 |
+
),
|
1139 |
+
array(
|
1140 |
+
'id' => 'account_name_disable',
|
1141 |
+
'type' => 'checkbox',
|
1142 |
+
'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
|
1143 |
+
'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
|
1144 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1145 |
+
),
|
1146 |
+
array(
|
1147 |
+
'id' => 'account_name_require',
|
1148 |
+
'type' => 'checkbox',
|
1149 |
+
'label' => __( 'Require First & Last Name', 'ultimate-member' ),
|
1150 |
+
'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
|
1151 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1152 |
+
),
|
1153 |
+
array(
|
1154 |
+
'id' => 'account_email',
|
1155 |
+
'type' => 'checkbox',
|
1156 |
+
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
|
1157 |
+
'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
|
1158 |
+
),
|
1159 |
+
array(
|
1160 |
+
'id' => 'account_general_password',
|
1161 |
+
'type' => 'checkbox',
|
1162 |
+
'label' => __( 'Password is required?', 'ultimate-member' ),
|
1163 |
+
'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
|
1164 |
+
),
|
1165 |
+
array(
|
1166 |
+
'id' => 'account_hide_in_directory',
|
1167 |
+
'type' => 'checkbox',
|
1168 |
+
'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
|
1169 |
+
'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
|
1170 |
+
'conditional' => array( 'account_tab_privacy', '=', '1' ),
|
1171 |
+
),
|
1172 |
+
array(
|
1173 |
+
'id' => 'account_hide_in_directory_default',
|
1174 |
+
'type' => 'select',
|
1175 |
+
'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
|
1176 |
+
'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
|
1177 |
+
'options' => array(
|
1178 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1179 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1180 |
+
),
|
1181 |
+
'size' => 'small',
|
1182 |
+
'conditional' => array( 'account_hide_in_directory', '=', '1' ),
|
1183 |
+
),
|
1184 |
+
),
|
1185 |
+
),
|
1186 |
+
'uploads' => array(
|
1187 |
+
'title' => __( 'Uploads', 'ultimate-member' ),
|
1188 |
+
'fields' => array(
|
1189 |
+
array(
|
1190 |
+
'id' => 'profile_photo_max_size',
|
1191 |
+
'type' => 'text',
|
1192 |
+
'size' => 'small',
|
1193 |
+
'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1194 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
|
1195 |
+
),
|
1196 |
+
array(
|
1197 |
+
'id' => 'cover_photo_max_size',
|
1198 |
+
'type' => 'text',
|
1199 |
+
'size' => 'small',
|
1200 |
+
'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1201 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
|
1202 |
+
),
|
1203 |
+
array(
|
1204 |
+
'id' => 'photo_thumb_sizes',
|
1205 |
+
'type' => 'multi_text',
|
1206 |
+
'size' => 'small',
|
1207 |
+
'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1208 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
|
1209 |
+
'validate' => 'numeric',
|
1210 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1211 |
+
'show_default_number' => 1,
|
1212 |
+
),
|
1213 |
+
array(
|
1214 |
+
'id' => 'cover_thumb_sizes',
|
1215 |
+
'type' => 'multi_text',
|
1216 |
+
'size' => 'small',
|
1217 |
+
'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1218 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
|
1219 |
+
'validate' => 'numeric',
|
1220 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1221 |
+
'show_default_number' => 1,
|
1222 |
+
),
|
1223 |
+
array(
|
1224 |
+
'id' => 'image_orientation_by_exif',
|
1225 |
+
'type' => 'checkbox',
|
1226 |
+
'label' => __( 'Change image orientation', 'ultimate-member' ),
|
1227 |
+
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
|
1228 |
+
),
|
1229 |
+
array(
|
1230 |
+
'id' => 'image_compression',
|
1231 |
+
'type' => 'text',
|
1232 |
+
'size' => 'small',
|
1233 |
+
'label' => __( 'Image Quality', 'ultimate-member' ),
|
1234 |
+
'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' ),
|
1235 |
+
),
|
1236 |
+
|
1237 |
+
array(
|
1238 |
+
'id' => 'image_max_width',
|
1239 |
+
'type' => 'text',
|
1240 |
+
'size' => 'small',
|
1241 |
+
'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
|
1242 |
+
'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
|
1243 |
+
),
|
1244 |
+
|
1245 |
+
array(
|
1246 |
+
'id' => 'cover_min_width',
|
1247 |
+
'type' => 'text',
|
1248 |
+
'size' => 'small',
|
1249 |
+
'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
|
1250 |
+
'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
|
1251 |
+
),
|
1252 |
+
),
|
1253 |
+
),
|
1254 |
+
),
|
1255 |
+
),
|
1256 |
+
'access' => array(
|
1257 |
+
'title' => __( 'Access', 'ultimate-member' ),
|
1258 |
+
'sections' => array(
|
1259 |
+
'' => array(
|
1260 |
+
'title' => __( 'Restriction Content', 'ultimate-member' ),
|
1261 |
+
'fields' => $access_fields,
|
1262 |
+
),
|
1263 |
+
'other' => array(
|
1264 |
+
'title' => __( 'Other', 'ultimate-member' ),
|
1265 |
+
'fields' => array(
|
1266 |
+
array(
|
1267 |
+
'id' => 'enable_reset_password_limit',
|
1268 |
+
'type' => 'checkbox',
|
1269 |
+
'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
|
1270 |
+
),
|
1271 |
+
array(
|
1272 |
+
'id' => 'reset_password_limit_number',
|
1273 |
+
'type' => 'text',
|
1274 |
+
'label' => __( 'Reset Password Limit', 'ultimate-member' ),
|
1275 |
+
'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
|
1276 |
+
'validate' => 'numeric',
|
1277 |
+
'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
|
1278 |
+
'size' => 'small',
|
1279 |
+
),
|
1280 |
+
array(
|
1281 |
+
'id' => 'blocked_emails',
|
1282 |
+
'type' => 'textarea',
|
1283 |
+
'label' => __( 'Blocked Email Addresses (Enter one email per line)', 'ultimate-member' ),
|
1284 |
+
'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ),
|
1285 |
+
),
|
1286 |
+
array(
|
1287 |
+
'id' => 'blocked_words',
|
1288 |
+
'type' => 'textarea',
|
1289 |
+
'label' => __( 'Blacklist Words (Enter one word per line)', 'ultimate-member' ),
|
1290 |
+
'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
|
1291 |
+
),
|
1292 |
+
),
|
1293 |
+
),
|
1294 |
+
),
|
1295 |
+
),
|
1296 |
+
'email' => array(
|
1297 |
+
'title' => __( 'Email', 'ultimate-member' ),
|
1298 |
+
'fields' => array(
|
1299 |
+
array(
|
1300 |
+
'id' => 'admin_email',
|
1301 |
+
'type' => 'text',
|
1302 |
+
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
|
1303 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1304 |
+
),
|
1305 |
+
array(
|
1306 |
+
'id' => 'mail_from',
|
1307 |
+
'type' => 'text',
|
1308 |
+
'label' => __( 'Mail appears from', 'ultimate-member' ),
|
1309 |
+
'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
|
1310 |
+
),
|
1311 |
+
array(
|
1312 |
+
'id' => 'mail_from_addr',
|
1313 |
+
'type' => 'text',
|
1314 |
+
'label' => __( 'Mail appears from address', 'ultimate-member' ),
|
1315 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1316 |
+
),
|
1317 |
+
array(
|
1318 |
+
'id' => 'email_html',
|
1319 |
+
'type' => 'checkbox',
|
1320 |
+
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
|
1321 |
+
'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ),
|
1322 |
+
),
|
1323 |
+
),
|
1324 |
+
),
|
1325 |
+
'appearance' => array(
|
1326 |
+
'title' => __( 'Appearance', 'ultimate-member' ),
|
1327 |
+
'sections' => array(
|
1328 |
+
'' => array(
|
1329 |
+
'title' => __( 'Profile', 'ultimate-member' ),
|
1330 |
+
'fields' => array(
|
1331 |
+
array(
|
1332 |
+
'id' => 'profile_template',
|
1333 |
+
'type' => 'select',
|
1334 |
+
'label' => __( 'Profile Default Template', 'ultimate-member' ),
|
1335 |
+
'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
|
1336 |
+
'default' => um_get_metadefault( 'profile_template' ),
|
1337 |
+
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
1338 |
+
'size' => 'small',
|
1339 |
+
),
|
1340 |
+
array(
|
1341 |
+
'id' => 'profile_max_width',
|
1342 |
+
'type' => 'text',
|
1343 |
+
'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
|
1344 |
+
'default' => um_get_metadefault( 'profile_max_width' ),
|
1345 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1346 |
+
'size' => 'small',
|
1347 |
+
),
|
1348 |
+
array(
|
1349 |
+
'id' => 'profile_area_max_width',
|
1350 |
+
'type' => 'text',
|
1351 |
+
'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
|
1352 |
+
'default' => um_get_metadefault( 'profile_area_max_width' ),
|
1353 |
+
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
1354 |
+
'size' => 'small',
|
1355 |
+
),
|
1356 |
+
array(
|
1357 |
+
'id' => 'profile_icons',
|
1358 |
+
'type' => 'select',
|
1359 |
+
'label' => __( 'Profile Field Icons', 'ultimate-member' ),
|
1360 |
+
'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
|
1361 |
+
'default' => um_get_metadefault( 'profile_icons' ),
|
1362 |
+
'options' => array(
|
1363 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1364 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1365 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1366 |
+
),
|
1367 |
+
'size' => 'small',
|
1368 |
+
),
|
1369 |
+
array(
|
1370 |
+
'id' => 'profile_primary_btn_word',
|
1371 |
+
'type' => 'text',
|
1372 |
+
'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
|
1373 |
+
'default' => um_get_metadefault( 'profile_primary_btn_word' ),
|
1374 |
+
'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
|
1375 |
+
'size' => 'medium',
|
1376 |
+
),
|
1377 |
+
array(
|
1378 |
+
'id' => 'profile_secondary_btn',
|
1379 |
+
'type' => 'checkbox',
|
1380 |
+
'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
|
1381 |
+
'default' => um_get_metadefault( 'profile_secondary_btn' ),
|
1382 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1383 |
+
),
|
1384 |
+
array(
|
1385 |
+
'id' => 'profile_secondary_btn_word',
|
1386 |
+
'type' => 'text',
|
1387 |
+
'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
|
1388 |
+
'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
|
1389 |
+
'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
|
1390 |
+
'conditional' => array( 'profile_secondary_btn', '=', 1 ),
|
1391 |
+
'size' => 'medium',
|
1392 |
+
),
|
1393 |
+
array(
|
1394 |
+
'id' => 'default_avatar',
|
1395 |
+
'type' => 'media',
|
1396 |
+
'label' => __( 'Default Profile Photo', 'ultimate-member' ),
|
1397 |
+
'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
|
1398 |
+
'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
|
1399 |
+
'default' => array(
|
1400 |
+
'url' => um_url . 'assets/img/default_avatar.jpg',
|
1401 |
+
),
|
1402 |
+
),
|
1403 |
+
array(
|
1404 |
+
'id' => 'default_cover',
|
1405 |
+
'type' => 'media',
|
1406 |
+
'url' => true,
|
1407 |
+
'preview' => false,
|
1408 |
+
'label' => __( 'Default Cover Photo', 'ultimate-member' ),
|
1409 |
+
'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ),
|
1410 |
+
'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
|
1411 |
+
),
|
1412 |
+
array(
|
1413 |
+
'id' => 'disable_profile_photo_upload',
|
1414 |
+
'type' => 'checkbox',
|
1415 |
+
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
1416 |
+
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
1417 |
+
'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
|
1418 |
+
),
|
1419 |
+
array(
|
1420 |
+
'id' => 'profile_photosize',
|
1421 |
+
'type' => 'select',
|
1422 |
+
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
1423 |
+
'default' => um_get_metadefault( 'profile_photosize' ),
|
1424 |
+
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
1425 |
+
'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1426 |
+
'size' => 'small',
|
1427 |
+
),
|
1428 |
+
array(
|
1429 |
+
'id' => 'profile_cover_enabled',
|
1430 |
+
'type' => 'checkbox',
|
1431 |
+
'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
|
1432 |
+
'default' => um_get_metadefault( 'profile_cover_enabled' ),
|
1433 |
+
'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
|
1434 |
+
),
|
1435 |
+
array(
|
1436 |
+
'id' => 'profile_coversize',
|
1437 |
+
'type' => 'select',
|
1438 |
+
'label' => __( 'Profile Cover Size', 'ultimate-member' ),
|
1439 |
+
'default' => um_get_metadefault( 'profile_coversize' ),
|
1440 |
+
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
1441 |
+
'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1442 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1443 |
+
'size' => 'small',
|
1444 |
+
),
|
1445 |
+
array(
|
1446 |
+
'id' => 'profile_cover_ratio',
|
1447 |
+
'type' => 'select',
|
1448 |
+
'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
|
1449 |
+
'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
|
1450 |
+
'default' => um_get_metadefault( 'profile_cover_ratio' ),
|
1451 |
+
'options' => array(
|
1452 |
+
'1.6:1' => '1.6:1',
|
1453 |
+
'2.7:1' => '2.7:1',
|
1454 |
+
'2.2:1' => '2.2:1',
|
1455 |
+
'3.2:1' => '3.2:1',
|
1456 |
+
),
|
1457 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1458 |
+
'size' => 'small',
|
1459 |
+
),
|
1460 |
+
array(
|
1461 |
+
'id' => 'profile_show_metaicon',
|
1462 |
+
'type' => 'checkbox',
|
1463 |
+
'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
|
1464 |
+
'default' => 0,
|
1465 |
+
'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
|
1466 |
+
),
|
1467 |
+
array(
|
1468 |
+
'id' => 'profile_show_name',
|
1469 |
+
'type' => 'checkbox',
|
1470 |
+
'label' => __( 'Show display name in profile header', 'ultimate-member' ),
|
1471 |
+
'default' => um_get_metadefault( 'profile_show_name' ),
|
1472 |
+
'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
|
1473 |
+
),
|
1474 |
+
array(
|
1475 |
+
'id' => 'profile_show_social_links',
|
1476 |
+
'type' => 'checkbox',
|
1477 |
+
'label' => __( 'Show social links in profile header', 'ultimate-member' ),
|
1478 |
+
'default' => um_get_metadefault( 'profile_show_social_links' ),
|
1479 |
+
'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
|
1480 |
+
),
|
1481 |
+
array(
|
1482 |
+
'id' => 'profile_show_bio',
|
1483 |
+
'type' => 'checkbox',
|
1484 |
+
'label' => __( 'Show user description in header', 'ultimate-member' ),
|
1485 |
+
'default' => um_get_metadefault( 'profile_show_bio' ),
|
1486 |
+
'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
|
1487 |
+
),
|
1488 |
+
array(
|
1489 |
+
'id' => 'profile_show_html_bio',
|
1490 |
+
'type' => 'checkbox',
|
1491 |
+
'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
|
1492 |
+
'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
|
1493 |
+
),
|
1494 |
+
array(
|
1495 |
+
'id' => 'profile_bio_maxchars',
|
1496 |
+
'type' => 'text',
|
1497 |
+
'label' => __( 'User description maximum chars', 'ultimate-member' ),
|
1498 |
+
'default' => um_get_metadefault( 'profile_bio_maxchars' ),
|
1499 |
+
'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
|
1500 |
+
'conditional' => array( 'profile_show_bio', '=', 1 ),
|
1501 |
+
'size' => 'small',
|
1502 |
+
),
|
1503 |
+
array(
|
1504 |
+
'id' => 'profile_header_menu',
|
1505 |
+
'type' => 'select',
|
1506 |
+
'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
|
1507 |
+
'default' => um_get_metadefault( 'profile_header_menu' ),
|
1508 |
+
'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
|
1509 |
+
'options' => array(
|
1510 |
+
'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
|
1511 |
+
'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
|
1512 |
+
),
|
1513 |
+
'size' => 'small',
|
1514 |
+
),
|
1515 |
+
array(
|
1516 |
+
'id' => 'profile_empty_text',
|
1517 |
+
'type' => 'checkbox',
|
1518 |
+
'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
|
1519 |
+
'default' => um_get_metadefault( 'profile_empty_text' ),
|
1520 |
+
'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
|
1521 |
+
),
|
1522 |
+
array(
|
1523 |
+
'id' => 'profile_empty_text_emo',
|
1524 |
+
'type' => 'checkbox',
|
1525 |
+
'label' => __( 'Show the emoticon', 'ultimate-member' ),
|
1526 |
+
'default' => um_get_metadefault( 'profile_empty_text_emo' ),
|
1527 |
+
'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
|
1528 |
+
'conditional' => array( 'profile_empty_text', '=', 1 ),
|
1529 |
+
),
|
1530 |
+
),
|
1531 |
+
),
|
1532 |
+
'profile_menu' => array(
|
1533 |
+
'title' => __( 'Profile Menu', 'ultimate-member' ),
|
1534 |
+
'fields' => $appearances_profile_menu_fields,
|
1535 |
+
),
|
1536 |
+
'registration_form' => array(
|
1537 |
+
'title' => __( 'Registration Form', 'ultimate-member' ),
|
1538 |
+
'fields' => array(
|
1539 |
+
array(
|
1540 |
+
'id' => 'register_template',
|
1541 |
+
'type' => 'select',
|
1542 |
+
'label' => __( 'Registration Default Template', 'ultimate-member' ),
|
1543 |
+
'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
|
1544 |
+
'default' => um_get_metadefault( 'register_template' ),
|
1545 |
+
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
1546 |
+
'size' => 'small',
|
1547 |
+
),
|
1548 |
+
array(
|
1549 |
+
'id' => 'register_max_width',
|
1550 |
+
'type' => 'text',
|
1551 |
+
'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
|
1552 |
+
'default' => um_get_metadefault( 'register_max_width' ),
|
1553 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1554 |
+
'size' => 'small',
|
1555 |
+
),
|
1556 |
+
array(
|
1557 |
+
'id' => 'register_align',
|
1558 |
+
'type' => 'select',
|
1559 |
+
'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
|
1560 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1561 |
+
'default' => um_get_metadefault( 'register_align' ),
|
1562 |
+
'options' => array(
|
1563 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1564 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1565 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1566 |
+
),
|
1567 |
+
'size' => 'small',
|
1568 |
+
),
|
1569 |
+
array(
|
1570 |
+
'id' => 'register_icons',
|
1571 |
+
'type' => 'select',
|
1572 |
+
'label' => __( 'Registration Field Icons', 'ultimate-member' ),
|
1573 |
+
'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
|
1574 |
+
'default' => um_get_metadefault( 'register_icons' ),
|
1575 |
+
'options' => array(
|
1576 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1577 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1578 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1579 |
+
),
|
1580 |
+
'size' => 'small',
|
1581 |
+
),
|
1582 |
+
array(
|
1583 |
+
'id' => 'register_primary_btn_word',
|
1584 |
+
'type' => 'text',
|
1585 |
+
'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
|
1586 |
+
'default' => um_get_metadefault( 'register_primary_btn_word' ),
|
1587 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1588 |
+
'size' => 'medium',
|
1589 |
+
),
|
1590 |
+
array(
|
1591 |
+
'id' => 'register_secondary_btn',
|
1592 |
+
'type' => 'checkbox',
|
1593 |
+
'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
|
1594 |
+
'default' => 1,
|
1595 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1596 |
+
),
|
1597 |
+
array(
|
1598 |
+
'id' => 'register_secondary_btn_word',
|
1599 |
+
'type' => 'text',
|
1600 |
+
'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
|
1601 |
+
'default' => um_get_metadefault( 'register_secondary_btn_word' ),
|
1602 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1603 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1604 |
+
'size' => 'medium',
|
1605 |
+
),
|
1606 |
+
array(
|
1607 |
+
'id' => 'register_secondary_btn_url',
|
1608 |
+
'type' => 'text',
|
1609 |
+
'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
|
1610 |
+
'default' => um_get_metadefault( 'register_secondary_btn_url' ),
|
1611 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1612 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1613 |
+
'size' => 'medium',
|
1614 |
+
),
|
1615 |
+
array(
|
1616 |
+
'id' => 'register_role',
|
1617 |
+
'type' => 'select',
|
1618 |
+
'label' => __( 'Registration Default Role', 'ultimate-member' ),
|
1619 |
+
'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
|
1620 |
+
'default' => um_get_metadefault( 'register_role' ),
|
1621 |
+
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
1622 |
+
'size' => 'small',
|
1623 |
+
),
|
1624 |
+
),
|
1625 |
+
),
|
1626 |
+
'login_form' => array(
|
1627 |
+
'title' => __( 'Login Form', 'ultimate-member' ),
|
1628 |
+
'fields' => array(
|
1629 |
+
array(
|
1630 |
+
'id' => 'login_template',
|
1631 |
+
'type' => 'select',
|
1632 |
+
'label' => __( 'Login Default Template', 'ultimate-member' ),
|
1633 |
+
'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
|
1634 |
+
'default' => um_get_metadefault( 'login_template' ),
|
1635 |
+
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
1636 |
+
'size' => 'small',
|
1637 |
+
),
|
1638 |
+
array(
|
1639 |
+
'id' => 'login_max_width',
|
1640 |
+
'type' => 'text',
|
1641 |
+
'label' => __( 'Login Maximum Width', 'ultimate-member' ),
|
1642 |
+
'default' => um_get_metadefault( 'login_max_width' ),
|
1643 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1644 |
+
'size' => 'small',
|
1645 |
+
),
|
1646 |
+
array(
|
1647 |
+
'id' => 'login_align',
|
1648 |
+
'type' => 'select',
|
1649 |
+
'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
|
1650 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1651 |
+
'default' => um_get_metadefault( 'login_align' ),
|
1652 |
+
'options' => array(
|
1653 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1654 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1655 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1656 |
+
),
|
1657 |
+
'size' => 'small',
|
1658 |
+
),
|
1659 |
+
array(
|
1660 |
+
'id' => 'login_icons',
|
1661 |
+
'type' => 'select',
|
1662 |
+
'label' => __( 'Login Field Icons', 'ultimate-member' ),
|
1663 |
+
'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
|
1664 |
+
'default' => um_get_metadefault( 'login_icons' ),
|
1665 |
+
'options' => array(
|
1666 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1667 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1668 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1669 |
+
),
|
1670 |
+
'size' => 'small',
|
1671 |
+
),
|
1672 |
+
array(
|
1673 |
+
'id' => 'login_primary_btn_word',
|
1674 |
+
'type' => 'text',
|
1675 |
+
'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
|
1676 |
+
'default' => um_get_metadefault( 'login_primary_btn_word' ),
|
1677 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1678 |
+
'size' => 'medium',
|
1679 |
+
),
|
1680 |
+
array(
|
1681 |
+
'id' => 'login_secondary_btn',
|
1682 |
+
'type' => 'checkbox',
|
1683 |
+
'label' => __( 'Login Secondary Button', 'ultimate-member' ),
|
1684 |
+
'default' => 1,
|
1685 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1686 |
+
),
|
1687 |
+
array(
|
1688 |
+
'id' => 'login_secondary_btn_word',
|
1689 |
+
'type' => 'text',
|
1690 |
+
'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
|
1691 |
+
'default' => um_get_metadefault( 'login_secondary_btn_word' ),
|
1692 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1693 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1694 |
+
'size' => 'medium',
|
1695 |
+
),
|
1696 |
+
array(
|
1697 |
+
'id' => 'login_secondary_btn_url',
|
1698 |
+
'type' => 'text',
|
1699 |
+
'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
|
1700 |
+
'default' => um_get_metadefault( 'login_secondary_btn_url' ),
|
1701 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1702 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1703 |
+
'size' => 'medium',
|
1704 |
+
),
|
1705 |
+
array(
|
1706 |
+
'id' => 'login_forgot_pass_link',
|
1707 |
+
'type' => 'checkbox',
|
1708 |
+
'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
|
1709 |
+
'default' => 1,
|
1710 |
+
'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
|
1711 |
+
),
|
1712 |
+
array(
|
1713 |
+
'id' => 'login_show_rememberme',
|
1714 |
+
'type' => 'checkbox',
|
1715 |
+
'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
|
1716 |
+
'default' => 1,
|
1717 |
+
'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ),
|
1718 |
+
),
|
1719 |
+
),
|
1720 |
+
),
|
1721 |
+
),
|
1722 |
+
),
|
1723 |
+
'extensions' => array(
|
1724 |
+
'title' => __( 'Extensions', 'ultimate-member' ),
|
1725 |
+
),
|
1726 |
+
'licenses' => array(
|
1727 |
+
'title' => __( 'Licenses', 'ultimate-member' ),
|
1728 |
+
),
|
1729 |
+
'misc' => array(
|
1730 |
+
'title' => __( 'Misc', 'ultimate-member' ),
|
1731 |
+
'fields' => array(
|
1732 |
+
array(
|
1733 |
+
'id' => 'form_asterisk',
|
1734 |
+
'type' => 'checkbox',
|
1735 |
+
'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
|
1736 |
+
),
|
1737 |
+
array(
|
1738 |
+
'id' => 'profile_title',
|
1739 |
+
'type' => 'text',
|
1740 |
+
'label' => __( 'User Profile Title', 'ultimate-member' ),
|
1741 |
+
'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
|
1742 |
+
'size' => 'medium',
|
1743 |
+
),
|
1744 |
+
array(
|
1745 |
+
'id' => 'profile_desc',
|
1746 |
+
'type' => 'textarea',
|
1747 |
+
'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
|
1748 |
+
'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
|
1749 |
+
'args' => array(
|
1750 |
+
'textarea_rows' => 6,
|
1751 |
+
),
|
1752 |
+
),
|
1753 |
+
array(
|
1754 |
+
'id' => 'um_profile_object_cache_stop',
|
1755 |
+
'type' => 'checkbox',
|
1756 |
+
'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
|
1757 |
+
'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
|
1758 |
+
),
|
1759 |
+
array(
|
1760 |
+
'id' => 'enable_blocks',
|
1761 |
+
'type' => 'checkbox',
|
1762 |
+
'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
|
1763 |
+
'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ),
|
1764 |
+
),
|
1765 |
+
array(
|
1766 |
+
'id' => 'rest_api_version',
|
1767 |
+
'type' => 'select',
|
1768 |
+
'label' => __( 'REST API version', 'ultimate-member' ),
|
1769 |
+
'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
|
1770 |
+
'options' => array(
|
1771 |
+
'1.0' => __( '1.0 version', 'ultimate-member' ),
|
1772 |
+
'2.0' => __( '2.0 version', 'ultimate-member' ),
|
1773 |
+
),
|
1774 |
+
),
|
1775 |
+
// backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
|
1776 |
+
// otherwise we filtering only results and restricted posts/terms can be visible
|
1777 |
+
array(
|
1778 |
+
'id' => 'disable_restriction_pre_queries',
|
1779 |
+
'type' => 'checkbox',
|
1780 |
+
'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
|
1781 |
+
'tooltip' => __( 'Please enable this option only in the cases when you have big or unnecessary queries on your site with active restriction logic. If you want to exclude posts only from the results queries instead of pre_get_posts and fully-hidden post logic also please enable this option. It activates the restriction content logic until 2.2.x version without latest security enhancements', 'ultimate-member' ),
|
1782 |
+
),
|
1783 |
+
$same_page_update,
|
1784 |
+
array(
|
1785 |
+
'id' => 'uninstall_on_delete',
|
1786 |
+
'type' => 'checkbox',
|
1787 |
+
'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
|
1788 |
+
'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ),
|
1789 |
+
),
|
1790 |
+
),
|
1791 |
+
),
|
1792 |
+
'install_info' => array(
|
1793 |
+
'title' => __( 'Install Info', 'ultimate-member' ),
|
1794 |
+
'fields' => array(
|
1795 |
+
array(
|
1796 |
+
'type' => 'install_info',
|
1797 |
+
),
|
1798 |
+
),
|
1799 |
+
),
|
1800 |
+
)
|
1801 |
+
);
|
1802 |
+
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
|
1806 |
+
/**
|
1807 |
+
* @param array $settings
|
1808 |
+
*
|
1809 |
+
* @return array
|
1810 |
+
*/
|
1811 |
+
public function sorting_licenses_options( $settings ) {
|
1812 |
+
//sorting licenses
|
1813 |
+
if ( ! empty( $settings['licenses']['fields'] ) ) {
|
1814 |
+
$licenses = $settings['licenses']['fields'];
|
1815 |
+
@uasort( $licenses, function( $a, $b ) {
|
1816 |
+
return strnatcasecmp( $a['label'], $b['label'] );
|
1817 |
+
} );
|
1818 |
+
$settings['licenses']['fields'] = $licenses;
|
1819 |
+
}
|
1820 |
+
|
1821 |
+
//sorting extensions by the title
|
1822 |
+
if ( ! empty( $settings['extensions']['sections'] ) ) {
|
1823 |
+
$extensions = $settings['extensions']['sections'];
|
1824 |
+
|
1825 |
+
@uasort( $extensions, function( $a, $b ) {
|
1826 |
+
return strnatcasecmp( $a['title'], $b['title'] );
|
1827 |
+
} );
|
1828 |
+
|
1829 |
+
$keys = array_keys( $extensions );
|
1830 |
+
$temp = array(
|
1831 |
+
'' => $extensions[ $keys[0] ],
|
1832 |
+
);
|
1833 |
+
|
1834 |
+
unset( $extensions[ $keys[0] ] );
|
1835 |
+
$extensions = $temp + $extensions;
|
1836 |
+
|
1837 |
+
$settings['extensions']['sections'] = $extensions;
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
return $settings;
|
1841 |
+
}
|
1842 |
+
|
1843 |
+
|
1844 |
+
/**
|
1845 |
+
* @param $tab
|
1846 |
+
* @param $section
|
1847 |
+
*
|
1848 |
+
* @return array
|
1849 |
+
*/
|
1850 |
+
function get_section_fields( $tab, $section ) {
|
1851 |
+
|
1852 |
+
if ( empty( $this->settings_structure[ $tab ] ) ) {
|
1853 |
+
return array();
|
1854 |
+
}
|
1855 |
+
|
1856 |
+
if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
1857 |
+
return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
1858 |
+
} elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
|
1859 |
+
return $this->settings_structure[ $tab ]['fields'];
|
1860 |
+
}
|
1861 |
+
|
1862 |
+
return array();
|
1863 |
+
}
|
1864 |
+
|
1865 |
+
|
1866 |
+
/**
|
1867 |
+
* Setup admin menu
|
1868 |
+
*/
|
1869 |
+
function primary_admin_menu() {
|
1870 |
+
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
|
1871 |
+
}
|
1872 |
+
|
1873 |
+
|
1874 |
+
/**
|
1875 |
+
* Settings page callback
|
1876 |
+
*/
|
1877 |
+
function settings_page() {
|
1878 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
1879 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
1880 |
+
|
1881 |
+
$settings_struct = $this->settings_structure[ $current_tab ];
|
1882 |
+
|
1883 |
+
//remove not option hidden fields
|
1884 |
+
if ( ! empty( $settings_struct['fields'] ) ) {
|
1885 |
+
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
|
1886 |
+
|
1887 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
1888 |
+
unset( $settings_struct['fields'][ $field_key ] );
|
1889 |
+
}
|
1890 |
+
|
1891 |
+
}
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
|
1895 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
|
1896 |
+
}
|
1897 |
+
|
1898 |
+
if ( ! empty( $settings_struct['sections'] ) ) {
|
1899 |
+
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
|
1900 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
|
1901 |
+
}
|
1902 |
+
}
|
1903 |
+
|
1904 |
+
echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
|
1905 |
+
|
1906 |
+
echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
|
1907 |
+
|
1908 |
+
/**
|
1909 |
+
* UM hook
|
1910 |
+
*
|
1911 |
+
* @type action
|
1912 |
+
* @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
|
1913 |
+
* @description Show some content before settings page content
|
1914 |
+
* @change_log
|
1915 |
+
* ["Since: 2.0"]
|
1916 |
+
* @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
|
1917 |
+
* @example
|
1918 |
+
* <?php
|
1919 |
+
* add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
|
1920 |
+
* function my_settings_page_before() {
|
1921 |
+
* // your code here
|
1922 |
+
* }
|
1923 |
+
* ?>
|
1924 |
+
*/
|
1925 |
+
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
1926 |
+
|
1927 |
+
if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) {
|
1928 |
+
|
1929 |
+
/**
|
1930 |
+
* UM hook
|
1931 |
+
*
|
1932 |
+
* @type action
|
1933 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1934 |
+
* @description Show some content before section content at settings page
|
1935 |
+
* @change_log
|
1936 |
+
* ["Since: 2.0"]
|
1937 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1938 |
+
* @example
|
1939 |
+
* <?php
|
1940 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1941 |
+
* function my_settings_page_before_section() {
|
1942 |
+
* // your code here
|
1943 |
+
* }
|
1944 |
+
* ?>
|
1945 |
+
*/
|
1946 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
1947 |
+
|
1948 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
1949 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
1950 |
+
|
1951 |
+
/**
|
1952 |
+
* UM hook
|
1953 |
+
*
|
1954 |
+
* @type filter
|
1955 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
1956 |
+
*
|
1957 |
+
* @description Render settings section
|
1958 |
+
* @input_vars
|
1959 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
1960 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
1961 |
+
* @change_log
|
1962 |
+
* ["Since: 2.0"]
|
1963 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
1964 |
+
* @example
|
1965 |
+
* <?php
|
1966 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
1967 |
+
* function my_settings_section( $content ) {
|
1968 |
+
* // your code here
|
1969 |
+
* return $content;
|
1970 |
+
* }
|
1971 |
+
* ?>
|
1972 |
+
*/
|
1973 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
1974 |
+
$settings_section,
|
1975 |
+
$section_fields
|
1976 |
+
);
|
1977 |
+
|
1978 |
+
} else { ?>
|
1979 |
+
|
1980 |
+
<form method="post" action="" name="um-settings-form" id="um-settings-form">
|
1981 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
1982 |
+
|
1983 |
+
<?php
|
1984 |
+
/**
|
1985 |
+
* UM hook
|
1986 |
+
*
|
1987 |
+
* @type action
|
1988 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1989 |
+
* @description Show some content before section content at settings page
|
1990 |
+
* @change_log
|
1991 |
+
* ["Since: 2.0"]
|
1992 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1993 |
+
* @example
|
1994 |
+
* <?php
|
1995 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1996 |
+
* function my_settings_page_before_section() {
|
1997 |
+
* // your code here
|
1998 |
+
* }
|
1999 |
+
* ?>
|
2000 |
+
*/
|
2001 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
2002 |
+
|
2003 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
2004 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
2005 |
+
|
2006 |
+
/**
|
2007 |
+
* UM hook
|
2008 |
+
*
|
2009 |
+
* @type filter
|
2010 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
2011 |
+
* @description Render settings section
|
2012 |
+
* @input_vars
|
2013 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
2014 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
2015 |
+
* @change_log
|
2016 |
+
* ["Since: 2.0"]
|
2017 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
2018 |
+
* @example
|
2019 |
+
* <?php
|
2020 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
2021 |
+
* function my_settings_section( $content ) {
|
2022 |
+
* // your code here
|
2023 |
+
* return $content;
|
2024 |
+
* }
|
2025 |
+
* ?>
|
2026 |
+
*/
|
2027 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
2028 |
+
$settings_section,
|
2029 |
+
$section_fields
|
2030 |
+
); ?>
|
2031 |
+
|
2032 |
+
|
2033 |
+
<p class="submit">
|
2034 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
|
2035 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2036 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2037 |
+
</p>
|
2038 |
+
</form>
|
2039 |
+
|
2040 |
+
<?php }
|
2041 |
+
}
|
2042 |
+
|
2043 |
+
|
2044 |
+
/**
|
2045 |
+
* Generate pages tabs
|
2046 |
+
*
|
2047 |
+
* @param string $page
|
2048 |
+
* @return string
|
2049 |
+
*/
|
2050 |
+
function generate_tabs_menu( $page = 'settings' ) {
|
2051 |
+
|
2052 |
+
$tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
|
2053 |
+
|
2054 |
+
switch( $page ) {
|
2055 |
+
case 'settings':
|
2056 |
+
$menu_tabs = array();
|
2057 |
+
foreach ( $this->settings_structure as $slug => $tab ) {
|
2058 |
+
if ( ! empty( $tab['fields'] ) ) {
|
2059 |
+
foreach ( $tab['fields'] as $field_key => $field_options ) {
|
2060 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
2061 |
+
unset( $tab['fields'][ $field_key ] );
|
2062 |
+
}
|
2063 |
+
}
|
2064 |
+
}
|
2065 |
+
|
2066 |
+
if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
|
2067 |
+
$menu_tabs[ $slug ] = $tab['title'];
|
2068 |
+
}
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2072 |
+
foreach ( $menu_tabs as $name => $label ) {
|
2073 |
+
$active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
|
2074 |
+
$tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
|
2075 |
+
$label .
|
2076 |
+
'</a>';
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
break;
|
2080 |
+
default:
|
2081 |
+
/**
|
2082 |
+
* UM hook
|
2083 |
+
*
|
2084 |
+
* @type filter
|
2085 |
+
* @title um_generate_tabs_menu_{$page}
|
2086 |
+
* @description Generate tabs menu
|
2087 |
+
* @input_vars
|
2088 |
+
* [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
|
2089 |
+
* @change_log
|
2090 |
+
* ["Since: 2.0"]
|
2091 |
+
* @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
|
2092 |
+
* @example
|
2093 |
+
* <?php
|
2094 |
+
* add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
|
2095 |
+
* function my_tabs_menu( $tabs ) {
|
2096 |
+
* // your code here
|
2097 |
+
* return $tabs;
|
2098 |
+
* }
|
2099 |
+
* ?>
|
2100 |
+
*/
|
2101 |
+
$tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
|
2102 |
+
break;
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
return $tabs . '</h2>';
|
2106 |
+
}
|
2107 |
+
|
2108 |
+
|
2109 |
+
/**
|
2110 |
+
* @param string $tab
|
2111 |
+
*
|
2112 |
+
* @return string
|
2113 |
+
*/
|
2114 |
+
function generate_subtabs_menu( $tab = '' ) {
|
2115 |
+
if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
|
2116 |
+
return '';
|
2117 |
+
}
|
2118 |
+
|
2119 |
+
$menu_subtabs = array();
|
2120 |
+
foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
|
2121 |
+
$menu_subtabs[ $slug ] = $subtab['title'];
|
2122 |
+
}
|
2123 |
+
|
2124 |
+
$subtabs = '<div><ul class="subsubsub">';
|
2125 |
+
|
2126 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2127 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
2128 |
+
foreach ( $menu_subtabs as $name => $label ) {
|
2129 |
+
$active = ( $current_subtab == $name ) ? 'current' : '';
|
2130 |
+
$subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '§ion=' . $name ) ) ) . '" class="' . $active . '">'
|
2131 |
+
. $label .
|
2132 |
+
'</a> | ';
|
2133 |
+
}
|
2134 |
+
|
2135 |
+
return substr( $subtabs, 0, -3 ) . '</ul></div>';
|
2136 |
+
}
|
2137 |
+
|
2138 |
+
|
2139 |
+
/**
|
2140 |
+
* Handler for settings forms
|
2141 |
+
* when "Save Settings" button click
|
2142 |
+
*
|
2143 |
+
*/
|
2144 |
+
function save_settings_handler() {
|
2145 |
+
|
2146 |
+
if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
|
2147 |
+
|
2148 |
+
$nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
|
2149 |
+
|
2150 |
+
if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
|
2151 |
+
// This nonce is not valid.
|
2152 |
+
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
/**
|
2156 |
+
* UM hook
|
2157 |
+
*
|
2158 |
+
* @type action
|
2159 |
+
* @title um_settings_before_save
|
2160 |
+
* @description Before settings save action
|
2161 |
+
* @change_log
|
2162 |
+
* ["Since: 2.0"]
|
2163 |
+
* @usage add_action( 'um_settings_before_save', 'function_name', 10 );
|
2164 |
+
* @example
|
2165 |
+
* <?php
|
2166 |
+
* add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
|
2167 |
+
* function my_settings_before_save() {
|
2168 |
+
* // your code here
|
2169 |
+
* }
|
2170 |
+
* ?>
|
2171 |
+
*/
|
2172 |
+
do_action( "um_settings_before_save" );
|
2173 |
+
|
2174 |
+
/**
|
2175 |
+
* UM hook
|
2176 |
+
*
|
2177 |
+
* @type filter
|
2178 |
+
* @title um_change_settings_before_save
|
2179 |
+
* @description Change settings before save
|
2180 |
+
* @input_vars
|
2181 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
|
2182 |
+
* @change_log
|
2183 |
+
* ["Since: 2.0"]
|
2184 |
+
* @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
|
2185 |
+
* @example
|
2186 |
+
* <?php
|
2187 |
+
* add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
|
2188 |
+
* function my_change_settings_before_save( $settings ) {
|
2189 |
+
* // your code here
|
2190 |
+
* return $settings;
|
2191 |
+
* }
|
2192 |
+
* ?>
|
2193 |
+
*/
|
2194 |
+
$settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
|
2195 |
+
|
2196 |
+
$settings = UM()->admin()->sanitize_options( $settings );
|
2197 |
+
|
2198 |
+
foreach ( $settings as $key => $value ) {
|
2199 |
+
UM()->options()->update( $key, $value );
|
2200 |
+
}
|
2201 |
+
|
2202 |
+
/**
|
2203 |
+
* UM hook
|
2204 |
+
*
|
2205 |
+
* @type action
|
2206 |
+
* @title um_settings_save
|
2207 |
+
* @description After settings save action
|
2208 |
+
* @change_log
|
2209 |
+
* ["Since: 2.0"]
|
2210 |
+
* @usage add_action( 'um_settings_save', 'function_name', 10 );
|
2211 |
+
* @example
|
2212 |
+
* <?php
|
2213 |
+
* add_action( 'um_settings_save', 'my_settings_save', 10 );
|
2214 |
+
* function my_settings_save() {
|
2215 |
+
* // your code here
|
2216 |
+
* }
|
2217 |
+
* ?>
|
2218 |
+
*/
|
2219 |
+
do_action( 'um_settings_save' );
|
2220 |
+
|
2221 |
+
//redirect after save settings
|
2222 |
+
$arg = array(
|
2223 |
+
'page' => 'um_options',
|
2224 |
+
'update' => 'settings_updated',
|
2225 |
+
);
|
2226 |
+
|
2227 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2228 |
+
$arg['tab'] = sanitize_key( $_GET['tab'] );
|
2229 |
+
}
|
2230 |
+
|
2231 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2232 |
+
$arg['section'] = sanitize_key( $_GET['section'] );
|
2233 |
+
}
|
2234 |
+
|
2235 |
+
um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
|
2236 |
+
}
|
2237 |
+
}
|
2238 |
+
|
2239 |
+
|
2240 |
+
function set_default_if_empty( $settings ) {
|
2241 |
+
$tab = '';
|
2242 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2243 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2244 |
+
}
|
2245 |
+
|
2246 |
+
$section = '';
|
2247 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2248 |
+
$section = sanitize_key( $_GET['section'] );
|
2249 |
+
}
|
2250 |
+
|
2251 |
+
|
2252 |
+
if ( 'access' === $tab && empty( $section ) ) {
|
2253 |
+
if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
|
2254 |
+
$settings['access_exclude_uris'] = array();
|
2255 |
+
}
|
2256 |
+
}
|
2257 |
+
|
2258 |
+
return $settings;
|
2259 |
+
}
|
2260 |
+
|
2261 |
+
|
2262 |
+
/**
|
2263 |
+
* Remove empty values from multi text fields
|
2264 |
+
*
|
2265 |
+
* @param $settings
|
2266 |
+
* @return array
|
2267 |
+
*/
|
2268 |
+
function remove_empty_values( $settings ) {
|
2269 |
+
$tab = '';
|
2270 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2271 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2272 |
+
}
|
2273 |
+
|
2274 |
+
$section = '';
|
2275 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2276 |
+
$section = sanitize_key( $_GET['section'] );
|
2277 |
+
}
|
2278 |
+
|
2279 |
+
if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
2280 |
+
$fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
2281 |
+
} else {
|
2282 |
+
$fields = $this->settings_structure[ $tab ]['fields'];
|
2283 |
+
}
|
2284 |
+
|
2285 |
+
if ( empty( $fields ) ) {
|
2286 |
+
return $settings;
|
2287 |
+
}
|
2288 |
+
|
2289 |
+
|
2290 |
+
$filtered_settings = array();
|
2291 |
+
foreach ( $settings as $key => $value ) {
|
2292 |
+
|
2293 |
+
$filtered_settings[ $key ] = $value;
|
2294 |
+
|
2295 |
+
foreach ( $fields as $field ) {
|
2296 |
+
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
|
2297 |
+
$filtered_settings[ $key ] = array_filter( $settings[ $key ] );
|
2298 |
+
}
|
2299 |
+
}
|
2300 |
+
}
|
2301 |
+
|
2302 |
+
return $filtered_settings;
|
2303 |
+
}
|
2304 |
+
|
2305 |
+
|
2306 |
+
/**
|
2307 |
+
*
|
2308 |
+
*/
|
2309 |
+
function check_permalinks_changes() {
|
2310 |
+
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2311 |
+
if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
|
2312 |
+
$this->need_change_permalinks = true;
|
2313 |
+
}
|
2314 |
+
}
|
2315 |
+
|
2316 |
+
// set variable if gravatar settings were changed
|
2317 |
+
// update for um_member_directory_data metakey
|
2318 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2319 |
+
$use_gravatar = UM()->options()->get( 'use_gravatars' );
|
2320 |
+
if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
|
2321 |
+
$this->gravatar_changed = true;
|
2322 |
+
}
|
2323 |
+
}
|
2324 |
+
}
|
2325 |
+
|
2326 |
+
|
2327 |
+
/**
|
2328 |
+
*
|
2329 |
+
*/
|
2330 |
+
function on_settings_save() {
|
2331 |
+
if ( ! empty( $_POST['um_options'] ) ) {
|
2332 |
+
|
2333 |
+
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
2334 |
+
$post_ids = new \WP_Query( array(
|
2335 |
+
'post_type' => 'page',
|
2336 |
+
'meta_query' => array(
|
2337 |
+
array(
|
2338 |
+
'key' => '_um_core',
|
2339 |
+
'compare' => 'EXISTS'
|
2340 |
+
)
|
2341 |
+
),
|
2342 |
+
'posts_per_page' => -1,
|
2343 |
+
'fields' => 'ids'
|
2344 |
+
) );
|
2345 |
+
|
2346 |
+
$post_ids = $post_ids->get_posts();
|
2347 |
+
|
2348 |
+
if ( ! empty( $post_ids ) ) {
|
2349 |
+
foreach ( $post_ids as $post_id ) {
|
2350 |
+
delete_post_meta( $post_id, '_um_core' );
|
2351 |
+
}
|
2352 |
+
}
|
2353 |
+
|
2354 |
+
foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
|
2355 |
+
$slug = str_replace( 'core_', '', $option_slug );
|
2356 |
+
update_post_meta( $post_id, '_um_core', $slug );
|
2357 |
+
}
|
2358 |
+
|
2359 |
+
// reset rewrite rules after re-save pages
|
2360 |
+
UM()->rewrite()->reset_rules();
|
2361 |
+
|
2362 |
+
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2363 |
+
if ( ! empty( $this->need_change_permalinks ) ) {
|
2364 |
+
$users = get_users( array(
|
2365 |
+
'fields' => 'ids',
|
2366 |
+
) );
|
2367 |
+
if ( ! empty( $users ) ) {
|
2368 |
+
foreach ( $users as $user_id ) {
|
2369 |
+
UM()->user()->generate_profile_slug( $user_id );
|
2370 |
+
}
|
2371 |
+
}
|
2372 |
+
}
|
2373 |
+
|
2374 |
+
|
2375 |
+
// update for um_member_directory_data metakey
|
2376 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2377 |
+
if ( $this->gravatar_changed ) {
|
2378 |
+
global $wpdb;
|
2379 |
+
|
2380 |
+
if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
|
2381 |
+
|
2382 |
+
$results = $wpdb->get_col(
|
2383 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2384 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
|
2385 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2386 |
+
WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
|
2387 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
|
2388 |
+
);
|
2389 |
+
|
2390 |
+
} else {
|
2391 |
+
|
2392 |
+
$results = $wpdb->get_col(
|
2393 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2394 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
|
2395 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2396 |
+
WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
|
2397 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
|
2398 |
+
);
|
2399 |
+
|
2400 |
+
}
|
2401 |
+
|
2402 |
+
if ( ! empty( $results ) ) {
|
2403 |
+
foreach ( $results as $user_id ) {
|
2404 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2405 |
+
if ( ! empty( $md_data ) ) {
|
2406 |
+
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
2407 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2408 |
+
}
|
2409 |
+
}
|
2410 |
+
}
|
2411 |
+
}
|
2412 |
+
}
|
2413 |
+
|
2414 |
+
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2415 |
+
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2416 |
+
global $wpdb;
|
2417 |
+
|
2418 |
+
$results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
|
2419 |
+
|
2420 |
+
if ( ! empty( $results ) ) {
|
2421 |
+
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
|
2422 |
+
}
|
2423 |
+
|
2424 |
+
update_option( 'um_member_directory_truncated', time() );
|
2425 |
+
}
|
2426 |
+
} elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
|
2427 |
+
|
2428 |
+
global $wpdb;
|
2429 |
+
|
2430 |
+
if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
|
2431 |
+
|
2432 |
+
$results = $wpdb->get_col(
|
2433 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2434 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2435 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2436 |
+
WHERE um.meta_value IS NULL AND
|
2437 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
|
2438 |
+
);
|
2439 |
+
|
2440 |
+
} else {
|
2441 |
+
|
2442 |
+
$results = $wpdb->get_col(
|
2443 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2444 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2445 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2446 |
+
WHERE um.meta_value IS NULL AND
|
2447 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
|
2448 |
+
);
|
2449 |
+
|
2450 |
+
}
|
2451 |
+
|
2452 |
+
if ( ! empty( $results ) ) {
|
2453 |
+
foreach ( $results as $user_id ) {
|
2454 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2455 |
+
if ( ! empty( $md_data ) ) {
|
2456 |
+
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
2457 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2458 |
+
}
|
2459 |
+
}
|
2460 |
+
}
|
2461 |
+
|
2462 |
+
}
|
2463 |
+
}
|
2464 |
+
}
|
2465 |
+
|
2466 |
+
|
2467 |
+
/**
|
2468 |
+
*
|
2469 |
+
*/
|
2470 |
+
function before_licenses_save() {
|
2471 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2472 |
+
return;
|
2473 |
+
}
|
2474 |
+
|
2475 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2476 |
+
$this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
|
2477 |
+
}
|
2478 |
+
}
|
2479 |
+
|
2480 |
+
|
2481 |
+
/**
|
2482 |
+
*
|
2483 |
+
*/
|
2484 |
+
function licenses_save() {
|
2485 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2486 |
+
return;
|
2487 |
+
}
|
2488 |
+
|
2489 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2490 |
+
$key = sanitize_key( $key );
|
2491 |
+
$value = sanitize_text_field( $value );
|
2492 |
+
|
2493 |
+
$edd_action = '';
|
2494 |
+
$license_key = '';
|
2495 |
+
if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
|
2496 |
+
$edd_action = 'activate_license';
|
2497 |
+
$license_key = $value;
|
2498 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
|
2499 |
+
$edd_action = 'deactivate_license';
|
2500 |
+
$license_key = $this->previous_licenses[ $key ];
|
2501 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
|
2502 |
+
$edd_action = 'check_license';
|
2503 |
+
$license_key = $value;
|
2504 |
+
}
|
2505 |
+
|
2506 |
+
if ( empty( $edd_action ) ) {
|
2507 |
+
continue;
|
2508 |
+
}
|
2509 |
+
|
2510 |
+
$item_name = false;
|
2511 |
+
$version = false;
|
2512 |
+
$author = false;
|
2513 |
+
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
2514 |
+
if ( $field_data['id'] == $key ) {
|
2515 |
+
$item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
|
2516 |
+
$version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
|
2517 |
+
$author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
|
2518 |
+
}
|
2519 |
+
}
|
2520 |
+
|
2521 |
+
$api_params = array(
|
2522 |
+
'edd_action' => $edd_action,
|
2523 |
+
'license' => $license_key,
|
2524 |
+
'item_name' => $item_name,
|
2525 |
+
'version' => $version,
|
2526 |
+
'author' => $author,
|
2527 |
+
'url' => home_url(),
|
2528 |
+
);
|
2529 |
+
|
2530 |
+
$request = wp_remote_post(
|
2531 |
+
UM()->store_url,
|
2532 |
+
array(
|
2533 |
+
'timeout' => UM()->request_timeout,
|
2534 |
+
'sslverify' => false,
|
2535 |
+
'body' => $api_params
|
2536 |
+
)
|
2537 |
+
);
|
2538 |
+
|
2539 |
+
if ( ! is_wp_error( $request ) ) {
|
2540 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2541 |
+
} else {
|
2542 |
+
$request = wp_remote_post(
|
2543 |
+
UM()->store_url,
|
2544 |
+
array(
|
2545 |
+
'timeout' => UM()->request_timeout,
|
2546 |
+
'sslverify' => true,
|
2547 |
+
'body' => $api_params
|
2548 |
+
)
|
2549 |
+
);
|
2550 |
+
|
2551 |
+
if ( ! is_wp_error( $request ) ) {
|
2552 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2553 |
+
}
|
2554 |
+
}
|
2555 |
+
|
2556 |
+
$request = ( $request ) ? maybe_unserialize( $request ) : false;
|
2557 |
+
|
2558 |
+
if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
|
2559 |
+
update_option( "{$key}_edd_answer", $request );
|
2560 |
+
} else {
|
2561 |
+
delete_option( "{$key}_edd_answer" );
|
2562 |
+
}
|
2563 |
+
|
2564 |
+
}
|
2565 |
+
}
|
2566 |
+
|
2567 |
+
|
2568 |
+
/**
|
2569 |
+
*
|
2570 |
+
*/
|
2571 |
+
function settings_before_email_tab() {
|
2572 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2573 |
+
$emails = UM()->config()->email_notifications;
|
2574 |
+
|
2575 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2576 |
+
include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
|
2577 |
+
}
|
2578 |
+
}
|
2579 |
+
|
2580 |
+
|
2581 |
+
/**
|
2582 |
+
* @param $section
|
2583 |
+
*
|
2584 |
+
* @return string
|
2585 |
+
*/
|
2586 |
+
function settings_email_tab( $section ) {
|
2587 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2588 |
+
$emails = UM()->config()->email_notifications;
|
2589 |
+
|
2590 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2591 |
+
return $section;
|
2592 |
+
}
|
2593 |
+
|
2594 |
+
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
2595 |
+
|
2596 |
+
/**
|
2597 |
+
* UM hook
|
2598 |
+
*
|
2599 |
+
* @type filter
|
2600 |
+
* @title um_admin_settings_email_section_fields
|
2601 |
+
* @description Extend UM Email Settings
|
2602 |
+
* @input_vars
|
2603 |
+
* [{"var":"$settings","type":"array","desc":"UM Email Settings"},
|
2604 |
+
* {"var":"$email_key","type":"string","desc":"Email Key"}]
|
2605 |
+
* @change_log
|
2606 |
+
* ["Since: 2.0"]
|
2607 |
+
* @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
|
2608 |
+
* @example
|
2609 |
+
* <?php
|
2610 |
+
* add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
|
2611 |
+
* function my_admin_settings_email_section( $settings, $email_key ) {
|
2612 |
+
* // your code here
|
2613 |
+
* return $settings;
|
2614 |
+
* }
|
2615 |
+
* ?>
|
2616 |
+
*/
|
2617 |
+
$section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
|
2618 |
+
array(
|
2619 |
+
'id' => 'um_email_template',
|
2620 |
+
'type' => 'hidden',
|
2621 |
+
'value' => $email_key,
|
2622 |
+
),
|
2623 |
+
array(
|
2624 |
+
'id' => $email_key . '_on',
|
2625 |
+
'type' => 'checkbox',
|
2626 |
+
'label' => $emails[ $email_key ]['title'],
|
2627 |
+
'tooltip' => $emails[ $email_key ]['description'],
|
2628 |
+
),
|
2629 |
+
array(
|
2630 |
+
'id' => $email_key . '_sub',
|
2631 |
+
'type' => 'text',
|
2632 |
+
'label' => __( 'Subject Line', 'ultimate-member' ),
|
2633 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2634 |
+
'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
|
2635 |
+
),
|
2636 |
+
array(
|
2637 |
+
'id' => $email_key,
|
2638 |
+
'type' => 'email_template',
|
2639 |
+
'label' => __( 'Message Body', 'ultimate-member' ),
|
2640 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2641 |
+
'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
|
2642 |
+
'value' => UM()->mail()->get_email_template( $email_key ),
|
2643 |
+
'in_theme' => $in_theme
|
2644 |
+
),
|
2645 |
+
), $email_key );
|
2646 |
+
|
2647 |
+
return $this->render_settings_section( $section_fields, 'email', $email_key );
|
2648 |
+
}
|
2649 |
+
|
2650 |
+
|
2651 |
+
/**
|
2652 |
+
*
|
2653 |
+
*/
|
2654 |
+
function settings_appearance_profile_tab() {
|
2655 |
+
wp_enqueue_media();
|
2656 |
+
}
|
2657 |
+
|
2658 |
+
|
2659 |
+
/**
|
2660 |
+
* @param $html
|
2661 |
+
* @param $section_fields
|
2662 |
+
*
|
2663 |
+
* @return string
|
2664 |
+
*/
|
2665 |
+
function settings_licenses_tab( $html, $section_fields ) {
|
2666 |
+
ob_start(); ?>
|
2667 |
+
|
2668 |
+
<div class="wrap-licenses">
|
2669 |
+
<input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
|
2670 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2671 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2672 |
+
<table class="form-table um-settings-section">
|
2673 |
+
<tbody>
|
2674 |
+
<?php foreach ( $section_fields as $field_data ) {
|
2675 |
+
$option_value = UM()->options()->get( $field_data['id'] );
|
2676 |
+
$value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
|
2677 |
+
|
2678 |
+
$license = get_option( "{$field_data['id']}_edd_answer" );
|
2679 |
+
|
2680 |
+
if ( is_object( $license ) && ! empty( $value ) ) {
|
2681 |
+
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
2682 |
+
if ( empty( $license->success ) ) {
|
2683 |
+
|
2684 |
+
if ( ! empty( $license->error ) ) {
|
2685 |
+
switch ( $license->error ) {
|
2686 |
+
|
2687 |
+
case 'expired' :
|
2688 |
+
|
2689 |
+
$class = 'expired';
|
2690 |
+
$messages[] = sprintf(
|
2691 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2692 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2693 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2694 |
+
);
|
2695 |
+
|
2696 |
+
$license_status = 'license-' . $class . '-notice';
|
2697 |
+
|
2698 |
+
break;
|
2699 |
+
|
2700 |
+
case 'revoked' :
|
2701 |
+
|
2702 |
+
$class = 'error';
|
2703 |
+
$messages[] = sprintf(
|
2704 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2705 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2706 |
+
);
|
2707 |
+
|
2708 |
+
$license_status = 'license-' . $class . '-notice';
|
2709 |
+
|
2710 |
+
break;
|
2711 |
+
|
2712 |
+
case 'missing' :
|
2713 |
+
|
2714 |
+
$class = 'error';
|
2715 |
+
$messages[] = sprintf(
|
2716 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2717 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2718 |
+
);
|
2719 |
+
|
2720 |
+
$license_status = 'license-' . $class . '-notice';
|
2721 |
+
|
2722 |
+
break;
|
2723 |
+
|
2724 |
+
case 'invalid' :
|
2725 |
+
case 'site_inactive' :
|
2726 |
+
|
2727 |
+
$class = 'error';
|
2728 |
+
$messages[] = sprintf(
|
2729 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2730 |
+
$field_data['item_name'],
|
2731 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2732 |
+
);
|
2733 |
+
|
2734 |
+
$license_status = 'license-' . $class . '-notice';
|
2735 |
+
|
2736 |
+
break;
|
2737 |
+
|
2738 |
+
case 'item_name_mismatch' :
|
2739 |
+
|
2740 |
+
$class = 'error';
|
2741 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2742 |
+
|
2743 |
+
$license_status = 'license-' . $class . '-notice';
|
2744 |
+
|
2745 |
+
break;
|
2746 |
+
|
2747 |
+
case 'no_activations_left':
|
2748 |
+
|
2749 |
+
$class = 'error';
|
2750 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2751 |
+
|
2752 |
+
$license_status = 'license-' . $class . '-notice';
|
2753 |
+
|
2754 |
+
break;
|
2755 |
+
|
2756 |
+
case 'license_not_activable':
|
2757 |
+
|
2758 |
+
$class = 'error';
|
2759 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2760 |
+
|
2761 |
+
$license_status = 'license-' . $class . '-notice';
|
2762 |
+
break;
|
2763 |
+
|
2764 |
+
default :
|
2765 |
+
|
2766 |
+
$class = 'error';
|
2767 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2768 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2769 |
+
|
2770 |
+
$license_status = 'license-' . $class . '-notice';
|
2771 |
+
break;
|
2772 |
+
}
|
2773 |
+
} else {
|
2774 |
+
$class = 'error';
|
2775 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2776 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2777 |
+
|
2778 |
+
$license_status = 'license-' . $class . '-notice';
|
2779 |
+
}
|
2780 |
+
|
2781 |
+
} elseif ( ! empty( $license->errors ) ) {
|
2782 |
+
|
2783 |
+
$errors = array_keys( $license->errors );
|
2784 |
+
$errors_data = array_values( $license->errors );
|
2785 |
+
|
2786 |
+
$class = 'error';
|
2787 |
+
$error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
|
2788 |
+
$errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
|
2789 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s%s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, $errors_data, 'https://ultimatemember.com/support' );
|
2790 |
+
|
2791 |
+
$license_status = 'license-' . $class . '-notice';
|
2792 |
+
|
2793 |
+
} else {
|
2794 |
+
|
2795 |
+
switch( $license->license ) {
|
2796 |
+
|
2797 |
+
case 'expired' :
|
2798 |
+
|
2799 |
+
$class = 'expired';
|
2800 |
+
$messages[] = sprintf(
|
2801 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2802 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2803 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2804 |
+
);
|
2805 |
+
|
2806 |
+
$license_status = 'license-' . $class . '-notice';
|
2807 |
+
|
2808 |
+
break;
|
2809 |
+
|
2810 |
+
case 'revoked' :
|
2811 |
+
|
2812 |
+
$class = 'error';
|
2813 |
+
$messages[] = sprintf(
|
2814 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2815 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2816 |
+
);
|
2817 |
+
|
2818 |
+
$license_status = 'license-' . $class . '-notice';
|
2819 |
+
|
2820 |
+
break;
|
2821 |
+
|
2822 |
+
case 'missing' :
|
2823 |
+
|
2824 |
+
$class = 'error';
|
2825 |
+
$messages[] = sprintf(
|
2826 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2827 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2828 |
+
);
|
2829 |
+
|
2830 |
+
$license_status = 'license-' . $class . '-notice';
|
2831 |
+
|
2832 |
+
break;
|
2833 |
+
|
2834 |
+
case 'invalid' :
|
2835 |
+
case 'site_inactive' :
|
2836 |
+
|
2837 |
+
$class = 'error';
|
2838 |
+
$messages[] = sprintf(
|
2839 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2840 |
+
$field_data['item_name'],
|
2841 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2842 |
+
);
|
2843 |
+
|
2844 |
+
$license_status = 'license-' . $class . '-notice';
|
2845 |
+
|
2846 |
+
break;
|
2847 |
+
|
2848 |
+
case 'item_name_mismatch' :
|
2849 |
+
|
2850 |
+
$class = 'error';
|
2851 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2852 |
+
|
2853 |
+
$license_status = 'license-' . $class . '-notice';
|
2854 |
+
|
2855 |
+
break;
|
2856 |
+
|
2857 |
+
case 'no_activations_left':
|
2858 |
+
|
2859 |
+
$class = 'error';
|
2860 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2861 |
+
|
2862 |
+
$license_status = 'license-' . $class . '-notice';
|
2863 |
+
|
2864 |
+
break;
|
2865 |
+
|
2866 |
+
case 'license_not_activable':
|
2867 |
+
|
2868 |
+
$class = 'error';
|
2869 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2870 |
+
|
2871 |
+
$license_status = 'license-' . $class . '-notice';
|
2872 |
+
break;
|
2873 |
+
|
2874 |
+
case 'valid' :
|
2875 |
+
default:
|
2876 |
+
|
2877 |
+
$class = 'valid';
|
2878 |
+
|
2879 |
+
$now = current_time( 'timestamp' );
|
2880 |
+
$expiration = strtotime( $license->expires, $now );
|
2881 |
+
|
2882 |
+
if( 'lifetime' === $license->expires ) {
|
2883 |
+
|
2884 |
+
$messages[] = __( 'License key never expires.', 'ultimate-member' );
|
2885 |
+
|
2886 |
+
$license_status = 'license-lifetime-notice';
|
2887 |
+
|
2888 |
+
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
2889 |
+
|
2890 |
+
$messages[] = sprintf(
|
2891 |
+
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
|
2892 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2893 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
|
2894 |
+
);
|
2895 |
+
|
2896 |
+
$license_status = 'license-expires-soon-notice';
|
2897 |
+
|
2898 |
+
} else {
|
2899 |
+
|
2900 |
+
$messages[] = sprintf(
|
2901 |
+
__( 'Your license key expires on %s.', 'ultimate-member' ),
|
2902 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
2903 |
+
);
|
2904 |
+
|
2905 |
+
$license_status = 'license-expiration-date-notice';
|
2906 |
+
|
2907 |
+
}
|
2908 |
+
|
2909 |
+
break;
|
2910 |
+
|
2911 |
+
}
|
2912 |
+
|
2913 |
+
}
|
2914 |
+
|
2915 |
+
} else {
|
2916 |
+
$class = 'empty';
|
2917 |
+
|
2918 |
+
$messages[] = sprintf(
|
2919 |
+
__( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
|
2920 |
+
$field_data['item_name']
|
2921 |
+
);
|
2922 |
+
|
2923 |
+
$license_status = null;
|
2924 |
+
|
2925 |
+
} ?>
|
2926 |
+
|
2927 |
+
<tr class="um-settings-line">
|
2928 |
+
<th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
|
2929 |
+
<td>
|
2930 |
+
<form method="post" action="" name="um-settings-form" class="um-settings-form">
|
2931 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
2932 |
+
<input type="hidden" name="licenses_settings" value="1" />
|
2933 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2934 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2935 |
+
<input type="text" id="um_options_<?php echo esc_attr( $field_data['id'] ) ?>" name="um_options[<?php echo esc_attr( $field_data['id'] ) ?>]" value="<?php echo $value ?>" class="um-option-field um-long-field" data-field_id="<?php echo esc_attr( $field_data['id'] ) ?>" />
|
2936 |
+
<?php if ( ! empty( $field_data['description'] ) ) { ?>
|
2937 |
+
<div class="description"><?php echo $field_data['description'] ?></div>
|
2938 |
+
<?php } ?>
|
2939 |
+
|
2940 |
+
<?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
|
2941 |
+
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2942 |
+
<?php } elseif ( empty( $value ) ) { ?>
|
2943 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
|
2944 |
+
<?php } else { ?>
|
2945 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
|
2946 |
+
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2947 |
+
<?php }
|
2948 |
+
|
2949 |
+
if ( ! empty( $messages ) ) {
|
2950 |
+
foreach ( $messages as $message ) { ?>
|
2951 |
+
<div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
|
2952 |
+
<p><?php echo $message ?></p>
|
2953 |
+
</div>
|
2954 |
+
<?php }
|
2955 |
+
} ?>
|
2956 |
+
</form>
|
2957 |
+
</td>
|
2958 |
+
</tr>
|
2959 |
+
<?php } ?>
|
2960 |
+
</tbody>
|
2961 |
+
</table>
|
2962 |
+
</div>
|
2963 |
+
<?php $section = ob_get_clean();
|
2964 |
+
|
2965 |
+
return $section;
|
2966 |
+
}
|
2967 |
+
|
2968 |
+
|
2969 |
+
/**
|
2970 |
+
* @param $html
|
2971 |
+
* @param $section_fields
|
2972 |
+
*/
|
2973 |
+
function settings_install_info_tab( $html, $section_fields ) {
|
2974 |
+
global $wpdb;
|
2975 |
+
|
2976 |
+
if ( ! class_exists( '\Browser' ) )
|
2977 |
+
require_once um_path . 'includes/lib/browser.php';
|
2978 |
+
|
2979 |
+
// Detect browser
|
2980 |
+
$browser = new \Browser();
|
2981 |
+
|
2982 |
+
// Get theme info
|
2983 |
+
$theme_data = wp_get_theme();
|
2984 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
2985 |
+
|
2986 |
+
// Identify Hosting Provider
|
2987 |
+
$host = um_get_host();
|
2988 |
+
|
2989 |
+
um_fetch_user( get_current_user_id() );
|
2990 |
+
|
2991 |
+
if ( isset( $this->content ) ) {
|
2992 |
+
echo $this->content;
|
2993 |
+
} else { ?>
|
2994 |
+
|
2995 |
+
<h3>Install Info</h3>
|
2996 |
+
|
2997 |
+
<form action="" method="post" dir="ltr">
|
2998 |
+
<textarea style="width:70%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="install-info-textarea" name="um-install-info" title="<?php _e( 'To copy the Install info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'ultimate-member' ); ?>">
|
2999 |
+
### Begin Install Info ###
|
3000 |
+
|
3001 |
+
## Please include this information when posting support requests ##
|
3002 |
+
|
3003 |
+
<?php
|
3004 |
+
/**
|
3005 |
+
* UM hook
|
3006 |
+
*
|
3007 |
+
* @type action
|
3008 |
+
* @title um_install_info_before
|
3009 |
+
* @description Before install info settings
|
3010 |
+
* @change_log
|
3011 |
+
* ["Since: 2.0"]
|
3012 |
+
* @usage add_action( 'um_install_info_before', 'function_name', 10 );
|
3013 |
+
* @example
|
3014 |
+
* <?php
|
3015 |
+
* add_action( 'um_install_info_before', 'my_install_info_before', 10 );
|
3016 |
+
* function my_install_info_before() {
|
3017 |
+
* // your code here
|
3018 |
+
* }
|
3019 |
+
* ?>
|
3020 |
+
*/
|
3021 |
+
do_action( 'um_install_info_before' ); ?>
|
3022 |
+
|
3023 |
+
--- Site Info ---
|
3024 |
+
|
3025 |
+
Site URL: <?php echo site_url() . "\n"; ?>
|
3026 |
+
Home URL: <?php echo home_url() . "\n"; ?>
|
3027 |
+
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
3028 |
+
|
3029 |
+
--- Hosting Provider ---
|
3030 |
+
|
3031 |
+
<?php if( $host ) : ?>
|
3032 |
+
Host: <?php echo $host . "\n"; ?>
|
3033 |
+
<?php endif; ?>
|
3034 |
+
|
3035 |
+
--- User Browser ---
|
3036 |
+
|
3037 |
+
<?php echo $browser ; ?>
|
3038 |
+
|
3039 |
+
---- Current User Details --
|
3040 |
+
|
3041 |
+
<?php $user = wp_get_current_user(); ?>
|
3042 |
+
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
3043 |
+
|
3044 |
+
|
3045 |
+
--- WordPress Configurations ---
|
3046 |
+
|
3047 |
+
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
3048 |
+
Language: <?php echo get_locale()."\n"; ?>
|
3049 |
+
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
3050 |
+
Active Theme: <?php echo $theme . "\n"; ?>
|
3051 |
+
<?php $show_on_front = get_option( 'show_on_front' ); ?>
|
3052 |
+
<?php if( $show_on_front == "posts" ): ?>
|
3053 |
+
Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
|
3054 |
+
<?php elseif( $show_on_front == "page" ): ?>
|
3055 |
+
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3056 |
+
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3057 |
+
<?php endif; ?>
|
3058 |
+
ABSPATH: <?php echo ABSPATH."\n"; ?>
|
3059 |
+
<?php $wp_count_posts = wp_count_posts(); ?>
|
3060 |
+
All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
|
3061 |
+
<?php
|
3062 |
+
$request['cmd'] = '_notify-validate';
|
3063 |
+
|
3064 |
+
$params = array(
|
3065 |
+
'sslverify' => false,
|
3066 |
+
'timeout' => 60,
|
3067 |
+
'user-agent' => 'UltimateMember/' . ultimatemember_version,
|
3068 |
+
'body' => $request
|
3069 |
+
);
|
3070 |
+
|
3071 |
+
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
3072 |
+
|
3073 |
+
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
3074 |
+
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
|
3075 |
+
} else {
|
3076 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
|
3077 |
+
}
|
3078 |
+
?>
|
3079 |
+
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
|
3080 |
+
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
3081 |
+
WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
|
3082 |
+
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
3083 |
+
|
3084 |
+
|
3085 |
+
--- UM Configurations ---
|
3086 |
+
|
3087 |
+
Version: <?php echo ultimatemember_version . "\n"; ?>
|
3088 |
+
Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
|
3089 |
+
Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
|
3090 |
+
Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3091 |
+
Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3092 |
+
Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3093 |
+
JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3094 |
+
<?php if( is_multisite() ): ?>
|
3095 |
+
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
3096 |
+
<?php endif; ?>
|
3097 |
+
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3098 |
+
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3099 |
+
|
3100 |
+
|
3101 |
+
--- UM Pages Configuration ---
|
3102 |
+
|
3103 |
+
<?php
|
3104 |
+
/**
|
3105 |
+
* UM hook
|
3106 |
+
*
|
3107 |
+
* @type action
|
3108 |
+
* @title um_install_info_before_page_config
|
3109 |
+
* @description Before page config install info
|
3110 |
+
* @change_log
|
3111 |
+
* ["Since: 2.0"]
|
3112 |
+
* @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
|
3113 |
+
* @example
|
3114 |
+
* <?php
|
3115 |
+
* add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
|
3116 |
+
* function my_install_info_before_page_config() {
|
3117 |
+
* // your code here
|
3118 |
+
* }
|
3119 |
+
* ?>
|
3120 |
+
*/
|
3121 |
+
do_action( "um_install_info_before_page_config" ); ?>
|
3122 |
+
User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
|
3123 |
+
Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
|
3124 |
+
Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
|
3125 |
+
Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
|
3126 |
+
Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
|
3127 |
+
Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
|
3128 |
+
Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
|
3129 |
+
<?php
|
3130 |
+
/**
|
3131 |
+
* UM hook
|
3132 |
+
*
|
3133 |
+
* @type action
|
3134 |
+
* @title um_install_info_after_page_config
|
3135 |
+
* @description After page config install info
|
3136 |
+
* @change_log
|
3137 |
+
* ["Since: 2.0"]
|
3138 |
+
* @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
|
3139 |
+
* @example
|
3140 |
+
* <?php
|
3141 |
+
* add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
|
3142 |
+
* function my_install_info_after_page_config() {
|
3143 |
+
* // your code here
|
3144 |
+
* }
|
3145 |
+
* ?>
|
3146 |
+
*/
|
3147 |
+
do_action( "um_install_info_after_page_config" ); ?>
|
3148 |
+
|
3149 |
+
|
3150 |
+
--- UM Users Configuration ---
|
3151 |
+
|
3152 |
+
Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
|
3153 |
+
Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
|
3154 |
+
User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
|
3155 |
+
Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
|
3156 |
+
Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
|
3157 |
+
Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
|
3158 |
+
Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
|
3159 |
+
<?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
|
3160 |
+
UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
|
3161 |
+
Require a strong password: <?php echo $this->info_value( UM()->options()->get('require_strongpass'), 'onoff', true ); ?>
|
3162 |
+
|
3163 |
+
|
3164 |
+
--- UM Access Configuration ---
|
3165 |
+
|
3166 |
+
Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
|
3167 |
+
Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
|
3168 |
+
<?php if( UM()->options()->get('accessible') == 2 ) { ?>
|
3169 |
+
Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
|
3170 |
+
Exclude the following URLs:<?php echo "\t\t\t\t".implode("\t\n\t\t\t\t\t\t\t\t\t\t",UM()->options()->get('access_exclude_uris') )."\n";?>
|
3171 |
+
<?php } ?>
|
3172 |
+
Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
|
3173 |
+
<?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
|
3174 |
+
Redirect to alternative login page: <?php if( UM()->options()->get('wpadmin_login_redirect') == 'um_login_page' ){ echo um_get_core_page('login')."\n"; }else{ echo UM()->options()->get('wpadmin_login_redirect_url')."\n"; }?>
|
3175 |
+
<?php } ?>
|
3176 |
+
Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
|
3177 |
+
<?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
|
3178 |
+
Redirect to alternative register page: <?php if( UM()->options()->get('wpadmin_register_redirect') == 'um_register_page' ){ echo um_get_core_page('register')."\n"; }else{ echo UM()->options()->get('wpadmin_register_redirect_url')."\n"; }?>
|
3179 |
+
<?php } ?>
|
3180 |
+
Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
|
3181 |
+
Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
|
3182 |
+
<?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
|
3183 |
+
Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
|
3184 |
+
Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
|
3185 |
+
<?php } ?>
|
3186 |
+
<?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
|
3187 |
+
Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
|
3188 |
+
<?php } ?>
|
3189 |
+
<?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
|
3190 |
+
Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
|
3191 |
+
<?php } ?>
|
3192 |
+
<?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
|
3193 |
+
Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
|
3194 |
+
<?php } ?>
|
3195 |
+
|
3196 |
+
|
3197 |
+
--- UM Email Configurations ---
|
3198 |
+
|
3199 |
+
Mail appears from: <?php $mail_from = UM()->options()->get('mail_from'); if( ! empty( $mail_from ) ){echo UM()->options()->get('mail_from');}else{echo "-";}; echo "\n";?>
|
3200 |
+
Mail appears from address: <?php $mail_from_addr = UM()->options()->get('mail_from_addr'); if( ! empty( $mail_from_addr ) ){echo UM()->options()->get('mail_from_addr');}else{echo "-";}; echo "\n";?>
|
3201 |
+
Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
|
3202 |
+
Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
|
3203 |
+
Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
|
3204 |
+
Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
|
3205 |
+
Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
|
3206 |
+
Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
|
3207 |
+
Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
|
3208 |
+
Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
|
3209 |
+
Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
|
3210 |
+
Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
|
3211 |
+
|
3212 |
+
|
3213 |
+
--- UM Total Users ---
|
3214 |
+
|
3215 |
+
<?php $result = count_users();
|
3216 |
+
echo 'All Users('.$result['total_users'].")\n";
|
3217 |
+
foreach( $result['avail_roles'] as $role => $count ) {
|
3218 |
+
echo $role."(".$count.")\n";
|
3219 |
+
} ?>
|
3220 |
+
|
3221 |
+
|
3222 |
+
--- UM Roles ---
|
3223 |
+
|
3224 |
+
<?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
|
3225 |
+
echo $role." ({$role_id})\n";
|
3226 |
+
} ?>
|
3227 |
+
|
3228 |
+
|
3229 |
+
--- UM Custom Templates ---
|
3230 |
+
|
3231 |
+
<?php // Show templates that have been copied to the theme's edd_templates dir
|
3232 |
+
$dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
|
3233 |
+
if ( ! empty( $dir ) ) {
|
3234 |
+
$found = glob( $dir );
|
3235 |
+
if ( ! empty( $found ) ) {
|
3236 |
+
foreach ( glob( $dir ) as $file ) {
|
3237 |
+
echo "File: " . $file . "\n";
|
3238 |
+
}
|
3239 |
+
} else {
|
3240 |
+
echo 'N/A'."\n";
|
3241 |
+
}
|
3242 |
+
} ?>
|
3243 |
+
|
3244 |
+
|
3245 |
+
--- UM Email HTML Templates ---
|
3246 |
+
|
3247 |
+
<?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
|
3248 |
+
|
3249 |
+
if ( ! empty( $dir ) ) {
|
3250 |
+
$found = glob( $dir );
|
3251 |
+
if ( ! empty( $found ) ){
|
3252 |
+
foreach ( glob( $dir ) as $file ) {
|
3253 |
+
echo "File: ". $file . "\n";
|
3254 |
+
}
|
3255 |
+
} else {
|
3256 |
+
echo 'N/A'."\n";
|
3257 |
+
}
|
3258 |
+
} ?>
|
3259 |
+
|
3260 |
+
|
3261 |
+
--- Web Server Configurations ---
|
3262 |
+
|
3263 |
+
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
|
3264 |
+
MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
|
3265 |
+
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
|
3266 |
+
|
3267 |
+
|
3268 |
+
--- PHP Configurations ---
|
3269 |
+
|
3270 |
+
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
|
3271 |
+
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3272 |
+
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
|
3273 |
+
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3274 |
+
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
|
3275 |
+
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
|
3276 |
+
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
|
3277 |
+
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
|
3278 |
+
|
3279 |
+
|
3280 |
+
--- Web Server Extensions/Modules ---
|
3281 |
+
|
3282 |
+
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
|
3283 |
+
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
|
3284 |
+
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
|
3285 |
+
SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
|
3286 |
+
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
|
3287 |
+
GD Library: <?php echo ( extension_loaded( 'gd' ) && function_exists('gd_info') ) ? 'PHP GD library is installed on your web server.' : 'PHP GD library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3288 |
+
Mail: <?php echo ( function_exists('mail') ) ? 'PHP mail function exist on your web server.' : 'PHP mail function doesn\'t exist on your web server.'; ?><?php echo "\n"; ?>
|
3289 |
+
Exif: <?php echo ( extension_loaded( 'exif' ) && function_exists('exif_imagetype') ) ? 'PHP Exif library is installed on your web server.' : 'PHP Exif library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3290 |
+
|
3291 |
+
|
3292 |
+
--- Session Configurations ---
|
3293 |
+
|
3294 |
+
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
|
3295 |
+
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
|
3296 |
+
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
|
3297 |
+
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
|
3298 |
+
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3299 |
+
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3300 |
+
|
3301 |
+
|
3302 |
+
--- WordPress Active Plugins ---
|
3303 |
+
|
3304 |
+
<?php $plugins = get_plugins();
|
3305 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
3306 |
+
|
3307 |
+
foreach ( $plugins as $plugin_path => $plugin ) {
|
3308 |
+
// If the plugin isn't active, don't show it.
|
3309 |
+
if ( ! in_array( $plugin_path, $active_plugins ) )
|
3310 |
+
continue;
|
3311 |
+
|
3312 |
+
echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
|
3313 |
+
}
|
3314 |
+
|
3315 |
+
if ( is_multisite() ) { ?>
|
3316 |
+
|
3317 |
+
--- WordPress Network Active Plugins ---
|
3318 |
+
|
3319 |
+
<?php $plugins = wp_get_active_network_plugins();
|
3320 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
3321 |
+
|
3322 |
+
foreach ( $plugins as $plugin_path ) {
|
3323 |
+
$plugin_base = plugin_basename( $plugin_path );
|
3324 |
+
|
3325 |
+
// If the plugin isn't active, don't show it.
|
3326 |
+
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
|
3327 |
+
continue;
|
3328 |
+
|
3329 |
+
$plugin = get_plugin_data( $plugin_path );
|
3330 |
+
|
3331 |
+
echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
|
3332 |
+
}
|
3333 |
+
|
3334 |
+
}
|
3335 |
+
|
3336 |
+
/**
|
3337 |
+
* UM hook
|
3338 |
+
*
|
3339 |
+
* @type action
|
3340 |
+
* @title um_install_info_after
|
3341 |
+
* @description After install info
|
3342 |
+
* @change_log
|
3343 |
+
* ["Since: 2.0"]
|
3344 |
+
* @usage add_action( 'um_install_info_after', 'function_name', 10 );
|
3345 |
+
* @example
|
3346 |
+
* <?php
|
3347 |
+
* add_action( 'um_install_info_after', 'my_install_info_after', 10 );
|
3348 |
+
* function my_install_info_after() {
|
3349 |
+
* // your code here
|
3350 |
+
* }
|
3351 |
+
* ?>
|
3352 |
+
*/
|
3353 |
+
do_action( 'um_install_info_after' ); ?>
|
3354 |
+
|
3355 |
+
### End Install Info ###
|
3356 |
+
</textarea>
|
3357 |
+
<p class="submit">
|
3358 |
+
<input type="hidden" name="um-addon-hook" value="download_install_info" />
|
3359 |
+
<?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
|
3360 |
+
</p>
|
3361 |
+
</form>
|
3362 |
+
|
3363 |
+
<?php }
|
3364 |
+
}
|
3365 |
+
|
3366 |
+
|
3367 |
+
/**
|
3368 |
+
*
|
3369 |
+
*/
|
3370 |
+
function um_download_install_info() {
|
3371 |
+
if ( ! empty( $_POST['download_install_info'] ) ) {
|
3372 |
+
nocache_headers();
|
3373 |
+
|
3374 |
+
header( "Content-type: text/plain" );
|
3375 |
+
header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
|
3376 |
+
|
3377 |
+
echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
|
3378 |
+
exit;
|
3379 |
+
}
|
3380 |
+
}
|
3381 |
+
|
3382 |
+
|
3383 |
+
/**
|
3384 |
+
* @param string $raw_value
|
3385 |
+
* @param string $type
|
3386 |
+
* @param string $default
|
3387 |
+
*
|
3388 |
+
* @return string
|
3389 |
+
*/
|
3390 |
+
function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
|
3391 |
+
|
3392 |
+
if ( $type == 'yesno' ) {
|
3393 |
+
$raw_value = ( $default == $raw_value ) ? "Yes" : "No";
|
3394 |
+
} elseif( $type == 'onoff' ) {
|
3395 |
+
$raw_value = ( $default == $raw_value ) ? "On" : "Off";
|
3396 |
+
}
|
3397 |
+
|
3398 |
+
return $raw_value."\n";
|
3399 |
+
}
|
3400 |
+
|
3401 |
+
|
3402 |
+
/**
|
3403 |
+
* Render settings section
|
3404 |
+
*
|
3405 |
+
* @param array $section_fields
|
3406 |
+
* @param string $current_tab
|
3407 |
+
* @param string $current_subtab
|
3408 |
+
*
|
3409 |
+
* @return string
|
3410 |
+
*/
|
3411 |
+
function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
|
3412 |
+
ob_start();
|
3413 |
+
|
3414 |
+
UM()->admin_forms_settings( array(
|
3415 |
+
'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
|
3416 |
+
'prefix_id' => 'um_options',
|
3417 |
+
'fields' => $section_fields
|
3418 |
+
) )->render_form(); ?>
|
3419 |
+
|
3420 |
+
<?php $section = ob_get_clean();
|
3421 |
+
|
3422 |
+
return $section;
|
3423 |
+
}
|
3424 |
+
|
3425 |
+
|
3426 |
+
/**
|
3427 |
+
* @param array $settings
|
3428 |
+
*
|
3429 |
+
* @return array
|
3430 |
+
*/
|
3431 |
+
function save_email_templates( $settings ) {
|
3432 |
+
|
3433 |
+
if ( empty( $settings['um_email_template'] ) ) {
|
3434 |
+
return $settings;
|
3435 |
+
}
|
3436 |
+
|
3437 |
+
$template = $settings['um_email_template'];
|
3438 |
+
$content = wp_kses_post( stripslashes( $settings[ $template ] ) );
|
3439 |
+
|
3440 |
+
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
|
3441 |
+
|
3442 |
+
if ( ! file_exists( $theme_template_path ) ) {
|
3443 |
+
UM()->mail()->copy_email_template( $template );
|
3444 |
+
}
|
3445 |
+
|
3446 |
+
$fp = fopen( $theme_template_path, "w" );
|
3447 |
+
$result = fputs( $fp, $content );
|
3448 |
+
fclose( $fp );
|
3449 |
+
|
3450 |
+
if ( $result !== false ) {
|
3451 |
+
unset( $settings['um_email_template'] );
|
3452 |
+
unset( $settings[ $template ] );
|
3453 |
+
}
|
3454 |
+
|
3455 |
+
return $settings;
|
3456 |
+
}
|
3457 |
+
}
|
3458 |
+
}
|
includes/admin/core/class-admin-users.php
CHANGED
@@ -1,584 +1,584 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Users
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Users {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Admin_Users constructor.
|
20 |
-
*/
|
21 |
-
function __construct() {
|
22 |
-
|
23 |
-
$this->custom_role = 'um_role';
|
24 |
-
|
25 |
-
add_action( 'restrict_manage_users', array( &$this, 'restrict_manage_users' ) );
|
26 |
-
|
27 |
-
add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
|
28 |
-
|
29 |
-
add_filter( 'user_has_cap', array( &$this, 'map_caps_by_role' ), 10, 4 );
|
30 |
-
|
31 |
-
add_filter( 'users_list_table_query_args', array( &$this, 'hide_by_caps' ), 1, 1 );
|
32 |
-
|
33 |
-
add_filter( 'pre_user_query', array( &$this, 'sort_by_newest' ) );
|
34 |
-
|
35 |
-
add_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
36 |
-
|
37 |
-
add_filter( 'views_users', array( &$this, 'add_status_links' ) );
|
38 |
-
|
39 |
-
add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
|
40 |
-
|
41 |
-
add_action( 'um_admin_user_action_hook', array( &$this, 'user_action_hook' ), 10, 1 );
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
function get_users() {
|
46 |
-
UM()->admin()->check_ajax_nonce();
|
47 |
-
|
48 |
-
$search_request = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
|
49 |
-
$page = ! empty( $_REQUEST['page'] ) ? absint( $_REQUEST['page'] ) : 1;
|
50 |
-
$per_page = 20;
|
51 |
-
|
52 |
-
$args = array(
|
53 |
-
'fields' => array( 'ID', 'user_login' ),
|
54 |
-
'paged' => $page,
|
55 |
-
'number' => $per_page
|
56 |
-
);
|
57 |
-
|
58 |
-
if ( ! empty( $search_request ) ) {
|
59 |
-
$args['search'] = $search_request;
|
60 |
-
}
|
61 |
-
|
62 |
-
$users_query = new \WP_User_Query( $args );
|
63 |
-
$users = $users_query->get_results();
|
64 |
-
$total_count = $users_query->get_total();
|
65 |
-
|
66 |
-
wp_send_json_success(
|
67 |
-
array(
|
68 |
-
'users' => $users,
|
69 |
-
'total_count' => $total_count,
|
70 |
-
)
|
71 |
-
);
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Restrict the edit/delete users via wp-admin screen by the UM role capabilities
|
77 |
-
*
|
78 |
-
* @param $allcaps
|
79 |
-
* @param $cap
|
80 |
-
* @param $args
|
81 |
-
* @param $user
|
82 |
-
*
|
83 |
-
* @return mixed
|
84 |
-
*/
|
85 |
-
function map_caps_by_role( $allcaps, $cap, $args, $user ) {
|
86 |
-
if ( isset( $cap[0] ) && $cap[0] == 'edit_users' ) {
|
87 |
-
if ( ! user_can( $args[1], 'administrator' ) && $args[0] == 'edit_user' ) {
|
88 |
-
if ( ! UM()->roles()->um_current_user_can( 'edit', $args[2] ) ) {
|
89 |
-
$allcaps[ $cap[0] ] = false;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
} elseif ( isset( $cap[0] ) && $cap[0] == 'delete_users' ) {
|
93 |
-
if ( ! user_can( $args[1], 'administrator' ) && $args[0] == 'delete_user' ) {
|
94 |
-
if ( ! UM()->roles()->um_current_user_can( 'delete', $args[2] ) ) {
|
95 |
-
$allcaps[ $cap[0] ] = false;
|
96 |
-
}
|
97 |
-
}
|
98 |
-
} elseif ( isset( $cap[0] ) && $cap[0] == 'list_users' ) {
|
99 |
-
if ( ! user_can( $args[1], 'administrator' ) && $args[0] == 'list_users' ) {
|
100 |
-
if ( ! um_user( 'can_view_all' ) ) {
|
101 |
-
$allcaps[ $cap[0] ] = false;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
return $allcaps;
|
107 |
-
}
|
108 |
-
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Does an action to user asap
|
112 |
-
*
|
113 |
-
* @param string $action
|
114 |
-
*/
|
115 |
-
function user_action_hook( $action ) {
|
116 |
-
switch ( $action ) {
|
117 |
-
default:
|
118 |
-
/**
|
119 |
-
* UM hook
|
120 |
-
*
|
121 |
-
* @type action
|
122 |
-
* @title um_admin_custom_hook_{$action}
|
123 |
-
* @description Integration hook on user action
|
124 |
-
* @input_vars
|
125 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
126 |
-
* @change_log
|
127 |
-
* ["Since: 2.0"]
|
128 |
-
* @usage add_action( 'um_admin_custom_hook_{$action}', 'function_name', 10, 1 );
|
129 |
-
* @example
|
130 |
-
* <?php
|
131 |
-
* add_action( 'um_admin_custom_hook_{$action}', 'my_admin_custom_hook', 10, 1 );
|
132 |
-
* function my_admin_after_main_notices( $user_id ) {
|
133 |
-
* // your code here
|
134 |
-
* }
|
135 |
-
* ?>
|
136 |
-
*/
|
137 |
-
do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
|
138 |
-
break;
|
139 |
-
|
140 |
-
case 'um_put_as_pending':
|
141 |
-
UM()->user()->pending();
|
142 |
-
break;
|
143 |
-
|
144 |
-
case 'um_approve_membership':
|
145 |
-
case 'um_reenable':
|
146 |
-
|
147 |
-
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
148 |
-
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
149 |
-
|
150 |
-
UM()->user()->approve();
|
151 |
-
break;
|
152 |
-
|
153 |
-
case 'um_reject_membership':
|
154 |
-
UM()->user()->reject();
|
155 |
-
break;
|
156 |
-
|
157 |
-
case 'um_resend_activation':
|
158 |
-
|
159 |
-
add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
|
160 |
-
add_filter( 'um_template_tags_replaces_hook', array( UM()->user(), 'add_activation_replace_placeholder' ), 10, 1 );
|
161 |
-
|
162 |
-
UM()->user()->email_pending();
|
163 |
-
break;
|
164 |
-
|
165 |
-
case 'um_deactivate':
|
166 |
-
UM()->user()->deactivate();
|
167 |
-
break;
|
168 |
-
|
169 |
-
case 'um_delete':
|
170 |
-
if ( is_admin() ) {
|
171 |
-
wp_die( __( 'This action is not allowed in backend.', 'ultimate-member' ) );
|
172 |
-
}
|
173 |
-
UM()->user()->delete();
|
174 |
-
break;
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Add UM Bulk actions to Users List Table
|
181 |
-
*
|
182 |
-
*/
|
183 |
-
function restrict_manage_users() { ?>
|
184 |
-
<div style="float:right;margin:0 4px">
|
185 |
-
|
186 |
-
<label class="screen-reader-text" for="um_bulk_action"><?php _e( 'UM Action', 'ultimate-member' ); ?></label>
|
187 |
-
|
188 |
-
<select name="um_bulk_action[]" id="um_bulk_action" class="" style="width: 200px">
|
189 |
-
<option value="0"><?php _e( 'UM Action', 'ultimate-member' ); ?></option>
|
190 |
-
<?php echo $this->get_bulk_admin_actions(); ?>
|
191 |
-
</select>
|
192 |
-
|
193 |
-
<input name="um_bulkedit" id="um_bulkedit" class="button" value="<?php esc_attr_e( 'Apply', 'ultimate-member' ); ?>" type="submit" />
|
194 |
-
|
195 |
-
</div>
|
196 |
-
|
197 |
-
<?php if ( ! empty( $_REQUEST['um_status'] ) ) { ?>
|
198 |
-
<input type="hidden" name="um_status" id="um_status" value="<?php echo esc_attr( sanitize_key( $_REQUEST['um_status'] ) );?>"/>
|
199 |
-
<?php }
|
200 |
-
}
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Get UM bulk actions HTML
|
205 |
-
*
|
206 |
-
* @return string
|
207 |
-
*/
|
208 |
-
function get_bulk_admin_actions() {
|
209 |
-
|
210 |
-
/**
|
211 |
-
* UM hook
|
212 |
-
*
|
213 |
-
* @type filter
|
214 |
-
* @title um_admin_bulk_user_actions_hook
|
215 |
-
* @description Admin Users List Table bulk actions
|
216 |
-
* @input_vars
|
217 |
-
* [{"var":"$actions","type":"array","desc":"User List Table bulk actions"}]
|
218 |
-
* @change_log
|
219 |
-
* ["Since: 2.0"]
|
220 |
-
* @usage add_filter( 'um_admin_bulk_user_actions_hook', 'function_name', 10, 1 );
|
221 |
-
* @example
|
222 |
-
* <?php
|
223 |
-
* add_filter( 'um_admin_bulk_user_actions_hook', 'my_admin_bulk_user_actions', 10, 1 );
|
224 |
-
* function my_admin_bulk_user_actions( $actions ) {
|
225 |
-
* // your code here
|
226 |
-
* $actions['my-custom-bulk'] = array(
|
227 |
-
* 'label' => 'My Custom Bulk Action'
|
228 |
-
* );
|
229 |
-
* return $actions;
|
230 |
-
* }
|
231 |
-
* ?>
|
232 |
-
*/
|
233 |
-
$actions = apply_filters( 'um_admin_bulk_user_actions_hook', array(
|
234 |
-
'um_approve_membership' => array(
|
235 |
-
'label' => __( 'Approve Membership', 'ultimate-member' )
|
236 |
-
),
|
237 |
-
'um_reject_membership' => array(
|
238 |
-
'label' => __( 'Reject Membership', 'ultimate-member' )
|
239 |
-
),
|
240 |
-
'um_put_as_pending' => array(
|
241 |
-
'label' => __( 'Put as Pending Review', 'ultimate-member' )
|
242 |
-
),
|
243 |
-
'um_resend_activation' => array(
|
244 |
-
'label' => __( 'Resend Activation E-mail', 'ultimate-member' )
|
245 |
-
),
|
246 |
-
'um_deactivate' => array(
|
247 |
-
'label' => __( 'Deactivate', 'ultimate-member' )
|
248 |
-
),
|
249 |
-
'um_reenable' => array(
|
250 |
-
'label' => __( 'Reactivate', 'ultimate-member' )
|
251 |
-
)
|
252 |
-
) );
|
253 |
-
|
254 |
-
$output = '';
|
255 |
-
foreach ( $actions as $id => $action_data ) {
|
256 |
-
$output .= '<option value="' . $id . '" '. disabled( isset( $arr['disabled'] ), true, false ) . '>' . $action_data['label'] . '</option>';
|
257 |
-
}
|
258 |
-
return $output;
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Custom row actions for users page
|
264 |
-
*
|
265 |
-
* @param array $actions
|
266 |
-
* @param $user_object \WP_User
|
267 |
-
* @return array
|
268 |
-
*/
|
269 |
-
function user_row_actions( $actions, $user_object ) {
|
270 |
-
$user_id = $user_object->ID;
|
271 |
-
|
272 |
-
$actions['frontend_profile'] = '<a href="' . um_user_profile_url( $user_id ) . '">' . __( 'View profile', 'ultimate-member' ) . '</a>';
|
273 |
-
|
274 |
-
$submitted = get_user_meta( $user_id, 'submitted', true );
|
275 |
-
if ( ! empty( $submitted ) ) {
|
276 |
-
$actions['view_info'] = '<a href="javascript:void(0);" data-modal="UM_preview_registration" data-modal-size="smaller"
|
277 |
-
data-dynamic-content="um_admin_review_registration" data-arg1="' . esc_attr( $user_id ) . '" data-arg2="edit_registration">' . __( 'Info', 'ultimate-member' ) . '</a>';
|
278 |
-
}
|
279 |
-
|
280 |
-
if ( ! current_user_can( 'administrator' ) ) {
|
281 |
-
if ( ! um_can_view_profile( $user_id ) ) {
|
282 |
-
unset( $actions['frontend_profile'] );
|
283 |
-
unset( $actions['view_info'] );
|
284 |
-
unset( $actions['view'] );
|
285 |
-
}
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* UM hook
|
290 |
-
*
|
291 |
-
* @type filter
|
292 |
-
* @title um_admin_user_row_actions
|
293 |
-
* @description Admin views array
|
294 |
-
* @input_vars
|
295 |
-
* [{"var":"$actions","type":"array","desc":"User List Table actions"},
|
296 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
297 |
-
* @change_log
|
298 |
-
* ["Since: 2.0"]
|
299 |
-
* @usage add_filter( 'um_admin_user_row_actions', 'function_name', 10, 2 );
|
300 |
-
* @example
|
301 |
-
* <?php
|
302 |
-
* add_filter( 'um_admin_user_row_actions', 'my_admin_user_row_actions', 10, 2 );
|
303 |
-
* function my_admin_user_row_actions( $actions, $user_id ) {
|
304 |
-
* // your code here
|
305 |
-
* return $actions;
|
306 |
-
* }
|
307 |
-
* ?>
|
308 |
-
*/
|
309 |
-
$actions = apply_filters( 'um_admin_user_row_actions', $actions, $user_id );
|
310 |
-
|
311 |
-
return $actions;
|
312 |
-
}
|
313 |
-
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Change default sorting at WP Users list table
|
317 |
-
*
|
318 |
-
* @param array $args
|
319 |
-
* @return array
|
320 |
-
*/
|
321 |
-
function hide_by_caps( $args ) {
|
322 |
-
if ( ! current_user_can( 'administrator' ) ) {
|
323 |
-
$can_view_roles = um_user( 'can_view_roles' );
|
324 |
-
if ( um_user( 'can_view_all' ) && ! empty( $can_view_roles ) ) {
|
325 |
-
$args['role__in'] = $can_view_roles;
|
326 |
-
}
|
327 |
-
}
|
328 |
-
|
329 |
-
return $args;
|
330 |
-
}
|
331 |
-
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Change default sorting at WP Users list table
|
335 |
-
*
|
336 |
-
* @param $query
|
337 |
-
* @return mixed
|
338 |
-
*/
|
339 |
-
public function sort_by_newest( $query ) {
|
340 |
-
global $pagenow;
|
341 |
-
|
342 |
-
if ( is_admin() && 'users.php' === $pagenow ) {
|
343 |
-
if ( ! isset( $_REQUEST['orderby'] ) ) {
|
344 |
-
$query->query_vars['order'] = 'desc';
|
345 |
-
$query->query_orderby = ' ORDER BY user_registered ' . ( 'desc' === $query->query_vars['order'] ? 'desc ' : 'asc ' ); //set sort order
|
346 |
-
}
|
347 |
-
}
|
348 |
-
|
349 |
-
return $query;
|
350 |
-
}
|
351 |
-
|
352 |
-
|
353 |
-
/**
|
354 |
-
* Filter WP users by UM Status
|
355 |
-
*
|
356 |
-
* @param $query
|
357 |
-
* @return mixed
|
358 |
-
*/
|
359 |
-
public function filter_users_by_status( $query ) {
|
360 |
-
global $wpdb, $pagenow;
|
361 |
-
if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['um_status'] ) ) {
|
362 |
-
|
363 |
-
$status = sanitize_key( $_REQUEST['um_status'] );
|
364 |
-
|
365 |
-
if ( 'needs-verification' === $status ) {
|
366 |
-
$query->query_where = str_replace('WHERE 1=1',
|
367 |
-
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
368 |
-
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
369 |
-
WHERE {$wpdb->usermeta}.meta_key = '_um_verified'
|
370 |
-
AND {$wpdb->usermeta}.meta_value = 'pending')",
|
371 |
-
$query->query_where
|
372 |
-
);
|
373 |
-
} else {
|
374 |
-
$query->query_where = str_replace('WHERE 1=1',
|
375 |
-
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
376 |
-
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
377 |
-
WHERE {$wpdb->usermeta}.meta_key = 'account_status'
|
378 |
-
AND {$wpdb->usermeta}.meta_value = '{$status}')",
|
379 |
-
$query->query_where
|
380 |
-
);
|
381 |
-
}
|
382 |
-
}
|
383 |
-
|
384 |
-
return $query;
|
385 |
-
}
|
386 |
-
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Add status links to WP Users List Table
|
390 |
-
*
|
391 |
-
* @param $views
|
392 |
-
* @return array
|
393 |
-
*/
|
394 |
-
public function add_status_links( $views ) {
|
395 |
-
remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
396 |
-
|
397 |
-
$old_views = $views;
|
398 |
-
$views = array();
|
399 |
-
|
400 |
-
if ( ! isset( $_REQUEST['role'] ) && ! isset( $_REQUEST['um_status'] ) ) {
|
401 |
-
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '" class="current">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
|
402 |
-
} else {
|
403 |
-
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
|
404 |
-
}
|
405 |
-
|
406 |
-
$status = array(
|
407 |
-
'approved' => __( 'Approved', 'ultimate-member' ),
|
408 |
-
'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
|
409 |
-
'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
|
410 |
-
'inactive' => __( 'Inactive', 'ultimate-member' ),
|
411 |
-
'rejected' => __( 'Rejected', 'ultimate-member' ),
|
412 |
-
);
|
413 |
-
|
414 |
-
UM()->query()->count_users_by_status( 'unassigned' );
|
415 |
-
|
416 |
-
foreach ( $status as $k => $v ) {
|
417 |
-
if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) {
|
418 |
-
$current = 'class="current"';
|
419 |
-
} else {
|
420 |
-
$current = '';
|
421 |
-
}
|
422 |
-
|
423 |
-
$views[ $k ] = '<a href="' . esc_url( admin_url( 'users.php' ) . '?um_status=' . $k ) . '" ' . $current . '>' . $v . ' <span class="count">(' . UM()->query()->count_users_by_status( $k ) . ')</span></a>';
|
424 |
-
}
|
425 |
-
|
426 |
-
/**
|
427 |
-
* UM hook
|
428 |
-
*
|
429 |
-
* @type filter
|
430 |
-
* @title um_admin_views_users
|
431 |
-
* @description Admin views array
|
432 |
-
* @input_vars
|
433 |
-
* [{"var":"$views","type":"array","desc":"User Views"}]
|
434 |
-
* @change_log
|
435 |
-
* ["Since: 2.0"]
|
436 |
-
* @usage add_filter( 'um_admin_views_users', 'function_name', 10, 1 );
|
437 |
-
* @example
|
438 |
-
* <?php
|
439 |
-
* add_filter( 'um_admin_views_users', 'my_admin_views_users', 10, 1 );
|
440 |
-
* function my_admin_views_users( $views ) {
|
441 |
-
* // your code here
|
442 |
-
* return $views;
|
443 |
-
* }
|
444 |
-
* ?>
|
445 |
-
*/
|
446 |
-
$views = apply_filters( 'um_admin_views_users', $views );
|
447 |
-
|
448 |
-
// remove all filters
|
449 |
-
unset( $old_views['all'] );
|
450 |
-
|
451 |
-
// add separator
|
452 |
-
$views['subsep'] = '<span></span>';
|
453 |
-
|
454 |
-
// merge views
|
455 |
-
foreach ( $old_views as $key => $view ) {
|
456 |
-
$views[ $key ] = $view;
|
457 |
-
}
|
458 |
-
|
459 |
-
// hide filters with not accessible roles
|
460 |
-
if ( ! current_user_can( 'administrator' ) ) {
|
461 |
-
$wp_roles = wp_roles();
|
462 |
-
$can_view_roles = um_user( 'can_view_roles' );
|
463 |
-
if ( ! empty( $can_view_roles ) ) {
|
464 |
-
foreach ( $wp_roles->get_names() as $this_role => $name ) {
|
465 |
-
if ( ! in_array( $this_role, $can_view_roles, true ) ) {
|
466 |
-
unset( $views[ $this_role ] );
|
467 |
-
}
|
468 |
-
}
|
469 |
-
}
|
470 |
-
}
|
471 |
-
|
472 |
-
return $views;
|
473 |
-
}
|
474 |
-
|
475 |
-
|
476 |
-
/**
|
477 |
-
* Bulk user editing actions
|
478 |
-
*/
|
479 |
-
public function um_bulk_users_edit() {
|
480 |
-
// bulk edit users
|
481 |
-
if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
|
482 |
-
|
483 |
-
$rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
|
484 |
-
$role = get_role( $rolename );
|
485 |
-
|
486 |
-
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
487 |
-
wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
|
488 |
-
}
|
489 |
-
|
490 |
-
check_admin_referer( 'bulk-users' );
|
491 |
-
|
492 |
-
$users = array_map( 'absint', (array) $_REQUEST['users'] );
|
493 |
-
$bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) );
|
494 |
-
|
495 |
-
foreach ( $users as $user_id ) {
|
496 |
-
UM()->user()->set( $user_id );
|
497 |
-
|
498 |
-
/**
|
499 |
-
* UM hook
|
500 |
-
*
|
501 |
-
* @type action
|
502 |
-
* @title um_admin_user_action_hook
|
503 |
-
* @description Action on bulk user action
|
504 |
-
* @input_vars
|
505 |
-
* [{"var":"$bulk_action","type":"string","desc":"Bulk Action"}]
|
506 |
-
* @change_log
|
507 |
-
* ["Since: 2.0"]
|
508 |
-
* @usage add_action( 'um_admin_user_action_hook{$action}', 'function_name', 10, 1 );
|
509 |
-
* @example
|
510 |
-
* <?php
|
511 |
-
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
512 |
-
* function my_admin_user_action( $bulk_action ) {
|
513 |
-
* // your code here
|
514 |
-
* }
|
515 |
-
* ?>
|
516 |
-
*/
|
517 |
-
do_action( 'um_admin_user_action_hook', $bulk_action );
|
518 |
-
|
519 |
-
/**
|
520 |
-
* UM hook
|
521 |
-
*
|
522 |
-
* @type action
|
523 |
-
* @title um_admin_user_action_{$bulk_action}_hook
|
524 |
-
* @description Action on bulk user action
|
525 |
-
* @change_log
|
526 |
-
* ["Since: 2.0"]
|
527 |
-
* @usage add_action( 'um_admin_user_action_{$bulk_action}_hook', 'function_name', 10 );
|
528 |
-
* @example
|
529 |
-
* <?php
|
530 |
-
* add_action( 'um_admin_user_action_{$bulk_action}_hook', 'my_admin_user_action', 10 );
|
531 |
-
* function my_admin_user_action() {
|
532 |
-
* // your code here
|
533 |
-
* }
|
534 |
-
* ?>
|
535 |
-
*/
|
536 |
-
do_action( "um_admin_user_action_{$bulk_action}_hook" );
|
537 |
-
}
|
538 |
-
|
539 |
-
// Finished. redirect now
|
540 |
-
//if ( $admin_err == 0 ) {
|
541 |
-
|
542 |
-
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
|
543 |
-
$uri = add_query_arg( 'update', 'users_updated', $uri );
|
544 |
-
|
545 |
-
wp_redirect( $uri );
|
546 |
-
exit;
|
547 |
-
|
548 |
-
/*} else {
|
549 |
-
wp_redirect( admin_url( 'users.php?update=err_users_updated' ) );
|
550 |
-
exit;
|
551 |
-
}*/
|
552 |
-
|
553 |
-
} elseif ( ! empty( $_REQUEST['um_bulkedit'] ) ) {
|
554 |
-
|
555 |
-
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
|
556 |
-
wp_redirect( $uri );
|
557 |
-
exit;
|
558 |
-
|
559 |
-
}
|
560 |
-
}
|
561 |
-
|
562 |
-
|
563 |
-
/**
|
564 |
-
* Sets redirect URI after bulk action
|
565 |
-
*
|
566 |
-
* @param string $uri
|
567 |
-
* @return string
|
568 |
-
*/
|
569 |
-
function set_redirect_uri( $uri ) {
|
570 |
-
|
571 |
-
if ( ! empty( $_REQUEST['s'] ) ) {
|
572 |
-
$uri = add_query_arg( 's', sanitize_text_field( $_REQUEST['s'] ), $uri );
|
573 |
-
}
|
574 |
-
|
575 |
-
if ( ! empty( $_REQUEST['um_status'] ) ) {
|
576 |
-
$uri = add_query_arg( 'um_status', sanitize_key( $_REQUEST['um_status'] ), $uri );
|
577 |
-
}
|
578 |
-
|
579 |
-
return $uri;
|
580 |
-
|
581 |
-
}
|
582 |
-
|
583 |
-
}
|
584 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Users
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Users {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Admin_Users constructor.
|
20 |
+
*/
|
21 |
+
function __construct() {
|
22 |
+
|
23 |
+
$this->custom_role = 'um_role';
|
24 |
+
|
25 |
+
add_action( 'restrict_manage_users', array( &$this, 'restrict_manage_users' ) );
|
26 |
+
|
27 |
+
add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
|
28 |
+
|
29 |
+
add_filter( 'user_has_cap', array( &$this, 'map_caps_by_role' ), 10, 4 );
|
30 |
+
|
31 |
+
add_filter( 'users_list_table_query_args', array( &$this, 'hide_by_caps' ), 1, 1 );
|
32 |
+
|
33 |
+
add_filter( 'pre_user_query', array( &$this, 'sort_by_newest' ) );
|
34 |
+
|
35 |
+
add_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
36 |
+
|
37 |
+
add_filter( 'views_users', array( &$this, 'add_status_links' ) );
|
38 |
+
|
39 |
+
add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
|
40 |
+
|
41 |
+
add_action( 'um_admin_user_action_hook', array( &$this, 'user_action_hook' ), 10, 1 );
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
function get_users() {
|
46 |
+
UM()->admin()->check_ajax_nonce();
|
47 |
+
|
48 |
+
$search_request = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
|
49 |
+
$page = ! empty( $_REQUEST['page'] ) ? absint( $_REQUEST['page'] ) : 1;
|
50 |
+
$per_page = 20;
|
51 |
+
|
52 |
+
$args = array(
|
53 |
+
'fields' => array( 'ID', 'user_login' ),
|
54 |
+
'paged' => $page,
|
55 |
+
'number' => $per_page
|
56 |
+
);
|
57 |
+
|
58 |
+
if ( ! empty( $search_request ) ) {
|
59 |
+
$args['search'] = $search_request;
|
60 |
+
}
|
61 |
+
|
62 |
+
$users_query = new \WP_User_Query( $args );
|
63 |
+
$users = $users_query->get_results();
|
64 |
+
$total_count = $users_query->get_total();
|
65 |
+
|
66 |
+
wp_send_json_success(
|
67 |
+
array(
|
68 |
+
'users' => $users,
|
69 |
+
'total_count' => $total_count,
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Restrict the edit/delete users via wp-admin screen by the UM role capabilities
|
77 |
+
*
|
78 |
+
* @param $allcaps
|
79 |
+
* @param $cap
|
80 |
+
* @param $args
|
81 |
+
* @param $user
|
82 |
+
*
|
83 |
+
* @return mixed
|
84 |
+
*/
|
85 |
+
function map_caps_by_role( $allcaps, $cap, $args, $user ) {
|
86 |
+
if ( isset( $cap[0] ) && $cap[0] == 'edit_users' ) {
|
87 |
+
if ( ! user_can( $args[1], 'administrator' ) && $args[0] == 'edit_user' ) {
|
88 |
+
if ( ! UM()->roles()->um_current_user_can( 'edit', $args[2] ) ) {
|
89 |
+
$allcaps[ $cap[0] ] = false;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
} elseif ( isset( $cap[0] ) && $cap[0] == 'delete_users' ) {
|
93 |
+
if ( ! user_can( $args[1], 'administrator' ) && $args[0] == 'delete_user' ) {
|
94 |
+
if ( ! UM()->roles()->um_current_user_can( 'delete', $args[2] ) ) {
|
95 |
+
$allcaps[ $cap[0] ] = false;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
} elseif ( isset( $cap[0] ) && $cap[0] == 'list_users' ) {
|
99 |
+
if ( ! user_can( $args[1], 'administrator' ) && $args[0] == 'list_users' ) {
|
100 |
+
if ( ! um_user( 'can_view_all' ) ) {
|
101 |
+
$allcaps[ $cap[0] ] = false;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
return $allcaps;
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Does an action to user asap
|
112 |
+
*
|
113 |
+
* @param string $action
|
114 |
+
*/
|
115 |
+
function user_action_hook( $action ) {
|
116 |
+
switch ( $action ) {
|
117 |
+
default:
|
118 |
+
/**
|
119 |
+
* UM hook
|
120 |
+
*
|
121 |
+
* @type action
|
122 |
+
* @title um_admin_custom_hook_{$action}
|
123 |
+
* @description Integration hook on user action
|
124 |
+
* @input_vars
|
125 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
126 |
+
* @change_log
|
127 |
+
* ["Since: 2.0"]
|
128 |
+
* @usage add_action( 'um_admin_custom_hook_{$action}', 'function_name', 10, 1 );
|
129 |
+
* @example
|
130 |
+
* <?php
|
131 |
+
* add_action( 'um_admin_custom_hook_{$action}', 'my_admin_custom_hook', 10, 1 );
|
132 |
+
* function my_admin_after_main_notices( $user_id ) {
|
133 |
+
* // your code here
|
134 |
+
* }
|
135 |
+
* ?>
|
136 |
+
*/
|
137 |
+
do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
|
138 |
+
break;
|
139 |
+
|
140 |
+
case 'um_put_as_pending':
|
141 |
+
UM()->user()->pending();
|
142 |
+
break;
|
143 |
+
|
144 |
+
case 'um_approve_membership':
|
145 |
+
case 'um_reenable':
|
146 |
+
|
147 |
+
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
148 |
+
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
149 |
+
|
150 |
+
UM()->user()->approve();
|
151 |
+
break;
|
152 |
+
|
153 |
+
case 'um_reject_membership':
|
154 |
+
UM()->user()->reject();
|
155 |
+
break;
|
156 |
+
|
157 |
+
case 'um_resend_activation':
|
158 |
+
|
159 |
+
add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
|
160 |
+
add_filter( 'um_template_tags_replaces_hook', array( UM()->user(), 'add_activation_replace_placeholder' ), 10, 1 );
|
161 |
+
|
162 |
+
UM()->user()->email_pending();
|
163 |
+
break;
|
164 |
+
|
165 |
+
case 'um_deactivate':
|
166 |
+
UM()->user()->deactivate();
|
167 |
+
break;
|
168 |
+
|
169 |
+
case 'um_delete':
|
170 |
+
if ( is_admin() ) {
|
171 |
+
wp_die( __( 'This action is not allowed in backend.', 'ultimate-member' ) );
|
172 |
+
}
|
173 |
+
UM()->user()->delete();
|
174 |
+
break;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Add UM Bulk actions to Users List Table
|
181 |
+
*
|
182 |
+
*/
|
183 |
+
function restrict_manage_users() { ?>
|
184 |
+
<div style="float:right;margin:0 4px">
|
185 |
+
|
186 |
+
<label class="screen-reader-text" for="um_bulk_action"><?php _e( 'UM Action', 'ultimate-member' ); ?></label>
|
187 |
+
|
188 |
+
<select name="um_bulk_action[]" id="um_bulk_action" class="" style="width: 200px">
|
189 |
+
<option value="0"><?php _e( 'UM Action', 'ultimate-member' ); ?></option>
|
190 |
+
<?php echo $this->get_bulk_admin_actions(); ?>
|
191 |
+
</select>
|
192 |
+
|
193 |
+
<input name="um_bulkedit" id="um_bulkedit" class="button" value="<?php esc_attr_e( 'Apply', 'ultimate-member' ); ?>" type="submit" />
|
194 |
+
|
195 |
+
</div>
|
196 |
+
|
197 |
+
<?php if ( ! empty( $_REQUEST['um_status'] ) ) { ?>
|
198 |
+
<input type="hidden" name="um_status" id="um_status" value="<?php echo esc_attr( sanitize_key( $_REQUEST['um_status'] ) );?>"/>
|
199 |
+
<?php }
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Get UM bulk actions HTML
|
205 |
+
*
|
206 |
+
* @return string
|
207 |
+
*/
|
208 |
+
function get_bulk_admin_actions() {
|
209 |
+
|
210 |
+
/**
|
211 |
+
* UM hook
|
212 |
+
*
|
213 |
+
* @type filter
|
214 |
+
* @title um_admin_bulk_user_actions_hook
|
215 |
+
* @description Admin Users List Table bulk actions
|
216 |
+
* @input_vars
|
217 |
+
* [{"var":"$actions","type":"array","desc":"User List Table bulk actions"}]
|
218 |
+
* @change_log
|
219 |
+
* ["Since: 2.0"]
|
220 |
+
* @usage add_filter( 'um_admin_bulk_user_actions_hook', 'function_name', 10, 1 );
|
221 |
+
* @example
|
222 |
+
* <?php
|
223 |
+
* add_filter( 'um_admin_bulk_user_actions_hook', 'my_admin_bulk_user_actions', 10, 1 );
|
224 |
+
* function my_admin_bulk_user_actions( $actions ) {
|
225 |
+
* // your code here
|
226 |
+
* $actions['my-custom-bulk'] = array(
|
227 |
+
* 'label' => 'My Custom Bulk Action'
|
228 |
+
* );
|
229 |
+
* return $actions;
|
230 |
+
* }
|
231 |
+
* ?>
|
232 |
+
*/
|
233 |
+
$actions = apply_filters( 'um_admin_bulk_user_actions_hook', array(
|
234 |
+
'um_approve_membership' => array(
|
235 |
+
'label' => __( 'Approve Membership', 'ultimate-member' )
|
236 |
+
),
|
237 |
+
'um_reject_membership' => array(
|
238 |
+
'label' => __( 'Reject Membership', 'ultimate-member' )
|
239 |
+
),
|
240 |
+
'um_put_as_pending' => array(
|
241 |
+
'label' => __( 'Put as Pending Review', 'ultimate-member' )
|
242 |
+
),
|
243 |
+
'um_resend_activation' => array(
|
244 |
+
'label' => __( 'Resend Activation E-mail', 'ultimate-member' )
|
245 |
+
),
|
246 |
+
'um_deactivate' => array(
|
247 |
+
'label' => __( 'Deactivate', 'ultimate-member' )
|
248 |
+
),
|
249 |
+
'um_reenable' => array(
|
250 |
+
'label' => __( 'Reactivate', 'ultimate-member' )
|
251 |
+
)
|
252 |
+
) );
|
253 |
+
|
254 |
+
$output = '';
|
255 |
+
foreach ( $actions as $id => $action_data ) {
|
256 |
+
$output .= '<option value="' . $id . '" '. disabled( isset( $arr['disabled'] ), true, false ) . '>' . $action_data['label'] . '</option>';
|
257 |
+
}
|
258 |
+
return $output;
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Custom row actions for users page
|
264 |
+
*
|
265 |
+
* @param array $actions
|
266 |
+
* @param $user_object \WP_User
|
267 |
+
* @return array
|
268 |
+
*/
|
269 |
+
function user_row_actions( $actions, $user_object ) {
|
270 |
+
$user_id = $user_object->ID;
|
271 |
+
|
272 |
+
$actions['frontend_profile'] = '<a href="' . um_user_profile_url( $user_id ) . '">' . __( 'View profile', 'ultimate-member' ) . '</a>';
|
273 |
+
|
274 |
+
$submitted = get_user_meta( $user_id, 'submitted', true );
|
275 |
+
if ( ! empty( $submitted ) ) {
|
276 |
+
$actions['view_info'] = '<a href="javascript:void(0);" data-modal="UM_preview_registration" data-modal-size="smaller"
|
277 |
+
data-dynamic-content="um_admin_review_registration" data-arg1="' . esc_attr( $user_id ) . '" data-arg2="edit_registration">' . __( 'Info', 'ultimate-member' ) . '</a>';
|
278 |
+
}
|
279 |
+
|
280 |
+
if ( ! current_user_can( 'administrator' ) ) {
|
281 |
+
if ( ! um_can_view_profile( $user_id ) ) {
|
282 |
+
unset( $actions['frontend_profile'] );
|
283 |
+
unset( $actions['view_info'] );
|
284 |
+
unset( $actions['view'] );
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* UM hook
|
290 |
+
*
|
291 |
+
* @type filter
|
292 |
+
* @title um_admin_user_row_actions
|
293 |
+
* @description Admin views array
|
294 |
+
* @input_vars
|
295 |
+
* [{"var":"$actions","type":"array","desc":"User List Table actions"},
|
296 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
297 |
+
* @change_log
|
298 |
+
* ["Since: 2.0"]
|
299 |
+
* @usage add_filter( 'um_admin_user_row_actions', 'function_name', 10, 2 );
|
300 |
+
* @example
|
301 |
+
* <?php
|
302 |
+
* add_filter( 'um_admin_user_row_actions', 'my_admin_user_row_actions', 10, 2 );
|
303 |
+
* function my_admin_user_row_actions( $actions, $user_id ) {
|
304 |
+
* // your code here
|
305 |
+
* return $actions;
|
306 |
+
* }
|
307 |
+
* ?>
|
308 |
+
*/
|
309 |
+
$actions = apply_filters( 'um_admin_user_row_actions', $actions, $user_id );
|
310 |
+
|
311 |
+
return $actions;
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Change default sorting at WP Users list table
|
317 |
+
*
|
318 |
+
* @param array $args
|
319 |
+
* @return array
|
320 |
+
*/
|
321 |
+
function hide_by_caps( $args ) {
|
322 |
+
if ( ! current_user_can( 'administrator' ) ) {
|
323 |
+
$can_view_roles = um_user( 'can_view_roles' );
|
324 |
+
if ( um_user( 'can_view_all' ) && ! empty( $can_view_roles ) ) {
|
325 |
+
$args['role__in'] = $can_view_roles;
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
return $args;
|
330 |
+
}
|
331 |
+
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Change default sorting at WP Users list table
|
335 |
+
*
|
336 |
+
* @param $query
|
337 |
+
* @return mixed
|
338 |
+
*/
|
339 |
+
public function sort_by_newest( $query ) {
|
340 |
+
global $pagenow;
|
341 |
+
|
342 |
+
if ( is_admin() && 'users.php' === $pagenow ) {
|
343 |
+
if ( ! isset( $_REQUEST['orderby'] ) ) {
|
344 |
+
$query->query_vars['order'] = 'desc';
|
345 |
+
$query->query_orderby = ' ORDER BY user_registered ' . ( 'desc' === $query->query_vars['order'] ? 'desc ' : 'asc ' ); //set sort order
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
return $query;
|
350 |
+
}
|
351 |
+
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Filter WP users by UM Status
|
355 |
+
*
|
356 |
+
* @param $query
|
357 |
+
* @return mixed
|
358 |
+
*/
|
359 |
+
public function filter_users_by_status( $query ) {
|
360 |
+
global $wpdb, $pagenow;
|
361 |
+
if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['um_status'] ) ) {
|
362 |
+
|
363 |
+
$status = sanitize_key( $_REQUEST['um_status'] );
|
364 |
+
|
365 |
+
if ( 'needs-verification' === $status ) {
|
366 |
+
$query->query_where = str_replace('WHERE 1=1',
|
367 |
+
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
368 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
369 |
+
WHERE {$wpdb->usermeta}.meta_key = '_um_verified'
|
370 |
+
AND {$wpdb->usermeta}.meta_value = 'pending')",
|
371 |
+
$query->query_where
|
372 |
+
);
|
373 |
+
} else {
|
374 |
+
$query->query_where = str_replace('WHERE 1=1',
|
375 |
+
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
376 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
377 |
+
WHERE {$wpdb->usermeta}.meta_key = 'account_status'
|
378 |
+
AND {$wpdb->usermeta}.meta_value = '{$status}')",
|
379 |
+
$query->query_where
|
380 |
+
);
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
return $query;
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Add status links to WP Users List Table
|
390 |
+
*
|
391 |
+
* @param $views
|
392 |
+
* @return array
|
393 |
+
*/
|
394 |
+
public function add_status_links( $views ) {
|
395 |
+
remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
396 |
+
|
397 |
+
$old_views = $views;
|
398 |
+
$views = array();
|
399 |
+
|
400 |
+
if ( ! isset( $_REQUEST['role'] ) && ! isset( $_REQUEST['um_status'] ) ) {
|
401 |
+
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '" class="current">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
|
402 |
+
} else {
|
403 |
+
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
|
404 |
+
}
|
405 |
+
|
406 |
+
$status = array(
|
407 |
+
'approved' => __( 'Approved', 'ultimate-member' ),
|
408 |
+
'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
|
409 |
+
'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
|
410 |
+
'inactive' => __( 'Inactive', 'ultimate-member' ),
|
411 |
+
'rejected' => __( 'Rejected', 'ultimate-member' ),
|
412 |
+
);
|
413 |
+
|
414 |
+
UM()->query()->count_users_by_status( 'unassigned' );
|
415 |
+
|
416 |
+
foreach ( $status as $k => $v ) {
|
417 |
+
if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) {
|
418 |
+
$current = 'class="current"';
|
419 |
+
} else {
|
420 |
+
$current = '';
|
421 |
+
}
|
422 |
+
|
423 |
+
$views[ $k ] = '<a href="' . esc_url( admin_url( 'users.php' ) . '?um_status=' . $k ) . '" ' . $current . '>' . $v . ' <span class="count">(' . UM()->query()->count_users_by_status( $k ) . ')</span></a>';
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* UM hook
|
428 |
+
*
|
429 |
+
* @type filter
|
430 |
+
* @title um_admin_views_users
|
431 |
+
* @description Admin views array
|
432 |
+
* @input_vars
|
433 |
+
* [{"var":"$views","type":"array","desc":"User Views"}]
|
434 |
+
* @change_log
|
435 |
+
* ["Since: 2.0"]
|
436 |
+
* @usage add_filter( 'um_admin_views_users', 'function_name', 10, 1 );
|
437 |
+
* @example
|
438 |
+
* <?php
|
439 |
+
* add_filter( 'um_admin_views_users', 'my_admin_views_users', 10, 1 );
|
440 |
+
* function my_admin_views_users( $views ) {
|
441 |
+
* // your code here
|
442 |
+
* return $views;
|
443 |
+
* }
|
444 |
+
* ?>
|
445 |
+
*/
|
446 |
+
$views = apply_filters( 'um_admin_views_users', $views );
|
447 |
+
|
448 |
+
// remove all filters
|
449 |
+
unset( $old_views['all'] );
|
450 |
+
|
451 |
+
// add separator
|
452 |
+
$views['subsep'] = '<span></span>';
|
453 |
+
|
454 |
+
// merge views
|
455 |
+
foreach ( $old_views as $key => $view ) {
|
456 |
+
$views[ $key ] = $view;
|
457 |
+
}
|
458 |
+
|
459 |
+
// hide filters with not accessible roles
|
460 |
+
if ( ! current_user_can( 'administrator' ) ) {
|
461 |
+
$wp_roles = wp_roles();
|
462 |
+
$can_view_roles = um_user( 'can_view_roles' );
|
463 |
+
if ( ! empty( $can_view_roles ) ) {
|
464 |
+
foreach ( $wp_roles->get_names() as $this_role => $name ) {
|
465 |
+
if ( ! in_array( $this_role, $can_view_roles, true ) ) {
|
466 |
+
unset( $views[ $this_role ] );
|
467 |
+
}
|
468 |
+
}
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
return $views;
|
473 |
+
}
|
474 |
+
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Bulk user editing actions
|
478 |
+
*/
|
479 |
+
public function um_bulk_users_edit() {
|
480 |
+
// bulk edit users
|
481 |
+
if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
|
482 |
+
|
483 |
+
$rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
|
484 |
+
$role = get_role( $rolename );
|
485 |
+
|
486 |
+
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
487 |
+
wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
|
488 |
+
}
|
489 |
+
|
490 |
+
check_admin_referer( 'bulk-users' );
|
491 |
+
|
492 |
+
$users = array_map( 'absint', (array) $_REQUEST['users'] );
|
493 |
+
$bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) );
|
494 |
+
|
495 |
+
foreach ( $users as $user_id ) {
|
496 |
+
UM()->user()->set( $user_id );
|
497 |
+
|
498 |
+
/**
|
499 |
+
* UM hook
|
500 |
+
*
|
501 |
+
* @type action
|
502 |
+
* @title um_admin_user_action_hook
|
503 |
+
* @description Action on bulk user action
|
504 |
+
* @input_vars
|
505 |
+
* [{"var":"$bulk_action","type":"string","desc":"Bulk Action"}]
|
506 |
+
* @change_log
|
507 |
+
* ["Since: 2.0"]
|
508 |
+
* @usage add_action( 'um_admin_user_action_hook{$action}', 'function_name', 10, 1 );
|
509 |
+
* @example
|
510 |
+
* <?php
|
511 |
+
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
512 |
+
* function my_admin_user_action( $bulk_action ) {
|
513 |
+
* // your code here
|
514 |
+
* }
|
515 |
+
* ?>
|
516 |
+
*/
|
517 |
+
do_action( 'um_admin_user_action_hook', $bulk_action );
|
518 |
+
|
519 |
+
/**
|
520 |
+
* UM hook
|
521 |
+
*
|
522 |
+
* @type action
|
523 |
+
* @title um_admin_user_action_{$bulk_action}_hook
|
524 |
+
* @description Action on bulk user action
|
525 |
+
* @change_log
|
526 |
+
* ["Since: 2.0"]
|
527 |
+
* @usage add_action( 'um_admin_user_action_{$bulk_action}_hook', 'function_name', 10 );
|
528 |
+
* @example
|
529 |
+
* <?php
|
530 |
+
* add_action( 'um_admin_user_action_{$bulk_action}_hook', 'my_admin_user_action', 10 );
|
531 |
+
* function my_admin_user_action() {
|
532 |
+
* // your code here
|
533 |
+
* }
|
534 |
+
* ?>
|
535 |
+
*/
|
536 |
+
do_action( "um_admin_user_action_{$bulk_action}_hook" );
|
537 |
+
}
|
538 |
+
|
539 |
+
// Finished. redirect now
|
540 |
+
//if ( $admin_err == 0 ) {
|
541 |
+
|
542 |
+
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
|
543 |
+
$uri = add_query_arg( 'update', 'users_updated', $uri );
|
544 |
+
|
545 |
+
wp_redirect( $uri );
|
546 |
+
exit;
|
547 |
+
|
548 |
+
/*} else {
|
549 |
+
wp_redirect( admin_url( 'users.php?update=err_users_updated' ) );
|
550 |
+
exit;
|
551 |
+
}*/
|
552 |
+
|
553 |
+
} elseif ( ! empty( $_REQUEST['um_bulkedit'] ) ) {
|
554 |
+
|
555 |
+
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
|
556 |
+
wp_redirect( $uri );
|
557 |
+
exit;
|
558 |
+
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
+
|
563 |
+
/**
|
564 |
+
* Sets redirect URI after bulk action
|
565 |
+
*
|
566 |
+
* @param string $uri
|
567 |
+
* @return string
|
568 |
+
*/
|
569 |
+
function set_redirect_uri( $uri ) {
|
570 |
+
|
571 |
+
if ( ! empty( $_REQUEST['s'] ) ) {
|
572 |
+
$uri = add_query_arg( 's', sanitize_text_field( $_REQUEST['s'] ), $uri );
|
573 |
+
}
|
574 |
+
|
575 |
+
if ( ! empty( $_REQUEST['um_status'] ) ) {
|
576 |
+
$uri = add_query_arg( 'um_status', sanitize_key( $_REQUEST['um_status'] ), $uri );
|
577 |
+
}
|
578 |
+
|
579 |
+
return $uri;
|
580 |
+
|
581 |
+
}
|
582 |
+
|
583 |
+
}
|
584 |
+
}
|
includes/core/class-fields.php
CHANGED
@@ -1,4868 +1,4868 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\Fields' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Fields
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class Fields {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var string
|
20 |
-
*/
|
21 |
-
var $set_mode = '';
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var int form_id
|
26 |
-
*/
|
27 |
-
public $set_id = null;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Fields constructor.
|
32 |
-
*/
|
33 |
-
function __construct() {
|
34 |
-
$this->editing = false;
|
35 |
-
$this->viewing = false;
|
36 |
-
$this->timestamp = current_time( 'timestamp' );
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Standard checkbox field
|
42 |
-
*
|
43 |
-
* @param integer $id
|
44 |
-
* @param string $title
|
45 |
-
* @param bool $checked
|
46 |
-
*/
|
47 |
-
function checkbox( $id, $title, $checked = true ) {
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Set value on form submission
|
51 |
-
*/
|
52 |
-
if ( isset( $_REQUEST[ $id ] ) ) {
|
53 |
-
$checked = (bool) $_REQUEST[ $id ];
|
54 |
-
}
|
55 |
-
|
56 |
-
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
57 |
-
|
58 |
-
?>
|
59 |
-
|
60 |
-
|
61 |
-
<div class="um-field um-field-c">
|
62 |
-
<div class="um-field-area">
|
63 |
-
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
64 |
-
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
65 |
-
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
66 |
-
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
67 |
-
</label>
|
68 |
-
</div>
|
69 |
-
</div>
|
70 |
-
|
71 |
-
<?php
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Shows social links
|
77 |
-
*/
|
78 |
-
function show_social_urls() {
|
79 |
-
$social = array();
|
80 |
-
|
81 |
-
$fields = UM()->builtin()->get_all_user_fields();
|
82 |
-
foreach ( $fields as $field => $args ) {
|
83 |
-
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
|
84 |
-
$social[ $field ] = $args;
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
foreach ( $social as $k => $arr ) {
|
89 |
-
if ( um_profile( $k ) ) { ?>
|
90 |
-
|
91 |
-
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
92 |
-
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
93 |
-
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
94 |
-
|
95 |
-
<?php
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Hidden field inside a shortcode
|
103 |
-
*
|
104 |
-
* @param string $field
|
105 |
-
*/
|
106 |
-
function add_hidden_field( $field ) {
|
107 |
-
echo '<div style="display: none !important;">';
|
108 |
-
|
109 |
-
$fields = UM()->builtin()->get_specific_fields( $field );
|
110 |
-
|
111 |
-
$output = null;
|
112 |
-
|
113 |
-
foreach ( $fields as $key => $data ) {
|
114 |
-
$output .= UM()->fields()->edit_field( $key, $data );
|
115 |
-
}
|
116 |
-
|
117 |
-
echo $output;
|
118 |
-
|
119 |
-
echo '</div>';
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Get hidden field
|
125 |
-
*
|
126 |
-
* @param string $key
|
127 |
-
* @param string $value
|
128 |
-
*
|
129 |
-
* @return string
|
130 |
-
*/
|
131 |
-
function disabled_hidden_field( $key, $value ) {
|
132 |
-
return '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '"/>';
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Updates a field globally
|
138 |
-
*
|
139 |
-
* @param integer $id
|
140 |
-
* @param array $args
|
141 |
-
*/
|
142 |
-
function globally_update_field( $id, $args ) {
|
143 |
-
$fields = UM()->builtin()->saved_fields;
|
144 |
-
|
145 |
-
$fields[ $id ] = $args;
|
146 |
-
|
147 |
-
unset( $fields[ $id ]['in_row'] );
|
148 |
-
unset( $fields[ $id ]['in_sub_row'] );
|
149 |
-
unset( $fields[ $id ]['in_column'] );
|
150 |
-
unset( $fields[ $id ]['in_group'] );
|
151 |
-
unset( $fields[ $id ]['position'] );
|
152 |
-
|
153 |
-
do_action( 'um_add_new_field', $id, $args );
|
154 |
-
|
155 |
-
update_option( 'um_fields', $fields );
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Updates a field in form only
|
161 |
-
*
|
162 |
-
* @param integer $id
|
163 |
-
* @param array $args
|
164 |
-
* @param integer $form_id
|
165 |
-
*/
|
166 |
-
function update_field( $id, $args, $form_id ) {
|
167 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
168 |
-
|
169 |
-
if ( $args['type'] == 'row' ) {
|
170 |
-
if ( isset( $fields[ $id ] ) ) {
|
171 |
-
$old_args = $fields[ $id ];
|
172 |
-
foreach ( $old_args as $k => $v ) {
|
173 |
-
if ( ! in_array( $k, array( 'sub_rows', 'cols' ) ) ) {
|
174 |
-
unset( $old_args[ $k ] );
|
175 |
-
}
|
176 |
-
}
|
177 |
-
$args = array_merge( $old_args, $args );
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
// custom fields support
|
182 |
-
if ( isset( UM()->builtin()->predefined_fields[ $id ] ) && isset( UM()->builtin()->predefined_fields[ $id ]['custom'] ) ) {
|
183 |
-
$args = array_merge( UM()->builtin()->predefined_fields[ $id ], $args );
|
184 |
-
}
|
185 |
-
|
186 |
-
$fields[ $id ] = $args;
|
187 |
-
|
188 |
-
// for group field only
|
189 |
-
if ( $args['type'] == 'group' ) {
|
190 |
-
$fields[ $id ]['in_group'] = '';
|
191 |
-
}
|
192 |
-
|
193 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Deletes a field in form only
|
199 |
-
*
|
200 |
-
* @param integer $id
|
201 |
-
* @param integer $form_id
|
202 |
-
*/
|
203 |
-
function delete_field_from_form( $id, $form_id ) {
|
204 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
205 |
-
|
206 |
-
if ( isset( $fields[ $id ] ) ) {
|
207 |
-
$condition_fields = get_option( 'um_fields' );
|
208 |
-
|
209 |
-
if( ! is_array( $condition_fields ) ) $condition_fields = array();
|
210 |
-
|
211 |
-
foreach ( $condition_fields as $key => $value ) {
|
212 |
-
$deleted_field = array_search( $id, $value );
|
213 |
-
|
214 |
-
if ( $key != $id && $deleted_field != false ) {
|
215 |
-
$deleted_field_id = str_replace( 'conditional_field', '', $deleted_field );
|
216 |
-
|
217 |
-
if ( $deleted_field_id == '' ) {
|
218 |
-
$arr_id = 0;
|
219 |
-
} else {
|
220 |
-
$arr_id = $deleted_field_id;
|
221 |
-
}
|
222 |
-
|
223 |
-
unset( $condition_fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
224 |
-
unset( $condition_fields[ $key ][ $deleted_field ] );
|
225 |
-
unset( $condition_fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
226 |
-
unset( $condition_fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
227 |
-
unset( $condition_fields[ $key ]['conditions'][ $arr_id ] );
|
228 |
-
|
229 |
-
unset( $fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
230 |
-
unset( $fields[ $key ][ $deleted_field ] );
|
231 |
-
unset( $fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
232 |
-
unset( $fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
233 |
-
unset( $fields[ $key ]['conditions'][ $arr_id ] );
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
update_option( 'um_fields' , $condition_fields );
|
238 |
-
unset( $fields[ $id ] );
|
239 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
240 |
-
}
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Deletes a field from custom fields
|
246 |
-
*
|
247 |
-
* @param integer $id
|
248 |
-
*/
|
249 |
-
function delete_field_from_db( $id ) {
|
250 |
-
$fields = UM()->builtin()->saved_fields;
|
251 |
-
if ( isset( $fields[ $id ] ) ) {
|
252 |
-
$args = $fields[ $id ];
|
253 |
-
|
254 |
-
unset( $fields[ $id ] );
|
255 |
-
|
256 |
-
do_action( 'um_delete_custom_field', $id, $args );
|
257 |
-
|
258 |
-
update_option( 'um_fields', $fields );
|
259 |
-
|
260 |
-
global $wpdb;
|
261 |
-
$forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
|
262 |
-
foreach ( $forms as $form_id ) {
|
263 |
-
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
264 |
-
unset( $form_fields[ $id ] );
|
265 |
-
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
266 |
-
}
|
267 |
-
|
268 |
-
$directories = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_directory'" );
|
269 |
-
foreach ( $directories as $directory_id ) {
|
270 |
-
// Frontend filters
|
271 |
-
$directory_search_fields = get_post_meta( $directory_id, '_um_search_fields', true );
|
272 |
-
$directory_search_fields = array_values( array_diff( $directory_search_fields, array( $id ) ) );
|
273 |
-
update_post_meta( $directory_id, '_um_search_fields', $directory_search_fields );
|
274 |
-
|
275 |
-
// Admin filtering
|
276 |
-
$directory_search_filters = get_post_meta( $directory_id, '_um_search_filters', true );
|
277 |
-
unset( $directory_search_filters[ $id ] );
|
278 |
-
update_post_meta( $directory_id, '_um_search_filters', $directory_search_filters );
|
279 |
-
|
280 |
-
// display in tagline
|
281 |
-
$directory_reveal_fields = get_post_meta( $directory_id, '_um_reveal_fields', true );
|
282 |
-
$directory_reveal_fields = array_values( array_diff( $directory_reveal_fields, array( $id ) ) );
|
283 |
-
update_post_meta( $directory_id, '_um_reveal_fields', $directory_reveal_fields );
|
284 |
-
|
285 |
-
// extra user information section
|
286 |
-
$directory_tagline_fields = get_post_meta( $directory_id, '_um_tagline_fields', true );
|
287 |
-
$directory_tagline_fields = array_values( array_diff( $directory_tagline_fields, array( $id ) ) );
|
288 |
-
update_post_meta( $directory_id, '_um_tagline_fields', $directory_tagline_fields );
|
289 |
-
|
290 |
-
// Custom fields selected in "Choose field(s) to enable in sorting"
|
291 |
-
$directory_sorting_fields = get_post_meta( $directory_id, '_um_sorting_fields', true );
|
292 |
-
foreach ( $directory_sorting_fields as $key => $sorting_data ) {
|
293 |
-
if ( is_array( $sorting_data ) && array_key_exists( $id, $sorting_data ) ) {
|
294 |
-
unset( $directory_sorting_fields[ $key ] );
|
295 |
-
}
|
296 |
-
}
|
297 |
-
$directory_sorting_fields = array_values( $directory_sorting_fields );
|
298 |
-
update_post_meta( $directory_id, '_um_sorting_fields', $directory_sorting_fields );
|
299 |
-
|
300 |
-
// If "Default sort users by" = "Other (Custom Field)" is selected when delete this custom field and set default sorting
|
301 |
-
$directory_sortby_custom = get_post_meta( $directory_id, '_um_sortby_custom', true );
|
302 |
-
if ( $directory_sortby_custom === $id ) {
|
303 |
-
$directory_sortby = get_post_meta( $directory_id, '_um_sortby', true );
|
304 |
-
if ( 'other' === $directory_sortby ) {
|
305 |
-
update_post_meta( $directory_id, '_um_sortby', 'user_registered_desc' );
|
306 |
-
}
|
307 |
-
update_post_meta( $directory_id, '_um_sortby_custom', '' );
|
308 |
-
update_post_meta( $directory_id, '_um_sortby_custom_label', '' );
|
309 |
-
}
|
310 |
-
}
|
311 |
-
|
312 |
-
}
|
313 |
-
}
|
314 |
-
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Quickly adds a field from custom fields
|
318 |
-
*
|
319 |
-
* @param integer $global_id
|
320 |
-
* @param integer $form_id
|
321 |
-
* @param array $position
|
322 |
-
*/
|
323 |
-
function add_field_from_list( $global_id, $form_id, $position = array() ) {
|
324 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
325 |
-
$field_scope = UM()->builtin()->saved_fields;
|
326 |
-
|
327 |
-
if ( ! isset( $fields[ $global_id ] ) ) {
|
328 |
-
|
329 |
-
$count = 1;
|
330 |
-
if ( ! empty( $fields ) ) {
|
331 |
-
$count = count( $fields ) + 1;
|
332 |
-
}
|
333 |
-
|
334 |
-
$fields[ $global_id ] = $field_scope[ $global_id ];
|
335 |
-
$fields[ $global_id ]['position'] = $count;
|
336 |
-
|
337 |
-
// set position
|
338 |
-
if ( $position ) {
|
339 |
-
foreach ( $position as $key => $val) {
|
340 |
-
$fields[ $global_id ][ $key ] = $val;
|
341 |
-
}
|
342 |
-
}
|
343 |
-
|
344 |
-
// add field to form
|
345 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
346 |
-
|
347 |
-
}
|
348 |
-
}
|
349 |
-
|
350 |
-
|
351 |
-
/**
|
352 |
-
* Quickly adds a field from pre-defined fields
|
353 |
-
*
|
354 |
-
* @param integer $global_id
|
355 |
-
* @param integer $form_id
|
356 |
-
* @param array $position
|
357 |
-
*/
|
358 |
-
function add_field_from_predefined( $global_id, $form_id, $position = array() ) {
|
359 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
360 |
-
$field_scope = UM()->builtin()->predefined_fields;
|
361 |
-
|
362 |
-
if ( ! isset( $fields[ $global_id ] ) ) {
|
363 |
-
|
364 |
-
$count = 1;
|
365 |
-
if ( ! empty( $fields ) ) {
|
366 |
-
$count = count( $fields ) + 1;
|
367 |
-
}
|
368 |
-
|
369 |
-
$fields[ $global_id ] = $field_scope[ $global_id ];
|
370 |
-
$fields[ $global_id ]['position'] = $count;
|
371 |
-
|
372 |
-
// set position
|
373 |
-
if ( $position ) {
|
374 |
-
foreach ( $position as $key => $val ) {
|
375 |
-
$fields[ $global_id ][ $key ] = $val;
|
376 |
-
}
|
377 |
-
}
|
378 |
-
|
379 |
-
// add field to form
|
380 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
381 |
-
}
|
382 |
-
}
|
383 |
-
|
384 |
-
|
385 |
-
/**
|
386 |
-
* Duplicates a frield by meta key
|
387 |
-
*
|
388 |
-
* @param integer $id
|
389 |
-
* @param integer $form_id
|
390 |
-
*/
|
391 |
-
function duplicate_field( $id, $form_id ) {
|
392 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
393 |
-
$all_fields = UM()->builtin()->saved_fields;
|
394 |
-
|
395 |
-
$inc = count( $fields ) + 1;
|
396 |
-
|
397 |
-
$duplicate = $fields[ $id ];
|
398 |
-
|
399 |
-
$new_metakey = $id . "_" . $inc;
|
400 |
-
$new_title = $fields[ $id ]['title'] . " #" . $inc;
|
401 |
-
$new_position = $inc;
|
402 |
-
|
403 |
-
$duplicate['title'] = $new_title;
|
404 |
-
$duplicate['metakey'] = $new_metakey;
|
405 |
-
$duplicate['position'] = $new_position;
|
406 |
-
|
407 |
-
$fields[ $new_metakey ] = $duplicate;
|
408 |
-
$all_fields[ $new_metakey ] = $duplicate;
|
409 |
-
|
410 |
-
// not global attributes
|
411 |
-
unset( $all_fields[ $new_metakey ]['in_row'] );
|
412 |
-
unset( $all_fields[ $new_metakey ]['in_sub_row'] );
|
413 |
-
unset( $all_fields[ $new_metakey ]['in_column'] );
|
414 |
-
unset( $all_fields[ $new_metakey ]['in_group'] );
|
415 |
-
unset( $all_fields[ $new_metakey ]['position'] );
|
416 |
-
|
417 |
-
|
418 |
-
do_action( 'um_add_new_field', $new_metakey, $duplicate );
|
419 |
-
|
420 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
421 |
-
update_option( 'um_fields', $all_fields );
|
422 |
-
}
|
423 |
-
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Print field error
|
427 |
-
*
|
428 |
-
* @param string $text
|
429 |
-
* @param bool $force_show
|
430 |
-
*
|
431 |
-
* @return string
|
432 |
-
*/
|
433 |
-
function field_error( $text, $force_show = false ) {
|
434 |
-
|
435 |
-
if ( empty( $text ) ) {
|
436 |
-
return '';
|
437 |
-
}
|
438 |
-
|
439 |
-
if ( $force_show ) {
|
440 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
441 |
-
return $output;
|
442 |
-
}
|
443 |
-
|
444 |
-
|
445 |
-
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
446 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
447 |
-
} else {
|
448 |
-
$output = '';
|
449 |
-
}
|
450 |
-
|
451 |
-
if ( ! UM()->form()->processing ) {
|
452 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
453 |
-
}
|
454 |
-
|
455 |
-
return $output;
|
456 |
-
}
|
457 |
-
|
458 |
-
|
459 |
-
/**
|
460 |
-
* Print field notice
|
461 |
-
*
|
462 |
-
* @param string $text
|
463 |
-
* @param bool $force_show
|
464 |
-
*
|
465 |
-
* @return string
|
466 |
-
*/
|
467 |
-
function field_notice( $text, $force_show = false ) {
|
468 |
-
|
469 |
-
if ( empty( $text ) ) {
|
470 |
-
return '';
|
471 |
-
}
|
472 |
-
|
473 |
-
if ( $force_show ) {
|
474 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
475 |
-
return $output;
|
476 |
-
}
|
477 |
-
|
478 |
-
|
479 |
-
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
480 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
481 |
-
} else {
|
482 |
-
$output = '';
|
483 |
-
}
|
484 |
-
|
485 |
-
if ( ! UM()->form()->processing ) {
|
486 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
487 |
-
}
|
488 |
-
|
489 |
-
return $output;
|
490 |
-
}
|
491 |
-
|
492 |
-
|
493 |
-
/**
|
494 |
-
* Checks if field has a server-side error
|
495 |
-
*
|
496 |
-
* @param string $key
|
497 |
-
*
|
498 |
-
* @return boolean
|
499 |
-
*/
|
500 |
-
function is_error( $key ) {
|
501 |
-
return UM()->form()->has_error( $key );
|
502 |
-
}
|
503 |
-
|
504 |
-
/**
|
505 |
-
* Checks if field has a notice
|
506 |
-
*
|
507 |
-
* @param string $key
|
508 |
-
*
|
509 |
-
* @return boolean
|
510 |
-
*/
|
511 |
-
function is_notice( $key ) {
|
512 |
-
return UM()->form()->has_notice( $key );
|
513 |
-
}
|
514 |
-
|
515 |
-
|
516 |
-
/**
|
517 |
-
* Returns field error
|
518 |
-
*
|
519 |
-
* @param string $key
|
520 |
-
*
|
521 |
-
* @return string
|
522 |
-
*/
|
523 |
-
function show_error( $key ) {
|
524 |
-
return UM()->form()->errors[ $key ];
|
525 |
-
}
|
526 |
-
|
527 |
-
/**
|
528 |
-
* Returns field notices
|
529 |
-
*
|
530 |
-
* @param string $key
|
531 |
-
*
|
532 |
-
* @return string
|
533 |
-
*/
|
534 |
-
function show_notice( $key ) {
|
535 |
-
return UM()->form()->notices[ $key ];
|
536 |
-
}
|
537 |
-
|
538 |
-
|
539 |
-
/**
|
540 |
-
* Display field label
|
541 |
-
*
|
542 |
-
* @param string $label
|
543 |
-
* @param string $key
|
544 |
-
* @param array $data
|
545 |
-
*
|
546 |
-
* @return string
|
547 |
-
*/
|
548 |
-
function field_label( $label, $key, $data ) {
|
549 |
-
$output = null;
|
550 |
-
$output .= '<div class="um-field-label">';
|
551 |
-
|
552 |
-
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
553 |
-
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
554 |
-
}
|
555 |
-
|
556 |
-
if ( $this->viewing == true ) {
|
557 |
-
/**
|
558 |
-
* UM hook
|
559 |
-
*
|
560 |
-
* @type filter
|
561 |
-
* @title um_view_label_{$key}
|
562 |
-
* @description Change field label on view by field $key
|
563 |
-
* @input_vars
|
564 |
-
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
565 |
-
* @change_log
|
566 |
-
* ["Since: 2.0"]
|
567 |
-
* @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 );
|
568 |
-
* @example
|
569 |
-
* <?php
|
570 |
-
* add_filter( 'um_view_label_{$key}', 'my_view_label', 10, 1 );
|
571 |
-
* function my_view_label( $label ) {
|
572 |
-
* // your code here
|
573 |
-
* return $label;
|
574 |
-
* }
|
575 |
-
* ?>
|
576 |
-
*/
|
577 |
-
$label = apply_filters( "um_view_label_{$key}", $label );
|
578 |
-
} else {
|
579 |
-
/**
|
580 |
-
* UM hook
|
581 |
-
*
|
582 |
-
* @type filter
|
583 |
-
* @title um_edit_label_{$key}
|
584 |
-
* @description Change field label on edit by field $key
|
585 |
-
* @input_vars
|
586 |
-
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
587 |
-
* @change_log
|
588 |
-
* ["Since: 2.0"]
|
589 |
-
* @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 );
|
590 |
-
* @example
|
591 |
-
* <?php
|
592 |
-
* add_filter( 'um_edit_label_{$key}', 'my_edit_label', 10, 1 );
|
593 |
-
* function my_edit_label( $label ) {
|
594 |
-
* // your code here
|
595 |
-
* return $label;
|
596 |
-
* }
|
597 |
-
* ?>
|
598 |
-
*/
|
599 |
-
$label = apply_filters( "um_edit_label_{$key}", $label );
|
600 |
-
/**
|
601 |
-
* UM hook
|
602 |
-
*
|
603 |
-
* @type filter
|
604 |
-
* @title um_edit_label_all_fields
|
605 |
-
* @description Change field label on view by field $key
|
606 |
-
* @input_vars
|
607 |
-
* [{"var":"$label","type":"string","desc":"Field Label"},
|
608 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
609 |
-
* @change_log
|
610 |
-
* ["Since: 2.0"]
|
611 |
-
* @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 );
|
612 |
-
* @example
|
613 |
-
* <?php
|
614 |
-
* add_filter( 'um_edit_label_all_fields', 'my_edit_label_all_fields', 10, 2 );
|
615 |
-
* function my_edit_label_all_fields( $label, $data ) {
|
616 |
-
* // your code here
|
617 |
-
* return $label;
|
618 |
-
* }
|
619 |
-
* ?>
|
620 |
-
*/
|
621 |
-
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
622 |
-
}
|
623 |
-
|
624 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
625 |
-
$for_attr = '';
|
626 |
-
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
|
627 |
-
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
628 |
-
}
|
629 |
-
|
630 |
-
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
631 |
-
|
632 |
-
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
633 |
-
|
634 |
-
if ( ! UM()->mobile()->isMobile() ) {
|
635 |
-
if ( ! isset( $this->disable_tooltips ) ) {
|
636 |
-
$output .= '<span class="um-tip um-tip-' . ( is_rtl() ? 'e' : 'w' ) . '" title="' . esc_attr__( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
637 |
-
}
|
638 |
-
}
|
639 |
-
|
640 |
-
if ( UM()->mobile()->isMobile() || isset( $this->disable_tooltips ) ) {
|
641 |
-
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
642 |
-
}
|
643 |
-
|
644 |
-
}
|
645 |
-
|
646 |
-
$output .= '<div class="um-clear"></div></div>';
|
647 |
-
|
648 |
-
return $output;
|
649 |
-
}
|
650 |
-
|
651 |
-
|
652 |
-
/**
|
653 |
-
* Output field classes
|
654 |
-
*
|
655 |
-
* @param string $key
|
656 |
-
* @param array $data
|
657 |
-
* @param string $add
|
658 |
-
*
|
659 |
-
* @return string
|
660 |
-
*/
|
661 |
-
function get_class( $key, $data, $add = null ) {
|
662 |
-
$classes = null;
|
663 |
-
|
664 |
-
$classes .= 'um-form-field ';
|
665 |
-
|
666 |
-
if ( $this->is_error( $key ) ) {
|
667 |
-
$classes .= 'um-error ';
|
668 |
-
} else {
|
669 |
-
$classes .= 'valid ';
|
670 |
-
}
|
671 |
-
|
672 |
-
if ( ! isset( $data['required'] ) ) {
|
673 |
-
$classes .= 'not-required ';
|
674 |
-
}
|
675 |
-
|
676 |
-
if ( $data['type'] == 'date' ) {
|
677 |
-
$classes .= 'um-datepicker ';
|
678 |
-
}
|
679 |
-
|
680 |
-
if ( $data['type'] == 'time' ) {
|
681 |
-
$classes .= 'um-timepicker ';
|
682 |
-
}
|
683 |
-
|
684 |
-
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
685 |
-
$classes .= 'um-iconed ';
|
686 |
-
}
|
687 |
-
|
688 |
-
if ( $add ) {
|
689 |
-
$classes .= $add . ' ';
|
690 |
-
}
|
691 |
-
|
692 |
-
/**
|
693 |
-
* UM hook
|
694 |
-
*
|
695 |
-
* @type filter
|
696 |
-
* @title um_extend_field_classes
|
697 |
-
* @description Change field classes
|
698 |
-
* @input_vars
|
699 |
-
* [{"var":"$classes","type":"string","desc":"Field Classes"},
|
700 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
701 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
702 |
-
* @change_log
|
703 |
-
* ["Since: 2.0"]
|
704 |
-
* @usage add_filter( 'um_extend_field_classes', 'function_name', 10, 3 );
|
705 |
-
* @example
|
706 |
-
* <?php
|
707 |
-
* add_filter( 'um_extend_field_classes', 'my_extend_field_classes', 10, 3 );
|
708 |
-
* function my_extend_field_classes( $classes, $key, $data ) {
|
709 |
-
* // your code here
|
710 |
-
* return $classes;
|
711 |
-
* }
|
712 |
-
* ?>
|
713 |
-
*/
|
714 |
-
$classes = apply_filters( 'um_extend_field_classes', $classes, $key, $data );
|
715 |
-
|
716 |
-
return $classes;
|
717 |
-
}
|
718 |
-
|
719 |
-
|
720 |
-
/**
|
721 |
-
* Gets field value
|
722 |
-
*
|
723 |
-
* @param string $key
|
724 |
-
* @param boolean $default
|
725 |
-
* @param array $data
|
726 |
-
*
|
727 |
-
* @return mixed
|
728 |
-
*/
|
729 |
-
function field_value( $key, $default = false, $data = null ) {
|
730 |
-
// preview in backend
|
731 |
-
if ( isset( UM()->user()->preview ) && UM()->user()->preview ) {
|
732 |
-
if ( $this->set_mode == 'login' || $this->set_mode == 'register' ) {
|
733 |
-
return '';
|
734 |
-
} else {
|
735 |
-
$val = um_user( $key );
|
736 |
-
if ( ! empty( $val ) ) {
|
737 |
-
return $val;
|
738 |
-
} else {
|
739 |
-
return '';
|
740 |
-
}
|
741 |
-
}
|
742 |
-
}
|
743 |
-
|
744 |
-
if ( isset( $_SESSION ) && isset( $_SESSION['um_social_profile'][ $key ] ) && isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
745 |
-
return $_SESSION['um_social_profile'][ $key ];
|
746 |
-
}
|
747 |
-
|
748 |
-
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
749 |
-
|
750 |
-
// normal state
|
751 |
-
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
752 |
-
//show empty value for password fields
|
753 |
-
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) {
|
754 |
-
return '';
|
755 |
-
}
|
756 |
-
|
757 |
-
if ( 'profile' === $this->set_mode ) {
|
758 |
-
if ( ! isset( UM()->form()->post_form['profile_nonce'] ) || false === wp_verify_nonce( UM()->form()->post_form['profile_nonce'], 'um-profile-nonce' . UM()->user()->target_id ) ) {
|
759 |
-
return '';
|
760 |
-
}
|
761 |
-
}
|
762 |
-
|
763 |
-
return stripslashes_deep( UM()->form()->post_form[ $key ] );
|
764 |
-
|
765 |
-
} elseif ( um_user( $key ) && $this->editing == true ) {
|
766 |
-
|
767 |
-
//show empty value for password fields
|
768 |
-
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
|
769 |
-
return '';
|
770 |
-
}
|
771 |
-
|
772 |
-
$value = um_user( $key );
|
773 |
-
/**
|
774 |
-
* UM hook
|
775 |
-
*
|
776 |
-
* @type filter
|
777 |
-
* @title um_edit_{$key}_field_value
|
778 |
-
* @description Change field value on edit by field $key
|
779 |
-
* @input_vars
|
780 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
781 |
-
* {"var":"$key","type":"string","desc":"Field Key"}]
|
782 |
-
* @change_log
|
783 |
-
* ["Since: 2.0"]
|
784 |
-
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
785 |
-
* @example
|
786 |
-
* <?php
|
787 |
-
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
788 |
-
* function my_edit_field_value( $value, $key ) {
|
789 |
-
* // your code here
|
790 |
-
* return $value;
|
791 |
-
* }
|
792 |
-
* ?>
|
793 |
-
*/
|
794 |
-
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
795 |
-
/**
|
796 |
-
* UM hook
|
797 |
-
*
|
798 |
-
* @type filter
|
799 |
-
* @title um_edit_{$type}_field_value
|
800 |
-
* @description Change field value on edit by field $type
|
801 |
-
* @input_vars
|
802 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
803 |
-
* {"var":"$key","type":"string","desc":"Field Key"}]
|
804 |
-
* @change_log
|
805 |
-
* ["Since: 2.0"]
|
806 |
-
* @usage add_filter( 'um_edit_{$type}_field_value', 'function_name', 10, 2 );
|
807 |
-
* @example
|
808 |
-
* <?php
|
809 |
-
* add_filter( 'um_edit_{$type}_field_value', 'my_edit_field_value', 10, 2 );
|
810 |
-
* function my_edit_field_value( $value, $key ) {
|
811 |
-
* // your code here
|
812 |
-
* return $value;
|
813 |
-
* }
|
814 |
-
* ?>
|
815 |
-
*/
|
816 |
-
$value = apply_filters( "um_edit_{$type}_field_value", $value, $key );
|
817 |
-
|
818 |
-
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) {
|
819 |
-
|
820 |
-
return um_filtered_value( $key, $data );
|
821 |
-
|
822 |
-
} elseif ( isset( UM()->user()->profile[ $key ] ) ) {
|
823 |
-
|
824 |
-
$value = UM()->user()->profile[ $key ];
|
825 |
-
/**
|
826 |
-
* UM hook
|
827 |
-
*
|
828 |
-
* @type filter
|
829 |
-
* @title um_edit_{$key}_field_value
|
830 |
-
* @description Change field value on edit by field $key
|
831 |
-
* @input_vars
|
832 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
833 |
-
* {"var":"$key","type":"string","desc":"Field Key"}]
|
834 |
-
* @change_log
|
835 |
-
* ["Since: 2.0"]
|
836 |
-
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
837 |
-
* @example
|
838 |
-
* <?php
|
839 |
-
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
840 |
-
* function my_edit_field_value( $value, $key ) {
|
841 |
-
* // your code here
|
842 |
-
* return $value;
|
843 |
-
* }
|
844 |
-
* ?>
|
845 |
-
*/
|
846 |
-
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
847 |
-
$value = maybe_unserialize( $value );
|
848 |
-
|
849 |
-
} elseif ( $default ) {
|
850 |
-
|
851 |
-
/**
|
852 |
-
* UM hook
|
853 |
-
*
|
854 |
-
* @type filter
|
855 |
-
* @title um_field_default_value
|
856 |
-
* @description Change field default value
|
857 |
-
* @input_vars
|
858 |
-
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
859 |
-
* {"var":"$data","type":"array","desc":"Field Data"},
|
860 |
-
* {"var":"$type","type":"string","desc":"Field Type"}]
|
861 |
-
* @change_log
|
862 |
-
* ["Since: 2.0"]
|
863 |
-
* @usage add_filter( 'um_field_default_value', 'function_name', 10, 2 );
|
864 |
-
* @example
|
865 |
-
* <?php
|
866 |
-
* add_filter( 'um_field_default_value', 'my_field_default_value', 10, 2 );
|
867 |
-
* function my_field_default_value( $default, $data, $type ) {
|
868 |
-
* // your code here
|
869 |
-
* return $default;
|
870 |
-
* }
|
871 |
-
* ?>
|
872 |
-
*/
|
873 |
-
$default = apply_filters( 'um_field_default_value', $default, $data, $type );
|
874 |
-
/**
|
875 |
-
* UM hook
|
876 |
-
*
|
877 |
-
* @type filter
|
878 |
-
* @title um_field_{$key}_default_value
|
879 |
-
* @description Change field default value by $key
|
880 |
-
* @input_vars
|
881 |
-
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
882 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
883 |
-
* @change_log
|
884 |
-
* ["Since: 2.0"]
|
885 |
-
* @usage add_filter( 'um_field_{$key}_default_value', 'function_name', 10, 2 );
|
886 |
-
* @example
|
887 |
-
* <?php
|
888 |
-
* add_filter( 'um_field_{$key}_default_value', 'my_field_default_value', 10, 2 );
|
889 |
-
* function my_field_default_value( $default, $data ) {
|
890 |
-
* // your code here
|
891 |
-
* return $default;
|
892 |
-
* }
|
893 |
-
* ?>
|
894 |
-
*/
|
895 |
-
$default = apply_filters( "um_field_{$key}_default_value", $default, $data );
|
896 |
-
/**
|
897 |
-
* UM hook
|
898 |
-
*
|
899 |
-
* @type filter
|
900 |
-
* @title um_field_{$type}_default_value
|
901 |
-
* @description Change field default value by $type
|
902 |
-
* @input_vars
|
903 |
-
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
904 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
905 |
-
* @change_log
|
906 |
-
* ["Since: 2.0"]
|
907 |
-
* @usage add_filter( 'um_field_{$type}_default_value', 'function_name', 10, 2 );
|
908 |
-
* @example
|
909 |
-
* <?php
|
910 |
-
* add_filter( 'um_field_{$type}_default_value', 'my_field_default_value', 10, 2 );
|
911 |
-
* function my_field_default_value( $default, $data ) {
|
912 |
-
* // your code here
|
913 |
-
* return $default;
|
914 |
-
* }
|
915 |
-
* ?>
|
916 |
-
*/
|
917 |
-
$default = apply_filters( "um_field_{$type}_default_value", $default, $data );
|
918 |
-
|
919 |
-
}
|
920 |
-
|
921 |
-
// Default Value for Registration Form and Profile Form editing
|
922 |
-
if ( ! isset( $value ) && ( $this->set_mode == 'register' || $this->editing == true ) ) {
|
923 |
-
|
924 |
-
/**
|
925 |
-
* UM hook
|
926 |
-
*
|
927 |
-
* @type filter
|
928 |
-
* @title um_edit_{$key}_field_value
|
929 |
-
* @description Change field value on edit by field $key
|
930 |
-
* @input_vars
|
931 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
932 |
-
* {"var":"$key","type":"string","desc":"Field Key"}]
|
933 |
-
* @change_log
|
934 |
-
* ["Since: 2.0"]
|
935 |
-
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
936 |
-
* @example
|
937 |
-
* <?php
|
938 |
-
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
939 |
-
* function my_edit_field_value( $value, $key ) {
|
940 |
-
* // your code here
|
941 |
-
* return $value;
|
942 |
-
* }
|
943 |
-
* ?>
|
944 |
-
*/
|
945 |
-
$value = apply_filters( "um_edit_{$key}_field_value", $default, $key );
|
946 |
-
|
947 |
-
} elseif ( isset( $value ) && is_array( $value ) && ! count( $value ) ) {
|
948 |
-
$value = '';
|
949 |
-
} elseif ( ! isset( $value ) ) {
|
950 |
-
$value = '';
|
951 |
-
}
|
952 |
-
|
953 |
-
|
954 |
-
/**
|
955 |
-
* UM hook
|
956 |
-
*
|
957 |
-
* @type filter
|
958 |
-
* @title um_field_value
|
959 |
-
* @description Change field value
|
960 |
-
* @input_vars
|
961 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
962 |
-
* {"var":"$key","type":"string","desc":"Field Key"},,
|
963 |
-
* {"var":"$type","type":"string","desc":"Field Type"}
|
964 |
-
* {"var":"$default","type":"string","desc":"Field Default Value"},
|
965 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
966 |
-
* @usage add_filter( 'um_field_value', 'function_name', 10, 5 );
|
967 |
-
*/
|
968 |
-
return apply_filters( 'um_field_value', $value, $default, $key, $type, $data );
|
969 |
-
}
|
970 |
-
|
971 |
-
|
972 |
-
/**
|
973 |
-
* Checks if an option is selected
|
974 |
-
*
|
975 |
-
* is used by Select, Multiselect and Checkbox fields
|
976 |
-
*
|
977 |
-
* @param string $key
|
978 |
-
* @param string $value
|
979 |
-
* @param array $data
|
980 |
-
*
|
981 |
-
* @return boolean
|
982 |
-
*/
|
983 |
-
function is_selected( $key, $value, $data ) {
|
984 |
-
global $wpdb;
|
985 |
-
|
986 |
-
/**
|
987 |
-
* UM hook
|
988 |
-
*
|
989 |
-
* @type filter
|
990 |
-
* @title um_is_selected_filter_key
|
991 |
-
* @description Change is selected filter key
|
992 |
-
* @input_vars
|
993 |
-
* [{"var":"$key","type":"string","desc":"Selected filter key"}]
|
994 |
-
* @change_log
|
995 |
-
* ["Since: 2.0"]
|
996 |
-
* @usage add_filter( 'um_is_selected_filter_key', 'function_name', 10, 1 );
|
997 |
-
* @example
|
998 |
-
* <?php
|
999 |
-
* add_filter( 'um_is_selected_filter_key', 'my_selected_filter_key', 10, 1 );
|
1000 |
-
* function my_selected_filter_key( $key ) {
|
1001 |
-
* // your code here
|
1002 |
-
* return $key;
|
1003 |
-
* }
|
1004 |
-
* ?>
|
1005 |
-
*/
|
1006 |
-
$key = apply_filters( 'um_is_selected_filter_key', $key );
|
1007 |
-
|
1008 |
-
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1009 |
-
|
1010 |
-
if ( is_array( UM()->form()->post_form[ $key ] ) ) {
|
1011 |
-
|
1012 |
-
if ( in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1013 |
-
return true;
|
1014 |
-
}
|
1015 |
-
|
1016 |
-
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
|
1017 |
-
if ( in_array( $value, $stripslashed ) ) {
|
1018 |
-
return true;
|
1019 |
-
}
|
1020 |
-
|
1021 |
-
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
|
1022 |
-
return true;
|
1023 |
-
}
|
1024 |
-
} else {
|
1025 |
-
|
1026 |
-
if ( $value == UM()->form()->post_form[ $key ] ) {
|
1027 |
-
return true;
|
1028 |
-
}
|
1029 |
-
|
1030 |
-
}
|
1031 |
-
|
1032 |
-
} else {
|
1033 |
-
|
1034 |
-
$field_value = um_user( $key );
|
1035 |
-
if ( ! $field_value ) {
|
1036 |
-
$field_value = 0;
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
if ( $field_value == 0 && $value == '0' ) {
|
1040 |
-
$value = (int) $value;
|
1041 |
-
}
|
1042 |
-
|
1043 |
-
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1044 |
-
$field_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1045 |
-
|
1046 |
-
$role_keys = get_option( 'um_roles', array() );
|
1047 |
-
|
1048 |
-
if ( ! empty( $role_keys ) ) {
|
1049 |
-
if ( in_array( $field_value, $role_keys ) ) {
|
1050 |
-
$field_value = 'um_' . $field_value;
|
1051 |
-
}
|
1052 |
-
}
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
|
1056 |
-
/**
|
1057 |
-
* UM hook
|
1058 |
-
*
|
1059 |
-
* @type filter
|
1060 |
-
* @title um_is_selected_filter_value
|
1061 |
-
* @description Change is selected filter value
|
1062 |
-
* @input_vars
|
1063 |
-
* [{"var":"$value","type":"string","desc":"Selected filter value"},
|
1064 |
-
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1065 |
-
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1066 |
-
* @change_log
|
1067 |
-
* ["Since: 2.0"]
|
1068 |
-
* @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 );
|
1069 |
-
* @example
|
1070 |
-
* <?php
|
1071 |
-
* add_filter( 'um_is_selected_filter_value', 'my_selected_filter_value', 10, 2 );
|
1072 |
-
* function my_selected_filter_value( $value, $key ) {
|
1073 |
-
* // your code here
|
1074 |
-
* return $field_value;
|
1075 |
-
* }
|
1076 |
-
* ?>
|
1077 |
-
*/
|
1078 |
-
$field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key, $value );
|
1079 |
-
|
1080 |
-
/**
|
1081 |
-
* UM hook
|
1082 |
-
*
|
1083 |
-
* @type filter
|
1084 |
-
* @title um_is_selected_filter_data
|
1085 |
-
* @description Change is selected filter data
|
1086 |
-
* @input_vars
|
1087 |
-
* [{"var":"$data","type":"array","desc":"Selected filter value"},
|
1088 |
-
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1089 |
-
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1090 |
-
* @change_log
|
1091 |
-
* ["Since: 2.0"]
|
1092 |
-
* @usage add_filter( 'um_is_selected_filter_data', 'function_name', 10, 3 );
|
1093 |
-
* @example
|
1094 |
-
* <?php
|
1095 |
-
* add_filter( 'um_is_selected_filter_data', 'my_selected_filter_data', 10, 3 );
|
1096 |
-
* function my_selected_filter_data( $data, $key, $value ) {
|
1097 |
-
* // your code here
|
1098 |
-
* return $data;
|
1099 |
-
* }
|
1100 |
-
* ?>
|
1101 |
-
*/
|
1102 |
-
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
1103 |
-
|
1104 |
-
if ( ! $this->editing || 'custom' == $this->set_mode ) {
|
1105 |
-
// show default on register screen if there is default
|
1106 |
-
if ( isset( $data['default'] ) ) {
|
1107 |
-
|
1108 |
-
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1109 |
-
return true;
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1113 |
-
return true;
|
1114 |
-
}
|
1115 |
-
|
1116 |
-
if ( is_array( $data['default'] ) && array_intersect( $data['options'], $data['default'] ) ) {
|
1117 |
-
return true;
|
1118 |
-
}
|
1119 |
-
|
1120 |
-
// default value with comma
|
1121 |
-
if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
|
1122 |
-
$choices = array_map( 'trim', explode( ',', $data['default'] ) );
|
1123 |
-
if ( in_array( $value, $choices ) ) {
|
1124 |
-
return true;
|
1125 |
-
}
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
}
|
1129 |
-
} else {
|
1130 |
-
|
1131 |
-
if ( $field_value && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) ) ) {
|
1132 |
-
return true;
|
1133 |
-
}
|
1134 |
-
|
1135 |
-
if ( $field_value == 0 && ! is_array( $field_value ) && $field_value === $value ) {
|
1136 |
-
return true;
|
1137 |
-
}
|
1138 |
-
|
1139 |
-
if ( $field_value && ! is_array( $field_value ) && $field_value == $value ) {
|
1140 |
-
return true;
|
1141 |
-
}
|
1142 |
-
|
1143 |
-
if ( $field_value && ! is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value ) ) {
|
1144 |
-
return true;
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
// show default on edit screen if there isn't meta row in usermeta table
|
1148 |
-
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1149 |
-
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) ) {
|
1150 |
-
if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
|
1151 |
-
$data['default'] = explode( ', ', $data['default'] );
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1155 |
-
return true;
|
1156 |
-
}
|
1157 |
-
|
1158 |
-
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1159 |
-
return true;
|
1160 |
-
}
|
1161 |
-
}
|
1162 |
-
}
|
1163 |
-
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
return false;
|
1167 |
-
}
|
1168 |
-
|
1169 |
-
|
1170 |
-
/**
|
1171 |
-
* Checks if a radio button is selected
|
1172 |
-
*
|
1173 |
-
* @param string $key
|
1174 |
-
* @param string $value
|
1175 |
-
* @param array $data
|
1176 |
-
*
|
1177 |
-
* @return boolean
|
1178 |
-
*/
|
1179 |
-
function is_radio_checked( $key, $value, $data ) {
|
1180 |
-
global $wpdb;
|
1181 |
-
|
1182 |
-
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1183 |
-
if ( is_array( UM()->form()->post_form[ $key ] ) && in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1184 |
-
return true;
|
1185 |
-
} elseif ( $value == UM()->form()->post_form[ $key ] ) {
|
1186 |
-
return true;
|
1187 |
-
}
|
1188 |
-
} else {
|
1189 |
-
|
1190 |
-
if ( $this->editing && 'custom' !== $this->set_mode ) {
|
1191 |
-
if ( um_user( $key ) ) {
|
1192 |
-
|
1193 |
-
$um_user_value = um_user( $key );
|
1194 |
-
|
1195 |
-
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1196 |
-
$um_user_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1197 |
-
|
1198 |
-
$role_keys = get_option( 'um_roles', array() );
|
1199 |
-
|
1200 |
-
if ( ! empty( $role_keys ) ) {
|
1201 |
-
if ( in_array( $um_user_value, $role_keys ) ) {
|
1202 |
-
$um_user_value = 'um_' . $um_user_value;
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
}
|
1206 |
-
|
1207 |
-
if ( $um_user_value == $value ) {
|
1208 |
-
return true;
|
1209 |
-
}
|
1210 |
-
|
1211 |
-
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
1212 |
-
return true;
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
if ( is_array( $um_user_value ) ) {
|
1216 |
-
foreach ( $um_user_value as $u ) {
|
1217 |
-
if ( $u == html_entity_decode( $value ) ) {
|
1218 |
-
return true;
|
1219 |
-
}
|
1220 |
-
}
|
1221 |
-
}
|
1222 |
-
} else {
|
1223 |
-
|
1224 |
-
// show default on edit screen if there isn't meta row in usermeta table
|
1225 |
-
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1226 |
-
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) && $data['default'] == $value ) {
|
1227 |
-
return true;
|
1228 |
-
}
|
1229 |
-
|
1230 |
-
}
|
1231 |
-
} else {
|
1232 |
-
if ( isset( $data['default'] ) && $data['default'] == $value ) {
|
1233 |
-
return true;
|
1234 |
-
}
|
1235 |
-
}
|
1236 |
-
}
|
1237 |
-
|
1238 |
-
return false;
|
1239 |
-
}
|
1240 |
-
|
1241 |
-
|
1242 |
-
/**
|
1243 |
-
* Get field icon
|
1244 |
-
*
|
1245 |
-
* @param string $key
|
1246 |
-
*
|
1247 |
-
* @return string
|
1248 |
-
*/
|
1249 |
-
function get_field_icon( $key ) {
|
1250 |
-
$fields = UM()->builtin()->all_user_fields;
|
1251 |
-
if ( isset( $fields[ $key ]['icon'] ) ) {
|
1252 |
-
return $fields[ $key ]['icon'];
|
1253 |
-
}
|
1254 |
-
|
1255 |
-
return '';
|
1256 |
-
}
|
1257 |
-
|
1258 |
-
|
1259 |
-
/**
|
1260 |
-
* Gets selected option value from a callback function
|
1261 |
-
*
|
1262 |
-
* @param string $value
|
1263 |
-
* @param array $data
|
1264 |
-
* @param string $type
|
1265 |
-
*
|
1266 |
-
* @return string
|
1267 |
-
*/
|
1268 |
-
function get_option_value_from_callback( $value, $data, $type ) {
|
1269 |
-
|
1270 |
-
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1271 |
-
|
1272 |
-
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1273 |
-
|
1274 |
-
if ( $has_custom_source ) {
|
1275 |
-
|
1276 |
-
$opts = apply_filters( "um_get_field__{$data['metakey']}", array() );
|
1277 |
-
$arr_options = $opts['options'];
|
1278 |
-
|
1279 |
-
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1280 |
-
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1281 |
-
$_POST['parent_option_name'] = $data['parent_dropdown_relationship'];
|
1282 |
-
$_POST['parent_option'] = um_user( $data['parent_dropdown_relationship'] );
|
1283 |
-
|
1284 |
-
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1285 |
-
} else {
|
1286 |
-
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1287 |
-
}
|
1288 |
-
}
|
1289 |
-
|
1290 |
-
if ( $has_custom_source || function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1291 |
-
if ( $type == 'select' ) {
|
1292 |
-
if ( ! empty( $arr_options[ $value ] ) ) {
|
1293 |
-
return $arr_options[ $value ];
|
1294 |
-
} elseif ( ! empty( $data['default'] ) && empty( $arr_options[ $value ] ) ) {
|
1295 |
-
return $arr_options[ $data['default'] ];
|
1296 |
-
} else {
|
1297 |
-
return '';
|
1298 |
-
}
|
1299 |
-
} elseif ( $type == 'multiselect' ) {
|
1300 |
-
|
1301 |
-
if ( is_array( $value ) ) {
|
1302 |
-
$values = $value;
|
1303 |
-
} else {
|
1304 |
-
$values = explode( ', ', $value );
|
1305 |
-
}
|
1306 |
-
|
1307 |
-
$arr_paired_options = array();
|
1308 |
-
|
1309 |
-
foreach ( $values as $option ) {
|
1310 |
-
if ( isset( $arr_options[ $option ] ) ) {
|
1311 |
-
$arr_paired_options[] = $arr_options[ $option ];
|
1312 |
-
}
|
1313 |
-
}
|
1314 |
-
|
1315 |
-
return implode( ', ', $arr_paired_options );
|
1316 |
-
}
|
1317 |
-
}
|
1318 |
-
|
1319 |
-
|
1320 |
-
}
|
1321 |
-
|
1322 |
-
return $value;
|
1323 |
-
}
|
1324 |
-
|
1325 |
-
|
1326 |
-
/**
|
1327 |
-
* Get select options from a callback function
|
1328 |
-
*
|
1329 |
-
* @param array $data
|
1330 |
-
* @param string $type
|
1331 |
-
*
|
1332 |
-
* @return array $arr_options
|
1333 |
-
*/
|
1334 |
-
function get_options_from_callback( $data, $type ) {
|
1335 |
-
$arr_options = array();
|
1336 |
-
|
1337 |
-
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1338 |
-
|
1339 |
-
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1340 |
-
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1341 |
-
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1342 |
-
} else {
|
1343 |
-
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1344 |
-
}
|
1345 |
-
}
|
1346 |
-
|
1347 |
-
}
|
1348 |
-
|
1349 |
-
return $arr_options;
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
|
1353 |
-
/**
|
1354 |
-
* Get field type
|
1355 |
-
*
|
1356 |
-
* @param string $key
|
1357 |
-
*
|
1358 |
-
* @return string
|
1359 |
-
*/
|
1360 |
-
function get_field_type( $key ) {
|
1361 |
-
$fields = UM()->builtin()->all_user_fields;
|
1362 |
-
if ( isset( $fields[ $key ]['type'] ) ) {
|
1363 |
-
return $fields[ $key ]['type'];
|
1364 |
-
}
|
1365 |
-
|
1366 |
-
return '';
|
1367 |
-
}
|
1368 |
-
|
1369 |
-
|
1370 |
-
/**
|
1371 |
-
* Get field label
|
1372 |
-
*
|
1373 |
-
* @param string $key
|
1374 |
-
*
|
1375 |
-
* @return string
|
1376 |
-
*/
|
1377 |
-
function get_label( $key ) {
|
1378 |
-
$label = '';
|
1379 |
-
|
1380 |
-
$fields = UM()->builtin()->all_user_fields;
|
1381 |
-
if ( isset( $fields[ $key ]['label'] ) ) {
|
1382 |
-
$label = stripslashes( $fields[ $key ]['label'] );
|
1383 |
-
}
|
1384 |
-
|
1385 |
-
if ( empty( $label ) && isset( $fields[ $key ]['title'] ) ) {
|
1386 |
-
$label = stripslashes( $fields[ $key ]['title'] );
|
1387 |
-
}
|
1388 |
-
|
1389 |
-
/**
|
1390 |
-
* UM hook
|
1391 |
-
*
|
1392 |
-
* @type filter
|
1393 |
-
* @title um_change_field_label
|
1394 |
-
* @description Change Field Label
|
1395 |
-
* @input_vars
|
1396 |
-
* [{"var":"$label","type":"string","desc":"Field Label"},
|
1397 |
-
* {"var":"$key","type":"string","desc":"Field Key"}]
|
1398 |
-
* @change_log
|
1399 |
-
* ["Since: 2.0.30"]
|
1400 |
-
* @usage add_filter( 'um_change_field_label', 'function_name', 10, 2 );
|
1401 |
-
* @example
|
1402 |
-
* <?php
|
1403 |
-
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 2 );
|
1404 |
-
* function my_form_fields( $label, $key ) {
|
1405 |
-
* // your code here
|
1406 |
-
* return $label;
|
1407 |
-
* }
|
1408 |
-
* ?>
|
1409 |
-
*/
|
1410 |
-
$label = apply_filters( 'um_change_field_label', $label, $key );
|
1411 |
-
|
1412 |
-
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
|
1413 |
-
return $label;
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
|
1417 |
-
/**
|
1418 |
-
* Get field title
|
1419 |
-
*
|
1420 |
-
* @param string $key
|
1421 |
-
*
|
1422 |
-
* @return string
|
1423 |
-
*/
|
1424 |
-
function get_field_title( $key ) {
|
1425 |
-
$fields = UM()->builtin()->all_user_fields;
|
1426 |
-
if ( isset( $fields[ $key ]['title'] ) ) {
|
1427 |
-
return $fields[ $key ]['title'];
|
1428 |
-
}
|
1429 |
-
if ( isset( $fields[ $key ]['label'] ) ) {
|
1430 |
-
return $fields[ $key ]['label'];
|
1431 |
-
}
|
1432 |
-
|
1433 |
-
return __( 'Custom Field', 'ultimate-member' );
|
1434 |
-
}
|
1435 |
-
|
1436 |
-
|
1437 |
-
/**
|
1438 |
-
* Get form fields
|
1439 |
-
*
|
1440 |
-
* @return array
|
1441 |
-
*/
|
1442 |
-
function get_fields() {
|
1443 |
-
/**
|
1444 |
-
* UM hook
|
1445 |
-
*
|
1446 |
-
* @type filter
|
1447 |
-
* @title um_get_form_fields
|
1448 |
-
* @description Extend form fields
|
1449 |
-
* @input_vars
|
1450 |
-
* [{"var":"$fields","type":"array","desc":"Selected filter value"}]
|
1451 |
-
* @change_log
|
1452 |
-
* ["Since: 2.0"]
|
1453 |
-
* @usage add_filter( 'um_get_form_fields', 'function_name', 10, 1 );
|
1454 |
-
* @example
|
1455 |
-
* <?php
|
1456 |
-
* add_filter( 'um_get_form_fields', 'my_form_fields', 10, 1 );
|
1457 |
-
* function my_form_fields( $fields ) {
|
1458 |
-
* // your code here
|
1459 |
-
* return $fields;
|
1460 |
-
* }
|
1461 |
-
* ?>
|
1462 |
-
*/
|
1463 |
-
$this->fields = apply_filters( 'um_get_form_fields', array() );
|
1464 |
-
return $this->fields;
|
1465 |
-
}
|
1466 |
-
|
1467 |
-
|
1468 |
-
/**
|
1469 |
-
* Get specific field
|
1470 |
-
*
|
1471 |
-
* @param $key
|
1472 |
-
*
|
1473 |
-
* @return mixed
|
1474 |
-
* @throws \Exception
|
1475 |
-
*/
|
1476 |
-
function get_field( $key ) {
|
1477 |
-
$fields = $this->get_fields();
|
1478 |
-
|
1479 |
-
if ( isset( $fields ) && is_array( $fields ) && isset( $fields[ $key ] ) ) {
|
1480 |
-
$array = $fields[ $key ];
|
1481 |
-
} else {
|
1482 |
-
if ( ! isset( UM()->builtin()->predefined_fields[ $key ] ) && ! isset( UM()->builtin()->all_user_fields[ $key ] ) ) {
|
1483 |
-
return '';
|
1484 |
-
}
|
1485 |
-
$array = ( isset( UM()->builtin()->predefined_fields[ $key ] ) ) ? UM()->builtin()->predefined_fields[ $key ] : UM()->builtin()->all_user_fields[ $key ];
|
1486 |
-
}
|
1487 |
-
|
1488 |
-
$array['classes'] = null;
|
1489 |
-
|
1490 |
-
if ( ! isset( $array['placeholder'] ) ) {
|
1491 |
-
$array['placeholder'] = null;
|
1492 |
-
}
|
1493 |
-
if ( ! isset( $array['required'] ) ) {
|
1494 |
-
$array['required'] = null;
|
1495 |
-
}
|
1496 |
-
if ( ! isset( $array['validate'] ) ) {
|
1497 |
-
$array['validate'] = null;
|
1498 |
-
}
|
1499 |
-
if ( ! isset( $array['default'] ) ) {
|
1500 |
-
$array['default'] = null;
|
1501 |
-
}
|
1502 |
-
|
1503 |
-
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && ! $this->viewing ) {
|
1504 |
-
$array['conditional'] = '';
|
1505 |
-
|
1506 |
-
foreach ( $array['conditions'] as $cond_id => $cond ) {
|
1507 |
-
$array['conditional'] .= ' data-cond-' . $cond_id . '-action="' . esc_attr( $cond[0] ) . '" data-cond-' . $cond_id . '-field="' . esc_attr( $cond[1] ) . '" data-cond-' . $cond_id . '-operator="' . esc_attr( $cond[2] ) . '" data-cond-' . $cond_id . '-value="' . esc_attr( $cond[3] ) . '"';
|
1508 |
-
}
|
1509 |
-
|
1510 |
-
$array['classes'] .= ' um-is-conditional';
|
1511 |
-
|
1512 |
-
} else {
|
1513 |
-
$array['conditional'] = null;
|
1514 |
-
}
|
1515 |
-
|
1516 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
1517 |
-
|
1518 |
-
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
|
1519 |
-
$array['classes'] .= ' um-field-' . esc_attr( $key );
|
1520 |
-
}
|
1521 |
-
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
|
1522 |
-
$array['classes'] .= ' um-field-type_' . esc_attr( $array['type'] );
|
1523 |
-
|
1524 |
-
switch ( $array['type'] ) {
|
1525 |
-
|
1526 |
-
case 'googlemap':
|
1527 |
-
case 'youtube_video':
|
1528 |
-
case 'vimeo_video':
|
1529 |
-
case 'soundcloud_track':
|
1530 |
-
$array['disabled'] = '';
|
1531 |
-
$array['input'] = 'text';
|
1532 |
-
break;
|
1533 |
-
|
1534 |
-
case 'text':
|
1535 |
-
|
1536 |
-
$array['disabled'] = '';
|
1537 |
-
|
1538 |
-
if ( $key == 'user_login' && isset( $this->set_mode ) && $this->set_mode == 'account' ) {
|
1539 |
-
$array['disabled'] = 'disabled="disabled"';
|
1540 |
-
}
|
1541 |
-
|
1542 |
-
$array['input'] = 'text';
|
1543 |
-
|
1544 |
-
break;
|
1545 |
-
|
1546 |
-
case 'password':
|
1547 |
-
|
1548 |
-
$array['input'] = 'password';
|
1549 |
-
|
1550 |
-
break;
|
1551 |
-
|
1552 |
-
case 'number':
|
1553 |
-
|
1554 |
-
$array['disabled'] = '';
|
1555 |
-
|
1556 |
-
break;
|
1557 |
-
|
1558 |
-
case 'url':
|
1559 |
-
|
1560 |
-
$array['input'] = 'text';
|
1561 |
-
|
1562 |
-
break;
|
1563 |
-
|
1564 |
-
case 'date':
|
1565 |
-
|
1566 |
-
$array['input'] = 'text';
|
1567 |
-
|
1568 |
-
if ( ! isset( $array['format'] ) ) {
|
1569 |
-
$array['format'] = 'j M Y';
|
1570 |
-
}
|
1571 |
-
|
1572 |
-
switch ( $array['format'] ) {
|
1573 |
-
case 'j M Y':
|
1574 |
-
$js_format = 'd mmm yyyy';
|
1575 |
-
break;
|
1576 |
-
case 'j F Y':
|
1577 |
-
$js_format = 'd mmmm yyyy';
|
1578 |
-
break;
|
1579 |
-
case 'M j Y':
|
1580 |
-
$js_format = 'mmm d yyyy';
|
1581 |
-
break;
|
1582 |
-
case 'F j Y':
|
1583 |
-
$js_format = 'mmmm d yyyy';
|
1584 |
-
break;
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
$array['js_format'] = $js_format;
|
1588 |
-
|
1589 |
-
if ( ! isset( $array['range'] ) ) {
|
1590 |
-
$array['range'] = 'years';
|
1591 |
-
}
|
1592 |
-
if ( ! isset( $array['years'] ) ) {
|
1593 |
-
$array['years'] = 100;
|
1594 |
-
}
|
1595 |
-
if ( ! isset( $array['years_x'] ) ) {
|
1596 |
-
$array['years_x'] = 'past';
|
1597 |
-
}
|
1598 |
-
if ( ! isset( $array['disabled_weekdays'] ) ) {
|
1599 |
-
$array['disabled_weekdays'] = '';
|
1600 |
-
}
|
1601 |
-
|
1602 |
-
if ( ! empty( $array['disabled_weekdays'] ) ) {
|
1603 |
-
$array['disabled_weekdays'] = '[' . implode( ',', $array['disabled_weekdays'] ) . ']';
|
1604 |
-
}
|
1605 |
-
|
1606 |
-
// When date range is strictly defined
|
1607 |
-
if ( $array['range'] == 'date_range' ) {
|
1608 |
-
|
1609 |
-
$array['date_min'] = str_replace( '/', ',', $array['range_start'] );
|
1610 |
-
$array['date_max'] = str_replace( '/', ',', $array['range_end'] );
|
1611 |
-
|
1612 |
-
} else {
|
1613 |
-
|
1614 |
-
if ( $array['years_x'] == 'past' ) {
|
1615 |
-
|
1616 |
-
$date = new \DateTime( date( 'Y-n-d' ) );
|
1617 |
-
$past = $date->modify( '-' . $array['years'] . ' years' );
|
1618 |
-
$past = $date->format( 'Y,n,d' );
|
1619 |
-
|
1620 |
-
$array['date_min'] = $past;
|
1621 |
-
$array['date_max'] = date( 'Y,n,d' );
|
1622 |
-
|
1623 |
-
} elseif ( $array['years_x'] == 'future' ) {
|
1624 |
-
|
1625 |
-
$date = new \DateTime( date( 'Y-n-d' ) );
|
1626 |
-
$future = $date->modify( '+' . $array['years'] . ' years' );
|
1627 |
-
$future = $date->format( 'Y,n,d' );
|
1628 |
-
|
1629 |
-
$array['date_min'] = date( 'Y,n,d' );
|
1630 |
-
$array['date_max'] = $future;
|
1631 |
-
|
1632 |
-
} else {
|
1633 |
-
|
1634 |
-
$date = new \DateTime( date( 'Y-n-d' ) );
|
1635 |
-
$date_f = new \DateTime( date( 'Y-n-d' ) );
|
1636 |
-
$past = $date->modify( '-' . ( $array['years'] / 2 ) . ' years' );
|
1637 |
-
$past = $date->format( 'Y,n,d' );
|
1638 |
-
$future = $date_f->modify( '+' . ( $array['years'] / 2 ) . ' years' );
|
1639 |
-
$future = $date_f->format( 'Y,n,d' );
|
1640 |
-
|
1641 |
-
$array['date_min'] = $past;
|
1642 |
-
$array['date_max'] = $future;
|
1643 |
-
|
1644 |
-
}
|
1645 |
-
|
1646 |
-
}
|
1647 |
-
|
1648 |
-
break;
|
1649 |
-
|
1650 |
-
case 'time':
|
1651 |
-
|
1652 |
-
$array['input'] = 'text';
|
1653 |
-
|
1654 |
-
if ( ! isset( $array['format'] ) ) {
|
1655 |
-
$array['format'] = 'g:i a';
|
1656 |
-
}
|
1657 |
-
|
1658 |
-
switch ( $array['format'] ) {
|
1659 |
-
case 'g:i a':
|
1660 |
-
$js_format = 'h:i a';
|
1661 |
-
break;
|
1662 |
-
case 'g:i A':
|
1663 |
-
$js_format = 'h:i A';
|
1664 |
-
break;
|
1665 |
-
case 'H:i':
|
1666 |
-
$js_format = 'HH:i';
|
1667 |
-
break;
|
1668 |
-
}
|
1669 |
-
|
1670 |
-
$array['js_format'] = $js_format;
|
1671 |
-
|
1672 |
-
if ( ! isset( $array['intervals'] ) ) {
|
1673 |
-
$array['intervals'] = 60;
|
1674 |
-
}
|
1675 |
-
|
1676 |
-
break;
|
1677 |
-
|
1678 |
-
case 'textarea':
|
1679 |
-
|
1680 |
-
if ( ! isset( $array['height'] ) ) {
|
1681 |
-
$array['height'] = '100px';
|
1682 |
-
}
|
1683 |
-
|
1684 |
-
break;
|
1685 |
-
|
1686 |
-
case 'rating':
|
1687 |
-
|
1688 |
-
if ( ! isset( $array['number'] ) ) {
|
1689 |
-
$array['number'] = 5;
|
1690 |
-
}
|
1691 |
-
|
1692 |
-
break;
|
1693 |
-
|
1694 |
-
case 'spacing':
|
1695 |
-
|
1696 |
-
if ( ! isset( $array['spacing'] ) ) {
|
1697 |
-
$array['spacing'] = '20px';
|
1698 |
-
}
|
1699 |
-
|
1700 |
-
break;
|
1701 |
-
|
1702 |
-
case 'divider':
|
1703 |
-
|
1704 |
-
if ( isset( $array['width'] ) ) {
|
1705 |
-
$array['borderwidth'] = $array['width'];
|
1706 |
-
} else {
|
1707 |
-
$array['borderwidth'] = 4;
|
1708 |
-
}
|
1709 |
-
|
1710 |
-
if ( isset( $array['color'] ) ) {
|
1711 |
-
$array['bordercolor'] = $array['color'];
|
1712 |
-
} else {
|
1713 |
-
$array['bordercolor'] = '#eee';
|
1714 |
-
}
|
1715 |
-
|
1716 |
-
if ( isset( $array['style'] ) ) {
|
1717 |
-
$array['borderstyle'] = $array['style'];
|
1718 |
-
} else {
|
1719 |
-
$array['borderstyle'] = 'solid';
|
1720 |
-
}
|
1721 |
-
|
1722 |
-
if ( ! isset( $array['divider_text'] ) ) {
|
1723 |
-
$array['divider_text'] = '';
|
1724 |
-
}
|
1725 |
-
|
1726 |
-
break;
|
1727 |
-
|
1728 |
-
case 'image':
|
1729 |
-
|
1730 |
-
if ( ! isset( $array['crop'] ) ) {
|
1731 |
-
$array['crop'] = 0;
|
1732 |
-
}
|
1733 |
-
|
1734 |
-
if ( $array['crop'] == 0 ) {
|
1735 |
-
$array['crop_data'] = 0;
|
1736 |
-
} elseif ( $array['crop'] == 1 ) {
|
1737 |
-
$array['crop_data'] = 'square';
|
1738 |
-
} elseif ( $array['crop'] == 2 ) {
|
1739 |
-
$array['crop_data'] = 'cover';
|
1740 |
-
} else {
|
1741 |
-
$array['crop_data'] = 'user';
|
1742 |
-
}
|
1743 |
-
|
1744 |
-
if ( ! isset( $array['modal_size'] ) ) {
|
1745 |
-
$array['modal_size'] = 'normal';
|
1746 |
-
}
|
1747 |
-
|
1748 |
-
if ( $array['crop'] > 0 ) {
|
1749 |
-
$array['crop_class'] = 'crop';
|
1750 |
-
} else {
|
1751 |
-
$array['crop_class'] = '';
|
1752 |
-
}
|
1753 |
-
|
1754 |
-
if ( ! isset( $array['ratio'] ) ) {
|
1755 |
-
$array['ratio'] = 1.0;
|
1756 |
-
}
|
1757 |
-
|
1758 |
-
if ( ! isset( $array['min_width'] ) ) {
|
1759 |
-
$array['min_width'] = '';
|
1760 |
-
}
|
1761 |
-
if ( ! isset( $array['min_height'] ) ) {
|
1762 |
-
$array['min_height'] = '';
|
1763 |
-
}
|
1764 |
-
|
1765 |
-
if ( $array['min_width'] == '' && $array['crop'] == 1 ) {
|
1766 |
-
$array['min_width'] = 600;
|
1767 |
-
}
|
1768 |
-
if ( $array['min_height'] == '' && $array['crop'] == 1 ) {
|
1769 |
-
$array['min_height'] = 600;
|
1770 |
-
}
|
1771 |
-
|
1772 |
-
if ( $array['min_width'] == '' && $array['crop'] == 3 ) {
|
1773 |
-
$array['min_width'] = 600;
|
1774 |
-
}
|
1775 |
-
if ( $array['min_height'] == '' && $array['crop'] == 3 ) {
|
1776 |
-
$array['min_height'] = 600;
|
1777 |
-
}
|
1778 |
-
|
1779 |
-
if ( ! isset( $array['invalid_image'] ) ) {
|
1780 |
-
$array['invalid_image'] = __( 'Please upload a valid image!', 'ultimate-member' );
|
1781 |
-
}
|
1782 |
-
if ( ! isset( $array['allowed_types'] ) ) {
|
1783 |
-
$array['allowed_types'] = 'gif,jpg,jpeg,png';
|
1784 |
-
} else {
|
1785 |
-
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1786 |
-
}
|
1787 |
-
if ( ! isset( $array['upload_text'] ) ) {
|
1788 |
-
$array['upload_text'] = '';
|
1789 |
-
}
|
1790 |
-
if ( ! isset( $array['button_text'] ) ) {
|
1791 |
-
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1792 |
-
}
|
1793 |
-
if ( ! isset( $array['extension_error'] ) ) {
|
1794 |
-
$array['extension_error'] = __( 'Sorry this is not a valid image.', 'ultimate-member' );
|
1795 |
-
}
|
1796 |
-
if ( ! isset( $array['max_size_error'] ) ) {
|
1797 |
-
$array['max_size_error'] = __( 'This image is too large!', 'ultimate-member' );
|
1798 |
-
}
|
1799 |
-
if ( ! isset( $array['min_size_error'] ) ) {
|
1800 |
-
$array['min_size_error'] = __( 'This image is too small!', 'ultimate-member' );
|
1801 |
-
}
|
1802 |
-
if ( ! isset( $array['max_files_error'] ) ) {
|
1803 |
-
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1804 |
-
}
|
1805 |
-
if ( empty( $array['max_size'] ) ) {
|
1806 |
-
$array['max_size'] = 999999999;
|
1807 |
-
}
|
1808 |
-
if ( ! isset( $array['upload_help_text'] ) ) {
|
1809 |
-
$array['upload_help_text'] = '';
|
1810 |
-
}
|
1811 |
-
if ( ! isset( $array['icon'] ) ) {
|
1812 |
-
$array['icon'] = '';
|
1813 |
-
}
|
1814 |
-
|
1815 |
-
break;
|
1816 |
-
|
1817 |
-
case 'file':
|
1818 |
-
|
1819 |
-
if ( ! isset( $array['modal_size'] ) ) {
|
1820 |
-
$array['modal_size'] = 'normal';
|
1821 |
-
}
|
1822 |
-
|
1823 |
-
if ( ! isset( $array['allowed_types'] ) ) {
|
1824 |
-
$array['allowed_types'] = 'pdf,txt';
|
1825 |
-
} else {
|
1826 |
-
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1827 |
-
}
|
1828 |
-
if ( ! isset( $array['upload_text'] ) ) {
|
1829 |
-
$array['upload_text'] = '';
|
1830 |
-
}
|
1831 |
-
if ( ! isset( $array['button_text'] ) ) {
|
1832 |
-
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1833 |
-
}
|
1834 |
-
if ( ! isset( $array['extension_error'] ) ) {
|
1835 |
-
$array['extension_error'] = __( 'Sorry this is not a valid file.', 'ultimate-member' );
|
1836 |
-
}
|
1837 |
-
if ( ! isset( $array['max_size_error'] ) ) {
|
1838 |
-
$array['max_size_error'] = __( 'This file is too large!', 'ultimate-member' );
|
1839 |
-
}
|
1840 |
-
if ( ! isset( $array['min_size_error'] ) ) {
|
1841 |
-
$array['min_size_error'] = __( 'This file is too small!', 'ultimate-member' );
|
1842 |
-
}
|
1843 |
-
if ( ! isset( $array['max_files_error'] ) ) {
|
1844 |
-
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1845 |
-
}
|
1846 |
-
if ( empty( $array['max_size'] ) ) {
|
1847 |
-
$array['max_size'] = 999999999;
|
1848 |
-
}
|
1849 |
-
if ( ! isset( $array['upload_help_text'] ) ) {
|
1850 |
-
$array['upload_help_text'] = '';
|
1851 |
-
}
|
1852 |
-
if ( ! isset( $array['icon'] ) ) {
|
1853 |
-
$array['icon'] = '';
|
1854 |
-
}
|
1855 |
-
|
1856 |
-
break;
|
1857 |
-
|
1858 |
-
case 'select':
|
1859 |
-
|
1860 |
-
break;
|
1861 |
-
|
1862 |
-
case 'multiselect':
|
1863 |
-
|
1864 |
-
break;
|
1865 |
-
|
1866 |
-
case 'group':
|
1867 |
-
|
1868 |
-
if ( ! isset( $array['max_entries'] ) ) {
|
1869 |
-
$array['max_entries'] = 0;
|
1870 |
-
}
|
1871 |
-
|
1872 |
-
break;
|
1873 |
-
|
1874 |
-
}
|
1875 |
-
|
1876 |
-
if ( ! isset( $array['visibility'] ) ) {
|
1877 |
-
$array['visibility'] = 'all';
|
1878 |
-
}
|
1879 |
-
|
1880 |
-
/**
|
1881 |
-
* UM hook
|
1882 |
-
*
|
1883 |
-
* @type filter
|
1884 |
-
* @title um_get_field__{$key}
|
1885 |
-
* @description Extend field data by field $key
|
1886 |
-
* @input_vars
|
1887 |
-
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
1888 |
-
* @change_log
|
1889 |
-
* ["Since: 2.0"]
|
1890 |
-
* @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 );
|
1891 |
-
* @example
|
1892 |
-
* <?php
|
1893 |
-
* add_filter( 'um_get_field__{$key}', 'my_get_field', 10, 1 );
|
1894 |
-
* function my_get_field( $data ) {
|
1895 |
-
* // your code here
|
1896 |
-
* return $data;
|
1897 |
-
* }
|
1898 |
-
* ?>
|
1899 |
-
*/
|
1900 |
-
$array = apply_filters( "um_get_field__{$key}", $array );
|
1901 |
-
|
1902 |
-
return $array;
|
1903 |
-
}
|
1904 |
-
|
1905 |
-
|
1906 |
-
/**
|
1907 |
-
* @param $option_value
|
1908 |
-
*
|
1909 |
-
* @return mixed|void
|
1910 |
-
*/
|
1911 |
-
function filter_field_non_utf8_value( $option_value ) {
|
1912 |
-
/**
|
1913 |
-
* UM hook
|
1914 |
-
*
|
1915 |
-
* @type filter
|
1916 |
-
* @title um_field_non_utf8_value
|
1917 |
-
* @description Change dropdown option text
|
1918 |
-
* @input_vars
|
1919 |
-
* [{"var":"$value","type":"string","desc":"Option Value"}]
|
1920 |
-
* @change_log
|
1921 |
-
* ["Since: 2.0"]
|
1922 |
-
* @usage add_filter( 'um_field_non_utf8_value', 'function_name', 10, 1 );
|
1923 |
-
* @example
|
1924 |
-
* <?php
|
1925 |
-
* add_filter( 'um_field_non_utf8_value', 'my_field_non_utf8_value', 10, 1 );
|
1926 |
-
* function my_field_non_utf8_value( $value ) {
|
1927 |
-
* // your code here
|
1928 |
-
* return $value;
|
1929 |
-
* }
|
1930 |
-
* ?>
|
1931 |
-
*/
|
1932 |
-
return apply_filters( 'um_field_non_utf8_value', $option_value );
|
1933 |
-
}
|
1934 |
-
|
1935 |
-
|
1936 |
-
/**
|
1937 |
-
* Getting the fields that need to be disabled in edit mode (profile)
|
1938 |
-
*
|
1939 |
-
* @param bool $_um_profile_id
|
1940 |
-
*
|
1941 |
-
* @return array
|
1942 |
-
*/
|
1943 |
-
function get_restricted_fields_for_edit( $_um_profile_id = false ) {
|
1944 |
-
// fields that need to be disabled in edit mode (profile)
|
1945 |
-
$arr_restricted_fields = array( 'user_email', 'username', 'user_login', 'user_password', '_um_last_login' );
|
1946 |
-
$arr_restricted_fields = apply_filters( 'um_user_profile_restricted_edit_fields', $arr_restricted_fields, $_um_profile_id );
|
1947 |
-
|
1948 |
-
return $arr_restricted_fields;
|
1949 |
-
}
|
1950 |
-
|
1951 |
-
|
1952 |
-
/**
|
1953 |
-
* Gets a field in 'input mode'
|
1954 |
-
*
|
1955 |
-
* @param string $key
|
1956 |
-
* @param array $data
|
1957 |
-
* @param bool $rule
|
1958 |
-
* @param array $args
|
1959 |
-
*
|
1960 |
-
* @return string|null
|
1961 |
-
* @throws \Exception
|
1962 |
-
*/
|
1963 |
-
function edit_field( $key, $data, $rule = false, $args = array() ) {
|
1964 |
-
global $_um_profile_id;
|
1965 |
-
|
1966 |
-
$output = '';
|
1967 |
-
$disabled = '';
|
1968 |
-
if ( empty( $_um_profile_id ) ) {
|
1969 |
-
$_um_profile_id = um_user( 'ID' );
|
1970 |
-
}
|
1971 |
-
|
1972 |
-
// get whole field data
|
1973 |
-
if ( isset( $data ) && is_array( $data ) ) {
|
1974 |
-
$data = $this->get_field( $key );
|
1975 |
-
if ( is_array( $data ) ) {
|
1976 |
-
/**
|
1977 |
-
* @var string $in_row
|
1978 |
-
* @var boolean $in_sub_row
|
1979 |
-
* @var boolean $in_column
|
1980 |
-
* @var string $type
|
1981 |
-
* @var string $metakey
|
1982 |
-
* @var int $position
|
1983 |
-
* @var string $title
|
1984 |
-
* @var string $help
|
1985 |
-
* @var array $options
|
1986 |
-
* @var string $visibility
|
1987 |
-
* @var string $label
|
1988 |
-
* @var string $placeholder
|
1989 |
-
* @var boolean $public
|
1990 |
-
* @var boolean $editable
|
1991 |
-
* @var string $icon
|
1992 |
-
* @var boolean $in_group
|
1993 |
-
* @var boolean $required
|
1994 |
-
* @var string $validate
|
1995 |
-
* @var string $default
|
1996 |
-
* @var string $conditional
|
1997 |
-
* @var string $input
|
1998 |
-
* @var string $js_format
|
1999 |
-
* @var string $date_max
|
2000 |
-
* @var string $date_min
|
2001 |
-
* @var string $disabled_weekdays
|
2002 |
-
* @var string $years_x
|
2003 |
-
* @var string $years
|
2004 |
-
* @var string $range
|
2005 |
-
* @var string $intervals
|
2006 |
-
* @var string $height
|
2007 |
-
* @var string $spacing
|
2008 |
-
* @var string $borderwidth
|
2009 |
-
* @var string $borderstyle
|
2010 |
-
* @var string $bordercolor
|
2011 |
-
* @var string $divider_text
|
2012 |
-
* @var string $crop_class
|
2013 |
-
* @var string $crop_data
|
2014 |
-
* @var string $modal_size
|
2015 |
-
* @var string $ratio
|
2016 |
-
* @var string $min_width
|
2017 |
-
* @var string $min_height
|
2018 |
-
* @var string $button_text
|
2019 |
-
* @var string $max_size
|
2020 |
-
* @var string $max_size_error
|
2021 |
-
* @var string $extension_error
|
2022 |
-
* @var string $allowed_types
|
2023 |
-
* @var string $upload_text
|
2024 |
-
* @var string $max_files_error
|
2025 |
-
* @var string $upload_help_text
|
2026 |
-
* @var string $min_size_error
|
2027 |
-
* @var string $filter
|
2028 |
-
* @var string $content
|
2029 |
-
* @var string $max_entries
|
2030 |
-
*/
|
2031 |
-
extract( $data );
|
2032 |
-
}
|
2033 |
-
}
|
2034 |
-
|
2035 |
-
if ( ! isset( $data['type'] ) ) {
|
2036 |
-
return '';
|
2037 |
-
}
|
2038 |
-
|
2039 |
-
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
2040 |
-
return '';
|
2041 |
-
}
|
2042 |
-
|
2043 |
-
// forbidden in edit mode? 'edit_forbidden' - it's field attribute predefined in the field data in code
|
2044 |
-
if ( isset( $data['edit_forbidden'] ) ) {
|
2045 |
-
return '';
|
2046 |
-
}
|
2047 |
-
|
2048 |
-
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
2049 |
-
if ( isset( $data['required_opt'] ) ) {
|
2050 |
-
$opt = $data['required_opt'];
|
2051 |
-
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
2052 |
-
return '';
|
2053 |
-
}
|
2054 |
-
}
|
2055 |
-
|
2056 |
-
// required user permission 'required_perm' - it's field attribute predefined in the field data in code
|
2057 |
-
if ( isset( $data['required_perm'] ) ) {
|
2058 |
-
if ( ! UM()->roles()->um_user_can( $data['required_perm'] ) ) {
|
2059 |
-
return '';
|
2060 |
-
}
|
2061 |
-
}
|
2062 |
-
|
2063 |
-
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
2064 |
-
$arr_restricted_fields = $this->get_restricted_fields_for_edit( $_um_profile_id );
|
2065 |
-
if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
|
2066 |
-
return '';
|
2067 |
-
}
|
2068 |
-
|
2069 |
-
|
2070 |
-
if ( $visibility == 'view' && $this->set_mode != 'register' ) {
|
2071 |
-
return '';
|
2072 |
-
}
|
2073 |
-
|
2074 |
-
if ( ! um_can_view_field( $data ) ) {
|
2075 |
-
return '';
|
2076 |
-
}
|
2077 |
-
|
2078 |
-
um_fetch_user( $_um_profile_id );
|
2079 |
-
|
2080 |
-
// Stop return empty values build field attributes:
|
2081 |
-
|
2082 |
-
if ( $visibility == 'view' && $this->set_mode == 'register' ) {
|
2083 |
-
|
2084 |
-
um_fetch_user( get_current_user_id() );
|
2085 |
-
if ( ! um_user( 'can_edit_everyone' ) ) {
|
2086 |
-
$disabled = ' disabled="disabled" ';
|
2087 |
-
}
|
2088 |
-
|
2089 |
-
um_fetch_user( $_um_profile_id );
|
2090 |
-
if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
|
2091 |
-
$current_user_roles = um_user( 'roles' );
|
2092 |
-
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
|
2093 |
-
$disabled = '';
|
2094 |
-
}
|
2095 |
-
}
|
2096 |
-
}
|
2097 |
-
|
2098 |
-
if ( ! empty( $this->editing ) && $this->set_mode == 'profile' ) {
|
2099 |
-
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
2100 |
-
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
2101 |
-
$disabled = ' disabled="disabled" ';
|
2102 |
-
}
|
2103 |
-
}
|
2104 |
-
}
|
2105 |
-
|
2106 |
-
$disabled = apply_filters( 'um_is_field_disabled', $disabled, $data );
|
2107 |
-
|
2108 |
-
if ( ! isset( $data['autocomplete'] ) ) {
|
2109 |
-
$autocomplete = 'off';
|
2110 |
-
}
|
2111 |
-
|
2112 |
-
if ( isset( $data['classes'] ) ) {
|
2113 |
-
$classes = explode( " ", $data['classes'] );
|
2114 |
-
}
|
2115 |
-
|
2116 |
-
um_fetch_user( $_um_profile_id );
|
2117 |
-
|
2118 |
-
/**
|
2119 |
-
* UM hook
|
2120 |
-
*
|
2121 |
-
* @type filter
|
2122 |
-
* @title um_hook_for_field_{$type}
|
2123 |
-
* @description Change field type
|
2124 |
-
* @input_vars
|
2125 |
-
* [{"var":"$type","type":"string","desc":"Field Type"}]
|
2126 |
-
* @change_log
|
2127 |
-
* ["Since: 2.0"]
|
2128 |
-
* @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 );
|
2129 |
-
* @example
|
2130 |
-
* <?php
|
2131 |
-
* add_filter( 'um_hook_for_field_{$type}', 'my_field_type', 10, 1 );
|
2132 |
-
* function my_get_field( $type ) {
|
2133 |
-
* // your code here
|
2134 |
-
* return $type;
|
2135 |
-
* }
|
2136 |
-
* ?>
|
2137 |
-
*/
|
2138 |
-
$type = apply_filters( "um_hook_for_field_{$type}", $type );
|
2139 |
-
switch ( $type ) {
|
2140 |
-
|
2141 |
-
case 'textarea':
|
2142 |
-
case 'multiselect':
|
2143 |
-
$field_id = $field_name = $key;
|
2144 |
-
$field_value = $this->field_value( $key, $default, $data );
|
2145 |
-
break;
|
2146 |
-
|
2147 |
-
case 'select':
|
2148 |
-
case 'radio':
|
2149 |
-
$form_key = str_replace( array( 'role_select', 'role_radio' ), 'role', $key );
|
2150 |
-
$field_id = $form_key;
|
2151 |
-
break;
|
2152 |
-
default:
|
2153 |
-
$field_id = '';
|
2154 |
-
break;
|
2155 |
-
}
|
2156 |
-
|
2157 |
-
/**
|
2158 |
-
* UM hook
|
2159 |
-
*
|
2160 |
-
* @type filter
|
2161 |
-
* @title um_completeness_field_id
|
2162 |
-
* @description use for change core id not allowed duplicate
|
2163 |
-
* @input_vars
|
2164 |
-
* [{"var":"$field_id","type":"string","desc":"Field id"},
|
2165 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2166 |
-
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
|
2167 |
-
* @change_log
|
2168 |
-
* ["Since: 2.0.13"]
|
2169 |
-
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2170 |
-
* @example
|
2171 |
-
* <?php
|
2172 |
-
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2173 |
-
* function function_name( $field_id, $data, $args ) {
|
2174 |
-
* // your code here
|
2175 |
-
* return $field_id;
|
2176 |
-
* }
|
2177 |
-
* ?>
|
2178 |
-
*/
|
2179 |
-
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
|
2180 |
-
|
2181 |
-
|
2182 |
-
/* Begin by field type */
|
2183 |
-
switch ( $type ) {
|
2184 |
-
|
2185 |
-
/* Default: Integration */
|
2186 |
-
default:
|
2187 |
-
$mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode';
|
2188 |
-
|
2189 |
-
/**
|
2190 |
-
* UM hook
|
2191 |
-
*
|
2192 |
-
* @type filter
|
2193 |
-
* @title um_edit_field_{$mode}_{$type}
|
2194 |
-
* @description Change field html by $mode and field $type
|
2195 |
-
* @input_vars
|
2196 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
2197 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2198 |
-
* @change_log
|
2199 |
-
* ["Since: 2.0"]
|
2200 |
-
* @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 );
|
2201 |
-
* @example
|
2202 |
-
* <?php
|
2203 |
-
* add_filter( 'um_edit_field_{$mode}_{$type}', 'my_edit_field_html', 10, 2 );
|
2204 |
-
* function my_edit_field_html( $output, $data ) {
|
2205 |
-
* // your code here
|
2206 |
-
* return $output;
|
2207 |
-
* }
|
2208 |
-
* ?>
|
2209 |
-
*/
|
2210 |
-
|
2211 |
-
$output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data );
|
2212 |
-
break;
|
2213 |
-
|
2214 |
-
/* Other fields */
|
2215 |
-
case 'googlemap':
|
2216 |
-
case 'youtube_video':
|
2217 |
-
case 'vimeo_video':
|
2218 |
-
case 'soundcloud_track':
|
2219 |
-
|
2220 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2221 |
-
|
2222 |
-
if ( isset( $data['label'] ) ) {
|
2223 |
-
$output .= $this->field_label( $label, $key, $data );
|
2224 |
-
}
|
2225 |
-
|
2226 |
-
$output .= '<div class="um-field-area">';
|
2227 |
-
|
2228 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2229 |
-
|
2230 |
-
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
|
2231 |
-
|
2232 |
-
}
|
2233 |
-
|
2234 |
-
$field_name = $key . UM()->form()->form_suffix;
|
2235 |
-
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2236 |
-
|
2237 |
-
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2238 |
-
|
2239 |
-
</div>';
|
2240 |
-
|
2241 |
-
if ( ! empty( $disabled ) ) {
|
2242 |
-
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2243 |
-
}
|
2244 |
-
|
2245 |
-
if ( $this->is_error( $key ) ) {
|
2246 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2247 |
-
}else if ( $this->is_notice( $key ) ) {
|
2248 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2249 |
-
}
|
2250 |
-
|
2251 |
-
$output .= '</div>';
|
2252 |
-
break;
|
2253 |
-
|
2254 |
-
/* Text */
|
2255 |
-
case 'text':
|
2256 |
-
|
2257 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2258 |
-
|
2259 |
-
if ( isset( $data['label'] ) ) {
|
2260 |
-
$output .= $this->field_label( $label, $key, $data );
|
2261 |
-
}
|
2262 |
-
|
2263 |
-
$output .= '<div class="um-field-area">';
|
2264 |
-
|
2265 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2266 |
-
|
2267 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2268 |
-
|
2269 |
-
}
|
2270 |
-
|
2271 |
-
$field_name = $key . UM()->form()->form_suffix;
|
2272 |
-
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2273 |
-
|
2274 |
-
$output .= '<input ' . $disabled . ' autocomplete="' . esc_attr( $autocomplete ) . '" class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2275 |
-
|
2276 |
-
</div>';
|
2277 |
-
|
2278 |
-
if ( ! empty( $disabled ) ) {
|
2279 |
-
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2280 |
-
}
|
2281 |
-
|
2282 |
-
if ( $this->is_error( $key ) ) {
|
2283 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2284 |
-
}else if ( $this->is_notice( $key ) ) {
|
2285 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2286 |
-
}
|
2287 |
-
|
2288 |
-
$output .= '</div>';
|
2289 |
-
break;
|
2290 |
-
|
2291 |
-
/* Number */
|
2292 |
-
case 'number':
|
2293 |
-
|
2294 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2295 |
-
|
2296 |
-
if ( isset( $data['label'] ) ) {
|
2297 |
-
$output .= $this->field_label( $label, $key, $data );
|
2298 |
-
}
|
2299 |
-
|
2300 |
-
$output .= '<div class="um-field-area">';
|
2301 |
-
|
2302 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2303 |
-
|
2304 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2305 |
-
|
2306 |
-
}
|
2307 |
-
|
2308 |
-
$number_limit = '';
|
2309 |
-
if ( isset( $min ) ) {
|
2310 |
-
$number_limit .= ' min="' . esc_attr( $min ) . '" ';
|
2311 |
-
}
|
2312 |
-
if ( isset( $max ) ) {
|
2313 |
-
$number_limit .= ' max="' . esc_attr( $max ) . '" ';
|
2314 |
-
}
|
2315 |
-
|
2316 |
-
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="number" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( htmlspecialchars( $this->field_value( $key, $default, $data ) ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" ' . $number_limit . ' />
|
2317 |
-
|
2318 |
-
</div>';
|
2319 |
-
|
2320 |
-
if ( $this->is_error( $key ) ) {
|
2321 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2322 |
-
}else if ( $this->is_notice( $key ) ) {
|
2323 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2324 |
-
}
|
2325 |
-
|
2326 |
-
$output .= '</div>';
|
2327 |
-
break;
|
2328 |
-
|
2329 |
-
/* Password */
|
2330 |
-
case 'password':
|
2331 |
-
|
2332 |
-
$original_key = $key;
|
2333 |
-
|
2334 |
-
if ( $key == 'single_user_password' ) {
|
2335 |
-
|
2336 |
-
$key = $original_key;
|
2337 |
-
|
2338 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2339 |
-
|
2340 |
-
if ( isset( $data['label'] ) ) {
|
2341 |
-
$output .= $this->field_label( $label, $key, $data );
|
2342 |
-
}
|
2343 |
-
|
2344 |
-
$output .= '<div class="um-field-area">';
|
2345 |
-
|
2346 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2347 |
-
|
2348 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2349 |
-
|
2350 |
-
}
|
2351 |
-
|
2352 |
-
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2353 |
-
|
2354 |
-
</div>';
|
2355 |
-
|
2356 |
-
if ( $this->is_error( $key ) ) {
|
2357 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2358 |
-
}else if ( $this->is_notice( $key ) ) {
|
2359 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2360 |
-
}
|
2361 |
-
|
2362 |
-
$output .= '</div>';
|
2363 |
-
|
2364 |
-
} else {
|
2365 |
-
|
2366 |
-
if ( UM()->account()->current_password_is_required( 'password' ) &&
|
2367 |
-
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
2368 |
-
|
2369 |
-
$key = 'current_' . $original_key;
|
2370 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2371 |
-
|
2372 |
-
if ( isset( $data['label'] ) ) {
|
2373 |
-
$output .= $this->field_label( __( 'Current Password', 'ultimate-member' ), $key, $data );
|
2374 |
-
}
|
2375 |
-
|
2376 |
-
$output .= '<div class="um-field-area">';
|
2377 |
-
|
2378 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2379 |
-
|
2380 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2381 |
-
|
2382 |
-
}
|
2383 |
-
|
2384 |
-
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2385 |
-
|
2386 |
-
</div>';
|
2387 |
-
|
2388 |
-
if ( $this->is_error( $key ) ) {
|
2389 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2390 |
-
} elseif ( $this->is_notice( $key ) ) {
|
2391 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2392 |
-
}
|
2393 |
-
|
2394 |
-
$output .= '</div>';
|
2395 |
-
|
2396 |
-
}
|
2397 |
-
|
2398 |
-
$key = $original_key;
|
2399 |
-
|
2400 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2401 |
-
|
2402 |
-
if ( $this->set_mode == 'account' && um_is_core_page( 'account' ) || $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2403 |
-
|
2404 |
-
$output .= $this->field_label( __( 'New Password', 'ultimate-member' ), $key, $data );
|
2405 |
-
|
2406 |
-
} elseif ( isset( $data['label'] ) ) {
|
2407 |
-
|
2408 |
-
$output .= $this->field_label( $label, $key, $data );
|
2409 |
-
|
2410 |
-
}
|
2411 |
-
|
2412 |
-
$output .= '<div class="um-field-area">';
|
2413 |
-
|
2414 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2415 |
-
|
2416 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2417 |
-
|
2418 |
-
}
|
2419 |
-
|
2420 |
-
$name = $key . UM()->form()->form_suffix;
|
2421 |
-
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2422 |
-
$name = $key;
|
2423 |
-
}
|
2424 |
-
|
2425 |
-
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2426 |
-
|
2427 |
-
</div>';
|
2428 |
-
|
2429 |
-
if ( $this->is_error( $key ) ) {
|
2430 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2431 |
-
} elseif ( $this->is_notice( $key ) ) {
|
2432 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2433 |
-
}
|
2434 |
-
|
2435 |
-
$output .= '</div>';
|
2436 |
-
|
2437 |
-
if ( $this->set_mode != 'login' && isset( $data['force_confirm_pass'] ) && $data['force_confirm_pass'] == 1 ) {
|
2438 |
-
|
2439 |
-
$key = 'confirm_' . $original_key;
|
2440 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2441 |
-
|
2442 |
-
if ( ! empty( $data['label_confirm_pass'] ) ) {
|
2443 |
-
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
|
2444 |
-
$output .= $this->field_label( $label_confirm_pass, $key, $data );
|
2445 |
-
} elseif ( isset( $data['label'] ) ) {
|
2446 |
-
$data['label'] = __( $data['label'], 'ultimate-member' );
|
2447 |
-
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
|
2448 |
-
}
|
2449 |
-
|
2450 |
-
$output .= '<div class="um-field-area">';
|
2451 |
-
|
2452 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2453 |
-
|
2454 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2455 |
-
|
2456 |
-
}
|
2457 |
-
|
2458 |
-
$name = $key . UM()->form()->form_suffix;
|
2459 |
-
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2460 |
-
$name = $key;
|
2461 |
-
}
|
2462 |
-
|
2463 |
-
if ( ! empty( $label_confirm_pass ) ) {
|
2464 |
-
$placeholder = $label_confirm_pass;
|
2465 |
-
} elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
|
2466 |
-
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
2467 |
-
} elseif( isset( $data['label'] ) ) {
|
2468 |
-
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
|
2469 |
-
}
|
2470 |
-
|
2471 |
-
|
2472 |
-
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />';
|
2473 |
-
|
2474 |
-
|
2475 |
-
$output .= '</div>';
|
2476 |
-
|
2477 |
-
if ( $this->is_error( $key ) ) {
|
2478 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2479 |
-
}else if ( $this->is_notice( $key ) ) {
|
2480 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2481 |
-
}
|
2482 |
-
|
2483 |
-
$output .= '</div>';
|
2484 |
-
|
2485 |
-
}
|
2486 |
-
|
2487 |
-
}
|
2488 |
-
|
2489 |
-
break;
|
2490 |
-
|
2491 |
-
/* URL */
|
2492 |
-
case 'url':
|
2493 |
-
|
2494 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2495 |
-
|
2496 |
-
if ( isset( $data['label'] ) ) {
|
2497 |
-
$output .= $this->field_label( $label, $key, $data );
|
2498 |
-
}
|
2499 |
-
|
2500 |
-
$output .= '<div class="um-field-area">';
|
2501 |
-
|
2502 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2503 |
-
|
2504 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2505 |
-
|
2506 |
-
}
|
2507 |
-
|
2508 |
-
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( $this->field_value( $key, $default, $data ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2509 |
-
|
2510 |
-
</div>';
|
2511 |
-
|
2512 |
-
if ( $this->is_error( $key ) ) {
|
2513 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2514 |
-
}else if ( $this->is_notice( $key ) ) {
|
2515 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2516 |
-
}
|
2517 |
-
|
2518 |
-
$output .= '</div>';
|
2519 |
-
break;
|
2520 |
-
|
2521 |
-
/* Date */
|
2522 |
-
case 'date':
|
2523 |
-
|
2524 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2525 |
-
|
2526 |
-
if (isset( $data['label'] )) {
|
2527 |
-
$output .= $this->field_label( $label, $key, $data );
|
2528 |
-
}
|
2529 |
-
|
2530 |
-
$output .= '<div class="um-field-area">';
|
2531 |
-
|
2532 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2533 |
-
|
2534 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2535 |
-
|
2536 |
-
}
|
2537 |
-
|
2538 |
-
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-range="' . esc_attr( $range ) . '" data-years="' . esc_attr( $years ) . '" data-years_x="' . esc_attr( $years_x ) . '" data-disabled_weekdays="' . esc_attr( $disabled_weekdays ) . '" data-date_min="' . esc_attr( $date_min ) . '" data-date_max="' . esc_attr( $date_max ) . '" data-format="' . esc_attr( $js_format ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2539 |
-
|
2540 |
-
</div>';
|
2541 |
-
|
2542 |
-
if ( $this->is_error( $key ) ) {
|
2543 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2544 |
-
}else if ( $this->is_notice( $key ) ) {
|
2545 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2546 |
-
}
|
2547 |
-
|
2548 |
-
$output .= '</div>';
|
2549 |
-
break;
|
2550 |
-
|
2551 |
-
/* Time */
|
2552 |
-
case 'time':
|
2553 |
-
|
2554 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2555 |
-
|
2556 |
-
if (isset( $data['label'] )) {
|
2557 |
-
$output .= $this->field_label( $label, $key, $data );
|
2558 |
-
}
|
2559 |
-
|
2560 |
-
$output .= '<div class="um-field-area">';
|
2561 |
-
|
2562 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2563 |
-
|
2564 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2565 |
-
|
2566 |
-
}
|
2567 |
-
|
2568 |
-
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-format="' . esc_attr( $js_format ) . '" data-intervals="' . esc_attr( $intervals ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2569 |
-
|
2570 |
-
</div>';
|
2571 |
-
|
2572 |
-
if ( $this->is_error( $key ) ) {
|
2573 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2574 |
-
}else if ( $this->is_notice( $key ) ) {
|
2575 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2576 |
-
}
|
2577 |
-
|
2578 |
-
$output .= '</div>';
|
2579 |
-
break;
|
2580 |
-
|
2581 |
-
/* Row */
|
2582 |
-
case 'row':
|
2583 |
-
$output .= '';
|
2584 |
-
break;
|
2585 |
-
|
2586 |
-
/* Textarea */
|
2587 |
-
case 'textarea':
|
2588 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2589 |
-
|
2590 |
-
if ( isset( $data['label'] ) ) {
|
2591 |
-
$output .= $this->field_label( $label, $key, $data );
|
2592 |
-
}
|
2593 |
-
|
2594 |
-
$output .= '<div class="um-field-area">';
|
2595 |
-
|
2596 |
-
if ( isset( $data['html'] ) && $data['html'] != 0 && $key != "description" ) {
|
2597 |
-
|
2598 |
-
$textarea_settings = array(
|
2599 |
-
'media_buttons' => false,
|
2600 |
-
'wpautop' => false,
|
2601 |
-
'editor_class' => $this->get_class( $key, $data ),
|
2602 |
-
'editor_height' => $height,
|
2603 |
-
'tinymce' => array(
|
2604 |
-
'toolbar1' => 'formatselect,bullist,numlist,bold,italic,underline,forecolor,blockquote,hr,removeformat,link,unlink,undo,redo',
|
2605 |
-
'toolbar2' => '',
|
2606 |
-
)
|
2607 |
-
);
|
2608 |
-
|
2609 |
-
if ( ! empty( $disabled ) ) {
|
2610 |
-
$textarea_settings['tinymce']['readonly'] = true;
|
2611 |
-
}
|
2612 |
-
|
2613 |
-
/**
|
2614 |
-
* UM hook
|
2615 |
-
*
|
2616 |
-
* @type filter
|
2617 |
-
* @title um_form_fields_textarea_settings
|
2618 |
-
* @description Change WP Editor options for textarea init
|
2619 |
-
* @input_vars
|
2620 |
-
* [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}]
|
2621 |
-
* @change_log
|
2622 |
-
* ["Since: 2.0"]
|
2623 |
-
* @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
|
2624 |
-
* @example
|
2625 |
-
* <?php
|
2626 |
-
* add_filter( 'um_form_fields_textarea_settings', 'my_textarea_settings', 10, 1 );
|
2627 |
-
* function my_edit_field_html( $textarea_settings ) {
|
2628 |
-
* // your code here
|
2629 |
-
* return $textarea_settings;
|
2630 |
-
* }
|
2631 |
-
* ?>
|
2632 |
-
*/
|
2633 |
-
$textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings );
|
2634 |
-
|
2635 |
-
// turn on the output buffer
|
2636 |
-
ob_start();
|
2637 |
-
|
2638 |
-
// echo the editor to the buffer
|
2639 |
-
wp_editor( $field_value, $key, $textarea_settings );
|
2640 |
-
|
2641 |
-
// add the contents of the buffer to the output variable
|
2642 |
-
$output .= ob_get_clean();
|
2643 |
-
$output .= '<br /><span class="description">' . $placeholder . '</span>';
|
2644 |
-
} else {
|
2645 |
-
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : strip_tags( $field_value );
|
2646 |
-
$output .= '<textarea ' . $disabled . ' style="height: ' . esc_attr( $height ) . ';" class="' . $this->get_class( $key, $data ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" placeholder="' . esc_attr( $placeholder ) . '">' . esc_textarea( $textarea_field_value ) . '</textarea>';
|
2647 |
-
}
|
2648 |
-
|
2649 |
-
$output .= '</div>';
|
2650 |
-
|
2651 |
-
if ( ! empty( $disabled ) ) {
|
2652 |
-
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2653 |
-
}
|
2654 |
-
|
2655 |
-
if ( $this->is_error( $key ) ) {
|
2656 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2657 |
-
}else if ( $this->is_notice( $key ) ) {
|
2658 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2659 |
-
}
|
2660 |
-
|
2661 |
-
$output .= '</div>';
|
2662 |
-
break;
|
2663 |
-
|
2664 |
-
/* Rating */
|
2665 |
-
case 'rating':
|
2666 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2667 |
-
|
2668 |
-
if ( isset( $data['label'] ) ) {
|
2669 |
-
$output .= $this->field_label( $label, $key, $data );
|
2670 |
-
}
|
2671 |
-
|
2672 |
-
$output .= '<div class="um-field-area">';
|
2673 |
-
|
2674 |
-
$output .= '<div class="um-rating um-raty" id="' . esc_attr( $key ) . '" data-key="' . esc_attr( $key ) . '" data-number="' . esc_attr( $data['number'] ) . '" data-score="' . $this->field_value( $key, $default, $data ) . '"></div>';
|
2675 |
-
$output .= '</div>';
|
2676 |
-
|
2677 |
-
if ( $this->is_error( $key ) ) {
|
2678 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2679 |
-
} elseif ( $this->is_notice( $key ) ) {
|
2680 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2681 |
-
}
|
2682 |
-
|
2683 |
-
$output .= '</div>';
|
2684 |
-
|
2685 |
-
break;
|
2686 |
-
|
2687 |
-
/* Gap/Space */
|
2688 |
-
case 'spacing':
|
2689 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
2690 |
-
break;
|
2691 |
-
|
2692 |
-
/* A line divider */
|
2693 |
-
case 'divider':
|
2694 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
2695 |
-
if ( $divider_text ) {
|
2696 |
-
$output .= '<div class="um-field-divider-text"><span>' . esc_html( $divider_text ) . '</span></div>';
|
2697 |
-
}
|
2698 |
-
$output .= '</div>';
|
2699 |
-
break;
|
2700 |
-
|
2701 |
-
/* Single Image Upload */
|
2702 |
-
case 'image':
|
2703 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2704 |
-
if ( in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2705 |
-
$field_value = '';
|
2706 |
-
} else {
|
2707 |
-
$field_value = $this->field_value( $key, $default, $data );
|
2708 |
-
}
|
2709 |
-
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $field_value . '" />';
|
2710 |
-
if ( isset( $data['label'] ) ) {
|
2711 |
-
$output .= $this->field_label( $label, $key, $data );
|
2712 |
-
}
|
2713 |
-
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
2714 |
-
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2715 |
-
|
2716 |
-
if ( ! empty( $field_value ) && $field_value != 'empty_file' ) {
|
2717 |
-
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2718 |
-
if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
|
2719 |
-
$image_info = get_transient("um_{$field_value}");
|
2720 |
-
} else {
|
2721 |
-
$image_info = um_user( $data['metakey']."_metadata" );
|
2722 |
-
}
|
2723 |
-
|
2724 |
-
if ( ( isset( $this->set_mode ) && $this->set_mode == 'register' ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
|
2725 |
-
$imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
|
2726 |
-
} else {
|
2727 |
-
$imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2728 |
-
}
|
2729 |
-
$img = '<img src="' . $imgValue . '" alt="" />';
|
2730 |
-
} else {
|
2731 |
-
$img = '';
|
2732 |
-
}
|
2733 |
-
$output .= '<div class="um-single-image-preview show ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2734 |
-
if ( empty( $disabled ) ) {
|
2735 |
-
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2736 |
-
}
|
2737 |
-
$output .= $img;
|
2738 |
-
$output .= '</div>';
|
2739 |
-
if ( empty( $disabled ) ) {
|
2740 |
-
$output .= '<a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . __( 'Change photo', 'ultimate-member' ) . '</a>';
|
2741 |
-
}
|
2742 |
-
|
2743 |
-
|
2744 |
-
} else {
|
2745 |
-
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2746 |
-
if ( empty( $disabled ) ) {
|
2747 |
-
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2748 |
-
}
|
2749 |
-
$output .= '<img src="" alt="" /><div class="um-clear"></div></div>';
|
2750 |
-
if ( empty( $disabled ) ) {
|
2751 |
-
$output .= '<a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . $button_text . '</a>';
|
2752 |
-
}
|
2753 |
-
|
2754 |
-
}
|
2755 |
-
$output .= '</div>';
|
2756 |
-
/* modal hidden */
|
2757 |
-
if ( empty( $disabled ) ) {
|
2758 |
-
$output .= '<div class="um-modal-hidden-content">';
|
2759 |
-
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2760 |
-
$output .= '<div class="um-modal-body">';
|
2761 |
-
if ( isset( $this->set_id ) ) {
|
2762 |
-
$set_id = $this->set_id;
|
2763 |
-
$set_mode = $this->set_mode;
|
2764 |
-
} else {
|
2765 |
-
$set_id = 0;
|
2766 |
-
$set_mode = '';
|
2767 |
-
}
|
2768 |
-
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2769 |
-
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-ratio="' . $ratio . '" data-min_width="' . $min_width . '" data-min_height="' . $min_height . '" data-coord=""><a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a><img src="" alt="" /><div class="um-clear"></div></div><div class="um-clear"></div>';
|
2770 |
-
$output .= '<div class="um-single-image-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-nonce="' . $nonce . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2771 |
-
$output .= '<div class="um-modal-footer">
|
2772 |
-
<div class="um-modal-right">
|
2773 |
-
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __( 'Change photo', 'ultimate-member' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Apply', 'ultimate-member' ) . '</a>
|
2774 |
-
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2775 |
-
</div>
|
2776 |
-
<div class="um-clear"></div>
|
2777 |
-
</div>';
|
2778 |
-
$output .= '</div>';
|
2779 |
-
$output .= '</div>';
|
2780 |
-
}
|
2781 |
-
/* end */
|
2782 |
-
if ( $this->is_error( $key ) ) {
|
2783 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2784 |
-
}else if ( $this->is_notice( $key ) ) {
|
2785 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2786 |
-
}
|
2787 |
-
$output .= '</div>';
|
2788 |
-
|
2789 |
-
break;
|
2790 |
-
|
2791 |
-
/* Single File Upload */
|
2792 |
-
case 'file':
|
2793 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2794 |
-
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" />';
|
2795 |
-
if ( isset( $data['label'] ) ) {
|
2796 |
-
$output .= $this->field_label( $label, $key, $data );
|
2797 |
-
}
|
2798 |
-
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload File', 'ultimate-member' );
|
2799 |
-
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2800 |
-
|
2801 |
-
$file_field_value = $this->field_value( $key, $default, $data );
|
2802 |
-
|
2803 |
-
if ( ! empty( $file_field_value ) && 'empty_file' !== $file_field_value ) {
|
2804 |
-
$file_type = wp_check_filetype( $file_field_value );
|
2805 |
-
|
2806 |
-
if ( um_is_temp_file( $file_field_value ) ) {
|
2807 |
-
$file_info = get_transient( "um_{$file_field_value}" );
|
2808 |
-
} else {
|
2809 |
-
$file_info = um_user( $data['metakey'] . "_metadata" );
|
2810 |
-
}
|
2811 |
-
|
2812 |
-
$file_field_name = $file_field_value;
|
2813 |
-
if ( ! empty( $file_info['original_name'] ) ) {
|
2814 |
-
$file_field_name = $file_info['original_name'];
|
2815 |
-
}
|
2816 |
-
|
2817 |
-
if ( ( isset( $this->set_mode ) && 'register' == $this->set_mode ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value ) ) {
|
2818 |
-
$file_url = UM()->uploader()->get_core_temp_url() . DIRECTORY_SEPARATOR . $file_field_value;
|
2819 |
-
$file_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value;
|
2820 |
-
} else {
|
2821 |
-
$file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2822 |
-
$file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
2823 |
-
}
|
2824 |
-
|
2825 |
-
//multisite fix for old customers
|
2826 |
-
if ( ! file_exists( $file_dir ) && is_multisite() ) {
|
2827 |
-
$file_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_dir );
|
2828 |
-
}
|
2829 |
-
|
2830 |
-
if ( file_exists( $file_dir ) ) {
|
2831 |
-
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">";
|
2832 |
-
if ( empty( $disabled ) ) {
|
2833 |
-
$output .= "<a href=\"#\" class=\"cancel\"><i class=\"um-icon-close\"></i></a>";
|
2834 |
-
}
|
2835 |
-
$output .= "<div class=\"um-single-fileinfo\">
|
2836 |
-
<a href=\"{$file_url}\" target=\"_blank\">
|
2837 |
-
<span class=\"icon\" style=\"background:" . UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . "\"><i class=\"" . UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) . "\"></i></span>
|
2838 |
-
<span class=\"filename\">{$file_field_name}</span>
|
2839 |
-
</a>
|
2840 |
-
</div></div>";
|
2841 |
-
} else {
|
2842 |
-
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">" . __('This file has been removed.','ultimate-member') . "</div>";
|
2843 |
-
}
|
2844 |
-
|
2845 |
-
if ( empty( $disabled ) ) {
|
2846 |
-
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">" . __( 'Change file', 'ultimate-member' ) . "</a>";
|
2847 |
-
}
|
2848 |
-
} else {
|
2849 |
-
$output .= "<div class=\"um-single-file-preview\" data-key=\"{$key}\"></div>";
|
2850 |
-
if ( empty( $disabled ) ) {
|
2851 |
-
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">{$button_text}</a>";
|
2852 |
-
}
|
2853 |
-
}
|
2854 |
-
$output .= '</div>';
|
2855 |
-
/* modal hidden */
|
2856 |
-
if ( empty( $disabled ) ) {
|
2857 |
-
$output .= '<div class="um-modal-hidden-content">';
|
2858 |
-
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2859 |
-
$output .= '<div class="um-modal-body">';
|
2860 |
-
if ( isset( $this->set_id ) ) {
|
2861 |
-
$set_id = $this->set_id;
|
2862 |
-
$set_mode = $this->set_mode;
|
2863 |
-
} else {
|
2864 |
-
$set_id = 0;
|
2865 |
-
$set_mode = '';
|
2866 |
-
}
|
2867 |
-
$output .= '<div class="um-single-file-preview">
|
2868 |
-
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>
|
2869 |
-
<div class="um-single-fileinfo">
|
2870 |
-
<a href="" target="_blank">
|
2871 |
-
<span class="icon"><i></i></span>
|
2872 |
-
<span class="filename"></span>
|
2873 |
-
</a>
|
2874 |
-
</div>
|
2875 |
-
</div>';
|
2876 |
-
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2877 |
-
$output .= '<div class="um-single-file-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-nonce="' . $nonce . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2878 |
-
$output .= '<div class="um-modal-footer">
|
2879 |
-
<div class="um-modal-right">
|
2880 |
-
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload file disabled" data-key="' . esc_attr( $key ) . '" data-change="' . esc_attr__( 'Change file' ) . '" data-processing="' . esc_attr__( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Save', 'ultimate-member' ) . '</a>
|
2881 |
-
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2882 |
-
</div>
|
2883 |
-
<div class="um-clear"></div>
|
2884 |
-
</div>';
|
2885 |
-
$output .= '</div>';
|
2886 |
-
$output .= '</div>';
|
2887 |
-
}
|
2888 |
-
/* end */
|
2889 |
-
if ( $this->is_error( $key ) ) {
|
2890 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
2891 |
-
}else if ( $this->is_notice( $key ) ) {
|
2892 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2893 |
-
}
|
2894 |
-
$output .= '</div>';
|
2895 |
-
|
2896 |
-
break;
|
2897 |
-
|
2898 |
-
/* Select dropdown */
|
2899 |
-
case 'select':
|
2900 |
-
|
2901 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2902 |
-
|
2903 |
-
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
2904 |
-
$class = 'um-s2';
|
2905 |
-
} else {
|
2906 |
-
$class = 'um-s1';
|
2907 |
-
}
|
2908 |
-
|
2909 |
-
if ( isset( $data['label'] ) ) {
|
2910 |
-
$output .= $this->field_label( $label, $key, $data );
|
2911 |
-
}
|
2912 |
-
|
2913 |
-
$output .= '<div class="um-field-area ' . ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
2914 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2915 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2916 |
-
}
|
2917 |
-
|
2918 |
-
$options = array();
|
2919 |
-
$has_parent_option = false;
|
2920 |
-
$disabled_by_parent_option = '';
|
2921 |
-
$atts_ajax = '';
|
2922 |
-
$select_original_option_value = '';
|
2923 |
-
|
2924 |
-
if ( isset( $data[ 'options' ] ) && is_array( $data[ 'options' ] ) ) {
|
2925 |
-
$options = $data[ 'options' ];
|
2926 |
-
}
|
2927 |
-
|
2928 |
-
if ( ! empty( $data['parent_dropdown_relationship'] ) && ! UM()->user()->preview ) {
|
2929 |
-
|
2930 |
-
$disabled_by_parent_option = 'disabled = disabled';
|
2931 |
-
|
2932 |
-
$has_parent_option = true;
|
2933 |
-
|
2934 |
-
/**
|
2935 |
-
* UM hook
|
2936 |
-
*
|
2937 |
-
* @type filter
|
2938 |
-
* @title um_custom_dropdown_options_parent__{$form_key}
|
2939 |
-
* @description Change parent dropdown relationship by $form_key
|
2940 |
-
* @input_vars
|
2941 |
-
* [{"var":"$parent","type":"string","desc":"Parent dropdown relationship"},
|
2942 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2943 |
-
* @change_log
|
2944 |
-
* ["Since: 2.0"]
|
2945 |
-
* @usage add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 );
|
2946 |
-
* @example
|
2947 |
-
* <?php
|
2948 |
-
* add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'my_custom_dropdown_options_parent', 10, 2 );
|
2949 |
-
* function my_custom_dropdown_options_parent( $parent, $data ) {
|
2950 |
-
* // your code here
|
2951 |
-
* return $parent;
|
2952 |
-
* }
|
2953 |
-
* ?>
|
2954 |
-
*/
|
2955 |
-
$parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data );
|
2956 |
-
$atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' ";
|
2957 |
-
|
2958 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
2959 |
-
um_user( $data['parent_dropdown_relationship'] )
|
2960 |
-
) {
|
2961 |
-
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2962 |
-
|
2963 |
-
$disabled_by_parent_option = '';
|
2964 |
-
if ( um_user( $form_key ) ) {
|
2965 |
-
$select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
|
2966 |
-
}
|
2967 |
-
}
|
2968 |
-
}
|
2969 |
-
|
2970 |
-
// Child dropdown option selected
|
2971 |
-
if ( isset( UM()->form()->post_form[ $form_key ] ) ) {
|
2972 |
-
$select_original_option_value = " data-um-original-value='" . esc_attr( UM()->form()->post_form[ $form_key ] ) . "' ";
|
2973 |
-
}
|
2974 |
-
|
2975 |
-
// Child dropdown
|
2976 |
-
if ( $has_parent_option ) {
|
2977 |
-
|
2978 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
2979 |
-
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
2980 |
-
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2981 |
-
}
|
2982 |
-
}
|
2983 |
-
|
2984 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
2985 |
-
|
2986 |
-
/**
|
2987 |
-
* UM hook
|
2988 |
-
*
|
2989 |
-
* @type filter
|
2990 |
-
* @title um_custom_dropdown_options_source__{$form_key}
|
2991 |
-
* @description Change custom dropdown options source by $form_key
|
2992 |
-
* @input_vars
|
2993 |
-
* [{"var":"$source","type":"string","desc":"Dropdown options source"},
|
2994 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2995 |
-
* @change_log
|
2996 |
-
* ["Since: 2.0"]
|
2997 |
-
* @usage add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'function_name', 10, 2 );
|
2998 |
-
* @example
|
2999 |
-
* <?php
|
3000 |
-
* add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'my_custom_dropdown_options_source', 10, 2 );
|
3001 |
-
* function my_custom_dropdown_options_source( $source, $data ) {
|
3002 |
-
* // your code here
|
3003 |
-
* return $source;
|
3004 |
-
* }
|
3005 |
-
* ?>
|
3006 |
-
*/
|
3007 |
-
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data );
|
3008 |
-
$atts_ajax .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
3009 |
-
|
3010 |
-
/**
|
3011 |
-
* UM hook
|
3012 |
-
*
|
3013 |
-
* @type filter
|
3014 |
-
* @title um_custom_dropdown_options_source_url__{$form_key}
|
3015 |
-
* @description Change custom dropdown options source URL by $form_key
|
3016 |
-
* @input_vars
|
3017 |
-
* [{"var":"$url","type":"string","desc":"Dropdown options source URL"},
|
3018 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3019 |
-
* @change_log
|
3020 |
-
* ["Since: 2.0"]
|
3021 |
-
* @usage add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'function_name', 10, 2 );
|
3022 |
-
* @example
|
3023 |
-
* <?php
|
3024 |
-
* add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'my_custom_dropdown_options_source_url', 10, 2 );
|
3025 |
-
* function my_custom_dropdown_options_source( $url, $data ) {
|
3026 |
-
* // your code here
|
3027 |
-
* return $url;
|
3028 |
-
* }
|
3029 |
-
* ?>
|
3030 |
-
*/
|
3031 |
-
// todo maybe deprecate
|
3032 |
-
// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
3033 |
-
// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
3034 |
-
|
3035 |
-
}
|
3036 |
-
|
3037 |
-
/**
|
3038 |
-
* UM hook
|
3039 |
-
*
|
3040 |
-
* @type filter
|
3041 |
-
* @title um_fields_options_enable_pairs__{$key}
|
3042 |
-
* @description Enable options pairs by field $key
|
3043 |
-
* @input_vars
|
3044 |
-
* [{"var":"$options_pairs","type":"string","desc":"Enable pairs"}]
|
3045 |
-
* @change_log
|
3046 |
-
* ["Since: 2.0"]
|
3047 |
-
* @usage add_filter( 'um_fields_options_enable_pairs__{$key}', 'function_name', 10, 1 );
|
3048 |
-
* @example
|
3049 |
-
* <?php
|
3050 |
-
* add_filter( 'um_fields_options_enable_pairs__{$key}', 'my_fields_options_enable_pairs', 10, 1 );
|
3051 |
-
* function my_fields_options_enable_pairs( $options_pairs ) {
|
3052 |
-
* // your code here
|
3053 |
-
* return $options_pairs;
|
3054 |
-
* }
|
3055 |
-
* ?>
|
3056 |
-
*/
|
3057 |
-
$enable_options_pair = apply_filters( "um_fields_options_enable_pairs__{$key}", false );
|
3058 |
-
|
3059 |
-
if ( ! $has_parent_option ) {
|
3060 |
-
if ( isset( $options ) && $options == 'builtin' ) {
|
3061 |
-
$options = UM()->builtin()->get ( $filter );
|
3062 |
-
}
|
3063 |
-
|
3064 |
-
// 'country'
|
3065 |
-
if ( $key === 'country' && empty( $options ) ) {
|
3066 |
-
$options = UM()->builtin()->get( 'countries' );
|
3067 |
-
} else if ( empty( $options ) && isset( $data['options'] ) ) {
|
3068 |
-
$options = $data['options'];
|
3069 |
-
}
|
3070 |
-
|
3071 |
-
$options = apply_filters( 'um_selectbox_options', $options, $key );
|
3072 |
-
|
3073 |
-
if ( isset( $options ) ) {
|
3074 |
-
/**
|
3075 |
-
* UM hook
|
3076 |
-
*
|
3077 |
-
* @type filter
|
3078 |
-
* @title um_select_dropdown_dynamic_options
|
3079 |
-
* @description Extend dropdown dynamic options
|
3080 |
-
* @input_vars
|
3081 |
-
* [{"var":"$options","type":"array","desc":"Dynamic options"},
|
3082 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3083 |
-
* @change_log
|
3084 |
-
* ["Since: 2.0"]
|
3085 |
-
* @usage add_filter( 'um_select_dropdown_dynamic_options', 'function_name', 10, 2 );
|
3086 |
-
* @example
|
3087 |
-
* <?php
|
3088 |
-
* add_filter( 'um_select_dropdown_dynamic_options', 'my_select_dropdown_dynamic_options', 10, 2 );
|
3089 |
-
* function my_select_dropdown_dynamic_options( $options, $data ) {
|
3090 |
-
* // your code here
|
3091 |
-
* return $options;
|
3092 |
-
* }
|
3093 |
-
* ?>
|
3094 |
-
*/
|
3095 |
-
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
|
3096 |
-
/**
|
3097 |
-
* UM hook
|
3098 |
-
*
|
3099 |
-
* @type filter
|
3100 |
-
* @title um_select_dropdown_dynamic_options_{$key}
|
3101 |
-
* @description Extend dropdown dynamic options by field $key
|
3102 |
-
* @input_vars
|
3103 |
-
* [{"var":"$options","type":"array","desc":"Dynamic options"}]
|
3104 |
-
* @change_log
|
3105 |
-
* ["Since: 2.0"]
|
3106 |
-
* @usage add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'function_name', 10, 1 );
|
3107 |
-
* @example
|
3108 |
-
* <?php
|
3109 |
-
* add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'my_select_dropdown_dynamic_options', 10, 1 );
|
3110 |
-
* function my_select_dropdown_dynamic_options( $options ) {
|
3111 |
-
* // your code here
|
3112 |
-
* return $options;
|
3113 |
-
* }
|
3114 |
-
* ?>
|
3115 |
-
*/
|
3116 |
-
$options = apply_filters( "um_select_dropdown_dynamic_options_{$key}", $options );
|
3117 |
-
}
|
3118 |
-
}
|
3119 |
-
|
3120 |
-
if ( $form_key === 'role' ) {
|
3121 |
-
$options = $this->get_available_roles( $form_key, $options );
|
3122 |
-
}
|
3123 |
-
|
3124 |
-
/**
|
3125 |
-
* UM hook
|
3126 |
-
*
|
3127 |
-
* @type filter
|
3128 |
-
* @title um_select_option_value
|
3129 |
-
* @description Enable options pair by field $data
|
3130 |
-
* @input_vars
|
3131 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3132 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3133 |
-
*/
|
3134 |
-
$options_pair = apply_filters( 'um_select_options_pair', null, $data );
|
3135 |
-
|
3136 |
-
// switch options pair for custom options from a callback function
|
3137 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3138 |
-
$options_pair = true;
|
3139 |
-
}
|
3140 |
-
|
3141 |
-
$field_value = '';
|
3142 |
-
|
3143 |
-
if ( ! empty( $placeholder ) && is_string( $placeholder ) ) {
|
3144 |
-
$placeholder = strip_tags( $placeholder );
|
3145 |
-
}
|
3146 |
-
|
3147 |
-
$output .= '<select data-default="' . $data['default'] . '" ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . esc_attr( $form_key ) . '" id="' . esc_attr( $field_id ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '" ' . $atts_ajax . '>';
|
3148 |
-
|
3149 |
-
$output .= '<option value=""></option>';
|
3150 |
-
|
3151 |
-
// add options
|
3152 |
-
if ( ! empty( $options ) ) {
|
3153 |
-
foreach ( $options as $k => $v ) {
|
3154 |
-
|
3155 |
-
$v = rtrim( $v );
|
3156 |
-
|
3157 |
-
$option_value = $v;
|
3158 |
-
$um_field_checkbox_item_title = $v;
|
3159 |
-
|
3160 |
-
|
3161 |
-
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3162 |
-
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3163 |
-
$option_value = $k;
|
3164 |
-
$um_field_checkbox_item_title = $v;
|
3165 |
-
}
|
3166 |
-
|
3167 |
-
if ( isset( $options_pair ) ) {
|
3168 |
-
$option_value = $k;
|
3169 |
-
$um_field_checkbox_item_title = $v;
|
3170 |
-
}
|
3171 |
-
|
3172 |
-
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3173 |
-
|
3174 |
-
$output .= '<option value="' . $option_value . '" ';
|
3175 |
-
|
3176 |
-
if ( $this->is_selected( $form_key, $option_value, $data ) ) {
|
3177 |
-
$output .= 'selected';
|
3178 |
-
$field_value = $option_value;
|
3179 |
-
} elseif ( ! isset( $options_pair ) && $this->is_selected( $form_key, $v, $data ) ) {
|
3180 |
-
$output .= 'selected';
|
3181 |
-
$field_value = $v;
|
3182 |
-
}
|
3183 |
-
|
3184 |
-
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3185 |
-
}
|
3186 |
-
}
|
3187 |
-
|
3188 |
-
if ( ! empty( $disabled ) ) {
|
3189 |
-
$output .= $this->disabled_hidden_field( $form_key, $field_value );
|
3190 |
-
}
|
3191 |
-
|
3192 |
-
$output .= '</select>';
|
3193 |
-
|
3194 |
-
$output .= '</div>';
|
3195 |
-
|
3196 |
-
|
3197 |
-
if ( $this->is_error( $form_key ) ) {
|
3198 |
-
$output .= $this->field_error( $this->show_error( $form_key ) );
|
3199 |
-
} elseif ( $this->is_notice( $form_key ) ) {
|
3200 |
-
$output .= $this->field_notice( $this->show_notice( $form_key ) );
|
3201 |
-
}
|
3202 |
-
|
3203 |
-
|
3204 |
-
$output .= '</div>';
|
3205 |
-
break;
|
3206 |
-
|
3207 |
-
/* Multi-Select dropdown */
|
3208 |
-
case 'multiselect':
|
3209 |
-
|
3210 |
-
$max_selections = ( isset( $max_selections ) ) ? absint( $max_selections ) : 0;
|
3211 |
-
|
3212 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3213 |
-
|
3214 |
-
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
3215 |
-
$class = 'um-s2';
|
3216 |
-
} else {
|
3217 |
-
$class = 'um-s1';
|
3218 |
-
}
|
3219 |
-
|
3220 |
-
if ( isset( $data['label'] ) ) {
|
3221 |
-
$output .= $this->field_label( $label, $key, $data );
|
3222 |
-
}
|
3223 |
-
|
3224 |
-
$field_icon = false;
|
3225 |
-
$field_icon_output = '';
|
3226 |
-
|
3227 |
-
/**
|
3228 |
-
* UM hook
|
3229 |
-
*
|
3230 |
-
* @type filter
|
3231 |
-
* @title um_multiselect_option_value
|
3232 |
-
* @description Change multiselect keyword data
|
3233 |
-
* @input_vars
|
3234 |
-
* [{"var":"$keyword","type":"int","desc":"Option Value"},
|
3235 |
-
* {"var":"$type","type":"string","desc":"Field Type"}]
|
3236 |
-
* @change_log
|
3237 |
-
* ["Since: 2.0"]
|
3238 |
-
* @usage add_filter( 'um_multiselect_option_value', 'function_name', 10, 2 );
|
3239 |
-
* @example
|
3240 |
-
* <?php
|
3241 |
-
* add_filter( 'um_multiselect_option_value', 'my_multiselect_option_value', 10, 2 );
|
3242 |
-
* function my_multiselect_option_value( $keyword, $type ) {
|
3243 |
-
* // your code here
|
3244 |
-
* return $keyword;
|
3245 |
-
* }
|
3246 |
-
* ?>
|
3247 |
-
*/
|
3248 |
-
$use_keyword = apply_filters( 'um_multiselect_option_value', 0, $data['type'] );
|
3249 |
-
|
3250 |
-
$output .= '<div class="um-field-area ' . (! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
3251 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
3252 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
3253 |
-
}
|
3254 |
-
|
3255 |
-
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . esc_attr( $field_name ) . '[]" id="' . esc_attr( $field_id ) . '" data-maxsize="' . esc_attr( $max_selections ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '">';
|
3256 |
-
|
3257 |
-
|
3258 |
-
if ( isset( $options ) && $options == 'builtin' ) {
|
3259 |
-
$options = UM()->builtin()->get( $filter );
|
3260 |
-
}
|
3261 |
-
|
3262 |
-
if ( ! isset( $options ) ) {
|
3263 |
-
$options = UM()->builtin()->get( 'countries' );
|
3264 |
-
}
|
3265 |
-
|
3266 |
-
if ( isset( $options ) ) {
|
3267 |
-
/**
|
3268 |
-
* UM hook
|
3269 |
-
*
|
3270 |
-
* @type filter
|
3271 |
-
* @title um_multiselect_options
|
3272 |
-
* @description Extend multiselect options
|
3273 |
-
* @input_vars
|
3274 |
-
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3275 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3276 |
-
* @change_log
|
3277 |
-
* ["Since: 2.0"]
|
3278 |
-
* @usage add_filter( 'um_multiselect_options', 'function_name', 10, 2 );
|
3279 |
-
* @example
|
3280 |
-
* <?php
|
3281 |
-
* add_filter( 'um_multiselect_options', 'my_multiselect_options', 10, 2 );
|
3282 |
-
* function my_multiselect_options( $options, $data ) {
|
3283 |
-
* // your code here
|
3284 |
-
* return $options;
|
3285 |
-
* }
|
3286 |
-
* ?>
|
3287 |
-
*/
|
3288 |
-
$options = apply_filters( 'um_multiselect_options', $options, $data );
|
3289 |
-
/**
|
3290 |
-
* UM hook
|
3291 |
-
*
|
3292 |
-
* @type filter
|
3293 |
-
* @title um_multiselect_options_{$key}
|
3294 |
-
* @description Extend multiselect options by field $key
|
3295 |
-
* @input_vars
|
3296 |
-
* [{"var":"$options","type":"array","desc":"Multiselect Options"}]
|
3297 |
-
* @change_log
|
3298 |
-
* ["Since: 2.0"]
|
3299 |
-
* @usage add_filter( 'um_multiselect_options_{$key}', 'function_name', 10, 1 );
|
3300 |
-
* @example
|
3301 |
-
* <?php
|
3302 |
-
* add_filter( 'um_multiselect_options_{$key}', 'my_multiselect_options', 10, 1 );
|
3303 |
-
* function my_multiselect_options( $options ) {
|
3304 |
-
* // your code here
|
3305 |
-
* return $options;
|
3306 |
-
* }
|
3307 |
-
* ?>
|
3308 |
-
*/
|
3309 |
-
$options = apply_filters( "um_multiselect_options_{$key}", $options );
|
3310 |
-
/**
|
3311 |
-
* UM hook
|
3312 |
-
*
|
3313 |
-
* @type filter
|
3314 |
-
* @title um_multiselect_options_{$type}
|
3315 |
-
* @description Extend multiselect options by field $type
|
3316 |
-
* @input_vars
|
3317 |
-
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3318 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3319 |
-
* @change_log
|
3320 |
-
* ["Since: 2.0"]
|
3321 |
-
* @usage add_filter( 'um_multiselect_options_{$type}', 'function_name', 10, 2 );
|
3322 |
-
* @example
|
3323 |
-
* <?php
|
3324 |
-
* add_filter( 'um_multiselect_options_{$type}', 'my_multiselect_options', 10, 2 );
|
3325 |
-
* function my_multiselect_option_value( $options, $data ) {
|
3326 |
-
* // your code here
|
3327 |
-
* return $options;
|
3328 |
-
* }
|
3329 |
-
* ?>
|
3330 |
-
*/
|
3331 |
-
$options = apply_filters( "um_multiselect_options_{$data['type']}", $options, $data );
|
3332 |
-
}
|
3333 |
-
|
3334 |
-
/**
|
3335 |
-
* UM hook
|
3336 |
-
*
|
3337 |
-
* @type filter
|
3338 |
-
* @title um_select_option_value
|
3339 |
-
* @description Enable options pair by field $data
|
3340 |
-
* @input_vars
|
3341 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3342 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3343 |
-
*/
|
3344 |
-
$use_keyword = apply_filters( 'um_select_options_pair', null, $data );
|
3345 |
-
|
3346 |
-
// switch options pair for custom options from a callback function
|
3347 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3348 |
-
$use_keyword = true;
|
3349 |
-
}
|
3350 |
-
|
3351 |
-
// add an empty option!
|
3352 |
-
$output .= '<option value=""></option>';
|
3353 |
-
|
3354 |
-
$arr_selected = array();
|
3355 |
-
// add options
|
3356 |
-
if ( ! empty( $options ) && is_array( $options ) ) {
|
3357 |
-
foreach ( $options as $k => $v ) {
|
3358 |
-
|
3359 |
-
$v = rtrim( $v );
|
3360 |
-
|
3361 |
-
$um_field_checkbox_item_title = $v;
|
3362 |
-
$opt_value = $v;
|
3363 |
-
|
3364 |
-
if ( $use_keyword ) {
|
3365 |
-
$um_field_checkbox_item_title = $v;
|
3366 |
-
$opt_value = $k;
|
3367 |
-
}
|
3368 |
-
|
3369 |
-
$opt_value = $this->filter_field_non_utf8_value( $opt_value );
|
3370 |
-
|
3371 |
-
$output .= '<option value="' . $opt_value . '" ';
|
3372 |
-
if ( $this->is_selected( $key, $opt_value, $data ) ) {
|
3373 |
-
|
3374 |
-
$output .= 'selected';
|
3375 |
-
$arr_selected[ $opt_value ] = $opt_value;
|
3376 |
-
}
|
3377 |
-
|
3378 |
-
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3379 |
-
|
3380 |
-
}
|
3381 |
-
}
|
3382 |
-
|
3383 |
-
$output .= '</select>';
|
3384 |
-
|
3385 |
-
if ( ! empty( $disabled ) && ! empty( $arr_selected ) ) {
|
3386 |
-
foreach ( $arr_selected as $item ) {
|
3387 |
-
$output .= $this->disabled_hidden_field( $key . '[]', $item );
|
3388 |
-
}
|
3389 |
-
}
|
3390 |
-
|
3391 |
-
$output .= '</div>';
|
3392 |
-
|
3393 |
-
|
3394 |
-
if ( $this->is_error( $key ) ) {
|
3395 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
3396 |
-
}else if ( $this->is_notice( $key ) ) {
|
3397 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3398 |
-
}
|
3399 |
-
|
3400 |
-
$output .= '</div>';
|
3401 |
-
break;
|
3402 |
-
|
3403 |
-
/* Radio */
|
3404 |
-
case 'radio':
|
3405 |
-
|
3406 |
-
if ( isset( $options ) ) {
|
3407 |
-
/**
|
3408 |
-
* UM hook
|
3409 |
-
*
|
3410 |
-
* @type filter
|
3411 |
-
* @title um_radio_field_options
|
3412 |
-
* @description Extend radio field options
|
3413 |
-
* @input_vars
|
3414 |
-
* [{"var":"$options","type":"array","desc":"Radio Field Options"},
|
3415 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3416 |
-
* @change_log
|
3417 |
-
* ["Since: 2.0"]
|
3418 |
-
* @usage add_filter( 'um_radio_field_options', 'function_name', 10, 2 );
|
3419 |
-
* @example
|
3420 |
-
* <?php
|
3421 |
-
* add_filter( 'um_radio_field_options', 'my_radio_field_options', 10, 2 );
|
3422 |
-
* function my_radio_field_options( $options, $data ) {
|
3423 |
-
* // your code here
|
3424 |
-
* return $options;
|
3425 |
-
* }
|
3426 |
-
* ?>
|
3427 |
-
*/
|
3428 |
-
$options = apply_filters( 'um_radio_field_options', $options, $data );
|
3429 |
-
/**
|
3430 |
-
* UM hook
|
3431 |
-
*
|
3432 |
-
* @type filter
|
3433 |
-
* @title um_radio_field_options_{$key}
|
3434 |
-
* @description Extend radio field options by field $key
|
3435 |
-
* @input_vars
|
3436 |
-
* [{"var":"$options","type":"array","desc":"Radio field Options"}]
|
3437 |
-
* @change_log
|
3438 |
-
* ["Since: 2.0"]
|
3439 |
-
* @usage add_filter( 'um_radio_field_options_{$key}', 'function_name', 10, 1 );
|
3440 |
-
* @example
|
3441 |
-
* <?php
|
3442 |
-
* add_filter( 'um_radio_field_options_{$key}', 'my_radio_field_options', 10, 1 );
|
3443 |
-
* function my_radio_field_options( $options ) {
|
3444 |
-
* // your code here
|
3445 |
-
* return $options;
|
3446 |
-
* }
|
3447 |
-
* ?>
|
3448 |
-
*/
|
3449 |
-
$options = apply_filters( "um_radio_field_options_{$key}", $options );
|
3450 |
-
}
|
3451 |
-
|
3452 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3453 |
-
|
3454 |
-
if ( isset( $data['label'] ) ) {
|
3455 |
-
$output .= $this->field_label( $label, $key, $data );
|
3456 |
-
}
|
3457 |
-
|
3458 |
-
$output .= '<div class="um-field-area">';
|
3459 |
-
|
3460 |
-
$options = $this->get_available_roles( $form_key, $options );
|
3461 |
-
|
3462 |
-
// add options
|
3463 |
-
$i = 0;
|
3464 |
-
$field_value = array();
|
3465 |
-
|
3466 |
-
/**
|
3467 |
-
* UM hook
|
3468 |
-
*
|
3469 |
-
* @type filter
|
3470 |
-
* @title um_radio_option_value
|
3471 |
-
* @description Enable options pair by field $data
|
3472 |
-
* @input_vars
|
3473 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3474 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3475 |
-
*/
|
3476 |
-
$options_pair = apply_filters( "um_radio_options_pair__{$key}", false, $data );
|
3477 |
-
|
3478 |
-
|
3479 |
-
if ( ! empty( $options ) ) {
|
3480 |
-
foreach ( $options as $k => $v ) {
|
3481 |
-
|
3482 |
-
$v = rtrim( $v );
|
3483 |
-
|
3484 |
-
$um_field_checkbox_item_title = $v;
|
3485 |
-
$option_value = $v;
|
3486 |
-
|
3487 |
-
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3488 |
-
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3489 |
-
$um_field_checkbox_item_title = $v;
|
3490 |
-
$option_value = $k;
|
3491 |
-
}
|
3492 |
-
|
3493 |
-
if( $options_pair ){
|
3494 |
-
$um_field_checkbox_item_title = $v;
|
3495 |
-
$option_value = $k;
|
3496 |
-
}
|
3497 |
-
|
3498 |
-
$i++;
|
3499 |
-
if ($i % 2 == 0) {
|
3500 |
-
$col_class = 'right';
|
3501 |
-
} else {
|
3502 |
-
$col_class = '';
|
3503 |
-
}
|
3504 |
-
|
3505 |
-
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3506 |
-
$active = 'active';
|
3507 |
-
$class = "um-icon-android-radio-button-on";
|
3508 |
-
} else {
|
3509 |
-
$active = '';
|
3510 |
-
$class = "um-icon-android-radio-button-off";
|
3511 |
-
}
|
3512 |
-
|
3513 |
-
|
3514 |
-
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3515 |
-
$col_class .= " um-field-radio-state-disabled";
|
3516 |
-
}
|
3517 |
-
|
3518 |
-
$output .= '<label class="um-field-radio ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3519 |
-
|
3520 |
-
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3521 |
-
|
3522 |
-
$output .= '<input ' . $disabled . ' type="radio" name="' . ( ( $form_key == 'role' ) ? esc_attr( $form_key ) : esc_attr( $form_key ) . '[]' ) . '" value="' . $option_value . '" ';
|
3523 |
-
|
3524 |
-
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3525 |
-
$output .= 'checked';
|
3526 |
-
$field_value[ $key ] = $option_value;
|
3527 |
-
}
|
3528 |
-
|
3529 |
-
$output .= ' />';
|
3530 |
-
|
3531 |
-
$output .= '<span class="um-field-radio-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3532 |
-
$output .= '<span class="um-field-radio-option">' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3533 |
-
$output .= '</label>';
|
3534 |
-
|
3535 |
-
if ( $i % 2 == 0 ) {
|
3536 |
-
$output .= '<div class="um-clear"></div>';
|
3537 |
-
}
|
3538 |
-
|
3539 |
-
}
|
3540 |
-
}
|
3541 |
-
|
3542 |
-
if ( ! empty( $disabled ) ) {
|
3543 |
-
foreach ( $field_value as $item ) {
|
3544 |
-
$output .= $this->disabled_hidden_field( $form_key, $item );
|
3545 |
-
}
|
3546 |
-
}
|
3547 |
-
|
3548 |
-
$output .= '<div class="um-clear"></div>';
|
3549 |
-
|
3550 |
-
$output .= '</div>';
|
3551 |
-
|
3552 |
-
if ( $this->is_error( $key ) ) {
|
3553 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
3554 |
-
}else if ( $this->is_notice( $key ) ) {
|
3555 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3556 |
-
}
|
3557 |
-
|
3558 |
-
$output .= '</div>';
|
3559 |
-
break;
|
3560 |
-
|
3561 |
-
/* Checkbox */
|
3562 |
-
case 'checkbox':
|
3563 |
-
|
3564 |
-
if ( isset( $options ) ) {
|
3565 |
-
/**
|
3566 |
-
* UM hook
|
3567 |
-
*
|
3568 |
-
* @type filter
|
3569 |
-
* @title um_checkbox_field_options
|
3570 |
-
* @description Extend checkbox options
|
3571 |
-
* @input_vars
|
3572 |
-
* [{"var":"$options","type":"array","desc":"Checkbox Options"},
|
3573 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3574 |
-
* @change_log
|
3575 |
-
* ["Since: 2.0"]
|
3576 |
-
* @usage add_filter( 'um_checkbox_field_options', 'function_name', 10, 2 );
|
3577 |
-
* @example
|
3578 |
-
* <?php
|
3579 |
-
* add_filter( 'um_checkbox_field_options', 'my_checkbox_options', 10, 2 );
|
3580 |
-
* function my_checkbox_options( $options, $data ) {
|
3581 |
-
* // your code here
|
3582 |
-
* return $options;
|
3583 |
-
* }
|
3584 |
-
* ?>
|
3585 |
-
*/
|
3586 |
-
$options = apply_filters( 'um_checkbox_field_options', $options, $data );
|
3587 |
-
/**
|
3588 |
-
* UM hook
|
3589 |
-
*
|
3590 |
-
* @type filter
|
3591 |
-
* @title um_checkbox_field_options_{$key}
|
3592 |
-
* @description Extend checkbox options by field $key
|
3593 |
-
* @input_vars
|
3594 |
-
* [{"var":"$options","type":"array","desc":"Checkbox Options"}]
|
3595 |
-
* @change_log
|
3596 |
-
* ["Since: 2.0"]
|
3597 |
-
* @usage add_filter( 'um_checkbox_field_options_{$key}', 'function_name', 10, 1 );
|
3598 |
-
* @example
|
3599 |
-
* <?php
|
3600 |
-
* add_filter( 'um_checkbox_field_options_{$key}', 'my_checkbox_options', 10, 1 );
|
3601 |
-
* function my_checkbox_options( $options ) {
|
3602 |
-
* // your code here
|
3603 |
-
* return $options;
|
3604 |
-
* }
|
3605 |
-
* ?>
|
3606 |
-
*/
|
3607 |
-
$options = apply_filters( "um_checkbox_field_options_{$key}", $options );
|
3608 |
-
}
|
3609 |
-
|
3610 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3611 |
-
|
3612 |
-
if ( isset( $data['label'] ) ) {
|
3613 |
-
$output .= $this->field_label( $label, $key, $data );
|
3614 |
-
}
|
3615 |
-
|
3616 |
-
$output .= '<div class="um-field-area">';
|
3617 |
-
|
3618 |
-
// add options
|
3619 |
-
$i = 0;
|
3620 |
-
|
3621 |
-
foreach ( $options as $k => $v ) {
|
3622 |
-
|
3623 |
-
$v = rtrim( $v );
|
3624 |
-
|
3625 |
-
$i++;
|
3626 |
-
if ( $i % 2 == 0 ) {
|
3627 |
-
$col_class = 'right';
|
3628 |
-
} else {
|
3629 |
-
$col_class = '';
|
3630 |
-
}
|
3631 |
-
|
3632 |
-
if ( $this->is_selected( $key, $v, $data ) ) {
|
3633 |
-
$active = 'active';
|
3634 |
-
$class = "um-icon-android-checkbox-outline";
|
3635 |
-
} else {
|
3636 |
-
$active = '';
|
3637 |
-
$class = "um-icon-android-checkbox-outline-blank";
|
3638 |
-
}
|
3639 |
-
|
3640 |
-
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3641 |
-
$col_class .= " um-field-radio-state-disabled";
|
3642 |
-
}
|
3643 |
-
|
3644 |
-
$output .= '<label class="um-field-checkbox ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3645 |
-
|
3646 |
-
$um_field_checkbox_item_title = $v;
|
3647 |
-
|
3648 |
-
$v = $this->filter_field_non_utf8_value( $v );
|
3649 |
-
|
3650 |
-
$output .= '<input ' . $disabled . ' type="checkbox" name="' . esc_attr( $key ) . '[]" value="' . strip_tags( $v ) . '" ';
|
3651 |
-
|
3652 |
-
if ( $this->is_selected( $key, $v, $data ) ) {
|
3653 |
-
$output .= 'checked';
|
3654 |
-
}
|
3655 |
-
|
3656 |
-
$output .= ' />';
|
3657 |
-
|
3658 |
-
if ( ! empty( $disabled ) && $this->is_selected( $key, $v, $data ) ) {
|
3659 |
-
$output .= $this->disabled_hidden_field( $key . '[]', strip_tags( $v ) );
|
3660 |
-
}
|
3661 |
-
|
3662 |
-
|
3663 |
-
$output .= '<span class="um-field-checkbox-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3664 |
-
/**
|
3665 |
-
* UM hook
|
3666 |
-
*
|
3667 |
-
* @type filter
|
3668 |
-
* @title um_field_checkbox_item_title
|
3669 |
-
* @description Change Checkbox item title
|
3670 |
-
* @input_vars
|
3671 |
-
* [{"var":"$checkbox_item_title","type":"array","desc":"Item Title"},
|
3672 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
3673 |
-
* {"var":"$value","type":"string","desc":"Field Value"},
|
3674 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3675 |
-
* @change_log
|
3676 |
-
* ["Since: 2.0"]
|
3677 |
-
* @usage add_filter( 'um_field_checkbox_item_title', 'function_name', 10, 4 );
|
3678 |
-
* @example
|
3679 |
-
* <?php
|
3680 |
-
* add_filter( 'um_field_checkbox_item_title', 'my_checkbox_item_title', 10, 4 );
|
3681 |
-
* function my_checkbox_item_title( $checkbox_item_title, $key, $value, $data ) {
|
3682 |
-
* // your code here
|
3683 |
-
* return $checkbox_item_title;
|
3684 |
-
* }
|
3685 |
-
* ?>
|
3686 |
-
*/
|
3687 |
-
$um_field_checkbox_item_title = apply_filters( 'um_field_checkbox_item_title', $um_field_checkbox_item_title, $key, $v, $data );
|
3688 |
-
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3689 |
-
$output .= '</label>';
|
3690 |
-
|
3691 |
-
if ( $i % 2 == 0 ) {
|
3692 |
-
$output .= '<div class="um-clear"></div>';
|
3693 |
-
}
|
3694 |
-
|
3695 |
-
}
|
3696 |
-
|
3697 |
-
$output .= '<div class="um-clear"></div>';
|
3698 |
-
|
3699 |
-
$output .= '</div>';
|
3700 |
-
|
3701 |
-
|
3702 |
-
if ( $this->is_error( $key ) ) {
|
3703 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
3704 |
-
}else if ( $this->is_notice( $key ) ) {
|
3705 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3706 |
-
}
|
3707 |
-
|
3708 |
-
$output .= '</div>';
|
3709 |
-
break;
|
3710 |
-
|
3711 |
-
/* HTML */
|
3712 |
-
case 'block':
|
3713 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3714 |
-
break;
|
3715 |
-
|
3716 |
-
/* Shortcode */
|
3717 |
-
case 'shortcode':
|
3718 |
-
|
3719 |
-
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
3720 |
-
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
3721 |
-
$content = do_shortcode( $content );
|
3722 |
-
} else {
|
3723 |
-
$content = apply_shortcodes( $content );
|
3724 |
-
}
|
3725 |
-
|
3726 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3727 |
-
break;
|
3728 |
-
|
3729 |
-
/* Unlimited Group */
|
3730 |
-
case 'group':
|
3731 |
-
|
3732 |
-
$fields = $this->get_fields_in_group( $key );
|
3733 |
-
if ( ! empty( $fields ) ) {
|
3734 |
-
|
3735 |
-
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
|
3736 |
-
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . esc_html__( $label, 'ultimate-member' ) . '</div>';
|
3737 |
-
$output .= '<div class="um-field-group-body"><a href="javascript:void(0);" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
|
3738 |
-
|
3739 |
-
foreach ( $fields as $subkey => $subdata ) {
|
3740 |
-
$output .= $this->edit_field( $subkey, $subdata, 'group' );
|
3741 |
-
}
|
3742 |
-
|
3743 |
-
$output .= '</div>';
|
3744 |
-
$output .= '</div>';
|
3745 |
-
|
3746 |
-
}
|
3747 |
-
|
3748 |
-
break;
|
3749 |
-
|
3750 |
-
}
|
3751 |
-
|
3752 |
-
// Custom filter for field output
|
3753 |
-
if ( isset( $this->set_mode ) ) {
|
3754 |
-
/**
|
3755 |
-
* UM hook
|
3756 |
-
*
|
3757 |
-
* @type filter
|
3758 |
-
* @title um_{$key}_form_edit_field
|
3759 |
-
* @description Change field HTML on edit mode by field $key
|
3760 |
-
* @input_vars
|
3761 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
3762 |
-
* {"var":"$mode","type":"string","desc":"Fields Mode"}]
|
3763 |
-
* @change_log
|
3764 |
-
* ["Since: 2.0"]
|
3765 |
-
* @usage add_filter( 'um_{$key}_form_edit_field', 'function_name', 10, 2 );
|
3766 |
-
* @example
|
3767 |
-
* <?php
|
3768 |
-
* add_filter( 'um_{$key}_form_edit_field', 'my_form_edit_field', 10, 2 );
|
3769 |
-
* function my_form_edit_field( $output, $mode ) {
|
3770 |
-
* // your code here
|
3771 |
-
* return $output;
|
3772 |
-
* }
|
3773 |
-
* ?>
|
3774 |
-
*/
|
3775 |
-
$output = apply_filters( "um_{$key}_form_edit_field", $output, $this->set_mode );
|
3776 |
-
}
|
3777 |
-
|
3778 |
-
return $output;
|
3779 |
-
}
|
3780 |
-
|
3781 |
-
|
3782 |
-
/**
|
3783 |
-
* Filter for user roles
|
3784 |
-
*
|
3785 |
-
* @param $form_key
|
3786 |
-
* @param array $options
|
3787 |
-
* @return array
|
3788 |
-
*/
|
3789 |
-
function get_available_roles( $form_key, $options = array() ) {
|
3790 |
-
if ( $form_key != 'role' ) {
|
3791 |
-
return $options;
|
3792 |
-
}
|
3793 |
-
|
3794 |
-
// role field
|
3795 |
-
global $wp_roles;
|
3796 |
-
$role_keys = array_map( function( $item ) {
|
3797 |
-
return 'um_' . $item;
|
3798 |
-
}, get_option( 'um_roles', array() ) );
|
3799 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
3800 |
-
|
3801 |
-
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
3802 |
-
|
3803 |
-
if ( ! empty( $options ) ) {
|
3804 |
-
|
3805 |
-
$roles = array_map( function( $item ) {
|
3806 |
-
return html_entity_decode( $item, ENT_QUOTES );
|
3807 |
-
}, $roles );
|
3808 |
-
|
3809 |
-
//fix when customers change options for role (radio/dropdown) fields
|
3810 |
-
$intersected_options = array();
|
3811 |
-
foreach ( $options as $key => $title ) {
|
3812 |
-
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
3813 |
-
$intersected_options[ $search_key ] = $title;
|
3814 |
-
} elseif ( isset( $roles[ $key ] ) ) {
|
3815 |
-
$intersected_options[ $key ] = $title;
|
3816 |
-
}
|
3817 |
-
}
|
3818 |
-
|
3819 |
-
$options = $intersected_options;
|
3820 |
-
} else {
|
3821 |
-
$options = $roles;
|
3822 |
-
}
|
3823 |
-
|
3824 |
-
return $options;
|
3825 |
-
}
|
3826 |
-
|
3827 |
-
|
3828 |
-
/**
|
3829 |
-
* Sorts columns array
|
3830 |
-
*
|
3831 |
-
* @param array $arr
|
3832 |
-
* @param string $col
|
3833 |
-
* @param string $dir
|
3834 |
-
*
|
3835 |
-
* @return array $arr
|
3836 |
-
*/
|
3837 |
-
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
3838 |
-
$sort_col = array();
|
3839 |
-
foreach ( $arr as $key => $row ) {
|
3840 |
-
if ( $key == 'form_id' ) {
|
3841 |
-
unset( $arr['form_id'] );
|
3842 |
-
continue;
|
3843 |
-
}
|
3844 |
-
|
3845 |
-
if ( isset( $row[ $col ] ) ) {
|
3846 |
-
$sort_col[ $key ] = $row[ $col ];
|
3847 |
-
} else {
|
3848 |
-
unset( $arr[ $key ] );
|
3849 |
-
}
|
3850 |
-
}
|
3851 |
-
|
3852 |
-
array_multisort( $sort_col, $dir, $arr );
|
3853 |
-
|
3854 |
-
return $arr;
|
3855 |
-
}
|
3856 |
-
|
3857 |
-
|
3858 |
-
/**
|
3859 |
-
* Get fields in row
|
3860 |
-
*
|
3861 |
-
* @param int $row_id
|
3862 |
-
*
|
3863 |
-
* @return string
|
3864 |
-
*/
|
3865 |
-
function get_fields_by_row( $row_id ) {
|
3866 |
-
if ( ! isset( $this->get_fields ) ) {
|
3867 |
-
return '';
|
3868 |
-
}
|
3869 |
-
|
3870 |
-
foreach ( $this->get_fields as $key => $array ) {
|
3871 |
-
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3872 |
-
$results[ $key ] = $array;
|
3873 |
-
}
|
3874 |
-
}
|
3875 |
-
|
3876 |
-
return ( isset ( $results ) ) ? $results : '';
|
3877 |
-
}
|
3878 |
-
|
3879 |
-
|
3880 |
-
/**
|
3881 |
-
* Get fields by sub row
|
3882 |
-
*
|
3883 |
-
* @param string $row_fields
|
3884 |
-
* @param integer $subrow_id
|
3885 |
-
*
|
3886 |
-
* @return mixed
|
3887 |
-
*/
|
3888 |
-
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
3889 |
-
if ( ! is_array( $row_fields ) ) {
|
3890 |
-
return '';
|
3891 |
-
}
|
3892 |
-
foreach ( $row_fields as $key => $array ) {
|
3893 |
-
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
3894 |
-
$results[ $key ] = $array;
|
3895 |
-
}
|
3896 |
-
}
|
3897 |
-
|
3898 |
-
return ( isset ( $results ) ) ? $results : '';
|
3899 |
-
}
|
3900 |
-
|
3901 |
-
|
3902 |
-
/**
|
3903 |
-
* Get fields in group
|
3904 |
-
*
|
3905 |
-
* @param integer $group_id
|
3906 |
-
*
|
3907 |
-
* @return mixed
|
3908 |
-
*/
|
3909 |
-
function get_fields_in_group( $group_id ) {
|
3910 |
-
foreach ( $this->get_fields as $key => $array ) {
|
3911 |
-
if ( isset( $array['in_group'] ) && $array['in_group'] == $group_id ) {
|
3912 |
-
$results[ $key ] = $array;
|
3913 |
-
}
|
3914 |
-
}
|
3915 |
-
|
3916 |
-
return ( isset ( $results ) ) ? $results : '';
|
3917 |
-
}
|
3918 |
-
|
3919 |
-
|
3920 |
-
/**
|
3921 |
-
* Get fields in column
|
3922 |
-
*
|
3923 |
-
* @param array $fields
|
3924 |
-
* @param integer $col_number
|
3925 |
-
*
|
3926 |
-
* @return mixed
|
3927 |
-
*/
|
3928 |
-
function get_fields_in_column( $fields, $col_number ) {
|
3929 |
-
foreach ( $fields as $key => $array ) {
|
3930 |
-
if ( isset( $array['in_column'] ) && $array['in_column'] == $col_number ) {
|
3931 |
-
$results[ $key ] = $array;
|
3932 |
-
}
|
3933 |
-
}
|
3934 |
-
|
3935 |
-
return ( isset ( $results ) ) ? $results : '';
|
3936 |
-
}
|
3937 |
-
|
3938 |
-
|
3939 |
-
/**
|
3940 |
-
* Display fields
|
3941 |
-
*
|
3942 |
-
* @param string $mode
|
3943 |
-
* @param array $args
|
3944 |
-
*
|
3945 |
-
* @return string|null
|
3946 |
-
* @throws \Exception
|
3947 |
-
*/
|
3948 |
-
function display( $mode, $args ) {
|
3949 |
-
$output = null;
|
3950 |
-
|
3951 |
-
$this->global_args = $args;
|
3952 |
-
|
3953 |
-
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
3954 |
-
|
3955 |
-
$this->set_mode = $mode;
|
3956 |
-
|
3957 |
-
if ( 'profile' === $mode ) {
|
3958 |
-
UM()->form()->nonce = wp_create_nonce( 'um-profile-nonce' . UM()->user()->target_id );
|
3959 |
-
}
|
3960 |
-
|
3961 |
-
$this->set_id = $this->global_args['form_id'];
|
3962 |
-
|
3963 |
-
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
3964 |
-
|
3965 |
-
// start output here
|
3966 |
-
$this->get_fields = $this->get_fields();
|
3967 |
-
|
3968 |
-
if ( ! empty( $this->get_fields ) ) {
|
3969 |
-
|
3970 |
-
// find rows
|
3971 |
-
foreach ( $this->get_fields as $key => $array ) {
|
3972 |
-
if ( $array['type'] == 'row' ) {
|
3973 |
-
$this->rows[ $key ] = $array;
|
3974 |
-
unset( $this->get_fields[ $key ] ); // not needed anymore
|
3975 |
-
}
|
3976 |
-
}
|
3977 |
-
|
3978 |
-
// rows fallback
|
3979 |
-
if ( ! isset( $this->rows ) ) {
|
3980 |
-
$this->rows = array(
|
3981 |
-
'_um_row_1' => array(
|
3982 |
-
'type' => 'row',
|
3983 |
-
'id' => '_um_row_1',
|
3984 |
-
'sub_rows' => 1,
|
3985 |
-
'cols' => 1,
|
3986 |
-
),
|
3987 |
-
);
|
3988 |
-
}
|
3989 |
-
|
3990 |
-
// master rows
|
3991 |
-
foreach ( $this->rows as $row_id => $row_array ) {
|
3992 |
-
|
3993 |
-
$row_fields = $this->get_fields_by_row( $row_id );
|
3994 |
-
if ( $row_fields ) {
|
3995 |
-
|
3996 |
-
$output .= $this->new_row_output( $row_id, $row_array );
|
3997 |
-
|
3998 |
-
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
3999 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4000 |
-
|
4001 |
-
// cols
|
4002 |
-
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4003 |
-
if ( is_numeric( $cols ) ) {
|
4004 |
-
$cols_num = (int) $cols;
|
4005 |
-
} else {
|
4006 |
-
if ( strstr( $cols, ':' ) ) {
|
4007 |
-
$col_split = explode( ':', $cols );
|
4008 |
-
} else {
|
4009 |
-
$col_split = array( $cols );
|
4010 |
-
}
|
4011 |
-
$cols_num = $col_split[ $c ];
|
4012 |
-
}
|
4013 |
-
|
4014 |
-
// sub row fields
|
4015 |
-
$subrow_fields = null;
|
4016 |
-
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4017 |
-
|
4018 |
-
if ( is_array( $subrow_fields ) ) {
|
4019 |
-
|
4020 |
-
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4021 |
-
|
4022 |
-
if ( $cols_num == 1 ) {
|
4023 |
-
|
4024 |
-
$output .= '<div class="um-col-1">';
|
4025 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4026 |
-
if ( $col1_fields ) {
|
4027 |
-
foreach ( $col1_fields as $key => $data ) {
|
4028 |
-
$output .= $this->edit_field( $key, $data );
|
4029 |
-
}
|
4030 |
-
}
|
4031 |
-
$output .= '</div>';
|
4032 |
-
|
4033 |
-
} else if ($cols_num == 2) {
|
4034 |
-
|
4035 |
-
$output .= '<div class="um-col-121">';
|
4036 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4037 |
-
if ( $col1_fields ) {
|
4038 |
-
foreach ( $col1_fields as $key => $data ) {
|
4039 |
-
$output .= $this->edit_field( $key, $data );
|
4040 |
-
}
|
4041 |
-
}
|
4042 |
-
$output .= '</div>';
|
4043 |
-
|
4044 |
-
$output .= '<div class="um-col-122">';
|
4045 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4046 |
-
if ( $col2_fields ) {
|
4047 |
-
foreach ( $col2_fields as $key => $data ) {
|
4048 |
-
$output .= $this->edit_field( $key, $data );
|
4049 |
-
}
|
4050 |
-
}
|
4051 |
-
$output .= '</div><div class="um-clear"></div>';
|
4052 |
-
|
4053 |
-
} else {
|
4054 |
-
|
4055 |
-
$output .= '<div class="um-col-131">';
|
4056 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4057 |
-
if ( $col1_fields ) {
|
4058 |
-
foreach ( $col1_fields as $key => $data ) {
|
4059 |
-
$output .= $this->edit_field( $key, $data );
|
4060 |
-
}
|
4061 |
-
}
|
4062 |
-
$output .= '</div>';
|
4063 |
-
|
4064 |
-
$output .= '<div class="um-col-132">';
|
4065 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4066 |
-
if ( $col2_fields ) {
|
4067 |
-
foreach ( $col2_fields as $key => $data ) {
|
4068 |
-
$output .= $this->edit_field( $key, $data );
|
4069 |
-
}
|
4070 |
-
}
|
4071 |
-
$output .= '</div>';
|
4072 |
-
|
4073 |
-
$output .= '<div class="um-col-133">';
|
4074 |
-
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4075 |
-
if ( $col3_fields ) {
|
4076 |
-
foreach ( $col3_fields as $key => $data ) {
|
4077 |
-
$output .= $this->edit_field( $key, $data );
|
4078 |
-
}
|
4079 |
-
}
|
4080 |
-
$output .= '</div><div class="um-clear"></div>';
|
4081 |
-
|
4082 |
-
}
|
4083 |
-
|
4084 |
-
}
|
4085 |
-
|
4086 |
-
}
|
4087 |
-
|
4088 |
-
$output .= '</div>';
|
4089 |
-
|
4090 |
-
}
|
4091 |
-
|
4092 |
-
}
|
4093 |
-
|
4094 |
-
}
|
4095 |
-
|
4096 |
-
return $output;
|
4097 |
-
}
|
4098 |
-
|
4099 |
-
|
4100 |
-
/**
|
4101 |
-
* Gets a field in `view mode`
|
4102 |
-
*
|
4103 |
-
* @param string $key
|
4104 |
-
* @param array $data
|
4105 |
-
* @param bool $rule
|
4106 |
-
*
|
4107 |
-
* @return string|null
|
4108 |
-
* @throws \Exception
|
4109 |
-
*/
|
4110 |
-
function view_field( $key, $data, $rule = false ) {
|
4111 |
-
$output = '';
|
4112 |
-
|
4113 |
-
// get whole field data
|
4114 |
-
if ( is_array( $data ) ) {
|
4115 |
-
$data = $this->get_field( $key );
|
4116 |
-
|
4117 |
-
if ( is_array( $data ) ) {
|
4118 |
-
/**
|
4119 |
-
* @var $visibility
|
4120 |
-
* @var $type
|
4121 |
-
* @var $default
|
4122 |
-
* @var $classes
|
4123 |
-
* @var $conditional
|
4124 |
-
* @var $content
|
4125 |
-
* @var $divider_text
|
4126 |
-
* @var $spacing
|
4127 |
-
* @var $borderwidth
|
4128 |
-
* @var $borderstyle
|
4129 |
-
* @var $bordercolor
|
4130 |
-
* @var $label
|
4131 |
-
*/
|
4132 |
-
extract( $data );
|
4133 |
-
}
|
4134 |
-
}
|
4135 |
-
|
4136 |
-
//hide if empty type
|
4137 |
-
if ( ! isset( $data['type'] ) ) {
|
4138 |
-
return '';
|
4139 |
-
}
|
4140 |
-
|
4141 |
-
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
4142 |
-
return '';
|
4143 |
-
}
|
4144 |
-
|
4145 |
-
//invisible on profile page
|
4146 |
-
if ( $visibility == 'edit' || $type == 'password' ) {
|
4147 |
-
return '';
|
4148 |
-
}
|
4149 |
-
|
4150 |
-
//hide if empty
|
4151 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4152 |
-
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4153 |
-
$_field_value = $this->field_value( $key, $default, $data );
|
4154 |
-
|
4155 |
-
if ( ! isset( $_field_value ) || $_field_value == '' ) {
|
4156 |
-
return '';
|
4157 |
-
}
|
4158 |
-
}
|
4159 |
-
|
4160 |
-
if ( ! um_can_view_field( $data ) ) {
|
4161 |
-
return '';
|
4162 |
-
}
|
4163 |
-
|
4164 |
-
// disable these fields in profile view only
|
4165 |
-
if ( in_array( $key, array( 'user_password' ) ) && $this->set_mode == 'profile' ) {
|
4166 |
-
return '';
|
4167 |
-
}
|
4168 |
-
|
4169 |
-
if ( ! um_field_conditions_are_met( $data ) ) {
|
4170 |
-
return '';
|
4171 |
-
}
|
4172 |
-
|
4173 |
-
|
4174 |
-
if ( isset( $data['classes'] ) ) {
|
4175 |
-
$classes = explode( " ", $data['classes'] );
|
4176 |
-
}
|
4177 |
-
|
4178 |
-
switch ( $type ) {
|
4179 |
-
|
4180 |
-
/* Default */
|
4181 |
-
default:
|
4182 |
-
|
4183 |
-
$_field_value = $this->field_value( $key, $default, $data );
|
4184 |
-
|
4185 |
-
if ( ! in_array( $type, $fields_without_metakey ) && ( ! isset( $_field_value ) || $_field_value == '' ) ) {
|
4186 |
-
$output = '';
|
4187 |
-
} else {
|
4188 |
-
|
4189 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4190 |
-
|
4191 |
-
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4192 |
-
|
4193 |
-
if ( ! isset( $data['label'] ) ) {
|
4194 |
-
$data['label'] = '';
|
4195 |
-
}
|
4196 |
-
|
4197 |
-
$output .= $this->field_label( $data['label'], $key, $data );
|
4198 |
-
}
|
4199 |
-
|
4200 |
-
$res = $this->field_value( $key, $default, $data );
|
4201 |
-
|
4202 |
-
if ( ! empty( $res ) ) {
|
4203 |
-
$res = stripslashes( $res );
|
4204 |
-
}
|
4205 |
-
if ( 'description' === $data['metakey'] ) {
|
4206 |
-
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
4207 |
-
$res = make_clickable( wpautop( wp_kses_post( $res ) ) );
|
4208 |
-
} else {
|
4209 |
-
$res = esc_html( $res );
|
4210 |
-
}
|
4211 |
-
|
4212 |
-
$res = nl2br( $res );
|
4213 |
-
}
|
4214 |
-
|
4215 |
-
$data['is_view_field'] = true;
|
4216 |
-
/**
|
4217 |
-
* UM hook
|
4218 |
-
*
|
4219 |
-
* @type filter
|
4220 |
-
* @title um_view_field
|
4221 |
-
* @description Change field HTML on view mode
|
4222 |
-
* @input_vars
|
4223 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4224 |
-
* {"var":"$data","type":"string","desc":"Field Data"},
|
4225 |
-
* {"var":"$type","type":"string","desc":"Field Type"}]
|
4226 |
-
* @change_log
|
4227 |
-
* ["Since: 2.0"]
|
4228 |
-
* @usage add_filter( 'um_view_field', 'function_name', 10, 3 );
|
4229 |
-
* @example
|
4230 |
-
* <?php
|
4231 |
-
* add_filter( 'um_view_field', 'my_view_field', 10, 3 );
|
4232 |
-
* function my_form_edit_field( $output, $data, $type ) {
|
4233 |
-
* // your code here
|
4234 |
-
* return $output;
|
4235 |
-
* }
|
4236 |
-
* ?>
|
4237 |
-
*/
|
4238 |
-
$res = apply_filters( 'um_view_field', $res, $data, $type );
|
4239 |
-
/**
|
4240 |
-
* UM hook
|
4241 |
-
*
|
4242 |
-
* @type filter
|
4243 |
-
* @title um_view_field_value_{$type}
|
4244 |
-
* @description Change field HTML on view mode by field type
|
4245 |
-
* @input_vars
|
4246 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4247 |
-
* {"var":"$data","type":"string","desc":"Field Data"}]
|
4248 |
-
* @change_log
|
4249 |
-
* ["Since: 2.0"]
|
4250 |
-
* @usage add_filter( 'um_view_field_value_{$type}', 'function_name', 10, 2 );
|
4251 |
-
* @example
|
4252 |
-
* <?php
|
4253 |
-
* add_filter( 'um_view_field_value_{$type}', 'my_view_field', 10, 2 );
|
4254 |
-
* function my_form_edit_field( $output, $data ) {
|
4255 |
-
* // your code here
|
4256 |
-
* return $output;
|
4257 |
-
* }
|
4258 |
-
* ?>
|
4259 |
-
*/
|
4260 |
-
$res = apply_filters( "um_view_field_value_{$type}", $res, $data );
|
4261 |
-
|
4262 |
-
$id_attr = '';
|
4263 |
-
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4264 |
-
$id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
4265 |
-
}
|
4266 |
-
|
4267 |
-
if ( empty( $res ) ) {
|
4268 |
-
$output = '';
|
4269 |
-
} else {
|
4270 |
-
$output .= '<div class="um-field-area">';
|
4271 |
-
$output .= '<div class="um-field-value"' . $id_attr . '>' . $res . '</div>';
|
4272 |
-
$output .= '</div>';
|
4273 |
-
|
4274 |
-
$output .= '</div>';
|
4275 |
-
}
|
4276 |
-
}
|
4277 |
-
|
4278 |
-
break;
|
4279 |
-
|
4280 |
-
/* HTML */
|
4281 |
-
case 'block':
|
4282 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4283 |
-
break;
|
4284 |
-
|
4285 |
-
/* Shortcode */
|
4286 |
-
case 'shortcode':
|
4287 |
-
|
4288 |
-
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
4289 |
-
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
4290 |
-
$content = do_shortcode( $content );
|
4291 |
-
} else {
|
4292 |
-
$content = apply_shortcodes( $content );
|
4293 |
-
}
|
4294 |
-
|
4295 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4296 |
-
break;
|
4297 |
-
|
4298 |
-
/* Gap/Space */
|
4299 |
-
case 'spacing':
|
4300 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
4301 |
-
break;
|
4302 |
-
|
4303 |
-
/* A line divider */
|
4304 |
-
case 'divider':
|
4305 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
4306 |
-
if ( $divider_text ) {
|
4307 |
-
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
|
4308 |
-
}
|
4309 |
-
$output .= '</div>';
|
4310 |
-
break;
|
4311 |
-
|
4312 |
-
/* Rating */
|
4313 |
-
case 'rating':
|
4314 |
-
|
4315 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4316 |
-
|
4317 |
-
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4318 |
-
$output .= $this->field_label( $label, $key, $data );
|
4319 |
-
}
|
4320 |
-
|
4321 |
-
ob_start(); ?>
|
4322 |
-
|
4323 |
-
<div class="um-field-area">
|
4324 |
-
<div class="um-field-value">
|
4325 |
-
<div class="um-rating-readonly um-raty" id="<?php echo esc_attr( $key ) ?>"
|
4326 |
-
data-key="<?php echo esc_attr( $key ) ?>" data-number="<?php echo esc_attr( $data['number'] ) ?>"
|
4327 |
-
data-score="<?php echo $this->field_value( $key, $default, $data ) ?>"></div>
|
4328 |
-
</div>
|
4329 |
-
</div>
|
4330 |
-
|
4331 |
-
<?php $output .= ob_get_clean();
|
4332 |
-
$output .= '</div>';
|
4333 |
-
|
4334 |
-
break;
|
4335 |
-
|
4336 |
-
}
|
4337 |
-
|
4338 |
-
// Custom filter for field output
|
4339 |
-
if ( isset( $this->set_mode ) ) {
|
4340 |
-
/**
|
4341 |
-
* UM hook
|
4342 |
-
*
|
4343 |
-
* @type filter
|
4344 |
-
* @title um_{$key}_form_show_field
|
4345 |
-
* @description Change field HTML by field $key
|
4346 |
-
* @input_vars
|
4347 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4348 |
-
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4349 |
-
* @change_log
|
4350 |
-
* ["Since: 2.0"]
|
4351 |
-
* @usage add_filter( 'um_{$key}_form_show_field', 'function_name', 10, 2 );
|
4352 |
-
* @example
|
4353 |
-
* <?php
|
4354 |
-
* add_filter( 'um_{$key}_form_show_field', 'my_form_show_field', 10, 2 );
|
4355 |
-
* function my_form_show_field( $output, $mode ) {
|
4356 |
-
* // your code here
|
4357 |
-
* return $output;
|
4358 |
-
* }
|
4359 |
-
* ?>
|
4360 |
-
*/
|
4361 |
-
$output = apply_filters( "um_{$key}_form_show_field", $output, $this->set_mode );
|
4362 |
-
/**
|
4363 |
-
* UM hook
|
4364 |
-
*
|
4365 |
-
* @type filter
|
4366 |
-
* @title um_{$type}_form_show_field
|
4367 |
-
* @description Change field HTML by field $type
|
4368 |
-
* @input_vars
|
4369 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4370 |
-
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4371 |
-
* @change_log
|
4372 |
-
* ["Since: 2.0"]
|
4373 |
-
* @usage add_filter( 'um_{$type}_form_show_field', 'function_name', 10, 2 );
|
4374 |
-
* @example
|
4375 |
-
* <?php
|
4376 |
-
* add_filter( 'um_{$type}_form_show_field', 'my_form_show_field', 10, 2 );
|
4377 |
-
* function my_form_show_field( $output, $mode ) {
|
4378 |
-
* // your code here
|
4379 |
-
* return $output;
|
4380 |
-
* }
|
4381 |
-
* ?>
|
4382 |
-
*/
|
4383 |
-
$output = apply_filters( "um_{$type}_form_show_field", $output, $this->set_mode );
|
4384 |
-
}
|
4385 |
-
|
4386 |
-
return $output;
|
4387 |
-
}
|
4388 |
-
|
4389 |
-
|
4390 |
-
/**
|
4391 |
-
* Filter field data
|
4392 |
-
*
|
4393 |
-
* @param array $data
|
4394 |
-
*
|
4395 |
-
* @return array
|
4396 |
-
*/
|
4397 |
-
function view_field_output( $data ) {
|
4398 |
-
/**
|
4399 |
-
* UM hook
|
4400 |
-
*
|
4401 |
-
* @type filter
|
4402 |
-
* @title um_view_field_output_{$type}
|
4403 |
-
* @description Change field data output by $type
|
4404 |
-
* @input_vars
|
4405 |
-
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
4406 |
-
* @change_log
|
4407 |
-
* ["Since: 2.0"]
|
4408 |
-
* @usage add_filter( 'um_view_field_output_{$type}', 'function_name', 10, 1 );
|
4409 |
-
* @example
|
4410 |
-
* <?php
|
4411 |
-
* add_filter( 'um_view_field_output_{$type}', 'my_view_field_output', 10, 1 );
|
4412 |
-
* function my_view_field_output( $data ) {
|
4413 |
-
* // your code here
|
4414 |
-
* return $data;
|
4415 |
-
* }
|
4416 |
-
* ?>
|
4417 |
-
*/
|
4418 |
-
return apply_filters( "um_view_field_output_" . $data['type'], $data );
|
4419 |
-
}
|
4420 |
-
|
4421 |
-
|
4422 |
-
/**
|
4423 |
-
* Display fields ( view mode )
|
4424 |
-
*
|
4425 |
-
* @param string $mode
|
4426 |
-
* @param array $args
|
4427 |
-
*
|
4428 |
-
* @return string|null
|
4429 |
-
* @throws \Exception
|
4430 |
-
*/
|
4431 |
-
function display_view( $mode, $args ) {
|
4432 |
-
$output = null;
|
4433 |
-
|
4434 |
-
$this->global_args = $args;
|
4435 |
-
|
4436 |
-
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
4437 |
-
|
4438 |
-
$this->set_mode = $mode;
|
4439 |
-
$this->set_id = $this->global_args['form_id'];
|
4440 |
-
|
4441 |
-
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
4442 |
-
|
4443 |
-
// start output here
|
4444 |
-
$this->get_fields = $this->get_fields();
|
4445 |
-
|
4446 |
-
if ( UM()->options()->get( 'profile_empty_text' ) ) {
|
4447 |
-
|
4448 |
-
$emo = UM()->options()->get( 'profile_empty_text_emo' );
|
4449 |
-
if ( $emo ) {
|
4450 |
-
$emo = '<i class="um-faicon-frown-o"></i>';
|
4451 |
-
} else {
|
4452 |
-
$emo = false;
|
4453 |
-
}
|
4454 |
-
|
4455 |
-
if ( um_is_myprofile() ) {
|
4456 |
-
$output .= '<p class="um-profile-note">' . $emo . '<span>' . sprintf( __( 'Your profile is looking a little empty. Why not <a href="%s">add</a> some information!', 'ultimate-member' ), esc_url( um_edit_profile_url() ) ) . '</span></p>';
|
4457 |
-
} else {
|
4458 |
-
$output .= '<p class="um-profile-note">' . $emo . '<span>' . __( 'This user has not added any information to their profile yet.', 'ultimate-member' ) . '</span></p>';
|
4459 |
-
}
|
4460 |
-
}
|
4461 |
-
|
4462 |
-
if ( ! empty( $this->get_fields ) ) {
|
4463 |
-
|
4464 |
-
// find rows
|
4465 |
-
foreach ( $this->get_fields as $key => $array ) {
|
4466 |
-
if ( $array['type'] == 'row' ) {
|
4467 |
-
$this->rows[ $key ] = $array;
|
4468 |
-
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4469 |
-
}
|
4470 |
-
}
|
4471 |
-
|
4472 |
-
// rows fallback
|
4473 |
-
if ( ! isset( $this->rows ) ) {
|
4474 |
-
$this->rows = array(
|
4475 |
-
'_um_row_1' => array(
|
4476 |
-
'type' => 'row',
|
4477 |
-
'id' => '_um_row_1',
|
4478 |
-
'sub_rows' => 1,
|
4479 |
-
'cols' => 1,
|
4480 |
-
),
|
4481 |
-
);
|
4482 |
-
}
|
4483 |
-
|
4484 |
-
// master rows
|
4485 |
-
foreach ( $this->rows as $row_id => $row_array ) {
|
4486 |
-
|
4487 |
-
$row_fields = $this->get_fields_by_row( $row_id );
|
4488 |
-
|
4489 |
-
if ( $row_fields ) {
|
4490 |
-
|
4491 |
-
$output .= $this->new_row_output( $row_id, $row_array );
|
4492 |
-
|
4493 |
-
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4494 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4495 |
-
|
4496 |
-
// cols
|
4497 |
-
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4498 |
-
if ( is_numeric( $cols ) ) {
|
4499 |
-
$cols_num = (int) $cols;
|
4500 |
-
} else {
|
4501 |
-
if ( strstr( $cols, ':' ) ) {
|
4502 |
-
$col_split = explode( ':', $cols );
|
4503 |
-
} else {
|
4504 |
-
$col_split = array( $cols );
|
4505 |
-
}
|
4506 |
-
$cols_num = $col_split[ $c ];
|
4507 |
-
}
|
4508 |
-
|
4509 |
-
// sub row fields
|
4510 |
-
$subrow_fields = null;
|
4511 |
-
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4512 |
-
|
4513 |
-
if ( is_array( $subrow_fields ) ) {
|
4514 |
-
|
4515 |
-
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4516 |
-
|
4517 |
-
if ( $cols_num == 1 ) {
|
4518 |
-
|
4519 |
-
$output .= '<div class="um-col-1">';
|
4520 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4521 |
-
if ( $col1_fields ) {
|
4522 |
-
foreach ( $col1_fields as $key => $data ) {
|
4523 |
-
|
4524 |
-
$data = $this->view_field_output( $data );
|
4525 |
-
$output .= $this->view_field( $key, $data );
|
4526 |
-
|
4527 |
-
}
|
4528 |
-
}
|
4529 |
-
$output .= '</div>';
|
4530 |
-
|
4531 |
-
} elseif ( $cols_num == 2 ) {
|
4532 |
-
|
4533 |
-
$output .= '<div class="um-col-121">';
|
4534 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4535 |
-
if ( $col1_fields ) {
|
4536 |
-
foreach ( $col1_fields as $key => $data ) {
|
4537 |
-
|
4538 |
-
$data = $this->view_field_output( $data );
|
4539 |
-
$output .= $this->view_field( $key, $data );
|
4540 |
-
|
4541 |
-
}
|
4542 |
-
}
|
4543 |
-
$output .= '</div>';
|
4544 |
-
|
4545 |
-
$output .= '<div class="um-col-122">';
|
4546 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4547 |
-
if ( $col2_fields ) {
|
4548 |
-
foreach ( $col2_fields as $key => $data ) {
|
4549 |
-
|
4550 |
-
$data = $this->view_field_output( $data );
|
4551 |
-
$output .= $this->view_field( $key, $data );
|
4552 |
-
|
4553 |
-
}
|
4554 |
-
}
|
4555 |
-
$output .= '</div><div class="um-clear"></div>';
|
4556 |
-
|
4557 |
-
} else {
|
4558 |
-
|
4559 |
-
$output .= '<div class="um-col-131">';
|
4560 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4561 |
-
if ( $col1_fields ) {
|
4562 |
-
foreach ( $col1_fields as $key => $data ) {
|
4563 |
-
|
4564 |
-
$data = $this->view_field_output( $data );
|
4565 |
-
$output .= $this->view_field( $key, $data );
|
4566 |
-
|
4567 |
-
}
|
4568 |
-
}
|
4569 |
-
$output .= '</div>';
|
4570 |
-
|
4571 |
-
$output .= '<div class="um-col-132">';
|
4572 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4573 |
-
if ( $col2_fields ) {
|
4574 |
-
foreach ( $col2_fields as $key => $data ) {
|
4575 |
-
|
4576 |
-
$data = $this->view_field_output( $data );
|
4577 |
-
$output .= $this->view_field( $key, $data );
|
4578 |
-
|
4579 |
-
}
|
4580 |
-
}
|
4581 |
-
$output .= '</div>';
|
4582 |
-
|
4583 |
-
$output .= '<div class="um-col-133">';
|
4584 |
-
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4585 |
-
if ( $col3_fields ) {
|
4586 |
-
foreach ( $col3_fields as $key => $data ) {
|
4587 |
-
|
4588 |
-
$data = $this->view_field_output( $data );
|
4589 |
-
$output .= $this->view_field( $key, $data );
|
4590 |
-
|
4591 |
-
}
|
4592 |
-
}
|
4593 |
-
$output .= '</div><div class="um-clear"></div>';
|
4594 |
-
|
4595 |
-
}
|
4596 |
-
|
4597 |
-
}
|
4598 |
-
|
4599 |
-
}
|
4600 |
-
|
4601 |
-
$output .= '</div>';
|
4602 |
-
|
4603 |
-
}
|
4604 |
-
|
4605 |
-
}
|
4606 |
-
|
4607 |
-
}
|
4608 |
-
|
4609 |
-
return $output;
|
4610 |
-
}
|
4611 |
-
|
4612 |
-
|
4613 |
-
/**
|
4614 |
-
* Get new row in form
|
4615 |
-
*
|
4616 |
-
* @param string $row_id
|
4617 |
-
* @param array $row_array
|
4618 |
-
*
|
4619 |
-
* @return string
|
4620 |
-
*/
|
4621 |
-
function new_row_output( $row_id, $row_array ) {
|
4622 |
-
$output = null;
|
4623 |
-
extract( $row_array );
|
4624 |
-
|
4625 |
-
$padding = ( isset( $padding ) ) ? $padding : '';
|
4626 |
-
$margin = ( isset( $margin ) ) ? $margin : '';
|
4627 |
-
$background = ( isset( $background ) ) ? $background : '';
|
4628 |
-
$text_color = ( isset( $text_color ) ) ? $text_color : '';
|
4629 |
-
$borderradius = ( isset( $borderradius ) ) ? $borderradius : '';
|
4630 |
-
$border = ( isset( $border ) ) ? $border : '';
|
4631 |
-
$bordercolor = ( isset( $bordercolor ) ) ? $bordercolor : '';
|
4632 |
-
$borderstyle = ( isset( $borderstyle ) ) ? $borderstyle : '';
|
4633 |
-
$heading = ( isset( $heading ) ) ? $heading : '';
|
4634 |
-
$css_class = ( isset( $css_class ) ) ? $css_class : '';
|
4635 |
-
|
4636 |
-
$css_padding = '';
|
4637 |
-
$css_margin = '';
|
4638 |
-
$css_background = '';
|
4639 |
-
$css_borderradius = '';
|
4640 |
-
$css_border = '';
|
4641 |
-
$css_bordercolor = '';
|
4642 |
-
$css_borderstyle = '';
|
4643 |
-
$css_heading_background_color = '';
|
4644 |
-
$css_heading_padding = '';
|
4645 |
-
$css_heading_text_color = '';
|
4646 |
-
$css_heading_borderradius = '';
|
4647 |
-
$css_text_color = '';
|
4648 |
-
|
4649 |
-
// row css rules
|
4650 |
-
if ( $padding ) {
|
4651 |
-
$css_padding = 'padding: ' . $padding . ';';
|
4652 |
-
}
|
4653 |
-
if ( $margin ) {
|
4654 |
-
$css_margin = 'margin: ' . $margin . ';';
|
4655 |
-
} else {
|
4656 |
-
$css_margin = 'margin: 0 0 30px 0;';
|
4657 |
-
}
|
4658 |
-
|
4659 |
-
if ( $background ) {
|
4660 |
-
$css_background = 'background-color: ' . $background . ';';
|
4661 |
-
}
|
4662 |
-
if ( $borderradius ) {
|
4663 |
-
$css_borderradius = 'border-radius: 0px 0px ' . $borderradius . ' ' . $borderradius . ';';
|
4664 |
-
}
|
4665 |
-
if ( $border ) {
|
4666 |
-
$css_border = 'border-width: ' . $border . ';';
|
4667 |
-
}
|
4668 |
-
if ( $bordercolor ) {
|
4669 |
-
$css_bordercolor = 'border-color: ' . $bordercolor . ';';
|
4670 |
-
}
|
4671 |
-
if ( $borderstyle ) {
|
4672 |
-
$css_borderstyle = 'border-style: ' . $borderstyle . ';';
|
4673 |
-
}
|
4674 |
-
if ( $text_color ) {
|
4675 |
-
$css_text_color = 'color: ' . $text_color . ' !important;';
|
4676 |
-
$css_class .= ' um-customized-row';
|
4677 |
-
}
|
4678 |
-
|
4679 |
-
// show the heading
|
4680 |
-
if ( $heading ) {
|
4681 |
-
|
4682 |
-
if ( ! empty( $heading_background_color ) ) {
|
4683 |
-
$css_heading_background_color = "background-color: $heading_background_color;";
|
4684 |
-
$css_heading_padding = 'padding: 10px 15px;';
|
4685 |
-
}
|
4686 |
-
|
4687 |
-
$css_heading_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius $borderradius 0px 0px;";
|
4688 |
-
$css_heading_border = $css_border . $css_borderstyle . $css_bordercolor . $css_heading_borderradius . 'border-bottom-width: 0px;';
|
4689 |
-
$css_heading_margin = $css_margin . 'margin-bottom: 0px;';
|
4690 |
-
$css_heading_text_color = empty( $heading_text_color ) ? '' : "color: $heading_text_color;";
|
4691 |
-
$css_icon_color = empty( $icon_color ) ? '' : "color: $icon_color;";
|
4692 |
-
|
4693 |
-
$output .= '<div class="um-row-heading" style="' . $css_heading_margin . $css_heading_padding . $css_heading_border . $css_heading_background_color . $css_heading_text_color . '">';
|
4694 |
-
|
4695 |
-
if ( ! empty( $icon ) ) {
|
4696 |
-
$output .= '<span class="um-row-heading-icon" style="' . $css_icon_color . '"><i class="' . $icon . '"></i></span>';
|
4697 |
-
}
|
4698 |
-
if ( ! empty( $heading_text ) ) {
|
4699 |
-
$output .= htmlspecialchars( $heading_text );
|
4700 |
-
}
|
4701 |
-
|
4702 |
-
$output .= '</div>';
|
4703 |
-
|
4704 |
-
$css_border .= 'border-top-width: 0px;';
|
4705 |
-
$css_margin .= 'margin-top: 0px;';
|
4706 |
-
|
4707 |
-
} else {
|
4708 |
-
|
4709 |
-
// no heading
|
4710 |
-
$css_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius;";
|
4711 |
-
|
4712 |
-
}
|
4713 |
-
|
4714 |
-
$output .= '<div class="um-row ' . $row_id . ' ' . $css_class . '" style="' . $css_padding . $css_background . $css_margin . $css_border . $css_borderstyle . $css_bordercolor . $css_borderradius . $css_text_color . '">';
|
4715 |
-
|
4716 |
-
return $output;
|
4717 |
-
}
|
4718 |
-
|
4719 |
-
|
4720 |
-
/**
|
4721 |
-
*
|
4722 |
-
*/
|
4723 |
-
function do_ajax_action() {
|
4724 |
-
UM()->admin()->check_ajax_nonce();
|
4725 |
-
|
4726 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
4727 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
4728 |
-
}
|
4729 |
-
|
4730 |
-
/**
|
4731 |
-
* @var $in_row
|
4732 |
-
* @var $in_sub_row
|
4733 |
-
* @var $in_column
|
4734 |
-
* @var $in_group
|
4735 |
-
* @var $act_id
|
4736 |
-
* @var $arg1
|
4737 |
-
* @var $arg2
|
4738 |
-
*/
|
4739 |
-
extract( $_POST );
|
4740 |
-
|
4741 |
-
$output = null;
|
4742 |
-
|
4743 |
-
$position = array();
|
4744 |
-
if ( ! empty( $in_column ) ) {
|
4745 |
-
$position['in_row'] = '_um_row_' . ( (int) $in_row + 1 );
|
4746 |
-
$position['in_sub_row'] = $in_sub_row;
|
4747 |
-
$position['in_column'] = $in_column;
|
4748 |
-
$position['in_group'] = $in_group;
|
4749 |
-
}
|
4750 |
-
|
4751 |
-
switch ( $act_id ) {
|
4752 |
-
|
4753 |
-
case 'um_admin_duplicate_field':
|
4754 |
-
$this->duplicate_field( $arg1, $arg2 );
|
4755 |
-
break;
|
4756 |
-
|
4757 |
-
case 'um_admin_remove_field_global':
|
4758 |
-
$this->delete_field_from_db( $arg1 );
|
4759 |
-
break;
|
4760 |
-
|
4761 |
-
case 'um_admin_remove_field':
|
4762 |
-
$this->delete_field_from_form( $arg1, $arg2 );
|
4763 |
-
break;
|
4764 |
-
|
4765 |
-
case 'um_admin_add_field_from_predefined':
|
4766 |
-
$this->add_field_from_predefined( $arg1, $arg2, $position );
|
4767 |
-
break;
|
4768 |
-
|
4769 |
-
case 'um_admin_add_field_from_list':
|
4770 |
-
$this->add_field_from_list( $arg1, $arg2, $position );
|
4771 |
-
break;
|
4772 |
-
|
4773 |
-
}
|
4774 |
-
|
4775 |
-
if ( is_array( $output ) ) {
|
4776 |
-
print_r( $output );
|
4777 |
-
} else {
|
4778 |
-
echo $output;
|
4779 |
-
}
|
4780 |
-
die;
|
4781 |
-
|
4782 |
-
}
|
4783 |
-
|
4784 |
-
|
4785 |
-
|
4786 |
-
/**
|
4787 |
-
* Get rendered field attributes
|
4788 |
-
*
|
4789 |
-
* @since 2.1.2
|
4790 |
-
*
|
4791 |
-
* @param string $key
|
4792 |
-
* @param array $classes
|
4793 |
-
* @param string $conditional
|
4794 |
-
* @param array $data
|
4795 |
-
* @param array $field_style
|
4796 |
-
*
|
4797 |
-
* @return string/html
|
4798 |
-
*/
|
4799 |
-
function get_atts( $key, $classes, $conditional, $data, $field_style = array() ) {
|
4800 |
-
|
4801 |
-
array_unshift( $classes, 'um-field-' . $data['type'] );
|
4802 |
-
array_unshift( $classes, 'um-field' );
|
4803 |
-
|
4804 |
-
$field_atts = array(
|
4805 |
-
'id' => array(
|
4806 |
-
"um_field_{$this->set_id}_{$key}",
|
4807 |
-
),
|
4808 |
-
'class' => $classes,
|
4809 |
-
'data-key' => array(
|
4810 |
-
esc_attr( $key )
|
4811 |
-
)
|
4812 |
-
);
|
4813 |
-
|
4814 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4815 |
-
|
4816 |
-
if ( in_array( $data['type'], $fields_without_metakey ) ) {
|
4817 |
-
unset( $field_atts['id'] );
|
4818 |
-
|
4819 |
-
if ( empty( $field_atts['data-key'] ) ) {
|
4820 |
-
unset( $field_atts['data-key'] );
|
4821 |
-
}
|
4822 |
-
}
|
4823 |
-
|
4824 |
-
if ( ! empty( $field_style ) && is_array( $field_style ) ) {
|
4825 |
-
|
4826 |
-
$arr_inline_style = '';
|
4827 |
-
foreach ( $field_style as $style_attr => $style_value ) {
|
4828 |
-
$arr_inline_style .= esc_attr( $style_attr ) . ':' . esc_attr( $style_value ) . ';';
|
4829 |
-
}
|
4830 |
-
$field_atts['style'] = array( $arr_inline_style );
|
4831 |
-
}
|
4832 |
-
|
4833 |
-
/**
|
4834 |
-
* UM hook
|
4835 |
-
*
|
4836 |
-
* @type filter
|
4837 |
-
* @title um_field_extra_atts
|
4838 |
-
* @description user for adding extra field attributes
|
4839 |
-
* @input_vars
|
4840 |
-
* [{"var":"$field_atts","type":"array","desc":"Field attributes"},
|
4841 |
-
* [{"var":"$key","type":"string","desc":"Field id"},
|
4842 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
4843 |
-
* @change_log
|
4844 |
-
* ["Since: 2.0.57"]
|
4845 |
-
* @usage add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4846 |
-
* @example
|
4847 |
-
* <?php
|
4848 |
-
* add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4849 |
-
* function function_name( $field_atts, $key, $data ) {
|
4850 |
-
* // your code here
|
4851 |
-
* return $array_extra_atts;
|
4852 |
-
* }
|
4853 |
-
* ?>
|
4854 |
-
*/
|
4855 |
-
$field_atts = apply_filters( 'um_field_extra_atts', $field_atts, $key, $data );
|
4856 |
-
|
4857 |
-
$html_atts = '';
|
4858 |
-
foreach ( $field_atts as $att_name => $att_values ) {
|
4859 |
-
$att_values = implode( " ", $att_values );
|
4860 |
-
$html_atts .= " {$att_name}=\"" . esc_attr( $att_values ) . "\"";
|
4861 |
-
}
|
4862 |
-
|
4863 |
-
$html_atts .= $conditional;
|
4864 |
-
|
4865 |
-
return $html_atts;
|
4866 |
-
}
|
4867 |
-
}
|
4868 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\Fields' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Fields
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class Fields {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
var $set_mode = '';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var int form_id
|
26 |
+
*/
|
27 |
+
public $set_id = null;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Fields constructor.
|
32 |
+
*/
|
33 |
+
function __construct() {
|
34 |
+
$this->editing = false;
|
35 |
+
$this->viewing = false;
|
36 |
+
$this->timestamp = current_time( 'timestamp' );
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Standard checkbox field
|
42 |
+
*
|
43 |
+
* @param integer $id
|
44 |
+
* @param string $title
|
45 |
+
* @param bool $checked
|
46 |
+
*/
|
47 |
+
function checkbox( $id, $title, $checked = true ) {
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Set value on form submission
|
51 |
+
*/
|
52 |
+
if ( isset( $_REQUEST[ $id ] ) ) {
|
53 |
+
$checked = (bool) $_REQUEST[ $id ];
|
54 |
+
}
|
55 |
+
|
56 |
+
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
57 |
+
|
58 |
+
?>
|
59 |
+
|
60 |
+
|
61 |
+
<div class="um-field um-field-c">
|
62 |
+
<div class="um-field-area">
|
63 |
+
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
64 |
+
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
65 |
+
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
66 |
+
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
67 |
+
</label>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Shows social links
|
77 |
+
*/
|
78 |
+
function show_social_urls() {
|
79 |
+
$social = array();
|
80 |
+
|
81 |
+
$fields = UM()->builtin()->get_all_user_fields();
|
82 |
+
foreach ( $fields as $field => $args ) {
|
83 |
+
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
|
84 |
+
$social[ $field ] = $args;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
foreach ( $social as $k => $arr ) {
|
89 |
+
if ( um_profile( $k ) ) { ?>
|
90 |
+
|
91 |
+
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
92 |
+
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
93 |
+
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
94 |
+
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Hidden field inside a shortcode
|
103 |
+
*
|
104 |
+
* @param string $field
|
105 |
+
*/
|
106 |
+
function add_hidden_field( $field ) {
|
107 |
+
echo '<div style="display: none !important;">';
|
108 |
+
|
109 |
+
$fields = UM()->builtin()->get_specific_fields( $field );
|
110 |
+
|
111 |
+
$output = null;
|
112 |
+
|
113 |
+
foreach ( $fields as $key => $data ) {
|
114 |
+
$output .= UM()->fields()->edit_field( $key, $data );
|
115 |
+
}
|
116 |
+
|
117 |
+
echo $output;
|
118 |
+
|
119 |
+
echo '</div>';
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get hidden field
|
125 |
+
*
|
126 |
+
* @param string $key
|
127 |
+
* @param string $value
|
128 |
+
*
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
function disabled_hidden_field( $key, $value ) {
|
132 |
+
return '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '"/>';
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Updates a field globally
|
138 |
+
*
|
139 |
+
* @param integer $id
|
140 |
+
* @param array $args
|
141 |
+
*/
|
142 |
+
function globally_update_field( $id, $args ) {
|
143 |
+
$fields = UM()->builtin()->saved_fields;
|
144 |
+
|
145 |
+
$fields[ $id ] = $args;
|
146 |
+
|
147 |
+
unset( $fields[ $id ]['in_row'] );
|
148 |
+
unset( $fields[ $id ]['in_sub_row'] );
|
149 |
+
unset( $fields[ $id ]['in_column'] );
|
150 |
+
unset( $fields[ $id ]['in_group'] );
|
151 |
+
unset( $fields[ $id ]['position'] );
|
152 |
+
|
153 |
+
do_action( 'um_add_new_field', $id, $args );
|
154 |
+
|
155 |
+
update_option( 'um_fields', $fields );
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Updates a field in form only
|
161 |
+
*
|
162 |
+
* @param integer $id
|
163 |
+
* @param array $args
|
164 |
+
* @param integer $form_id
|
165 |
+
*/
|
166 |
+
function update_field( $id, $args, $form_id ) {
|
167 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
168 |
+
|
169 |
+
if ( $args['type'] == 'row' ) {
|
170 |
+
if ( isset( $fields[ $id ] ) ) {
|
171 |
+
$old_args = $fields[ $id ];
|
172 |
+
foreach ( $old_args as $k => $v ) {
|
173 |
+
if ( ! in_array( $k, array( 'sub_rows', 'cols' ) ) ) {
|
174 |
+
unset( $old_args[ $k ] );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
$args = array_merge( $old_args, $args );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
// custom fields support
|
182 |
+
if ( isset( UM()->builtin()->predefined_fields[ $id ] ) && isset( UM()->builtin()->predefined_fields[ $id ]['custom'] ) ) {
|
183 |
+
$args = array_merge( UM()->builtin()->predefined_fields[ $id ], $args );
|
184 |
+
}
|
185 |
+
|
186 |
+
$fields[ $id ] = $args;
|
187 |
+
|
188 |
+
// for group field only
|
189 |
+
if ( $args['type'] == 'group' ) {
|
190 |
+
$fields[ $id ]['in_group'] = '';
|
191 |
+
}
|
192 |
+
|
193 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Deletes a field in form only
|
199 |
+
*
|
200 |
+
* @param integer $id
|
201 |
+
* @param integer $form_id
|
202 |
+
*/
|
203 |
+
function delete_field_from_form( $id, $form_id ) {
|
204 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
205 |
+
|
206 |
+
if ( isset( $fields[ $id ] ) ) {
|
207 |
+
$condition_fields = get_option( 'um_fields' );
|
208 |
+
|
209 |
+
if( ! is_array( $condition_fields ) ) $condition_fields = array();
|
210 |
+
|
211 |
+
foreach ( $condition_fields as $key => $value ) {
|
212 |
+
$deleted_field = array_search( $id, $value );
|
213 |
+
|
214 |
+
if ( $key != $id && $deleted_field != false ) {
|
215 |
+
$deleted_field_id = str_replace( 'conditional_field', '', $deleted_field );
|
216 |
+
|
217 |
+
if ( $deleted_field_id == '' ) {
|
218 |
+
$arr_id = 0;
|
219 |
+
} else {
|
220 |
+
$arr_id = $deleted_field_id;
|
221 |
+
}
|
222 |
+
|
223 |
+
unset( $condition_fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
224 |
+
unset( $condition_fields[ $key ][ $deleted_field ] );
|
225 |
+
unset( $condition_fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
226 |
+
unset( $condition_fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
227 |
+
unset( $condition_fields[ $key ]['conditions'][ $arr_id ] );
|
228 |
+
|
229 |
+
unset( $fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
230 |
+
unset( $fields[ $key ][ $deleted_field ] );
|
231 |
+
unset( $fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
232 |
+
unset( $fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
233 |
+
unset( $fields[ $key ]['conditions'][ $arr_id ] );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
update_option( 'um_fields' , $condition_fields );
|
238 |
+
unset( $fields[ $id ] );
|
239 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Deletes a field from custom fields
|
246 |
+
*
|
247 |
+
* @param integer $id
|
248 |
+
*/
|
249 |
+
function delete_field_from_db( $id ) {
|
250 |
+
$fields = UM()->builtin()->saved_fields;
|
251 |
+
if ( isset( $fields[ $id ] ) ) {
|
252 |
+
$args = $fields[ $id ];
|
253 |
+
|
254 |
+
unset( $fields[ $id ] );
|
255 |
+
|
256 |
+
do_action( 'um_delete_custom_field', $id, $args );
|
257 |
+
|
258 |
+
update_option( 'um_fields', $fields );
|
259 |
+
|
260 |
+
global $wpdb;
|
261 |
+
$forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
|
262 |
+
foreach ( $forms as $form_id ) {
|
263 |
+
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
264 |
+
unset( $form_fields[ $id ] );
|
265 |
+
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
266 |
+
}
|
267 |
+
|
268 |
+
$directories = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_directory'" );
|
269 |
+
foreach ( $directories as $directory_id ) {
|
270 |
+
// Frontend filters
|
271 |
+
$directory_search_fields = get_post_meta( $directory_id, '_um_search_fields', true );
|
272 |
+
$directory_search_fields = array_values( array_diff( $directory_search_fields, array( $id ) ) );
|
273 |
+
update_post_meta( $directory_id, '_um_search_fields', $directory_search_fields );
|
274 |
+
|
275 |
+
// Admin filtering
|
276 |
+
$directory_search_filters = get_post_meta( $directory_id, '_um_search_filters', true );
|
277 |
+
unset( $directory_search_filters[ $id ] );
|
278 |
+
update_post_meta( $directory_id, '_um_search_filters', $directory_search_filters );
|
279 |
+
|
280 |
+
// display in tagline
|
281 |
+
$directory_reveal_fields = get_post_meta( $directory_id, '_um_reveal_fields', true );
|
282 |
+
$directory_reveal_fields = array_values( array_diff( $directory_reveal_fields, array( $id ) ) );
|
283 |
+
update_post_meta( $directory_id, '_um_reveal_fields', $directory_reveal_fields );
|
284 |
+
|
285 |
+
// extra user information section
|
286 |
+
$directory_tagline_fields = get_post_meta( $directory_id, '_um_tagline_fields', true );
|
287 |
+
$directory_tagline_fields = array_values( array_diff( $directory_tagline_fields, array( $id ) ) );
|
288 |
+
update_post_meta( $directory_id, '_um_tagline_fields', $directory_tagline_fields );
|
289 |
+
|
290 |
+
// Custom fields selected in "Choose field(s) to enable in sorting"
|
291 |
+
$directory_sorting_fields = get_post_meta( $directory_id, '_um_sorting_fields', true );
|
292 |
+
foreach ( $directory_sorting_fields as $key => $sorting_data ) {
|
293 |
+
if ( is_array( $sorting_data ) && array_key_exists( $id, $sorting_data ) ) {
|
294 |
+
unset( $directory_sorting_fields[ $key ] );
|
295 |
+
}
|
296 |
+
}
|
297 |
+
$directory_sorting_fields = array_values( $directory_sorting_fields );
|
298 |
+
update_post_meta( $directory_id, '_um_sorting_fields', $directory_sorting_fields );
|
299 |
+
|
300 |
+
// If "Default sort users by" = "Other (Custom Field)" is selected when delete this custom field and set default sorting
|
301 |
+
$directory_sortby_custom = get_post_meta( $directory_id, '_um_sortby_custom', true );
|
302 |
+
if ( $directory_sortby_custom === $id ) {
|
303 |
+
$directory_sortby = get_post_meta( $directory_id, '_um_sortby', true );
|
304 |
+
if ( 'other' === $directory_sortby ) {
|
305 |
+
update_post_meta( $directory_id, '_um_sortby', 'user_registered_desc' );
|
306 |
+
}
|
307 |
+
update_post_meta( $directory_id, '_um_sortby_custom', '' );
|
308 |
+
update_post_meta( $directory_id, '_um_sortby_custom_label', '' );
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Quickly adds a field from custom fields
|
318 |
+
*
|
319 |
+
* @param integer $global_id
|
320 |
+
* @param integer $form_id
|
321 |
+
* @param array $position
|
322 |
+
*/
|
323 |
+
function add_field_from_list( $global_id, $form_id, $position = array() ) {
|
324 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
325 |
+
$field_scope = UM()->builtin()->saved_fields;
|
326 |
+
|
327 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
328 |
+
|
329 |
+
$count = 1;
|
330 |
+
if ( ! empty( $fields ) ) {
|
331 |
+
$count = count( $fields ) + 1;
|
332 |
+
}
|
333 |
+
|
334 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
335 |
+
$fields[ $global_id ]['position'] = $count;
|
336 |
+
|
337 |
+
// set position
|
338 |
+
if ( $position ) {
|
339 |
+
foreach ( $position as $key => $val) {
|
340 |
+
$fields[ $global_id ][ $key ] = $val;
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
// add field to form
|
345 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
346 |
+
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Quickly adds a field from pre-defined fields
|
353 |
+
*
|
354 |
+
* @param integer $global_id
|
355 |
+
* @param integer $form_id
|
356 |
+
* @param array $position
|
357 |
+
*/
|
358 |
+
function add_field_from_predefined( $global_id, $form_id, $position = array() ) {
|
359 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
360 |
+
$field_scope = UM()->builtin()->predefined_fields;
|
361 |
+
|
362 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
363 |
+
|
364 |
+
$count = 1;
|
365 |
+
if ( ! empty( $fields ) ) {
|
366 |
+
$count = count( $fields ) + 1;
|
367 |
+
}
|
368 |
+
|
369 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
370 |
+
$fields[ $global_id ]['position'] = $count;
|
371 |
+
|
372 |
+
// set position
|
373 |
+
if ( $position ) {
|
374 |
+
foreach ( $position as $key => $val ) {
|
375 |
+
$fields[ $global_id ][ $key ] = $val;
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
// add field to form
|
380 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Duplicates a frield by meta key
|
387 |
+
*
|
388 |
+
* @param integer $id
|
389 |
+
* @param integer $form_id
|
390 |
+
*/
|
391 |
+
function duplicate_field( $id, $form_id ) {
|
392 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
393 |
+
$all_fields = UM()->builtin()->saved_fields;
|
394 |
+
|
395 |
+
$inc = count( $fields ) + 1;
|
396 |
+
|
397 |
+
$duplicate = $fields[ $id ];
|
398 |
+
|
399 |
+
$new_metakey = $id . "_" . $inc;
|
400 |
+
$new_title = $fields[ $id ]['title'] . " #" . $inc;
|
401 |
+
$new_position = $inc;
|
402 |
+
|
403 |
+
$duplicate['title'] = $new_title;
|
404 |
+
$duplicate['metakey'] = $new_metakey;
|
405 |
+
$duplicate['position'] = $new_position;
|
406 |
+
|
407 |
+
$fields[ $new_metakey ] = $duplicate;
|
408 |
+
$all_fields[ $new_metakey ] = $duplicate;
|
409 |
+
|
410 |
+
// not global attributes
|
411 |
+
unset( $all_fields[ $new_metakey ]['in_row'] );
|
412 |
+
unset( $all_fields[ $new_metakey ]['in_sub_row'] );
|
413 |
+
unset( $all_fields[ $new_metakey ]['in_column'] );
|
414 |
+
unset( $all_fields[ $new_metakey ]['in_group'] );
|
415 |
+
unset( $all_fields[ $new_metakey ]['position'] );
|
416 |
+
|
417 |
+
|
418 |
+
do_action( 'um_add_new_field', $new_metakey, $duplicate );
|
419 |
+
|
420 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
421 |
+
update_option( 'um_fields', $all_fields );
|
422 |
+
}
|
423 |
+
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Print field error
|
427 |
+
*
|
428 |
+
* @param string $text
|
429 |
+
* @param bool $force_show
|
430 |
+
*
|
431 |
+
* @return string
|
432 |
+
*/
|
433 |
+
function field_error( $text, $force_show = false ) {
|
434 |
+
|
435 |
+
if ( empty( $text ) ) {
|
436 |
+
return '';
|
437 |
+
}
|
438 |
+
|
439 |
+
if ( $force_show ) {
|
440 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
441 |
+
return $output;
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
446 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
447 |
+
} else {
|
448 |
+
$output = '';
|
449 |
+
}
|
450 |
+
|
451 |
+
if ( ! UM()->form()->processing ) {
|
452 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
453 |
+
}
|
454 |
+
|
455 |
+
return $output;
|
456 |
+
}
|
457 |
+
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Print field notice
|
461 |
+
*
|
462 |
+
* @param string $text
|
463 |
+
* @param bool $force_show
|
464 |
+
*
|
465 |
+
* @return string
|
466 |
+
*/
|
467 |
+
function field_notice( $text, $force_show = false ) {
|
468 |
+
|
469 |
+
if ( empty( $text ) ) {
|
470 |
+
return '';
|
471 |
+
}
|
472 |
+
|
473 |
+
if ( $force_show ) {
|
474 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
475 |
+
return $output;
|
476 |
+
}
|
477 |
+
|
478 |
+
|
479 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
480 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
481 |
+
} else {
|
482 |
+
$output = '';
|
483 |
+
}
|
484 |
+
|
485 |
+
if ( ! UM()->form()->processing ) {
|
486 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
487 |
+
}
|
488 |
+
|
489 |
+
return $output;
|
490 |
+
}
|
491 |
+
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Checks if field has a server-side error
|
495 |
+
*
|
496 |
+
* @param string $key
|
497 |
+
*
|
498 |
+
* @return boolean
|
499 |
+
*/
|
500 |
+
function is_error( $key ) {
|
501 |
+
return UM()->form()->has_error( $key );
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Checks if field has a notice
|
506 |
+
*
|
507 |
+
* @param string $key
|
508 |
+
*
|
509 |
+
* @return boolean
|
510 |
+
*/
|
511 |
+
function is_notice( $key ) {
|
512 |
+
return UM()->form()->has_notice( $key );
|
513 |
+
}
|
514 |
+
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Returns field error
|
518 |
+
*
|
519 |
+
* @param string $key
|
520 |
+
*
|
521 |
+
* @return string
|
522 |
+
*/
|
523 |
+
function show_error( $key ) {
|
524 |
+
return UM()->form()->errors[ $key ];
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Returns field notices
|
529 |
+
*
|
530 |
+
* @param string $key
|
531 |
+
*
|
532 |
+
* @return string
|
533 |
+
*/
|
534 |
+
function show_notice( $key ) {
|
535 |
+
return UM()->form()->notices[ $key ];
|
536 |
+
}
|
537 |
+
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Display field label
|
541 |
+
*
|
542 |
+
* @param string $label
|
543 |
+
* @param string $key
|
544 |
+
* @param array $data
|
545 |
+
*
|
546 |
+
* @return string
|
547 |
+
*/
|
548 |
+
function field_label( $label, $key, $data ) {
|
549 |
+
$output = null;
|
550 |
+
$output .= '<div class="um-field-label">';
|
551 |
+
|
552 |
+
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
553 |
+
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
554 |
+
}
|
555 |
+
|
556 |
+
if ( $this->viewing == true ) {
|
557 |
+
/**
|
558 |
+
* UM hook
|
559 |
+
*
|
560 |
+
* @type filter
|
561 |
+
* @title um_view_label_{$key}
|
562 |
+
* @description Change field label on view by field $key
|
563 |
+
* @input_vars
|
564 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
565 |
+
* @change_log
|
566 |
+
* ["Since: 2.0"]
|
567 |
+
* @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 );
|
568 |
+
* @example
|
569 |
+
* <?php
|
570 |
+
* add_filter( 'um_view_label_{$key}', 'my_view_label', 10, 1 );
|
571 |
+
* function my_view_label( $label ) {
|
572 |
+
* // your code here
|
573 |
+
* return $label;
|
574 |
+
* }
|
575 |
+
* ?>
|
576 |
+
*/
|
577 |
+
$label = apply_filters( "um_view_label_{$key}", $label );
|
578 |
+
} else {
|
579 |
+
/**
|
580 |
+
* UM hook
|
581 |
+
*
|
582 |
+
* @type filter
|
583 |
+
* @title um_edit_label_{$key}
|
584 |
+
* @description Change field label on edit by field $key
|
585 |
+
* @input_vars
|
586 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
587 |
+
* @change_log
|
588 |
+
* ["Since: 2.0"]
|
589 |
+
* @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 );
|
590 |
+
* @example
|
591 |
+
* <?php
|
592 |
+
* add_filter( 'um_edit_label_{$key}', 'my_edit_label', 10, 1 );
|
593 |
+
* function my_edit_label( $label ) {
|
594 |
+
* // your code here
|
595 |
+
* return $label;
|
596 |
+
* }
|
597 |
+
* ?>
|
598 |
+
*/
|
599 |
+
$label = apply_filters( "um_edit_label_{$key}", $label );
|
600 |
+
/**
|
601 |
+
* UM hook
|
602 |
+
*
|
603 |
+
* @type filter
|
604 |
+
* @title um_edit_label_all_fields
|
605 |
+
* @description Change field label on view by field $key
|
606 |
+
* @input_vars
|
607 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
608 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
609 |
+
* @change_log
|
610 |
+
* ["Since: 2.0"]
|
611 |
+
* @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 );
|
612 |
+
* @example
|
613 |
+
* <?php
|
614 |
+
* add_filter( 'um_edit_label_all_fields', 'my_edit_label_all_fields', 10, 2 );
|
615 |
+
* function my_edit_label_all_fields( $label, $data ) {
|
616 |
+
* // your code here
|
617 |
+
* return $label;
|
618 |
+
* }
|
619 |
+
* ?>
|
620 |
+
*/
|
621 |
+
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
622 |
+
}
|
623 |
+
|
624 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
625 |
+
$for_attr = '';
|
626 |
+
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
|
627 |
+
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
628 |
+
}
|
629 |
+
|
630 |
+
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
631 |
+
|
632 |
+
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
633 |
+
|
634 |
+
if ( ! UM()->mobile()->isMobile() ) {
|
635 |
+
if ( ! isset( $this->disable_tooltips ) ) {
|
636 |
+
$output .= '<span class="um-tip um-tip-' . ( is_rtl() ? 'e' : 'w' ) . '" title="' . esc_attr__( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
637 |
+
}
|
638 |
+
}
|
639 |
+
|
640 |
+
if ( UM()->mobile()->isMobile() || isset( $this->disable_tooltips ) ) {
|
641 |
+
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
642 |
+
}
|
643 |
+
|
644 |
+
}
|
645 |
+
|
646 |
+
$output .= '<div class="um-clear"></div></div>';
|
647 |
+
|
648 |
+
return $output;
|
649 |
+
}
|
650 |
+
|
651 |
+
|
652 |
+
/**
|
653 |
+
* Output field classes
|
654 |
+
*
|
655 |
+
* @param string $key
|
656 |
+
* @param array $data
|
657 |
+
* @param string $add
|
658 |
+
*
|
659 |
+
* @return string
|
660 |
+
*/
|
661 |
+
function get_class( $key, $data, $add = null ) {
|
662 |
+
$classes = null;
|
663 |
+
|
664 |
+
$classes .= 'um-form-field ';
|
665 |
+
|
666 |
+
if ( $this->is_error( $key ) ) {
|
667 |
+
$classes .= 'um-error ';
|
668 |
+
} else {
|
669 |
+
$classes .= 'valid ';
|
670 |
+
}
|
671 |
+
|
672 |
+
if ( ! isset( $data['required'] ) ) {
|
673 |
+
$classes .= 'not-required ';
|
674 |
+
}
|
675 |
+
|
676 |
+
if ( $data['type'] == 'date' ) {
|
677 |
+
$classes .= 'um-datepicker ';
|
678 |
+
}
|
679 |
+
|
680 |
+
if ( $data['type'] == 'time' ) {
|
681 |
+
$classes .= 'um-timepicker ';
|
682 |
+
}
|
683 |
+
|
684 |
+
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
685 |
+
$classes .= 'um-iconed ';
|
686 |
+
}
|
687 |
+
|
688 |
+
if ( $add ) {
|
689 |
+
$classes .= $add . ' ';
|
690 |
+
}
|
691 |
+
|
692 |
+
/**
|
693 |
+
* UM hook
|
694 |
+
*
|
695 |
+
* @type filter
|
696 |
+
* @title um_extend_field_classes
|
697 |
+
* @description Change field classes
|
698 |
+
* @input_vars
|
699 |
+
* [{"var":"$classes","type":"string","desc":"Field Classes"},
|
700 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
701 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
702 |
+
* @change_log
|
703 |
+
* ["Since: 2.0"]
|
704 |
+
* @usage add_filter( 'um_extend_field_classes', 'function_name', 10, 3 );
|
705 |
+
* @example
|
706 |
+
* <?php
|
707 |
+
* add_filter( 'um_extend_field_classes', 'my_extend_field_classes', 10, 3 );
|
708 |
+
* function my_extend_field_classes( $classes, $key, $data ) {
|
709 |
+
* // your code here
|
710 |
+
* return $classes;
|
711 |
+
* }
|
712 |
+
* ?>
|
713 |
+
*/
|
714 |
+
$classes = apply_filters( 'um_extend_field_classes', $classes, $key, $data );
|
715 |
+
|
716 |
+
return $classes;
|
717 |
+
}
|
718 |
+
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Gets field value
|
722 |
+
*
|
723 |
+
* @param string $key
|
724 |
+
* @param boolean $default
|
725 |
+
* @param array $data
|
726 |
+
*
|
727 |
+
* @return mixed
|
728 |
+
*/
|
729 |
+
function field_value( $key, $default = false, $data = null ) {
|
730 |
+
// preview in backend
|
731 |
+
if ( isset( UM()->user()->preview ) && UM()->user()->preview ) {
|
732 |
+
if ( $this->set_mode == 'login' || $this->set_mode == 'register' ) {
|
733 |
+
return '';
|
734 |
+
} else {
|
735 |
+
$val = um_user( $key );
|
736 |
+
if ( ! empty( $val ) ) {
|
737 |
+
return $val;
|
738 |
+
} else {
|
739 |
+
return '';
|
740 |
+
}
|
741 |
+
}
|
742 |
+
}
|
743 |
+
|
744 |
+
if ( isset( $_SESSION ) && isset( $_SESSION['um_social_profile'][ $key ] ) && isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
745 |
+
return $_SESSION['um_social_profile'][ $key ];
|
746 |
+
}
|
747 |
+
|
748 |
+
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
749 |
+
|
750 |
+
// normal state
|
751 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
752 |
+
//show empty value for password fields
|
753 |
+
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) {
|
754 |
+
return '';
|
755 |
+
}
|
756 |
+
|
757 |
+
if ( 'profile' === $this->set_mode ) {
|
758 |
+
if ( ! isset( UM()->form()->post_form['profile_nonce'] ) || false === wp_verify_nonce( UM()->form()->post_form['profile_nonce'], 'um-profile-nonce' . UM()->user()->target_id ) ) {
|
759 |
+
return '';
|
760 |
+
}
|
761 |
+
}
|
762 |
+
|
763 |
+
return stripslashes_deep( UM()->form()->post_form[ $key ] );
|
764 |
+
|
765 |
+
} elseif ( um_user( $key ) && $this->editing == true ) {
|
766 |
+
|
767 |
+
//show empty value for password fields
|
768 |
+
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
|
769 |
+
return '';
|
770 |
+
}
|
771 |
+
|
772 |
+
$value = um_user( $key );
|
773 |
+
/**
|
774 |
+
* UM hook
|
775 |
+
*
|
776 |
+
* @type filter
|
777 |
+
* @title um_edit_{$key}_field_value
|
778 |
+
* @description Change field value on edit by field $key
|
779 |
+
* @input_vars
|
780 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
781 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
782 |
+
* @change_log
|
783 |
+
* ["Since: 2.0"]
|
784 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
785 |
+
* @example
|
786 |
+
* <?php
|
787 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
788 |
+
* function my_edit_field_value( $value, $key ) {
|
789 |
+
* // your code here
|
790 |
+
* return $value;
|
791 |
+
* }
|
792 |
+
* ?>
|
793 |
+
*/
|
794 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
795 |
+
/**
|
796 |
+
* UM hook
|
797 |
+
*
|
798 |
+
* @type filter
|
799 |
+
* @title um_edit_{$type}_field_value
|
800 |
+
* @description Change field value on edit by field $type
|
801 |
+
* @input_vars
|
802 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
803 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
804 |
+
* @change_log
|
805 |
+
* ["Since: 2.0"]
|
806 |
+
* @usage add_filter( 'um_edit_{$type}_field_value', 'function_name', 10, 2 );
|
807 |
+
* @example
|
808 |
+
* <?php
|
809 |
+
* add_filter( 'um_edit_{$type}_field_value', 'my_edit_field_value', 10, 2 );
|
810 |
+
* function my_edit_field_value( $value, $key ) {
|
811 |
+
* // your code here
|
812 |
+
* return $value;
|
813 |
+
* }
|
814 |
+
* ?>
|
815 |
+
*/
|
816 |
+
$value = apply_filters( "um_edit_{$type}_field_value", $value, $key );
|
817 |
+
|
818 |
+
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) {
|
819 |
+
|
820 |
+
return um_filtered_value( $key, $data );
|
821 |
+
|
822 |
+
} elseif ( isset( UM()->user()->profile[ $key ] ) ) {
|
823 |
+
|
824 |
+
$value = UM()->user()->profile[ $key ];
|
825 |
+
/**
|
826 |
+
* UM hook
|
827 |
+
*
|
828 |
+
* @type filter
|
829 |
+
* @title um_edit_{$key}_field_value
|
830 |
+
* @description Change field value on edit by field $key
|
831 |
+
* @input_vars
|
832 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
833 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
834 |
+
* @change_log
|
835 |
+
* ["Since: 2.0"]
|
836 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
837 |
+
* @example
|
838 |
+
* <?php
|
839 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
840 |
+
* function my_edit_field_value( $value, $key ) {
|
841 |
+
* // your code here
|
842 |
+
* return $value;
|
843 |
+
* }
|
844 |
+
* ?>
|
845 |
+
*/
|
846 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
847 |
+
$value = maybe_unserialize( $value );
|
848 |
+
|
849 |
+
} elseif ( $default ) {
|
850 |
+
|
851 |
+
/**
|
852 |
+
* UM hook
|
853 |
+
*
|
854 |
+
* @type filter
|
855 |
+
* @title um_field_default_value
|
856 |
+
* @description Change field default value
|
857 |
+
* @input_vars
|
858 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
859 |
+
* {"var":"$data","type":"array","desc":"Field Data"},
|
860 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
861 |
+
* @change_log
|
862 |
+
* ["Since: 2.0"]
|
863 |
+
* @usage add_filter( 'um_field_default_value', 'function_name', 10, 2 );
|
864 |
+
* @example
|
865 |
+
* <?php
|
866 |
+
* add_filter( 'um_field_default_value', 'my_field_default_value', 10, 2 );
|
867 |
+
* function my_field_default_value( $default, $data, $type ) {
|
868 |
+
* // your code here
|
869 |
+
* return $default;
|
870 |
+
* }
|
871 |
+
* ?>
|
872 |
+
*/
|
873 |
+
$default = apply_filters( 'um_field_default_value', $default, $data, $type );
|
874 |
+
/**
|
875 |
+
* UM hook
|
876 |
+
*
|
877 |
+
* @type filter
|
878 |
+
* @title um_field_{$key}_default_value
|
879 |
+
* @description Change field default value by $key
|
880 |
+
* @input_vars
|
881 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
882 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
883 |
+
* @change_log
|
884 |
+
* ["Since: 2.0"]
|
885 |
+
* @usage add_filter( 'um_field_{$key}_default_value', 'function_name', 10, 2 );
|
886 |
+
* @example
|
887 |
+
* <?php
|
888 |
+
* add_filter( 'um_field_{$key}_default_value', 'my_field_default_value', 10, 2 );
|
889 |
+
* function my_field_default_value( $default, $data ) {
|
890 |
+
* // your code here
|
891 |
+
* return $default;
|
892 |
+
* }
|
893 |
+
* ?>
|
894 |
+
*/
|
895 |
+
$default = apply_filters( "um_field_{$key}_default_value", $default, $data );
|
896 |
+
/**
|
897 |
+
* UM hook
|
898 |
+
*
|
899 |
+
* @type filter
|
900 |
+
* @title um_field_{$type}_default_value
|
901 |
+
* @description Change field default value by $type
|
902 |
+
* @input_vars
|
903 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
904 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
905 |
+
* @change_log
|
906 |
+
* ["Since: 2.0"]
|
907 |
+
* @usage add_filter( 'um_field_{$type}_default_value', 'function_name', 10, 2 );
|
908 |
+
* @example
|
909 |
+
* <?php
|
910 |
+
* add_filter( 'um_field_{$type}_default_value', 'my_field_default_value', 10, 2 );
|
911 |
+
* function my_field_default_value( $default, $data ) {
|
912 |
+
* // your code here
|
913 |
+
* return $default;
|
914 |
+
* }
|
915 |
+
* ?>
|
916 |
+
*/
|
917 |
+
$default = apply_filters( "um_field_{$type}_default_value", $default, $data );
|
918 |
+
|
919 |
+
}
|
920 |
+
|
921 |
+
// Default Value for Registration Form and Profile Form editing
|
922 |
+
if ( ! isset( $value ) && ( $this->set_mode == 'register' || $this->editing == true ) ) {
|
923 |
+
|
924 |
+
/**
|
925 |
+
* UM hook
|
926 |
+
*
|
927 |
+
* @type filter
|
928 |
+
* @title um_edit_{$key}_field_value
|
929 |
+
* @description Change field value on edit by field $key
|
930 |
+
* @input_vars
|
931 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
932 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
933 |
+
* @change_log
|
934 |
+
* ["Since: 2.0"]
|
935 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
936 |
+
* @example
|
937 |
+
* <?php
|
938 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
939 |
+
* function my_edit_field_value( $value, $key ) {
|
940 |
+
* // your code here
|
941 |
+
* return $value;
|
942 |
+
* }
|
943 |
+
* ?>
|
944 |
+
*/
|
945 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $default, $key );
|
946 |
+
|
947 |
+
} elseif ( isset( $value ) && is_array( $value ) && ! count( $value ) ) {
|
948 |
+
$value = '';
|
949 |
+
} elseif ( ! isset( $value ) ) {
|
950 |
+
$value = '';
|
951 |
+
}
|
952 |
+
|
953 |
+
|
954 |
+
/**
|
955 |
+
* UM hook
|
956 |
+
*
|
957 |
+
* @type filter
|
958 |
+
* @title um_field_value
|
959 |
+
* @description Change field value
|
960 |
+
* @input_vars
|
961 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
962 |
+
* {"var":"$key","type":"string","desc":"Field Key"},,
|
963 |
+
* {"var":"$type","type":"string","desc":"Field Type"}
|
964 |
+
* {"var":"$default","type":"string","desc":"Field Default Value"},
|
965 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
966 |
+
* @usage add_filter( 'um_field_value', 'function_name', 10, 5 );
|
967 |
+
*/
|
968 |
+
return apply_filters( 'um_field_value', $value, $default, $key, $type, $data );
|
969 |
+
}
|
970 |
+
|
971 |
+
|
972 |
+
/**
|
973 |
+
* Checks if an option is selected
|
974 |
+
*
|
975 |
+
* is used by Select, Multiselect and Checkbox fields
|
976 |
+
*
|
977 |
+
* @param string $key
|
978 |
+
* @param string $value
|
979 |
+
* @param array $data
|
980 |
+
*
|
981 |
+
* @return boolean
|
982 |
+
*/
|
983 |
+
function is_selected( $key, $value, $data ) {
|
984 |
+
global $wpdb;
|
985 |
+
|
986 |
+
/**
|
987 |
+
* UM hook
|
988 |
+
*
|
989 |
+
* @type filter
|
990 |
+
* @title um_is_selected_filter_key
|
991 |
+
* @description Change is selected filter key
|
992 |
+
* @input_vars
|
993 |
+
* [{"var":"$key","type":"string","desc":"Selected filter key"}]
|
994 |
+
* @change_log
|
995 |
+
* ["Since: 2.0"]
|
996 |
+
* @usage add_filter( 'um_is_selected_filter_key', 'function_name', 10, 1 );
|
997 |
+
* @example
|
998 |
+
* <?php
|
999 |
+
* add_filter( 'um_is_selected_filter_key', 'my_selected_filter_key', 10, 1 );
|
1000 |
+
* function my_selected_filter_key( $key ) {
|
1001 |
+
* // your code here
|
1002 |
+
* return $key;
|
1003 |
+
* }
|
1004 |
+
* ?>
|
1005 |
+
*/
|
1006 |
+
$key = apply_filters( 'um_is_selected_filter_key', $key );
|
1007 |
+
|
1008 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1009 |
+
|
1010 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) ) {
|
1011 |
+
|
1012 |
+
if ( in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1013 |
+
return true;
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
|
1017 |
+
if ( in_array( $value, $stripslashed ) ) {
|
1018 |
+
return true;
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
|
1022 |
+
return true;
|
1023 |
+
}
|
1024 |
+
} else {
|
1025 |
+
|
1026 |
+
if ( $value == UM()->form()->post_form[ $key ] ) {
|
1027 |
+
return true;
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
} else {
|
1033 |
+
|
1034 |
+
$field_value = um_user( $key );
|
1035 |
+
if ( ! $field_value ) {
|
1036 |
+
$field_value = 0;
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
if ( $field_value == 0 && $value == '0' ) {
|
1040 |
+
$value = (int) $value;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1044 |
+
$field_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1045 |
+
|
1046 |
+
$role_keys = get_option( 'um_roles', array() );
|
1047 |
+
|
1048 |
+
if ( ! empty( $role_keys ) ) {
|
1049 |
+
if ( in_array( $field_value, $role_keys ) ) {
|
1050 |
+
$field_value = 'um_' . $field_value;
|
1051 |
+
}
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
|
1056 |
+
/**
|
1057 |
+
* UM hook
|
1058 |
+
*
|
1059 |
+
* @type filter
|
1060 |
+
* @title um_is_selected_filter_value
|
1061 |
+
* @description Change is selected filter value
|
1062 |
+
* @input_vars
|
1063 |
+
* [{"var":"$value","type":"string","desc":"Selected filter value"},
|
1064 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1065 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1066 |
+
* @change_log
|
1067 |
+
* ["Since: 2.0"]
|
1068 |
+
* @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 );
|
1069 |
+
* @example
|
1070 |
+
* <?php
|
1071 |
+
* add_filter( 'um_is_selected_filter_value', 'my_selected_filter_value', 10, 2 );
|
1072 |
+
* function my_selected_filter_value( $value, $key ) {
|
1073 |
+
* // your code here
|
1074 |
+
* return $field_value;
|
1075 |
+
* }
|
1076 |
+
* ?>
|
1077 |
+
*/
|
1078 |
+
$field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key, $value );
|
1079 |
+
|
1080 |
+
/**
|
1081 |
+
* UM hook
|
1082 |
+
*
|
1083 |
+
* @type filter
|
1084 |
+
* @title um_is_selected_filter_data
|
1085 |
+
* @description Change is selected filter data
|
1086 |
+
* @input_vars
|
1087 |
+
* [{"var":"$data","type":"array","desc":"Selected filter value"},
|
1088 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1089 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1090 |
+
* @change_log
|
1091 |
+
* ["Since: 2.0"]
|
1092 |
+
* @usage add_filter( 'um_is_selected_filter_data', 'function_name', 10, 3 );
|
1093 |
+
* @example
|
1094 |
+
* <?php
|
1095 |
+
* add_filter( 'um_is_selected_filter_data', 'my_selected_filter_data', 10, 3 );
|
1096 |
+
* function my_selected_filter_data( $data, $key, $value ) {
|
1097 |
+
* // your code here
|
1098 |
+
* return $data;
|
1099 |
+
* }
|
1100 |
+
* ?>
|
1101 |
+
*/
|
1102 |
+
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
1103 |
+
|
1104 |
+
if ( ! $this->editing || 'custom' == $this->set_mode ) {
|
1105 |
+
// show default on register screen if there is default
|
1106 |
+
if ( isset( $data['default'] ) ) {
|
1107 |
+
|
1108 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1109 |
+
return true;
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1113 |
+
return true;
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
if ( is_array( $data['default'] ) && array_intersect( $data['options'], $data['default'] ) ) {
|
1117 |
+
return true;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
// default value with comma
|
1121 |
+
if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
|
1122 |
+
$choices = array_map( 'trim', explode( ',', $data['default'] ) );
|
1123 |
+
if ( in_array( $value, $choices ) ) {
|
1124 |
+
return true;
|
1125 |
+
}
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
}
|
1129 |
+
} else {
|
1130 |
+
|
1131 |
+
if ( $field_value && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) ) ) {
|
1132 |
+
return true;
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
if ( $field_value == 0 && ! is_array( $field_value ) && $field_value === $value ) {
|
1136 |
+
return true;
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
if ( $field_value && ! is_array( $field_value ) && $field_value == $value ) {
|
1140 |
+
return true;
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
if ( $field_value && ! is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value ) ) {
|
1144 |
+
return true;
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1148 |
+
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1149 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) ) {
|
1150 |
+
if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
|
1151 |
+
$data['default'] = explode( ', ', $data['default'] );
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1155 |
+
return true;
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1159 |
+
return true;
|
1160 |
+
}
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
return false;
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
|
1170 |
+
/**
|
1171 |
+
* Checks if a radio button is selected
|
1172 |
+
*
|
1173 |
+
* @param string $key
|
1174 |
+
* @param string $value
|
1175 |
+
* @param array $data
|
1176 |
+
*
|
1177 |
+
* @return boolean
|
1178 |
+
*/
|
1179 |
+
function is_radio_checked( $key, $value, $data ) {
|
1180 |
+
global $wpdb;
|
1181 |
+
|
1182 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1183 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) && in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1184 |
+
return true;
|
1185 |
+
} elseif ( $value == UM()->form()->post_form[ $key ] ) {
|
1186 |
+
return true;
|
1187 |
+
}
|
1188 |
+
} else {
|
1189 |
+
|
1190 |
+
if ( $this->editing && 'custom' !== $this->set_mode ) {
|
1191 |
+
if ( um_user( $key ) ) {
|
1192 |
+
|
1193 |
+
$um_user_value = um_user( $key );
|
1194 |
+
|
1195 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1196 |
+
$um_user_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1197 |
+
|
1198 |
+
$role_keys = get_option( 'um_roles', array() );
|
1199 |
+
|
1200 |
+
if ( ! empty( $role_keys ) ) {
|
1201 |
+
if ( in_array( $um_user_value, $role_keys ) ) {
|
1202 |
+
$um_user_value = 'um_' . $um_user_value;
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
}
|
1206 |
+
|
1207 |
+
if ( $um_user_value == $value ) {
|
1208 |
+
return true;
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
1212 |
+
return true;
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
if ( is_array( $um_user_value ) ) {
|
1216 |
+
foreach ( $um_user_value as $u ) {
|
1217 |
+
if ( $u == html_entity_decode( $value ) ) {
|
1218 |
+
return true;
|
1219 |
+
}
|
1220 |
+
}
|
1221 |
+
}
|
1222 |
+
} else {
|
1223 |
+
|
1224 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1225 |
+
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1226 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) && $data['default'] == $value ) {
|
1227 |
+
return true;
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
}
|
1231 |
+
} else {
|
1232 |
+
if ( isset( $data['default'] ) && $data['default'] == $value ) {
|
1233 |
+
return true;
|
1234 |
+
}
|
1235 |
+
}
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
return false;
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
|
1242 |
+
/**
|
1243 |
+
* Get field icon
|
1244 |
+
*
|
1245 |
+
* @param string $key
|
1246 |
+
*
|
1247 |
+
* @return string
|
1248 |
+
*/
|
1249 |
+
function get_field_icon( $key ) {
|
1250 |
+
$fields = UM()->builtin()->all_user_fields;
|
1251 |
+
if ( isset( $fields[ $key ]['icon'] ) ) {
|
1252 |
+
return $fields[ $key ]['icon'];
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
return '';
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
|
1259 |
+
/**
|
1260 |
+
* Gets selected option value from a callback function
|
1261 |
+
*
|
1262 |
+
* @param string $value
|
1263 |
+
* @param array $data
|
1264 |
+
* @param string $type
|
1265 |
+
*
|
1266 |
+
* @return string
|
1267 |
+
*/
|
1268 |
+
function get_option_value_from_callback( $value, $data, $type ) {
|
1269 |
+
|
1270 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1271 |
+
|
1272 |
+
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1273 |
+
|
1274 |
+
if ( $has_custom_source ) {
|
1275 |
+
|
1276 |
+
$opts = apply_filters( "um_get_field__{$data['metakey']}", array() );
|
1277 |
+
$arr_options = $opts['options'];
|
1278 |
+
|
1279 |
+
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1280 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1281 |
+
$_POST['parent_option_name'] = $data['parent_dropdown_relationship'];
|
1282 |
+
$_POST['parent_option'] = um_user( $data['parent_dropdown_relationship'] );
|
1283 |
+
|
1284 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1285 |
+
} else {
|
1286 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1287 |
+
}
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
if ( $has_custom_source || function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1291 |
+
if ( $type == 'select' ) {
|
1292 |
+
if ( ! empty( $arr_options[ $value ] ) ) {
|
1293 |
+
return $arr_options[ $value ];
|
1294 |
+
} elseif ( ! empty( $data['default'] ) && empty( $arr_options[ $value ] ) ) {
|
1295 |
+
return $arr_options[ $data['default'] ];
|
1296 |
+
} else {
|
1297 |
+
return '';
|
1298 |
+
}
|
1299 |
+
} elseif ( $type == 'multiselect' ) {
|
1300 |
+
|
1301 |
+
if ( is_array( $value ) ) {
|
1302 |
+
$values = $value;
|
1303 |
+
} else {
|
1304 |
+
$values = explode( ', ', $value );
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
$arr_paired_options = array();
|
1308 |
+
|
1309 |
+
foreach ( $values as $option ) {
|
1310 |
+
if ( isset( $arr_options[ $option ] ) ) {
|
1311 |
+
$arr_paired_options[] = $arr_options[ $option ];
|
1312 |
+
}
|
1313 |
+
}
|
1314 |
+
|
1315 |
+
return implode( ', ', $arr_paired_options );
|
1316 |
+
}
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
return $value;
|
1323 |
+
}
|
1324 |
+
|
1325 |
+
|
1326 |
+
/**
|
1327 |
+
* Get select options from a callback function
|
1328 |
+
*
|
1329 |
+
* @param array $data
|
1330 |
+
* @param string $type
|
1331 |
+
*
|
1332 |
+
* @return array $arr_options
|
1333 |
+
*/
|
1334 |
+
function get_options_from_callback( $data, $type ) {
|
1335 |
+
$arr_options = array();
|
1336 |
+
|
1337 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1338 |
+
|
1339 |
+
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1340 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1341 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1342 |
+
} else {
|
1343 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1344 |
+
}
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
return $arr_options;
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
|
1353 |
+
/**
|
1354 |
+
* Get field type
|
1355 |
+
*
|
1356 |
+
* @param string $key
|
1357 |
+
*
|
1358 |
+
* @return string
|
1359 |
+
*/
|
1360 |
+
function get_field_type( $key ) {
|
1361 |
+
$fields = UM()->builtin()->all_user_fields;
|
1362 |
+
if ( isset( $fields[ $key ]['type'] ) ) {
|
1363 |
+
return $fields[ $key ]['type'];
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
return '';
|
1367 |
+
}
|
1368 |
+
|
1369 |
+
|
1370 |
+
/**
|
1371 |
+
* Get field label
|
1372 |
+
*
|
1373 |
+
* @param string $key
|
1374 |
+
*
|
1375 |
+
* @return string
|
1376 |
+
*/
|
1377 |
+
function get_label( $key ) {
|
1378 |
+
$label = '';
|
1379 |
+
|
1380 |
+
$fields = UM()->builtin()->all_user_fields;
|
1381 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1382 |
+
$label = stripslashes( $fields[ $key ]['label'] );
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
if ( empty( $label ) && isset( $fields[ $key ]['title'] ) ) {
|
1386 |
+
$label = stripslashes( $fields[ $key ]['title'] );
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* UM hook
|
1391 |
+
*
|
1392 |
+
* @type filter
|
1393 |
+
* @title um_change_field_label
|
1394 |
+
* @description Change Field Label
|
1395 |
+
* @input_vars
|
1396 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
1397 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
1398 |
+
* @change_log
|
1399 |
+
* ["Since: 2.0.30"]
|
1400 |
+
* @usage add_filter( 'um_change_field_label', 'function_name', 10, 2 );
|
1401 |
+
* @example
|
1402 |
+
* <?php
|
1403 |
+
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 2 );
|
1404 |
+
* function my_form_fields( $label, $key ) {
|
1405 |
+
* // your code here
|
1406 |
+
* return $label;
|
1407 |
+
* }
|
1408 |
+
* ?>
|
1409 |
+
*/
|
1410 |
+
$label = apply_filters( 'um_change_field_label', $label, $key );
|
1411 |
+
|
1412 |
+
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
|
1413 |
+
return $label;
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
|
1417 |
+
/**
|
1418 |
+
* Get field title
|
1419 |
+
*
|
1420 |
+
* @param string $key
|
1421 |
+
*
|
1422 |
+
* @return string
|
1423 |
+
*/
|
1424 |
+
function get_field_title( $key ) {
|
1425 |
+
$fields = UM()->builtin()->all_user_fields;
|
1426 |
+
if ( isset( $fields[ $key ]['title'] ) ) {
|
1427 |
+
return $fields[ $key ]['title'];
|
1428 |
+
}
|
1429 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1430 |
+
return $fields[ $key ]['label'];
|
1431 |
+
}
|
1432 |
+
|
1433 |
+
return __( 'Custom Field', 'ultimate-member' );
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
|
1437 |
+
/**
|
1438 |
+
* Get form fields
|
1439 |
+
*
|
1440 |
+
* @return array
|
1441 |
+
*/
|
1442 |
+
function get_fields() {
|
1443 |
+
/**
|
1444 |
+
* UM hook
|
1445 |
+
*
|
1446 |
+
* @type filter
|
1447 |
+
* @title um_get_form_fields
|
1448 |
+
* @description Extend form fields
|
1449 |
+
* @input_vars
|
1450 |
+
* [{"var":"$fields","type":"array","desc":"Selected filter value"}]
|
1451 |
+
* @change_log
|
1452 |
+
* ["Since: 2.0"]
|
1453 |
+
* @usage add_filter( 'um_get_form_fields', 'function_name', 10, 1 );
|
1454 |
+
* @example
|
1455 |
+
* <?php
|
1456 |
+
* add_filter( 'um_get_form_fields', 'my_form_fields', 10, 1 );
|
1457 |
+
* function my_form_fields( $fields ) {
|
1458 |
+
* // your code here
|
1459 |
+
* return $fields;
|
1460 |
+
* }
|
1461 |
+
* ?>
|
1462 |
+
*/
|
1463 |
+
$this->fields = apply_filters( 'um_get_form_fields', array() );
|
1464 |
+
return $this->fields;
|
1465 |
+
}
|
1466 |
+
|
1467 |
+
|
1468 |
+
/**
|
1469 |
+
* Get specific field
|
1470 |
+
*
|
1471 |
+
* @param $key
|
1472 |
+
*
|
1473 |
+
* @return mixed
|
1474 |
+
* @throws \Exception
|
1475 |
+
*/
|
1476 |
+
function get_field( $key ) {
|
1477 |
+
$fields = $this->get_fields();
|
1478 |
+
|
1479 |
+
if ( isset( $fields ) && is_array( $fields ) && isset( $fields[ $key ] ) ) {
|
1480 |
+
$array = $fields[ $key ];
|
1481 |
+
} else {
|
1482 |
+
if ( ! isset( UM()->builtin()->predefined_fields[ $key ] ) && ! isset( UM()->builtin()->all_user_fields[ $key ] ) ) {
|
1483 |
+
return '';
|
1484 |
+
}
|
1485 |
+
$array = ( isset( UM()->builtin()->predefined_fields[ $key ] ) ) ? UM()->builtin()->predefined_fields[ $key ] : UM()->builtin()->all_user_fields[ $key ];
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
$array['classes'] = null;
|
1489 |
+
|
1490 |
+
if ( ! isset( $array['placeholder'] ) ) {
|
1491 |
+
$array['placeholder'] = null;
|
1492 |
+
}
|
1493 |
+
if ( ! isset( $array['required'] ) ) {
|
1494 |
+
$array['required'] = null;
|
1495 |
+
}
|
1496 |
+
if ( ! isset( $array['validate'] ) ) {
|
1497 |
+
$array['validate'] = null;
|
1498 |
+
}
|
1499 |
+
if ( ! isset( $array['default'] ) ) {
|
1500 |
+
$array['default'] = null;
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && ! $this->viewing ) {
|
1504 |
+
$array['conditional'] = '';
|
1505 |
+
|
1506 |
+
foreach ( $array['conditions'] as $cond_id => $cond ) {
|
1507 |
+
$array['conditional'] .= ' data-cond-' . $cond_id . '-action="' . esc_attr( $cond[0] ) . '" data-cond-' . $cond_id . '-field="' . esc_attr( $cond[1] ) . '" data-cond-' . $cond_id . '-operator="' . esc_attr( $cond[2] ) . '" data-cond-' . $cond_id . '-value="' . esc_attr( $cond[3] ) . '"';
|
1508 |
+
}
|
1509 |
+
|
1510 |
+
$array['classes'] .= ' um-is-conditional';
|
1511 |
+
|
1512 |
+
} else {
|
1513 |
+
$array['conditional'] = null;
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
1517 |
+
|
1518 |
+
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
|
1519 |
+
$array['classes'] .= ' um-field-' . esc_attr( $key );
|
1520 |
+
}
|
1521 |
+
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
|
1522 |
+
$array['classes'] .= ' um-field-type_' . esc_attr( $array['type'] );
|
1523 |
+
|
1524 |
+
switch ( $array['type'] ) {
|
1525 |
+
|
1526 |
+
case 'googlemap':
|
1527 |
+
case 'youtube_video':
|
1528 |
+
case 'vimeo_video':
|
1529 |
+
case 'soundcloud_track':
|
1530 |
+
$array['disabled'] = '';
|
1531 |
+
$array['input'] = 'text';
|
1532 |
+
break;
|
1533 |
+
|
1534 |
+
case 'text':
|
1535 |
+
|
1536 |
+
$array['disabled'] = '';
|
1537 |
+
|
1538 |
+
if ( $key == 'user_login' && isset( $this->set_mode ) && $this->set_mode == 'account' ) {
|
1539 |
+
$array['disabled'] = 'disabled="disabled"';
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
$array['input'] = 'text';
|
1543 |
+
|
1544 |
+
break;
|
1545 |
+
|
1546 |
+
case 'password':
|
1547 |
+
|
1548 |
+
$array['input'] = 'password';
|
1549 |
+
|
1550 |
+
break;
|
1551 |
+
|
1552 |
+
case 'number':
|
1553 |
+
|
1554 |
+
$array['disabled'] = '';
|
1555 |
+
|
1556 |
+
break;
|
1557 |
+
|
1558 |
+
case 'url':
|
1559 |
+
|
1560 |
+
$array['input'] = 'text';
|
1561 |
+
|
1562 |
+
break;
|
1563 |
+
|
1564 |
+
case 'date':
|
1565 |
+
|
1566 |
+
$array['input'] = 'text';
|
1567 |
+
|
1568 |
+
if ( ! isset( $array['format'] ) ) {
|
1569 |
+
$array['format'] = 'j M Y';
|
1570 |
+
}
|
1571 |
+
|
1572 |
+
switch ( $array['format'] ) {
|
1573 |
+
case 'j M Y':
|
1574 |
+
$js_format = 'd mmm yyyy';
|
1575 |
+
break;
|
1576 |
+
case 'j F Y':
|
1577 |
+
$js_format = 'd mmmm yyyy';
|
1578 |
+
break;
|
1579 |
+
case 'M j Y':
|
1580 |
+
$js_format = 'mmm d yyyy';
|
1581 |
+
break;
|
1582 |
+
case 'F j Y':
|
1583 |
+
$js_format = 'mmmm d yyyy';
|
1584 |
+
break;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
$array['js_format'] = $js_format;
|
1588 |
+
|
1589 |
+
if ( ! isset( $array['range'] ) ) {
|
1590 |
+
$array['range'] = 'years';
|
1591 |
+
}
|
1592 |
+
if ( ! isset( $array['years'] ) ) {
|
1593 |
+
$array['years'] = 100;
|
1594 |
+
}
|
1595 |
+
if ( ! isset( $array['years_x'] ) ) {
|
1596 |
+
$array['years_x'] = 'past';
|
1597 |
+
}
|
1598 |
+
if ( ! isset( $array['disabled_weekdays'] ) ) {
|
1599 |
+
$array['disabled_weekdays'] = '';
|
1600 |
+
}
|
1601 |
+
|
1602 |
+
if ( ! empty( $array['disabled_weekdays'] ) ) {
|
1603 |
+
$array['disabled_weekdays'] = '[' . implode( ',', $array['disabled_weekdays'] ) . ']';
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
// When date range is strictly defined
|
1607 |
+
if ( $array['range'] == 'date_range' ) {
|
1608 |
+
|
1609 |
+
$array['date_min'] = str_replace( '/', ',', $array['range_start'] );
|
1610 |
+
$array['date_max'] = str_replace( '/', ',', $array['range_end'] );
|
1611 |
+
|
1612 |
+
} else {
|
1613 |
+
|
1614 |
+
if ( $array['years_x'] == 'past' ) {
|
1615 |
+
|
1616 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1617 |
+
$past = $date->modify( '-' . $array['years'] . ' years' );
|
1618 |
+
$past = $date->format( 'Y,n,d' );
|
1619 |
+
|
1620 |
+
$array['date_min'] = $past;
|
1621 |
+
$array['date_max'] = date( 'Y,n,d' );
|
1622 |
+
|
1623 |
+
} elseif ( $array['years_x'] == 'future' ) {
|
1624 |
+
|
1625 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1626 |
+
$future = $date->modify( '+' . $array['years'] . ' years' );
|
1627 |
+
$future = $date->format( 'Y,n,d' );
|
1628 |
+
|
1629 |
+
$array['date_min'] = date( 'Y,n,d' );
|
1630 |
+
$array['date_max'] = $future;
|
1631 |
+
|
1632 |
+
} else {
|
1633 |
+
|
1634 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1635 |
+
$date_f = new \DateTime( date( 'Y-n-d' ) );
|
1636 |
+
$past = $date->modify( '-' . ( $array['years'] / 2 ) . ' years' );
|
1637 |
+
$past = $date->format( 'Y,n,d' );
|
1638 |
+
$future = $date_f->modify( '+' . ( $array['years'] / 2 ) . ' years' );
|
1639 |
+
$future = $date_f->format( 'Y,n,d' );
|
1640 |
+
|
1641 |
+
$array['date_min'] = $past;
|
1642 |
+
$array['date_max'] = $future;
|
1643 |
+
|
1644 |
+
}
|
1645 |
+
|
1646 |
+
}
|
1647 |
+
|
1648 |
+
break;
|
1649 |
+
|
1650 |
+
case 'time':
|
1651 |
+
|
1652 |
+
$array['input'] = 'text';
|
1653 |
+
|
1654 |
+
if ( ! isset( $array['format'] ) ) {
|
1655 |
+
$array['format'] = 'g:i a';
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
switch ( $array['format'] ) {
|
1659 |
+
case 'g:i a':
|
1660 |
+
$js_format = 'h:i a';
|
1661 |
+
break;
|
1662 |
+
case 'g:i A':
|
1663 |
+
$js_format = 'h:i A';
|
1664 |
+
break;
|
1665 |
+
case 'H:i':
|
1666 |
+
$js_format = 'HH:i';
|
1667 |
+
break;
|
1668 |
+
}
|
1669 |
+
|
1670 |
+
$array['js_format'] = $js_format;
|
1671 |
+
|
1672 |
+
if ( ! isset( $array['intervals'] ) ) {
|
1673 |
+
$array['intervals'] = 60;
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
break;
|
1677 |
+
|
1678 |
+
case 'textarea':
|
1679 |
+
|
1680 |
+
if ( ! isset( $array['height'] ) ) {
|
1681 |
+
$array['height'] = '100px';
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
break;
|
1685 |
+
|
1686 |
+
case 'rating':
|
1687 |
+
|
1688 |
+
if ( ! isset( $array['number'] ) ) {
|
1689 |
+
$array['number'] = 5;
|
1690 |
+
}
|
1691 |
+
|
1692 |
+
break;
|
1693 |
+
|
1694 |
+
case 'spacing':
|
1695 |
+
|
1696 |
+
if ( ! isset( $array['spacing'] ) ) {
|
1697 |
+
$array['spacing'] = '20px';
|
1698 |
+
}
|
1699 |
+
|
1700 |
+
break;
|
1701 |
+
|
1702 |
+
case 'divider':
|
1703 |
+
|
1704 |
+
if ( isset( $array['width'] ) ) {
|
1705 |
+
$array['borderwidth'] = $array['width'];
|
1706 |
+
} else {
|
1707 |
+
$array['borderwidth'] = 4;
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
if ( isset( $array['color'] ) ) {
|
1711 |
+
$array['bordercolor'] = $array['color'];
|
1712 |
+
} else {
|
1713 |
+
$array['bordercolor'] = '#eee';
|
1714 |
+
}
|
1715 |
+
|
1716 |
+
if ( isset( $array['style'] ) ) {
|
1717 |
+
$array['borderstyle'] = $array['style'];
|
1718 |
+
} else {
|
1719 |
+
$array['borderstyle'] = 'solid';
|
1720 |
+
}
|
1721 |
+
|
1722 |
+
if ( ! isset( $array['divider_text'] ) ) {
|
1723 |
+
$array['divider_text'] = '';
|
1724 |
+
}
|
1725 |
+
|
1726 |
+
break;
|
1727 |
+
|
1728 |
+
case 'image':
|
1729 |
+
|
1730 |
+
if ( ! isset( $array['crop'] ) ) {
|
1731 |
+
$array['crop'] = 0;
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
if ( $array['crop'] == 0 ) {
|
1735 |
+
$array['crop_data'] = 0;
|
1736 |
+
} elseif ( $array['crop'] == 1 ) {
|
1737 |
+
$array['crop_data'] = 'square';
|
1738 |
+
} elseif ( $array['crop'] == 2 ) {
|
1739 |
+
$array['crop_data'] = 'cover';
|
1740 |
+
} else {
|
1741 |
+
$array['crop_data'] = 'user';
|
1742 |
+
}
|
1743 |
+
|
1744 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1745 |
+
$array['modal_size'] = 'normal';
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
if ( $array['crop'] > 0 ) {
|
1749 |
+
$array['crop_class'] = 'crop';
|
1750 |
+
} else {
|
1751 |
+
$array['crop_class'] = '';
|
1752 |
+
}
|
1753 |
+
|
1754 |
+
if ( ! isset( $array['ratio'] ) ) {
|
1755 |
+
$array['ratio'] = 1.0;
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
if ( ! isset( $array['min_width'] ) ) {
|
1759 |
+
$array['min_width'] = '';
|
1760 |
+
}
|
1761 |
+
if ( ! isset( $array['min_height'] ) ) {
|
1762 |
+
$array['min_height'] = '';
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
if ( $array['min_width'] == '' && $array['crop'] == 1 ) {
|
1766 |
+
$array['min_width'] = 600;
|
1767 |
+
}
|
1768 |
+
if ( $array['min_height'] == '' && $array['crop'] == 1 ) {
|
1769 |
+
$array['min_height'] = 600;
|
1770 |
+
}
|
1771 |
+
|
1772 |
+
if ( $array['min_width'] == '' && $array['crop'] == 3 ) {
|
1773 |
+
$array['min_width'] = 600;
|
1774 |
+
}
|
1775 |
+
if ( $array['min_height'] == '' && $array['crop'] == 3 ) {
|
1776 |
+
$array['min_height'] = 600;
|
1777 |
+
}
|
1778 |
+
|
1779 |
+
if ( ! isset( $array['invalid_image'] ) ) {
|
1780 |
+
$array['invalid_image'] = __( 'Please upload a valid image!', 'ultimate-member' );
|
1781 |
+
}
|
1782 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1783 |
+
$array['allowed_types'] = 'gif,jpg,jpeg,png';
|
1784 |
+
} else {
|
1785 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1786 |
+
}
|
1787 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1788 |
+
$array['upload_text'] = '';
|
1789 |
+
}
|
1790 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1791 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1792 |
+
}
|
1793 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1794 |
+
$array['extension_error'] = __( 'Sorry this is not a valid image.', 'ultimate-member' );
|
1795 |
+
}
|
1796 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1797 |
+
$array['max_size_error'] = __( 'This image is too large!', 'ultimate-member' );
|
1798 |
+
}
|
1799 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1800 |
+
$array['min_size_error'] = __( 'This image is too small!', 'ultimate-member' );
|
1801 |
+
}
|
1802 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1803 |
+
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1804 |
+
}
|
1805 |
+
if ( empty( $array['max_size'] ) ) {
|
1806 |
+
$array['max_size'] = 999999999;
|
1807 |
+
}
|
1808 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1809 |
+
$array['upload_help_text'] = '';
|
1810 |
+
}
|
1811 |
+
if ( ! isset( $array['icon'] ) ) {
|
1812 |
+
$array['icon'] = '';
|
1813 |
+
}
|
1814 |
+
|
1815 |
+
break;
|
1816 |
+
|
1817 |
+
case 'file':
|
1818 |
+
|
1819 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1820 |
+
$array['modal_size'] = 'normal';
|
1821 |
+
}
|
1822 |
+
|
1823 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1824 |
+
$array['allowed_types'] = 'pdf,txt';
|
1825 |
+
} else {
|
1826 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1827 |
+
}
|
1828 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1829 |
+
$array['upload_text'] = '';
|
1830 |
+
}
|
1831 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1832 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1833 |
+
}
|
1834 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1835 |
+
$array['extension_error'] = __( 'Sorry this is not a valid file.', 'ultimate-member' );
|
1836 |
+
}
|
1837 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1838 |
+
$array['max_size_error'] = __( 'This file is too large!', 'ultimate-member' );
|
1839 |
+
}
|
1840 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1841 |
+
$array['min_size_error'] = __( 'This file is too small!', 'ultimate-member' );
|
1842 |
+
}
|
1843 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1844 |
+
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1845 |
+
}
|
1846 |
+
if ( empty( $array['max_size'] ) ) {
|
1847 |
+
$array['max_size'] = 999999999;
|
1848 |
+
}
|
1849 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1850 |
+
$array['upload_help_text'] = '';
|
1851 |
+
}
|
1852 |
+
if ( ! isset( $array['icon'] ) ) {
|
1853 |
+
$array['icon'] = '';
|
1854 |
+
}
|
1855 |
+
|
1856 |
+
break;
|
1857 |
+
|
1858 |
+
case 'select':
|
1859 |
+
|
1860 |
+
break;
|
1861 |
+
|
1862 |
+
case 'multiselect':
|
1863 |
+
|
1864 |
+
break;
|
1865 |
+
|
1866 |
+
case 'group':
|
1867 |
+
|
1868 |
+
if ( ! isset( $array['max_entries'] ) ) {
|
1869 |
+
$array['max_entries'] = 0;
|
1870 |
+
}
|
1871 |
+
|
1872 |
+
break;
|
1873 |
+
|
1874 |
+
}
|
1875 |
+
|
1876 |
+
if ( ! isset( $array['visibility'] ) ) {
|
1877 |
+
$array['visibility'] = 'all';
|
1878 |
+
}
|
1879 |
+
|
1880 |
+
/**
|
1881 |
+
* UM hook
|
1882 |
+
*
|
1883 |
+
* @type filter
|
1884 |
+
* @title um_get_field__{$key}
|
1885 |
+
* @description Extend field data by field $key
|
1886 |
+
* @input_vars
|
1887 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
1888 |
+
* @change_log
|
1889 |
+
* ["Since: 2.0"]
|
1890 |
+
* @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 );
|
1891 |
+
* @example
|
1892 |
+
* <?php
|
1893 |
+
* add_filter( 'um_get_field__{$key}', 'my_get_field', 10, 1 );
|
1894 |
+
* function my_get_field( $data ) {
|
1895 |
+
* // your code here
|
1896 |
+
* return $data;
|
1897 |
+
* }
|
1898 |
+
* ?>
|
1899 |
+
*/
|
1900 |
+
$array = apply_filters( "um_get_field__{$key}", $array );
|
1901 |
+
|
1902 |
+
return $array;
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
|
1906 |
+
/**
|
1907 |
+
* @param $option_value
|
1908 |
+
*
|
1909 |
+
* @return mixed|void
|
1910 |
+
*/
|
1911 |
+
function filter_field_non_utf8_value( $option_value ) {
|
1912 |
+
/**
|
1913 |
+
* UM hook
|
1914 |
+
*
|
1915 |
+
* @type filter
|
1916 |
+
* @title um_field_non_utf8_value
|
1917 |
+
* @description Change dropdown option text
|
1918 |
+
* @input_vars
|
1919 |
+
* [{"var":"$value","type":"string","desc":"Option Value"}]
|
1920 |
+
* @change_log
|
1921 |
+
* ["Since: 2.0"]
|
1922 |
+
* @usage add_filter( 'um_field_non_utf8_value', 'function_name', 10, 1 );
|
1923 |
+
* @example
|
1924 |
+
* <?php
|
1925 |
+
* add_filter( 'um_field_non_utf8_value', 'my_field_non_utf8_value', 10, 1 );
|
1926 |
+
* function my_field_non_utf8_value( $value ) {
|
1927 |
+
* // your code here
|
1928 |
+
* return $value;
|
1929 |
+
* }
|
1930 |
+
* ?>
|
1931 |
+
*/
|
1932 |
+
return apply_filters( 'um_field_non_utf8_value', $option_value );
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
|
1936 |
+
/**
|
1937 |
+
* Getting the fields that need to be disabled in edit mode (profile)
|
1938 |
+
*
|
1939 |
+
* @param bool $_um_profile_id
|
1940 |
+
*
|
1941 |
+
* @return array
|
1942 |
+
*/
|
1943 |
+
function get_restricted_fields_for_edit( $_um_profile_id = false ) {
|
1944 |
+
// fields that need to be disabled in edit mode (profile)
|
1945 |
+
$arr_restricted_fields = array( 'user_email', 'username', 'user_login', 'user_password', '_um_last_login' );
|
1946 |
+
$arr_restricted_fields = apply_filters( 'um_user_profile_restricted_edit_fields', $arr_restricted_fields, $_um_profile_id );
|
1947 |
+
|
1948 |
+
return $arr_restricted_fields;
|
1949 |
+
}
|
1950 |
+
|
1951 |
+
|
1952 |
+
/**
|
1953 |
+
* Gets a field in 'input mode'
|
1954 |
+
*
|
1955 |
+
* @param string $key
|
1956 |
+
* @param array $data
|
1957 |
+
* @param bool $rule
|
1958 |
+
* @param array $args
|
1959 |
+
*
|
1960 |
+
* @return string|null
|
1961 |
+
* @throws \Exception
|
1962 |
+
*/
|
1963 |
+
function edit_field( $key, $data, $rule = false, $args = array() ) {
|
1964 |
+
global $_um_profile_id;
|
1965 |
+
|
1966 |
+
$output = '';
|
1967 |
+
$disabled = '';
|
1968 |
+
if ( empty( $_um_profile_id ) ) {
|
1969 |
+
$_um_profile_id = um_user( 'ID' );
|
1970 |
+
}
|
1971 |
+
|
1972 |
+
// get whole field data
|
1973 |
+
if ( isset( $data ) && is_array( $data ) ) {
|
1974 |
+
$data = $this->get_field( $key );
|
1975 |
+
if ( is_array( $data ) ) {
|
1976 |
+
/**
|
1977 |
+
* @var string $in_row
|
1978 |
+
* @var boolean $in_sub_row
|
1979 |
+
* @var boolean $in_column
|
1980 |
+
* @var string $type
|
1981 |
+
* @var string $metakey
|
1982 |
+
* @var int $position
|
1983 |
+
* @var string $title
|
1984 |
+
* @var string $help
|
1985 |
+
* @var array $options
|
1986 |
+
* @var string $visibility
|
1987 |
+
* @var string $label
|
1988 |
+
* @var string $placeholder
|
1989 |
+
* @var boolean $public
|
1990 |
+
* @var boolean $editable
|
1991 |
+
* @var string $icon
|
1992 |
+
* @var boolean $in_group
|
1993 |
+
* @var boolean $required
|
1994 |
+
* @var string $validate
|
1995 |
+
* @var string $default
|
1996 |
+
* @var string $conditional
|
1997 |
+
* @var string $input
|
1998 |
+
* @var string $js_format
|
1999 |
+
* @var string $date_max
|
2000 |
+
* @var string $date_min
|
2001 |
+
* @var string $disabled_weekdays
|
2002 |
+
* @var string $years_x
|
2003 |
+
* @var string $years
|
2004 |
+
* @var string $range
|
2005 |
+
* @var string $intervals
|
2006 |
+
* @var string $height
|
2007 |
+
* @var string $spacing
|
2008 |
+
* @var string $borderwidth
|
2009 |
+
* @var string $borderstyle
|
2010 |
+
* @var string $bordercolor
|
2011 |
+
* @var string $divider_text
|
2012 |
+
* @var string $crop_class
|
2013 |
+
* @var string $crop_data
|
2014 |
+
* @var string $modal_size
|
2015 |
+
* @var string $ratio
|
2016 |
+
* @var string $min_width
|
2017 |
+
* @var string $min_height
|
2018 |
+
* @var string $button_text
|
2019 |
+
* @var string $max_size
|
2020 |
+
* @var string $max_size_error
|
2021 |
+
* @var string $extension_error
|
2022 |
+
* @var string $allowed_types
|
2023 |
+
* @var string $upload_text
|
2024 |
+
* @var string $max_files_error
|
2025 |
+
* @var string $upload_help_text
|
2026 |
+
* @var string $min_size_error
|
2027 |
+
* @var string $filter
|
2028 |
+
* @var string $content
|
2029 |
+
* @var string $max_entries
|
2030 |
+
*/
|
2031 |
+
extract( $data );
|
2032 |
+
}
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
if ( ! isset( $data['type'] ) ) {
|
2036 |
+
return '';
|
2037 |
+
}
|
2038 |
+
|
2039 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
2040 |
+
return '';
|
2041 |
+
}
|
2042 |
+
|
2043 |
+
// forbidden in edit mode? 'edit_forbidden' - it's field attribute predefined in the field data in code
|
2044 |
+
if ( isset( $data['edit_forbidden'] ) ) {
|
2045 |
+
return '';
|
2046 |
+
}
|
2047 |
+
|
2048 |
+
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
2049 |
+
if ( isset( $data['required_opt'] ) ) {
|
2050 |
+
$opt = $data['required_opt'];
|
2051 |
+
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
2052 |
+
return '';
|
2053 |
+
}
|
2054 |
+
}
|
2055 |
+
|
2056 |
+
// required user permission 'required_perm' - it's field attribute predefined in the field data in code
|
2057 |
+
if ( isset( $data['required_perm'] ) ) {
|
2058 |
+
if ( ! UM()->roles()->um_user_can( $data['required_perm'] ) ) {
|
2059 |
+
return '';
|
2060 |
+
}
|
2061 |
+
}
|
2062 |
+
|
2063 |
+
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
2064 |
+
$arr_restricted_fields = $this->get_restricted_fields_for_edit( $_um_profile_id );
|
2065 |
+
if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
|
2066 |
+
return '';
|
2067 |
+
}
|
2068 |
+
|
2069 |
+
|
2070 |
+
if ( $visibility == 'view' && $this->set_mode != 'register' ) {
|
2071 |
+
return '';
|
2072 |
+
}
|
2073 |
+
|
2074 |
+
if ( ! um_can_view_field( $data ) ) {
|
2075 |
+
return '';
|
2076 |
+
}
|
2077 |
+
|
2078 |
+
um_fetch_user( $_um_profile_id );
|
2079 |
+
|
2080 |
+
// Stop return empty values build field attributes:
|
2081 |
+
|
2082 |
+
if ( $visibility == 'view' && $this->set_mode == 'register' ) {
|
2083 |
+
|
2084 |
+
um_fetch_user( get_current_user_id() );
|
2085 |
+
if ( ! um_user( 'can_edit_everyone' ) ) {
|
2086 |
+
$disabled = ' disabled="disabled" ';
|
2087 |
+
}
|
2088 |
+
|
2089 |
+
um_fetch_user( $_um_profile_id );
|
2090 |
+
if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
|
2091 |
+
$current_user_roles = um_user( 'roles' );
|
2092 |
+
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
|
2093 |
+
$disabled = '';
|
2094 |
+
}
|
2095 |
+
}
|
2096 |
+
}
|
2097 |
+
|
2098 |
+
if ( ! empty( $this->editing ) && $this->set_mode == 'profile' ) {
|
2099 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
2100 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
2101 |
+
$disabled = ' disabled="disabled" ';
|
2102 |
+
}
|
2103 |
+
}
|
2104 |
+
}
|
2105 |
+
|
2106 |
+
$disabled = apply_filters( 'um_is_field_disabled', $disabled, $data );
|
2107 |
+
|
2108 |
+
if ( ! isset( $data['autocomplete'] ) ) {
|
2109 |
+
$autocomplete = 'off';
|
2110 |
+
}
|
2111 |
+
|
2112 |
+
if ( isset( $data['classes'] ) ) {
|
2113 |
+
$classes = explode( " ", $data['classes'] );
|
2114 |
+
}
|
2115 |
+
|
2116 |
+
um_fetch_user( $_um_profile_id );
|
2117 |
+
|
2118 |
+
/**
|
2119 |
+
* UM hook
|
2120 |
+
*
|
2121 |
+
* @type filter
|
2122 |
+
* @title um_hook_for_field_{$type}
|
2123 |
+
* @description Change field type
|
2124 |
+
* @input_vars
|
2125 |
+
* [{"var":"$type","type":"string","desc":"Field Type"}]
|
2126 |
+
* @change_log
|
2127 |
+
* ["Since: 2.0"]
|
2128 |
+
* @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 );
|
2129 |
+
* @example
|
2130 |
+
* <?php
|
2131 |
+
* add_filter( 'um_hook_for_field_{$type}', 'my_field_type', 10, 1 );
|
2132 |
+
* function my_get_field( $type ) {
|
2133 |
+
* // your code here
|
2134 |
+
* return $type;
|
2135 |
+
* }
|
2136 |
+
* ?>
|
2137 |
+
*/
|
2138 |
+
$type = apply_filters( "um_hook_for_field_{$type}", $type );
|
2139 |
+
switch ( $type ) {
|
2140 |
+
|
2141 |
+
case 'textarea':
|
2142 |
+
case 'multiselect':
|
2143 |
+
$field_id = $field_name = $key;
|
2144 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2145 |
+
break;
|
2146 |
+
|
2147 |
+
case 'select':
|
2148 |
+
case 'radio':
|
2149 |
+
$form_key = str_replace( array( 'role_select', 'role_radio' ), 'role', $key );
|
2150 |
+
$field_id = $form_key;
|
2151 |
+
break;
|
2152 |
+
default:
|
2153 |
+
$field_id = '';
|
2154 |
+
break;
|
2155 |
+
}
|
2156 |
+
|
2157 |
+
/**
|
2158 |
+
* UM hook
|
2159 |
+
*
|
2160 |
+
* @type filter
|
2161 |
+
* @title um_completeness_field_id
|
2162 |
+
* @description use for change core id not allowed duplicate
|
2163 |
+
* @input_vars
|
2164 |
+
* [{"var":"$field_id","type":"string","desc":"Field id"},
|
2165 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2166 |
+
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
|
2167 |
+
* @change_log
|
2168 |
+
* ["Since: 2.0.13"]
|
2169 |
+
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2170 |
+
* @example
|
2171 |
+
* <?php
|
2172 |
+
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2173 |
+
* function function_name( $field_id, $data, $args ) {
|
2174 |
+
* // your code here
|
2175 |
+
* return $field_id;
|
2176 |
+
* }
|
2177 |
+
* ?>
|
2178 |
+
*/
|
2179 |
+
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
|
2180 |
+
|
2181 |
+
|
2182 |
+
/* Begin by field type */
|
2183 |
+
switch ( $type ) {
|
2184 |
+
|
2185 |
+
/* Default: Integration */
|
2186 |
+
default:
|
2187 |
+
$mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode';
|
2188 |
+
|
2189 |
+
/**
|
2190 |
+
* UM hook
|
2191 |
+
*
|
2192 |
+
* @type filter
|
2193 |
+
* @title um_edit_field_{$mode}_{$type}
|
2194 |
+
* @description Change field html by $mode and field $type
|
2195 |
+
* @input_vars
|
2196 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
2197 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2198 |
+
* @change_log
|
2199 |
+
* ["Since: 2.0"]
|
2200 |
+
* @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 );
|
2201 |
+
* @example
|
2202 |
+
* <?php
|
2203 |
+
* add_filter( 'um_edit_field_{$mode}_{$type}', 'my_edit_field_html', 10, 2 );
|
2204 |
+
* function my_edit_field_html( $output, $data ) {
|
2205 |
+
* // your code here
|
2206 |
+
* return $output;
|
2207 |
+
* }
|
2208 |
+
* ?>
|
2209 |
+
*/
|
2210 |
+
|
2211 |
+
$output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data );
|
2212 |
+
break;
|
2213 |
+
|
2214 |
+
/* Other fields */
|
2215 |
+
case 'googlemap':
|
2216 |
+
case 'youtube_video':
|
2217 |
+
case 'vimeo_video':
|
2218 |
+
case 'soundcloud_track':
|
2219 |
+
|
2220 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2221 |
+
|
2222 |
+
if ( isset( $data['label'] ) ) {
|
2223 |
+
$output .= $this->field_label( $label, $key, $data );
|
2224 |
+
}
|
2225 |
+
|
2226 |
+
$output .= '<div class="um-field-area">';
|
2227 |
+
|
2228 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2229 |
+
|
2230 |
+
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
|
2231 |
+
|
2232 |
+
}
|
2233 |
+
|
2234 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2235 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2236 |
+
|
2237 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2238 |
+
|
2239 |
+
</div>';
|
2240 |
+
|
2241 |
+
if ( ! empty( $disabled ) ) {
|
2242 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2243 |
+
}
|
2244 |
+
|
2245 |
+
if ( $this->is_error( $key ) ) {
|
2246 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2247 |
+
}else if ( $this->is_notice( $key ) ) {
|
2248 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2249 |
+
}
|
2250 |
+
|
2251 |
+
$output .= '</div>';
|
2252 |
+
break;
|
2253 |
+
|
2254 |
+
/* Text */
|
2255 |
+
case 'text':
|
2256 |
+
|
2257 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2258 |
+
|
2259 |
+
if ( isset( $data['label'] ) ) {
|
2260 |
+
$output .= $this->field_label( $label, $key, $data );
|
2261 |
+
}
|
2262 |
+
|
2263 |
+
$output .= '<div class="um-field-area">';
|
2264 |
+
|
2265 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2266 |
+
|
2267 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2268 |
+
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2272 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2273 |
+
|
2274 |
+
$output .= '<input ' . $disabled . ' autocomplete="' . esc_attr( $autocomplete ) . '" class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2275 |
+
|
2276 |
+
</div>';
|
2277 |
+
|
2278 |
+
if ( ! empty( $disabled ) ) {
|
2279 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2280 |
+
}
|
2281 |
+
|
2282 |
+
if ( $this->is_error( $key ) ) {
|
2283 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2284 |
+
}else if ( $this->is_notice( $key ) ) {
|
2285 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2286 |
+
}
|
2287 |
+
|
2288 |
+
$output .= '</div>';
|
2289 |
+
break;
|
2290 |
+
|
2291 |
+
/* Number */
|
2292 |
+
case 'number':
|
2293 |
+
|
2294 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2295 |
+
|
2296 |
+
if ( isset( $data['label'] ) ) {
|
2297 |
+
$output .= $this->field_label( $label, $key, $data );
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
$output .= '<div class="um-field-area">';
|
2301 |
+
|
2302 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2303 |
+
|
2304 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2305 |
+
|
2306 |
+
}
|
2307 |
+
|
2308 |
+
$number_limit = '';
|
2309 |
+
if ( isset( $min ) ) {
|
2310 |
+
$number_limit .= ' min="' . esc_attr( $min ) . '" ';
|
2311 |
+
}
|
2312 |
+
if ( isset( $max ) ) {
|
2313 |
+
$number_limit .= ' max="' . esc_attr( $max ) . '" ';
|
2314 |
+
}
|
2315 |
+
|
2316 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="number" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( htmlspecialchars( $this->field_value( $key, $default, $data ) ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" ' . $number_limit . ' />
|
2317 |
+
|
2318 |
+
</div>';
|
2319 |
+
|
2320 |
+
if ( $this->is_error( $key ) ) {
|
2321 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2322 |
+
}else if ( $this->is_notice( $key ) ) {
|
2323 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2324 |
+
}
|
2325 |
+
|
2326 |
+
$output .= '</div>';
|
2327 |
+
break;
|
2328 |
+
|
2329 |
+
/* Password */
|
2330 |
+
case 'password':
|
2331 |
+
|
2332 |
+
$original_key = $key;
|
2333 |
+
|
2334 |
+
if ( $key == 'single_user_password' ) {
|
2335 |
+
|
2336 |
+
$key = $original_key;
|
2337 |
+
|
2338 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2339 |
+
|
2340 |
+
if ( isset( $data['label'] ) ) {
|
2341 |
+
$output .= $this->field_label( $label, $key, $data );
|
2342 |
+
}
|
2343 |
+
|
2344 |
+
$output .= '<div class="um-field-area">';
|
2345 |
+
|
2346 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2347 |
+
|
2348 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2349 |
+
|
2350 |
+
}
|
2351 |
+
|
2352 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2353 |
+
|
2354 |
+
</div>';
|
2355 |
+
|
2356 |
+
if ( $this->is_error( $key ) ) {
|
2357 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2358 |
+
}else if ( $this->is_notice( $key ) ) {
|
2359 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2360 |
+
}
|
2361 |
+
|
2362 |
+
$output .= '</div>';
|
2363 |
+
|
2364 |
+
} else {
|
2365 |
+
|
2366 |
+
if ( UM()->account()->current_password_is_required( 'password' ) &&
|
2367 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
2368 |
+
|
2369 |
+
$key = 'current_' . $original_key;
|
2370 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2371 |
+
|
2372 |
+
if ( isset( $data['label'] ) ) {
|
2373 |
+
$output .= $this->field_label( __( 'Current Password', 'ultimate-member' ), $key, $data );
|
2374 |
+
}
|
2375 |
+
|
2376 |
+
$output .= '<div class="um-field-area">';
|
2377 |
+
|
2378 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2379 |
+
|
2380 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2381 |
+
|
2382 |
+
}
|
2383 |
+
|
2384 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2385 |
+
|
2386 |
+
</div>';
|
2387 |
+
|
2388 |
+
if ( $this->is_error( $key ) ) {
|
2389 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2390 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2391 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2392 |
+
}
|
2393 |
+
|
2394 |
+
$output .= '</div>';
|
2395 |
+
|
2396 |
+
}
|
2397 |
+
|
2398 |
+
$key = $original_key;
|
2399 |
+
|
2400 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2401 |
+
|
2402 |
+
if ( $this->set_mode == 'account' && um_is_core_page( 'account' ) || $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2403 |
+
|
2404 |
+
$output .= $this->field_label( __( 'New Password', 'ultimate-member' ), $key, $data );
|
2405 |
+
|
2406 |
+
} elseif ( isset( $data['label'] ) ) {
|
2407 |
+
|
2408 |
+
$output .= $this->field_label( $label, $key, $data );
|
2409 |
+
|
2410 |
+
}
|
2411 |
+
|
2412 |
+
$output .= '<div class="um-field-area">';
|
2413 |
+
|
2414 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2415 |
+
|
2416 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2417 |
+
|
2418 |
+
}
|
2419 |
+
|
2420 |
+
$name = $key . UM()->form()->form_suffix;
|
2421 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2422 |
+
$name = $key;
|
2423 |
+
}
|
2424 |
+
|
2425 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2426 |
+
|
2427 |
+
</div>';
|
2428 |
+
|
2429 |
+
if ( $this->is_error( $key ) ) {
|
2430 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2431 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2432 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2433 |
+
}
|
2434 |
+
|
2435 |
+
$output .= '</div>';
|
2436 |
+
|
2437 |
+
if ( $this->set_mode != 'login' && isset( $data['force_confirm_pass'] ) && $data['force_confirm_pass'] == 1 ) {
|
2438 |
+
|
2439 |
+
$key = 'confirm_' . $original_key;
|
2440 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2441 |
+
|
2442 |
+
if ( ! empty( $data['label_confirm_pass'] ) ) {
|
2443 |
+
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
|
2444 |
+
$output .= $this->field_label( $label_confirm_pass, $key, $data );
|
2445 |
+
} elseif ( isset( $data['label'] ) ) {
|
2446 |
+
$data['label'] = __( $data['label'], 'ultimate-member' );
|
2447 |
+
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
|
2448 |
+
}
|
2449 |
+
|
2450 |
+
$output .= '<div class="um-field-area">';
|
2451 |
+
|
2452 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2453 |
+
|
2454 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2455 |
+
|
2456 |
+
}
|
2457 |
+
|
2458 |
+
$name = $key . UM()->form()->form_suffix;
|
2459 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2460 |
+
$name = $key;
|
2461 |
+
}
|
2462 |
+
|
2463 |
+
if ( ! empty( $label_confirm_pass ) ) {
|
2464 |
+
$placeholder = $label_confirm_pass;
|
2465 |
+
} elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
|
2466 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
2467 |
+
} elseif( isset( $data['label'] ) ) {
|
2468 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
|
2469 |
+
}
|
2470 |
+
|
2471 |
+
|
2472 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />';
|
2473 |
+
|
2474 |
+
|
2475 |
+
$output .= '</div>';
|
2476 |
+
|
2477 |
+
if ( $this->is_error( $key ) ) {
|
2478 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2479 |
+
}else if ( $this->is_notice( $key ) ) {
|
2480 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2481 |
+
}
|
2482 |
+
|
2483 |
+
$output .= '</div>';
|
2484 |
+
|
2485 |
+
}
|
2486 |
+
|
2487 |
+
}
|
2488 |
+
|
2489 |
+
break;
|
2490 |
+
|
2491 |
+
/* URL */
|
2492 |
+
case 'url':
|
2493 |
+
|
2494 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2495 |
+
|
2496 |
+
if ( isset( $data['label'] ) ) {
|
2497 |
+
$output .= $this->field_label( $label, $key, $data );
|
2498 |
+
}
|
2499 |
+
|
2500 |
+
$output .= '<div class="um-field-area">';
|
2501 |
+
|
2502 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2503 |
+
|
2504 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2505 |
+
|
2506 |
+
}
|
2507 |
+
|
2508 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( $this->field_value( $key, $default, $data ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2509 |
+
|
2510 |
+
</div>';
|
2511 |
+
|
2512 |
+
if ( $this->is_error( $key ) ) {
|
2513 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2514 |
+
}else if ( $this->is_notice( $key ) ) {
|
2515 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2516 |
+
}
|
2517 |
+
|
2518 |
+
$output .= '</div>';
|
2519 |
+
break;
|
2520 |
+
|
2521 |
+
/* Date */
|
2522 |
+
case 'date':
|
2523 |
+
|
2524 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2525 |
+
|
2526 |
+
if (isset( $data['label'] )) {
|
2527 |
+
$output .= $this->field_label( $label, $key, $data );
|
2528 |
+
}
|
2529 |
+
|
2530 |
+
$output .= '<div class="um-field-area">';
|
2531 |
+
|
2532 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2533 |
+
|
2534 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2535 |
+
|
2536 |
+
}
|
2537 |
+
|
2538 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-range="' . esc_attr( $range ) . '" data-years="' . esc_attr( $years ) . '" data-years_x="' . esc_attr( $years_x ) . '" data-disabled_weekdays="' . esc_attr( $disabled_weekdays ) . '" data-date_min="' . esc_attr( $date_min ) . '" data-date_max="' . esc_attr( $date_max ) . '" data-format="' . esc_attr( $js_format ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2539 |
+
|
2540 |
+
</div>';
|
2541 |
+
|
2542 |
+
if ( $this->is_error( $key ) ) {
|
2543 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2544 |
+
}else if ( $this->is_notice( $key ) ) {
|
2545 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2546 |
+
}
|
2547 |
+
|
2548 |
+
$output .= '</div>';
|
2549 |
+
break;
|
2550 |
+
|
2551 |
+
/* Time */
|
2552 |
+
case 'time':
|
2553 |
+
|
2554 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2555 |
+
|
2556 |
+
if (isset( $data['label'] )) {
|
2557 |
+
$output .= $this->field_label( $label, $key, $data );
|
2558 |
+
}
|
2559 |
+
|
2560 |
+
$output .= '<div class="um-field-area">';
|
2561 |
+
|
2562 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2563 |
+
|
2564 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2565 |
+
|
2566 |
+
}
|
2567 |
+
|
2568 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-format="' . esc_attr( $js_format ) . '" data-intervals="' . esc_attr( $intervals ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2569 |
+
|
2570 |
+
</div>';
|
2571 |
+
|
2572 |
+
if ( $this->is_error( $key ) ) {
|
2573 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2574 |
+
}else if ( $this->is_notice( $key ) ) {
|
2575 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2576 |
+
}
|
2577 |
+
|
2578 |
+
$output .= '</div>';
|
2579 |
+
break;
|
2580 |
+
|
2581 |
+
/* Row */
|
2582 |
+
case 'row':
|
2583 |
+
$output .= '';
|
2584 |
+
break;
|
2585 |
+
|
2586 |
+
/* Textarea */
|
2587 |
+
case 'textarea':
|
2588 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2589 |
+
|
2590 |
+
if ( isset( $data['label'] ) ) {
|
2591 |
+
$output .= $this->field_label( $label, $key, $data );
|
2592 |
+
}
|
2593 |
+
|
2594 |
+
$output .= '<div class="um-field-area">';
|
2595 |
+
|
2596 |
+
if ( isset( $data['html'] ) && $data['html'] != 0 && $key != "description" ) {
|
2597 |
+
|
2598 |
+
$textarea_settings = array(
|
2599 |
+
'media_buttons' => false,
|
2600 |
+
'wpautop' => false,
|
2601 |
+
'editor_class' => $this->get_class( $key, $data ),
|
2602 |
+
'editor_height' => $height,
|
2603 |
+
'tinymce' => array(
|
2604 |
+
'toolbar1' => 'formatselect,bullist,numlist,bold,italic,underline,forecolor,blockquote,hr,removeformat,link,unlink,undo,redo',
|
2605 |
+
'toolbar2' => '',
|
2606 |
+
)
|
2607 |
+
);
|
2608 |
+
|
2609 |
+
if ( ! empty( $disabled ) ) {
|
2610 |
+
$textarea_settings['tinymce']['readonly'] = true;
|
2611 |
+
}
|
2612 |
+
|
2613 |
+
/**
|
2614 |
+
* UM hook
|
2615 |
+
*
|
2616 |
+
* @type filter
|
2617 |
+
* @title um_form_fields_textarea_settings
|
2618 |
+
* @description Change WP Editor options for textarea init
|
2619 |
+
* @input_vars
|
2620 |
+
* [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}]
|
2621 |
+
* @change_log
|
2622 |
+
* ["Since: 2.0"]
|
2623 |
+
* @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
|
2624 |
+
* @example
|
2625 |
+
* <?php
|
2626 |
+
* add_filter( 'um_form_fields_textarea_settings', 'my_textarea_settings', 10, 1 );
|
2627 |
+
* function my_edit_field_html( $textarea_settings ) {
|
2628 |
+
* // your code here
|
2629 |
+
* return $textarea_settings;
|
2630 |
+
* }
|
2631 |
+
* ?>
|
2632 |
+
*/
|
2633 |
+
$textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings );
|
2634 |
+
|
2635 |
+
// turn on the output buffer
|
2636 |
+
ob_start();
|
2637 |
+
|
2638 |
+
// echo the editor to the buffer
|
2639 |
+
wp_editor( $field_value, $key, $textarea_settings );
|
2640 |
+
|
2641 |
+
// add the contents of the buffer to the output variable
|
2642 |
+
$output .= ob_get_clean();
|
2643 |
+
$output .= '<br /><span class="description">' . $placeholder . '</span>';
|
2644 |
+
} else {
|
2645 |
+
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : strip_tags( $field_value );
|
2646 |
+
$output .= '<textarea ' . $disabled . ' style="height: ' . esc_attr( $height ) . ';" class="' . $this->get_class( $key, $data ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" placeholder="' . esc_attr( $placeholder ) . '">' . esc_textarea( $textarea_field_value ) . '</textarea>';
|
2647 |
+
}
|
2648 |
+
|
2649 |
+
$output .= '</div>';
|
2650 |
+
|
2651 |
+
if ( ! empty( $disabled ) ) {
|
2652 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2653 |
+
}
|
2654 |
+
|
2655 |
+
if ( $this->is_error( $key ) ) {
|
2656 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2657 |
+
}else if ( $this->is_notice( $key ) ) {
|
2658 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2659 |
+
}
|
2660 |
+
|
2661 |
+
$output .= '</div>';
|
2662 |
+
break;
|
2663 |
+
|
2664 |
+
/* Rating */
|
2665 |
+
case 'rating':
|
2666 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2667 |
+
|
2668 |
+
if ( isset( $data['label'] ) ) {
|
2669 |
+
$output .= $this->field_label( $label, $key, $data );
|
2670 |
+
}
|
2671 |
+
|
2672 |
+
$output .= '<div class="um-field-area">';
|
2673 |
+
|
2674 |
+
$output .= '<div class="um-rating um-raty" id="' . esc_attr( $key ) . '" data-key="' . esc_attr( $key ) . '" data-number="' . esc_attr( $data['number'] ) . '" data-score="' . $this->field_value( $key, $default, $data ) . '"></div>';
|
2675 |
+
$output .= '</div>';
|
2676 |
+
|
2677 |
+
if ( $this->is_error( $key ) ) {
|
2678 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2679 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2680 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2681 |
+
}
|
2682 |
+
|
2683 |
+
$output .= '</div>';
|
2684 |
+
|
2685 |
+
break;
|
2686 |
+
|
2687 |
+
/* Gap/Space */
|
2688 |
+
case 'spacing':
|
2689 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
2690 |
+
break;
|
2691 |
+
|
2692 |
+
/* A line divider */
|
2693 |
+
case 'divider':
|
2694 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
2695 |
+
if ( $divider_text ) {
|
2696 |
+
$output .= '<div class="um-field-divider-text"><span>' . esc_html( $divider_text ) . '</span></div>';
|
2697 |
+
}
|
2698 |
+
$output .= '</div>';
|
2699 |
+
break;
|
2700 |
+
|
2701 |
+
/* Single Image Upload */
|
2702 |
+
case 'image':
|
2703 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2704 |
+
if ( in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2705 |
+
$field_value = '';
|
2706 |
+
} else {
|
2707 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2708 |
+
}
|
2709 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $field_value . '" />';
|
2710 |
+
if ( isset( $data['label'] ) ) {
|
2711 |
+
$output .= $this->field_label( $label, $key, $data );
|
2712 |
+
}
|
2713 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
2714 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2715 |
+
|
2716 |
+
if ( ! empty( $field_value ) && $field_value != 'empty_file' ) {
|
2717 |
+
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2718 |
+
if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
|
2719 |
+
$image_info = get_transient("um_{$field_value}");
|
2720 |
+
} else {
|
2721 |
+
$image_info = um_user( $data['metakey']."_metadata" );
|
2722 |
+
}
|
2723 |
+
|
2724 |
+
if ( ( isset( $this->set_mode ) && $this->set_mode == 'register' ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
|
2725 |
+
$imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
|
2726 |
+
} else {
|
2727 |
+
$imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2728 |
+
}
|
2729 |
+
$img = '<img src="' . $imgValue . '" alt="" />';
|
2730 |
+
} else {
|
2731 |
+
$img = '';
|
2732 |
+
}
|
2733 |
+
$output .= '<div class="um-single-image-preview show ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2734 |
+
if ( empty( $disabled ) ) {
|
2735 |
+
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2736 |
+
}
|
2737 |
+
$output .= $img;
|
2738 |
+
$output .= '</div>';
|
2739 |
+
if ( empty( $disabled ) ) {
|
2740 |
+
$output .= '<a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . __( 'Change photo', 'ultimate-member' ) . '</a>';
|
2741 |
+
}
|
2742 |
+
|
2743 |
+
|
2744 |
+
} else {
|
2745 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2746 |
+
if ( empty( $disabled ) ) {
|
2747 |
+
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2748 |
+
}
|
2749 |
+
$output .= '<img src="" alt="" /><div class="um-clear"></div></div>';
|
2750 |
+
if ( empty( $disabled ) ) {
|
2751 |
+
$output .= '<a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . $button_text . '</a>';
|
2752 |
+
}
|
2753 |
+
|
2754 |
+
}
|
2755 |
+
$output .= '</div>';
|
2756 |
+
/* modal hidden */
|
2757 |
+
if ( empty( $disabled ) ) {
|
2758 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2759 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2760 |
+
$output .= '<div class="um-modal-body">';
|
2761 |
+
if ( isset( $this->set_id ) ) {
|
2762 |
+
$set_id = $this->set_id;
|
2763 |
+
$set_mode = $this->set_mode;
|
2764 |
+
} else {
|
2765 |
+
$set_id = 0;
|
2766 |
+
$set_mode = '';
|
2767 |
+
}
|
2768 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2769 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-ratio="' . $ratio . '" data-min_width="' . $min_width . '" data-min_height="' . $min_height . '" data-coord=""><a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a><img src="" alt="" /><div class="um-clear"></div></div><div class="um-clear"></div>';
|
2770 |
+
$output .= '<div class="um-single-image-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-nonce="' . $nonce . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2771 |
+
$output .= '<div class="um-modal-footer">
|
2772 |
+
<div class="um-modal-right">
|
2773 |
+
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __( 'Change photo', 'ultimate-member' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Apply', 'ultimate-member' ) . '</a>
|
2774 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2775 |
+
</div>
|
2776 |
+
<div class="um-clear"></div>
|
2777 |
+
</div>';
|
2778 |
+
$output .= '</div>';
|
2779 |
+
$output .= '</div>';
|
2780 |
+
}
|
2781 |
+
/* end */
|
2782 |
+
if ( $this->is_error( $key ) ) {
|
2783 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2784 |
+
}else if ( $this->is_notice( $key ) ) {
|
2785 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2786 |
+
}
|
2787 |
+
$output .= '</div>';
|
2788 |
+
|
2789 |
+
break;
|
2790 |
+
|
2791 |
+
/* Single File Upload */
|
2792 |
+
case 'file':
|
2793 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2794 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" />';
|
2795 |
+
if ( isset( $data['label'] ) ) {
|
2796 |
+
$output .= $this->field_label( $label, $key, $data );
|
2797 |
+
}
|
2798 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload File', 'ultimate-member' );
|
2799 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2800 |
+
|
2801 |
+
$file_field_value = $this->field_value( $key, $default, $data );
|
2802 |
+
|
2803 |
+
if ( ! empty( $file_field_value ) && 'empty_file' !== $file_field_value ) {
|
2804 |
+
$file_type = wp_check_filetype( $file_field_value );
|
2805 |
+
|
2806 |
+
if ( um_is_temp_file( $file_field_value ) ) {
|
2807 |
+
$file_info = get_transient( "um_{$file_field_value}" );
|
2808 |
+
} else {
|
2809 |
+
$file_info = um_user( $data['metakey'] . "_metadata" );
|
2810 |
+
}
|
2811 |
+
|
2812 |
+
$file_field_name = $file_field_value;
|
2813 |
+
if ( ! empty( $file_info['original_name'] ) ) {
|
2814 |
+
$file_field_name = $file_info['original_name'];
|
2815 |
+
}
|
2816 |
+
|
2817 |
+
if ( ( isset( $this->set_mode ) && 'register' == $this->set_mode ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value ) ) {
|
2818 |
+
$file_url = UM()->uploader()->get_core_temp_url() . DIRECTORY_SEPARATOR . $file_field_value;
|
2819 |
+
$file_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value;
|
2820 |
+
} else {
|
2821 |
+
$file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2822 |
+
$file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
2823 |
+
}
|
2824 |
+
|
2825 |
+
//multisite fix for old customers
|
2826 |
+
if ( ! file_exists( $file_dir ) && is_multisite() ) {
|
2827 |
+
$file_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_dir );
|
2828 |
+
}
|
2829 |
+
|
2830 |
+
if ( file_exists( $file_dir ) ) {
|
2831 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">";
|
2832 |
+
if ( empty( $disabled ) ) {
|
2833 |
+
$output .= "<a href=\"#\" class=\"cancel\"><i class=\"um-icon-close\"></i></a>";
|
2834 |
+
}
|
2835 |
+
$output .= "<div class=\"um-single-fileinfo\">
|
2836 |
+
<a href=\"{$file_url}\" target=\"_blank\">
|
2837 |
+
<span class=\"icon\" style=\"background:" . UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . "\"><i class=\"" . UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) . "\"></i></span>
|
2838 |
+
<span class=\"filename\">{$file_field_name}</span>
|
2839 |
+
</a>
|
2840 |
+
</div></div>";
|
2841 |
+
} else {
|
2842 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">" . __('This file has been removed.','ultimate-member') . "</div>";
|
2843 |
+
}
|
2844 |
+
|
2845 |
+
if ( empty( $disabled ) ) {
|
2846 |
+
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">" . __( 'Change file', 'ultimate-member' ) . "</a>";
|
2847 |
+
}
|
2848 |
+
} else {
|
2849 |
+
$output .= "<div class=\"um-single-file-preview\" data-key=\"{$key}\"></div>";
|
2850 |
+
if ( empty( $disabled ) ) {
|
2851 |
+
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">{$button_text}</a>";
|
2852 |
+
}
|
2853 |
+
}
|
2854 |
+
$output .= '</div>';
|
2855 |
+
/* modal hidden */
|
2856 |
+
if ( empty( $disabled ) ) {
|
2857 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2858 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2859 |
+
$output .= '<div class="um-modal-body">';
|
2860 |
+
if ( isset( $this->set_id ) ) {
|
2861 |
+
$set_id = $this->set_id;
|
2862 |
+
$set_mode = $this->set_mode;
|
2863 |
+
} else {
|
2864 |
+
$set_id = 0;
|
2865 |
+
$set_mode = '';
|
2866 |
+
}
|
2867 |
+
$output .= '<div class="um-single-file-preview">
|
2868 |
+
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>
|
2869 |
+
<div class="um-single-fileinfo">
|
2870 |
+
<a href="" target="_blank">
|
2871 |
+
<span class="icon"><i></i></span>
|
2872 |
+
<span class="filename"></span>
|
2873 |
+
</a>
|
2874 |
+
</div>
|
2875 |
+
</div>';
|
2876 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2877 |
+
$output .= '<div class="um-single-file-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-nonce="' . $nonce . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2878 |
+
$output .= '<div class="um-modal-footer">
|
2879 |
+
<div class="um-modal-right">
|
2880 |
+
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload file disabled" data-key="' . esc_attr( $key ) . '" data-change="' . esc_attr__( 'Change file' ) . '" data-processing="' . esc_attr__( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Save', 'ultimate-member' ) . '</a>
|
2881 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2882 |
+
</div>
|
2883 |
+
<div class="um-clear"></div>
|
2884 |
+
</div>';
|
2885 |
+
$output .= '</div>';
|
2886 |
+
$output .= '</div>';
|
2887 |
+
}
|
2888 |
+
/* end */
|
2889 |
+
if ( $this->is_error( $key ) ) {
|
2890 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2891 |
+
}else if ( $this->is_notice( $key ) ) {
|
2892 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2893 |
+
}
|
2894 |
+
$output .= '</div>';
|
2895 |
+
|
2896 |
+
break;
|
2897 |
+
|
2898 |
+
/* Select dropdown */
|
2899 |
+
case 'select':
|
2900 |
+
|
2901 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2902 |
+
|
2903 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
2904 |
+
$class = 'um-s2';
|
2905 |
+
} else {
|
2906 |
+
$class = 'um-s1';
|
2907 |
+
}
|
2908 |
+
|
2909 |
+
if ( isset( $data['label'] ) ) {
|
2910 |
+
$output .= $this->field_label( $label, $key, $data );
|
2911 |
+
}
|
2912 |
+
|
2913 |
+
$output .= '<div class="um-field-area ' . ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
2914 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2915 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2916 |
+
}
|
2917 |
+
|
2918 |
+
$options = array();
|
2919 |
+
$has_parent_option = false;
|
2920 |
+
$disabled_by_parent_option = '';
|
2921 |
+
$atts_ajax = '';
|
2922 |
+
$select_original_option_value = '';
|
2923 |
+
|
2924 |
+
if ( isset( $data[ 'options' ] ) && is_array( $data[ 'options' ] ) ) {
|
2925 |
+
$options = $data[ 'options' ];
|
2926 |
+
}
|
2927 |
+
|
2928 |
+
if ( ! empty( $data['parent_dropdown_relationship'] ) && ! UM()->user()->preview ) {
|
2929 |
+
|
2930 |
+
$disabled_by_parent_option = 'disabled = disabled';
|
2931 |
+
|
2932 |
+
$has_parent_option = true;
|
2933 |
+
|
2934 |
+
/**
|
2935 |
+
* UM hook
|
2936 |
+
*
|
2937 |
+
* @type filter
|
2938 |
+
* @title um_custom_dropdown_options_parent__{$form_key}
|
2939 |
+
* @description Change parent dropdown relationship by $form_key
|
2940 |
+
* @input_vars
|
2941 |
+
* [{"var":"$parent","type":"string","desc":"Parent dropdown relationship"},
|
2942 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2943 |
+
* @change_log
|
2944 |
+
* ["Since: 2.0"]
|
2945 |
+
* @usage add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 );
|
2946 |
+
* @example
|
2947 |
+
* <?php
|
2948 |
+
* add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'my_custom_dropdown_options_parent', 10, 2 );
|
2949 |
+
* function my_custom_dropdown_options_parent( $parent, $data ) {
|
2950 |
+
* // your code here
|
2951 |
+
* return $parent;
|
2952 |
+
* }
|
2953 |
+
* ?>
|
2954 |
+
*/
|
2955 |
+
$parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data );
|
2956 |
+
$atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' ";
|
2957 |
+
|
2958 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
2959 |
+
um_user( $data['parent_dropdown_relationship'] )
|
2960 |
+
) {
|
2961 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2962 |
+
|
2963 |
+
$disabled_by_parent_option = '';
|
2964 |
+
if ( um_user( $form_key ) ) {
|
2965 |
+
$select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
|
2966 |
+
}
|
2967 |
+
}
|
2968 |
+
}
|
2969 |
+
|
2970 |
+
// Child dropdown option selected
|
2971 |
+
if ( isset( UM()->form()->post_form[ $form_key ] ) ) {
|
2972 |
+
$select_original_option_value = " data-um-original-value='" . esc_attr( UM()->form()->post_form[ $form_key ] ) . "' ";
|
2973 |
+
}
|
2974 |
+
|
2975 |
+
// Child dropdown
|
2976 |
+
if ( $has_parent_option ) {
|
2977 |
+
|
2978 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
2979 |
+
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
2980 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2981 |
+
}
|
2982 |
+
}
|
2983 |
+
|
2984 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
2985 |
+
|
2986 |
+
/**
|
2987 |
+
* UM hook
|
2988 |
+
*
|
2989 |
+
* @type filter
|
2990 |
+
* @title um_custom_dropdown_options_source__{$form_key}
|
2991 |
+
* @description Change custom dropdown options source by $form_key
|
2992 |
+
* @input_vars
|
2993 |
+
* [{"var":"$source","type":"string","desc":"Dropdown options source"},
|
2994 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2995 |
+
* @change_log
|
2996 |
+
* ["Since: 2.0"]
|
2997 |
+
* @usage add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'function_name', 10, 2 );
|
2998 |
+
* @example
|
2999 |
+
* <?php
|
3000 |
+
* add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'my_custom_dropdown_options_source', 10, 2 );
|
3001 |
+
* function my_custom_dropdown_options_source( $source, $data ) {
|
3002 |
+
* // your code here
|
3003 |
+
* return $source;
|
3004 |
+
* }
|
3005 |
+
* ?>
|
3006 |
+
*/
|
3007 |
+
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data );
|
3008 |
+
$atts_ajax .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
3009 |
+
|
3010 |
+
/**
|
3011 |
+
* UM hook
|
3012 |
+
*
|
3013 |
+
* @type filter
|
3014 |
+
* @title um_custom_dropdown_options_source_url__{$form_key}
|
3015 |
+
* @description Change custom dropdown options source URL by $form_key
|
3016 |
+
* @input_vars
|
3017 |
+
* [{"var":"$url","type":"string","desc":"Dropdown options source URL"},
|
3018 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3019 |
+
* @change_log
|
3020 |
+
* ["Since: 2.0"]
|
3021 |
+
* @usage add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'function_name', 10, 2 );
|
3022 |
+
* @example
|
3023 |
+
* <?php
|
3024 |
+
* add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'my_custom_dropdown_options_source_url', 10, 2 );
|
3025 |
+
* function my_custom_dropdown_options_source( $url, $data ) {
|
3026 |
+
* // your code here
|
3027 |
+
* return $url;
|
3028 |
+
* }
|
3029 |
+
* ?>
|
3030 |
+
*/
|
3031 |
+
// todo maybe deprecate
|
3032 |
+
// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
3033 |
+
// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
3034 |
+
|
3035 |
+
}
|
3036 |
+
|
3037 |
+
/**
|
3038 |
+
* UM hook
|
3039 |
+
*
|
3040 |
+
* @type filter
|
3041 |
+
* @title um_fields_options_enable_pairs__{$key}
|
3042 |
+
* @description Enable options pairs by field $key
|
3043 |
+
* @input_vars
|
3044 |
+
* [{"var":"$options_pairs","type":"string","desc":"Enable pairs"}]
|
3045 |
+
* @change_log
|
3046 |
+
* ["Since: 2.0"]
|
3047 |
+
* @usage add_filter( 'um_fields_options_enable_pairs__{$key}', 'function_name', 10, 1 );
|
3048 |
+
* @example
|
3049 |
+
* <?php
|
3050 |
+
* add_filter( 'um_fields_options_enable_pairs__{$key}', 'my_fields_options_enable_pairs', 10, 1 );
|
3051 |
+
* function my_fields_options_enable_pairs( $options_pairs ) {
|
3052 |
+
* // your code here
|
3053 |
+
* return $options_pairs;
|
3054 |
+
* }
|
3055 |
+
* ?>
|
3056 |
+
*/
|
3057 |
+
$enable_options_pair = apply_filters( "um_fields_options_enable_pairs__{$key}", false );
|
3058 |
+
|
3059 |
+
if ( ! $has_parent_option ) {
|
3060 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
3061 |
+
$options = UM()->builtin()->get ( $filter );
|
3062 |
+
}
|
3063 |
+
|
3064 |
+
// 'country'
|
3065 |
+
if ( $key === 'country' && empty( $options ) ) {
|
3066 |
+
$options = UM()->builtin()->get( 'countries' );
|
3067 |
+
} else if ( empty( $options ) && isset( $data['options'] ) ) {
|
3068 |
+
$options = $data['options'];
|
3069 |
+
}
|
3070 |
+
|
3071 |
+
$options = apply_filters( 'um_selectbox_options', $options, $key );
|
3072 |
+
|
3073 |
+
if ( isset( $options ) ) {
|
3074 |
+
/**
|
3075 |
+
* UM hook
|
3076 |
+
*
|
3077 |
+
* @type filter
|
3078 |
+
* @title um_select_dropdown_dynamic_options
|
3079 |
+
* @description Extend dropdown dynamic options
|
3080 |
+
* @input_vars
|
3081 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"},
|
3082 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3083 |
+
* @change_log
|
3084 |
+
* ["Since: 2.0"]
|
3085 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options', 'function_name', 10, 2 );
|
3086 |
+
* @example
|
3087 |
+
* <?php
|
3088 |
+
* add_filter( 'um_select_dropdown_dynamic_options', 'my_select_dropdown_dynamic_options', 10, 2 );
|
3089 |
+
* function my_select_dropdown_dynamic_options( $options, $data ) {
|
3090 |
+
* // your code here
|
3091 |
+
* return $options;
|
3092 |
+
* }
|
3093 |
+
* ?>
|
3094 |
+
*/
|
3095 |
+
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
|
3096 |
+
/**
|
3097 |
+
* UM hook
|
3098 |
+
*
|
3099 |
+
* @type filter
|
3100 |
+
* @title um_select_dropdown_dynamic_options_{$key}
|
3101 |
+
* @description Extend dropdown dynamic options by field $key
|
3102 |
+
* @input_vars
|
3103 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"}]
|
3104 |
+
* @change_log
|
3105 |
+
* ["Since: 2.0"]
|
3106 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'function_name', 10, 1 );
|
3107 |
+
* @example
|
3108 |
+
* <?php
|
3109 |
+
* add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'my_select_dropdown_dynamic_options', 10, 1 );
|
3110 |
+
* function my_select_dropdown_dynamic_options( $options ) {
|
3111 |
+
* // your code here
|
3112 |
+
* return $options;
|
3113 |
+
* }
|
3114 |
+
* ?>
|
3115 |
+
*/
|
3116 |
+
$options = apply_filters( "um_select_dropdown_dynamic_options_{$key}", $options );
|
3117 |
+
}
|
3118 |
+
}
|
3119 |
+
|
3120 |
+
if ( $form_key === 'role' ) {
|
3121 |
+
$options = $this->get_available_roles( $form_key, $options );
|
3122 |
+
}
|
3123 |
+
|
3124 |
+
/**
|
3125 |
+
* UM hook
|
3126 |
+
*
|
3127 |
+
* @type filter
|
3128 |
+
* @title um_select_option_value
|
3129 |
+
* @description Enable options pair by field $data
|
3130 |
+
* @input_vars
|
3131 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3132 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3133 |
+
*/
|
3134 |
+
$options_pair = apply_filters( 'um_select_options_pair', null, $data );
|
3135 |
+
|
3136 |
+
// switch options pair for custom options from a callback function
|
3137 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3138 |
+
$options_pair = true;
|
3139 |
+
}
|
3140 |
+
|
3141 |
+
$field_value = '';
|
3142 |
+
|
3143 |
+
if ( ! empty( $placeholder ) && is_string( $placeholder ) ) {
|
3144 |
+
$placeholder = strip_tags( $placeholder );
|
3145 |
+
}
|
3146 |
+
|
3147 |
+
$output .= '<select data-default="' . $data['default'] . '" ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . esc_attr( $form_key ) . '" id="' . esc_attr( $field_id ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '" ' . $atts_ajax . '>';
|
3148 |
+
|
3149 |
+
$output .= '<option value=""></option>';
|
3150 |
+
|
3151 |
+
// add options
|
3152 |
+
if ( ! empty( $options ) ) {
|
3153 |
+
foreach ( $options as $k => $v ) {
|
3154 |
+
|
3155 |
+
$v = rtrim( $v );
|
3156 |
+
|
3157 |
+
$option_value = $v;
|
3158 |
+
$um_field_checkbox_item_title = $v;
|
3159 |
+
|
3160 |
+
|
3161 |
+
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3162 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3163 |
+
$option_value = $k;
|
3164 |
+
$um_field_checkbox_item_title = $v;
|
3165 |
+
}
|
3166 |
+
|
3167 |
+
if ( isset( $options_pair ) ) {
|
3168 |
+
$option_value = $k;
|
3169 |
+
$um_field_checkbox_item_title = $v;
|
3170 |
+
}
|
3171 |
+
|
3172 |
+
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3173 |
+
|
3174 |
+
$output .= '<option value="' . $option_value . '" ';
|
3175 |
+
|
3176 |
+
if ( $this->is_selected( $form_key, $option_value, $data ) ) {
|
3177 |
+
$output .= 'selected';
|
3178 |
+
$field_value = $option_value;
|
3179 |
+
} elseif ( ! isset( $options_pair ) && $this->is_selected( $form_key, $v, $data ) ) {
|
3180 |
+
$output .= 'selected';
|
3181 |
+
$field_value = $v;
|
3182 |
+
}
|
3183 |
+
|
3184 |
+
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3185 |
+
}
|
3186 |
+
}
|
3187 |
+
|
3188 |
+
if ( ! empty( $disabled ) ) {
|
3189 |
+
$output .= $this->disabled_hidden_field( $form_key, $field_value );
|
3190 |
+
}
|
3191 |
+
|
3192 |
+
$output .= '</select>';
|
3193 |
+
|
3194 |
+
$output .= '</div>';
|
3195 |
+
|
3196 |
+
|
3197 |
+
if ( $this->is_error( $form_key ) ) {
|
3198 |
+
$output .= $this->field_error( $this->show_error( $form_key ) );
|
3199 |
+
} elseif ( $this->is_notice( $form_key ) ) {
|
3200 |
+
$output .= $this->field_notice( $this->show_notice( $form_key ) );
|
3201 |
+
}
|
3202 |
+
|
3203 |
+
|
3204 |
+
$output .= '</div>';
|
3205 |
+
break;
|
3206 |
+
|
3207 |
+
/* Multi-Select dropdown */
|
3208 |
+
case 'multiselect':
|
3209 |
+
|
3210 |
+
$max_selections = ( isset( $max_selections ) ) ? absint( $max_selections ) : 0;
|
3211 |
+
|
3212 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3213 |
+
|
3214 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
3215 |
+
$class = 'um-s2';
|
3216 |
+
} else {
|
3217 |
+
$class = 'um-s1';
|
3218 |
+
}
|
3219 |
+
|
3220 |
+
if ( isset( $data['label'] ) ) {
|
3221 |
+
$output .= $this->field_label( $label, $key, $data );
|
3222 |
+
}
|
3223 |
+
|
3224 |
+
$field_icon = false;
|
3225 |
+
$field_icon_output = '';
|
3226 |
+
|
3227 |
+
/**
|
3228 |
+
* UM hook
|
3229 |
+
*
|
3230 |
+
* @type filter
|
3231 |
+
* @title um_multiselect_option_value
|
3232 |
+
* @description Change multiselect keyword data
|
3233 |
+
* @input_vars
|
3234 |
+
* [{"var":"$keyword","type":"int","desc":"Option Value"},
|
3235 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
3236 |
+
* @change_log
|
3237 |
+
* ["Since: 2.0"]
|
3238 |
+
* @usage add_filter( 'um_multiselect_option_value', 'function_name', 10, 2 );
|
3239 |
+
* @example
|
3240 |
+
* <?php
|
3241 |
+
* add_filter( 'um_multiselect_option_value', 'my_multiselect_option_value', 10, 2 );
|
3242 |
+
* function my_multiselect_option_value( $keyword, $type ) {
|
3243 |
+
* // your code here
|
3244 |
+
* return $keyword;
|
3245 |
+
* }
|
3246 |
+
* ?>
|
3247 |
+
*/
|
3248 |
+
$use_keyword = apply_filters( 'um_multiselect_option_value', 0, $data['type'] );
|
3249 |
+
|
3250 |
+
$output .= '<div class="um-field-area ' . (! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
3251 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
3252 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
3253 |
+
}
|
3254 |
+
|
3255 |
+
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . esc_attr( $field_name ) . '[]" id="' . esc_attr( $field_id ) . '" data-maxsize="' . esc_attr( $max_selections ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '">';
|
3256 |
+
|
3257 |
+
|
3258 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
3259 |
+
$options = UM()->builtin()->get( $filter );
|
3260 |
+
}
|
3261 |
+
|
3262 |
+
if ( ! isset( $options ) ) {
|
3263 |
+
$options = UM()->builtin()->get( 'countries' );
|
3264 |
+
}
|
3265 |
+
|
3266 |
+
if ( isset( $options ) ) {
|
3267 |
+
/**
|
3268 |
+
* UM hook
|
3269 |
+
*
|
3270 |
+
* @type filter
|
3271 |
+
* @title um_multiselect_options
|
3272 |
+
* @description Extend multiselect options
|
3273 |
+
* @input_vars
|
3274 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3275 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3276 |
+
* @change_log
|
3277 |
+
* ["Since: 2.0"]
|
3278 |
+
* @usage add_filter( 'um_multiselect_options', 'function_name', 10, 2 );
|
3279 |
+
* @example
|
3280 |
+
* <?php
|
3281 |
+
* add_filter( 'um_multiselect_options', 'my_multiselect_options', 10, 2 );
|
3282 |
+
* function my_multiselect_options( $options, $data ) {
|
3283 |
+
* // your code here
|
3284 |
+
* return $options;
|
3285 |
+
* }
|
3286 |
+
* ?>
|
3287 |
+
*/
|
3288 |
+
$options = apply_filters( 'um_multiselect_options', $options, $data );
|
3289 |
+
/**
|
3290 |
+
* UM hook
|
3291 |
+
*
|
3292 |
+
* @type filter
|
3293 |
+
* @title um_multiselect_options_{$key}
|
3294 |
+
* @description Extend multiselect options by field $key
|
3295 |
+
* @input_vars
|
3296 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"}]
|
3297 |
+
* @change_log
|
3298 |
+
* ["Since: 2.0"]
|
3299 |
+
* @usage add_filter( 'um_multiselect_options_{$key}', 'function_name', 10, 1 );
|
3300 |
+
* @example
|
3301 |
+
* <?php
|
3302 |
+
* add_filter( 'um_multiselect_options_{$key}', 'my_multiselect_options', 10, 1 );
|
3303 |
+
* function my_multiselect_options( $options ) {
|
3304 |
+
* // your code here
|
3305 |
+
* return $options;
|
3306 |
+
* }
|
3307 |
+
* ?>
|
3308 |
+
*/
|
3309 |
+
$options = apply_filters( "um_multiselect_options_{$key}", $options );
|
3310 |
+
/**
|
3311 |
+
* UM hook
|
3312 |
+
*
|
3313 |
+
* @type filter
|
3314 |
+
* @title um_multiselect_options_{$type}
|
3315 |
+
* @description Extend multiselect options by field $type
|
3316 |
+
* @input_vars
|
3317 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3318 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3319 |
+
* @change_log
|
3320 |
+
* ["Since: 2.0"]
|
3321 |
+
* @usage add_filter( 'um_multiselect_options_{$type}', 'function_name', 10, 2 );
|
3322 |
+
* @example
|
3323 |
+
* <?php
|
3324 |
+
* add_filter( 'um_multiselect_options_{$type}', 'my_multiselect_options', 10, 2 );
|
3325 |
+
* function my_multiselect_option_value( $options, $data ) {
|
3326 |
+
* // your code here
|
3327 |
+
* return $options;
|
3328 |
+
* }
|
3329 |
+
* ?>
|
3330 |
+
*/
|
3331 |
+
$options = apply_filters( "um_multiselect_options_{$data['type']}", $options, $data );
|
3332 |
+
}
|
3333 |
+
|
3334 |
+
/**
|
3335 |
+
* UM hook
|
3336 |
+
*
|
3337 |
+
* @type filter
|
3338 |
+
* @title um_select_option_value
|
3339 |
+
* @description Enable options pair by field $data
|
3340 |
+
* @input_vars
|
3341 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3342 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3343 |
+
*/
|
3344 |
+
$use_keyword = apply_filters( 'um_select_options_pair', null, $data );
|
3345 |
+
|
3346 |
+
// switch options pair for custom options from a callback function
|
3347 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3348 |
+
$use_keyword = true;
|
3349 |
+
}
|
3350 |
+
|
3351 |
+
// add an empty option!
|
3352 |
+
$output .= '<option value=""></option>';
|
3353 |
+
|
3354 |
+
$arr_selected = array();
|
3355 |
+
// add options
|
3356 |
+
if ( ! empty( $options ) && is_array( $options ) ) {
|
3357 |
+
foreach ( $options as $k => $v ) {
|
3358 |
+
|
3359 |
+
$v = rtrim( $v );
|
3360 |
+
|
3361 |
+
$um_field_checkbox_item_title = $v;
|
3362 |
+
$opt_value = $v;
|
3363 |
+
|
3364 |
+
if ( $use_keyword ) {
|
3365 |
+
$um_field_checkbox_item_title = $v;
|
3366 |
+
$opt_value = $k;
|
3367 |
+
}
|
3368 |
+
|
3369 |
+
$opt_value = $this->filter_field_non_utf8_value( $opt_value );
|
3370 |
+
|
3371 |
+
$output .= '<option value="' . $opt_value . '" ';
|
3372 |
+
if ( $this->is_selected( $key, $opt_value, $data ) ) {
|
3373 |
+
|
3374 |
+
$output .= 'selected';
|
3375 |
+
$arr_selected[ $opt_value ] = $opt_value;
|
3376 |
+
}
|
3377 |
+
|
3378 |
+
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3379 |
+
|
3380 |
+
}
|
3381 |
+
}
|
3382 |
+
|
3383 |
+
$output .= '</select>';
|
3384 |
+
|
3385 |
+
if ( ! empty( $disabled ) && ! empty( $arr_selected ) ) {
|
3386 |
+
foreach ( $arr_selected as $item ) {
|
3387 |
+
$output .= $this->disabled_hidden_field( $key . '[]', $item );
|
3388 |
+
}
|
3389 |
+
}
|
3390 |
+
|
3391 |
+
$output .= '</div>';
|
3392 |
+
|
3393 |
+
|
3394 |
+
if ( $this->is_error( $key ) ) {
|
3395 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3396 |
+
}else if ( $this->is_notice( $key ) ) {
|
3397 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3398 |
+
}
|
3399 |
+
|
3400 |
+
$output .= '</div>';
|
3401 |
+
break;
|
3402 |
+
|
3403 |
+
/* Radio */
|
3404 |
+
case 'radio':
|
3405 |
+
|
3406 |
+
if ( isset( $options ) ) {
|
3407 |
+
/**
|
3408 |
+
* UM hook
|
3409 |
+
*
|
3410 |
+
* @type filter
|
3411 |
+
* @title um_radio_field_options
|
3412 |
+
* @description Extend radio field options
|
3413 |
+
* @input_vars
|
3414 |
+
* [{"var":"$options","type":"array","desc":"Radio Field Options"},
|
3415 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3416 |
+
* @change_log
|
3417 |
+
* ["Since: 2.0"]
|
3418 |
+
* @usage add_filter( 'um_radio_field_options', 'function_name', 10, 2 );
|
3419 |
+
* @example
|
3420 |
+
* <?php
|
3421 |
+
* add_filter( 'um_radio_field_options', 'my_radio_field_options', 10, 2 );
|
3422 |
+
* function my_radio_field_options( $options, $data ) {
|
3423 |
+
* // your code here
|
3424 |
+
* return $options;
|
3425 |
+
* }
|
3426 |
+
* ?>
|
3427 |
+
*/
|
3428 |
+
$options = apply_filters( 'um_radio_field_options', $options, $data );
|
3429 |
+
/**
|
3430 |
+
* UM hook
|
3431 |
+
*
|
3432 |
+
* @type filter
|
3433 |
+
* @title um_radio_field_options_{$key}
|
3434 |
+
* @description Extend radio field options by field $key
|
3435 |
+
* @input_vars
|
3436 |
+
* [{"var":"$options","type":"array","desc":"Radio field Options"}]
|
3437 |
+
* @change_log
|
3438 |
+
* ["Since: 2.0"]
|
3439 |
+
* @usage add_filter( 'um_radio_field_options_{$key}', 'function_name', 10, 1 );
|
3440 |
+
* @example
|
3441 |
+
* <?php
|
3442 |
+
* add_filter( 'um_radio_field_options_{$key}', 'my_radio_field_options', 10, 1 );
|
3443 |
+
* function my_radio_field_options( $options ) {
|
3444 |
+
* // your code here
|
3445 |
+
* return $options;
|
3446 |
+
* }
|
3447 |
+
* ?>
|
3448 |
+
*/
|
3449 |
+
$options = apply_filters( "um_radio_field_options_{$key}", $options );
|
3450 |
+
}
|
3451 |
+
|
3452 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3453 |
+
|
3454 |
+
if ( isset( $data['label'] ) ) {
|
3455 |
+
$output .= $this->field_label( $label, $key, $data );
|
3456 |
+
}
|
3457 |
+
|
3458 |
+
$output .= '<div class="um-field-area">';
|
3459 |
+
|
3460 |
+
$options = $this->get_available_roles( $form_key, $options );
|
3461 |
+
|
3462 |
+
// add options
|
3463 |
+
$i = 0;
|
3464 |
+
$field_value = array();
|
3465 |
+
|
3466 |
+
/**
|
3467 |
+
* UM hook
|
3468 |
+
*
|
3469 |
+
* @type filter
|
3470 |
+
* @title um_radio_option_value
|
3471 |
+
* @description Enable options pair by field $data
|
3472 |
+
* @input_vars
|
3473 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3474 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3475 |
+
*/
|
3476 |
+
$options_pair = apply_filters( "um_radio_options_pair__{$key}", false, $data );
|
3477 |
+
|
3478 |
+
|
3479 |
+
if ( ! empty( $options ) ) {
|
3480 |
+
foreach ( $options as $k => $v ) {
|
3481 |
+
|
3482 |
+
$v = rtrim( $v );
|
3483 |
+
|
3484 |
+
$um_field_checkbox_item_title = $v;
|
3485 |
+
$option_value = $v;
|
3486 |
+
|
3487 |
+
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3488 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3489 |
+
$um_field_checkbox_item_title = $v;
|
3490 |
+
$option_value = $k;
|
3491 |
+
}
|
3492 |
+
|
3493 |
+
if( $options_pair ){
|
3494 |
+
$um_field_checkbox_item_title = $v;
|
3495 |
+
$option_value = $k;
|
3496 |
+
}
|
3497 |
+
|
3498 |
+
$i++;
|
3499 |
+
if ($i % 2 == 0) {
|
3500 |
+
$col_class = 'right';
|
3501 |
+
} else {
|
3502 |
+
$col_class = '';
|
3503 |
+
}
|
3504 |
+
|
3505 |
+
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3506 |
+
$active = 'active';
|
3507 |
+
$class = "um-icon-android-radio-button-on";
|
3508 |
+
} else {
|
3509 |
+
$active = '';
|
3510 |
+
$class = "um-icon-android-radio-button-off";
|
3511 |
+
}
|
3512 |
+
|
3513 |
+
|
3514 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3515 |
+
$col_class .= " um-field-radio-state-disabled";
|
3516 |
+
}
|
3517 |
+
|
3518 |
+
$output .= '<label class="um-field-radio ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3519 |
+
|
3520 |
+
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3521 |
+
|
3522 |
+
$output .= '<input ' . $disabled . ' type="radio" name="' . ( ( $form_key == 'role' ) ? esc_attr( $form_key ) : esc_attr( $form_key ) . '[]' ) . '" value="' . $option_value . '" ';
|
3523 |
+
|
3524 |
+
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3525 |
+
$output .= 'checked';
|
3526 |
+
$field_value[ $key ] = $option_value;
|
3527 |
+
}
|
3528 |
+
|
3529 |
+
$output .= ' />';
|
3530 |
+
|
3531 |
+
$output .= '<span class="um-field-radio-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3532 |
+
$output .= '<span class="um-field-radio-option">' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3533 |
+
$output .= '</label>';
|
3534 |
+
|
3535 |
+
if ( $i % 2 == 0 ) {
|
3536 |
+
$output .= '<div class="um-clear"></div>';
|
3537 |
+
}
|
3538 |
+
|
3539 |
+
}
|
3540 |
+
}
|
3541 |
+
|
3542 |
+
if ( ! empty( $disabled ) ) {
|
3543 |
+
foreach ( $field_value as $item ) {
|
3544 |
+
$output .= $this->disabled_hidden_field( $form_key, $item );
|
3545 |
+
}
|
3546 |
+
}
|
3547 |
+
|
3548 |
+
$output .= '<div class="um-clear"></div>';
|
3549 |
+
|
3550 |
+
$output .= '</div>';
|
3551 |
+
|
3552 |
+
if ( $this->is_error( $key ) ) {
|
3553 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3554 |
+
}else if ( $this->is_notice( $key ) ) {
|
3555 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3556 |
+
}
|
3557 |
+
|
3558 |
+
$output .= '</div>';
|
3559 |
+
break;
|
3560 |
+
|
3561 |
+
/* Checkbox */
|
3562 |
+
case 'checkbox':
|
3563 |
+
|
3564 |
+
if ( isset( $options ) ) {
|
3565 |
+
/**
|
3566 |
+
* UM hook
|
3567 |
+
*
|
3568 |
+
* @type filter
|
3569 |
+
* @title um_checkbox_field_options
|
3570 |
+
* @description Extend checkbox options
|
3571 |
+
* @input_vars
|
3572 |
+
* [{"var":"$options","type":"array","desc":"Checkbox Options"},
|
3573 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3574 |
+
* @change_log
|
3575 |
+
* ["Since: 2.0"]
|
3576 |
+
* @usage add_filter( 'um_checkbox_field_options', 'function_name', 10, 2 );
|
3577 |
+
* @example
|
3578 |
+
* <?php
|
3579 |
+
* add_filter( 'um_checkbox_field_options', 'my_checkbox_options', 10, 2 );
|
3580 |
+
* function my_checkbox_options( $options, $data ) {
|
3581 |
+
* // your code here
|
3582 |
+
* return $options;
|
3583 |
+
* }
|
3584 |
+
* ?>
|
3585 |
+
*/
|
3586 |
+
$options = apply_filters( 'um_checkbox_field_options', $options, $data );
|
3587 |
+
/**
|
3588 |
+
* UM hook
|
3589 |
+
*
|
3590 |
+
* @type filter
|
3591 |
+
* @title um_checkbox_field_options_{$key}
|
3592 |
+
* @description Extend checkbox options by field $key
|
3593 |
+
* @input_vars
|
3594 |
+
* [{"var":"$options","type":"array","desc":"Checkbox Options"}]
|
3595 |
+
* @change_log
|
3596 |
+
* ["Since: 2.0"]
|
3597 |
+
* @usage add_filter( 'um_checkbox_field_options_{$key}', 'function_name', 10, 1 );
|
3598 |
+
* @example
|
3599 |
+
* <?php
|
3600 |
+
* add_filter( 'um_checkbox_field_options_{$key}', 'my_checkbox_options', 10, 1 );
|
3601 |
+
* function my_checkbox_options( $options ) {
|
3602 |
+
* // your code here
|
3603 |
+
* return $options;
|
3604 |
+
* }
|
3605 |
+
* ?>
|
3606 |
+
*/
|
3607 |
+
$options = apply_filters( "um_checkbox_field_options_{$key}", $options );
|
3608 |
+
}
|
3609 |
+
|
3610 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3611 |
+
|
3612 |
+
if ( isset( $data['label'] ) ) {
|
3613 |
+
$output .= $this->field_label( $label, $key, $data );
|
3614 |
+
}
|
3615 |
+
|
3616 |
+
$output .= '<div class="um-field-area">';
|
3617 |
+
|
3618 |
+
// add options
|
3619 |
+
$i = 0;
|
3620 |
+
|
3621 |
+
foreach ( $options as $k => $v ) {
|
3622 |
+
|
3623 |
+
$v = rtrim( $v );
|
3624 |
+
|
3625 |
+
$i++;
|
3626 |
+
if ( $i % 2 == 0 ) {
|
3627 |
+
$col_class = 'right';
|
3628 |
+
} else {
|
3629 |
+
$col_class = '';
|
3630 |
+
}
|
3631 |
+
|
3632 |
+
if ( $this->is_selected( $key, $v, $data ) ) {
|
3633 |
+
$active = 'active';
|
3634 |
+
$class = "um-icon-android-checkbox-outline";
|
3635 |
+
} else {
|
3636 |
+
$active = '';
|
3637 |
+
$class = "um-icon-android-checkbox-outline-blank";
|
3638 |
+
}
|
3639 |
+
|
3640 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3641 |
+
$col_class .= " um-field-radio-state-disabled";
|
3642 |
+
}
|
3643 |
+
|
3644 |
+
$output .= '<label class="um-field-checkbox ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3645 |
+
|
3646 |
+
$um_field_checkbox_item_title = $v;
|
3647 |
+
|
3648 |
+
$v = $this->filter_field_non_utf8_value( $v );
|
3649 |
+
|
3650 |
+
$output .= '<input ' . $disabled . ' type="checkbox" name="' . esc_attr( $key ) . '[]" value="' . strip_tags( $v ) . '" ';
|
3651 |
+
|
3652 |
+
if ( $this->is_selected( $key, $v, $data ) ) {
|
3653 |
+
$output .= 'checked';
|
3654 |
+
}
|
3655 |
+
|
3656 |
+
$output .= ' />';
|
3657 |
+
|
3658 |
+
if ( ! empty( $disabled ) && $this->is_selected( $key, $v, $data ) ) {
|
3659 |
+
$output .= $this->disabled_hidden_field( $key . '[]', strip_tags( $v ) );
|
3660 |
+
}
|
3661 |
+
|
3662 |
+
|
3663 |
+
$output .= '<span class="um-field-checkbox-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3664 |
+
/**
|
3665 |
+
* UM hook
|
3666 |
+
*
|
3667 |
+
* @type filter
|
3668 |
+
* @title um_field_checkbox_item_title
|
3669 |
+
* @description Change Checkbox item title
|
3670 |
+
* @input_vars
|
3671 |
+
* [{"var":"$checkbox_item_title","type":"array","desc":"Item Title"},
|
3672 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
3673 |
+
* {"var":"$value","type":"string","desc":"Field Value"},
|
3674 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3675 |
+
* @change_log
|
3676 |
+
* ["Since: 2.0"]
|
3677 |
+
* @usage add_filter( 'um_field_checkbox_item_title', 'function_name', 10, 4 );
|
3678 |
+
* @example
|
3679 |
+
* <?php
|
3680 |
+
* add_filter( 'um_field_checkbox_item_title', 'my_checkbox_item_title', 10, 4 );
|
3681 |
+
* function my_checkbox_item_title( $checkbox_item_title, $key, $value, $data ) {
|
3682 |
+
* // your code here
|
3683 |
+
* return $checkbox_item_title;
|
3684 |
+
* }
|
3685 |
+
* ?>
|
3686 |
+
*/
|
3687 |
+
$um_field_checkbox_item_title = apply_filters( 'um_field_checkbox_item_title', $um_field_checkbox_item_title, $key, $v, $data );
|
3688 |
+
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3689 |
+
$output .= '</label>';
|
3690 |
+
|
3691 |
+
if ( $i % 2 == 0 ) {
|
3692 |
+
$output .= '<div class="um-clear"></div>';
|
3693 |
+
}
|
3694 |
+
|
3695 |
+
}
|
3696 |
+
|
3697 |
+
$output .= '<div class="um-clear"></div>';
|
3698 |
+
|
3699 |
+
$output .= '</div>';
|
3700 |
+
|
3701 |
+
|
3702 |
+
if ( $this->is_error( $key ) ) {
|
3703 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3704 |
+
}else if ( $this->is_notice( $key ) ) {
|
3705 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3706 |
+
}
|
3707 |
+
|
3708 |
+
$output .= '</div>';
|
3709 |
+
break;
|
3710 |
+
|
3711 |
+
/* HTML */
|
3712 |
+
case 'block':
|
3713 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3714 |
+
break;
|
3715 |
+
|
3716 |
+
/* Shortcode */
|
3717 |
+
case 'shortcode':
|
3718 |
+
|
3719 |
+
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
3720 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
3721 |
+
$content = do_shortcode( $content );
|
3722 |
+
} else {
|
3723 |
+
$content = apply_shortcodes( $content );
|
3724 |
+
}
|
3725 |
+
|
3726 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3727 |
+
break;
|
3728 |
+
|
3729 |
+
/* Unlimited Group */
|
3730 |
+
case 'group':
|
3731 |
+
|
3732 |
+
$fields = $this->get_fields_in_group( $key );
|
3733 |
+
if ( ! empty( $fields ) ) {
|
3734 |
+
|
3735 |
+
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
|
3736 |
+
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . esc_html__( $label, 'ultimate-member' ) . '</div>';
|
3737 |
+
$output .= '<div class="um-field-group-body"><a href="javascript:void(0);" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
|
3738 |
+
|
3739 |
+
foreach ( $fields as $subkey => $subdata ) {
|
3740 |
+
$output .= $this->edit_field( $subkey, $subdata, 'group' );
|
3741 |
+
}
|
3742 |
+
|
3743 |
+
$output .= '</div>';
|
3744 |
+
$output .= '</div>';
|
3745 |
+
|
3746 |
+
}
|
3747 |
+
|
3748 |
+
break;
|
3749 |
+
|
3750 |
+
}
|
3751 |
+
|
3752 |
+
// Custom filter for field output
|
3753 |
+
if ( isset( $this->set_mode ) ) {
|
3754 |
+
/**
|
3755 |
+
* UM hook
|
3756 |
+
*
|
3757 |
+
* @type filter
|
3758 |
+
* @title um_{$key}_form_edit_field
|
3759 |
+
* @description Change field HTML on edit mode by field $key
|
3760 |
+
* @input_vars
|
3761 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
3762 |
+
* {"var":"$mode","type":"string","desc":"Fields Mode"}]
|
3763 |
+
* @change_log
|
3764 |
+
* ["Since: 2.0"]
|
3765 |
+
* @usage add_filter( 'um_{$key}_form_edit_field', 'function_name', 10, 2 );
|
3766 |
+
* @example
|
3767 |
+
* <?php
|
3768 |
+
* add_filter( 'um_{$key}_form_edit_field', 'my_form_edit_field', 10, 2 );
|
3769 |
+
* function my_form_edit_field( $output, $mode ) {
|
3770 |
+
* // your code here
|
3771 |
+
* return $output;
|
3772 |
+
* }
|
3773 |
+
* ?>
|
3774 |
+
*/
|
3775 |
+
$output = apply_filters( "um_{$key}_form_edit_field", $output, $this->set_mode );
|
3776 |
+
}
|
3777 |
+
|
3778 |
+
return $output;
|
3779 |
+
}
|
3780 |
+
|
3781 |
+
|
3782 |
+
/**
|
3783 |
+
* Filter for user roles
|
3784 |
+
*
|
3785 |
+
* @param $form_key
|
3786 |
+
* @param array $options
|
3787 |
+
* @return array
|
3788 |
+
*/
|
3789 |
+
function get_available_roles( $form_key, $options = array() ) {
|
3790 |
+
if ( $form_key != 'role' ) {
|
3791 |
+
return $options;
|
3792 |
+
}
|
3793 |
+
|
3794 |
+
// role field
|
3795 |
+
global $wp_roles;
|
3796 |
+
$role_keys = array_map( function( $item ) {
|
3797 |
+
return 'um_' . $item;
|
3798 |
+
}, get_option( 'um_roles', array() ) );
|
3799 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
3800 |
+
|
3801 |
+
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
3802 |
+
|
3803 |
+
if ( ! empty( $options ) ) {
|
3804 |
+
|
3805 |
+
$roles = array_map( function( $item ) {
|
3806 |
+
return html_entity_decode( $item, ENT_QUOTES );
|
3807 |
+
}, $roles );
|
3808 |
+
|
3809 |
+
//fix when customers change options for role (radio/dropdown) fields
|
3810 |
+
$intersected_options = array();
|
3811 |
+
foreach ( $options as $key => $title ) {
|
3812 |
+
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
3813 |
+
$intersected_options[ $search_key ] = $title;
|
3814 |
+
} elseif ( isset( $roles[ $key ] ) ) {
|
3815 |
+
$intersected_options[ $key ] = $title;
|
3816 |
+
}
|
3817 |
+
}
|
3818 |
+
|
3819 |
+
$options = $intersected_options;
|
3820 |
+
} else {
|
3821 |
+
$options = $roles;
|
3822 |
+
}
|
3823 |
+
|
3824 |
+
return $options;
|
3825 |
+
}
|
3826 |
+
|
3827 |
+
|
3828 |
+
/**
|
3829 |
+
* Sorts columns array
|
3830 |
+
*
|
3831 |
+
* @param array $arr
|
3832 |
+
* @param string $col
|
3833 |
+
* @param string $dir
|
3834 |
+
*
|
3835 |
+
* @return array $arr
|
3836 |
+
*/
|
3837 |
+
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
3838 |
+
$sort_col = array();
|
3839 |
+
foreach ( $arr as $key => $row ) {
|
3840 |
+
if ( $key == 'form_id' ) {
|
3841 |
+
unset( $arr['form_id'] );
|
3842 |
+
continue;
|
3843 |
+
}
|
3844 |
+
|
3845 |
+
if ( isset( $row[ $col ] ) ) {
|
3846 |
+
$sort_col[ $key ] = $row[ $col ];
|
3847 |
+
} else {
|
3848 |
+
unset( $arr[ $key ] );
|
3849 |
+
}
|
3850 |
+
}
|
3851 |
+
|
3852 |
+
array_multisort( $sort_col, $dir, $arr );
|
3853 |
+
|
3854 |
+
return $arr;
|
3855 |
+
}
|
3856 |
+
|
3857 |
+
|
3858 |
+
/**
|
3859 |
+
* Get fields in row
|
3860 |
+
*
|
3861 |
+
* @param int $row_id
|
3862 |
+
*
|
3863 |
+
* @return string
|
3864 |
+
*/
|
3865 |
+
function get_fields_by_row( $row_id ) {
|
3866 |
+
if ( ! isset( $this->get_fields ) ) {
|
3867 |
+
return '';
|
3868 |
+
}
|
3869 |
+
|
3870 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3871 |
+
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3872 |
+
$results[ $key ] = $array;
|
3873 |
+
}
|
3874 |
+
}
|
3875 |
+
|
3876 |
+
return ( isset ( $results ) ) ? $results : '';
|
3877 |
+
}
|
3878 |
+
|
3879 |
+
|
3880 |
+
/**
|
3881 |
+
* Get fields by sub row
|
3882 |
+
*
|
3883 |
+
* @param string $row_fields
|
3884 |
+
* @param integer $subrow_id
|
3885 |
+
*
|
3886 |
+
* @return mixed
|
3887 |
+
*/
|
3888 |
+
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
3889 |
+
if ( ! is_array( $row_fields ) ) {
|
3890 |
+
return '';
|
3891 |
+
}
|
3892 |
+
foreach ( $row_fields as $key => $array ) {
|
3893 |
+
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
3894 |
+
$results[ $key ] = $array;
|
3895 |
+
}
|
3896 |
+
}
|
3897 |
+
|
3898 |
+
return ( isset ( $results ) ) ? $results : '';
|
3899 |
+
}
|
3900 |
+
|
3901 |
+
|
3902 |
+
/**
|
3903 |
+
* Get fields in group
|
3904 |
+
*
|
3905 |
+
* @param integer $group_id
|
3906 |
+
*
|
3907 |
+
* @return mixed
|
3908 |
+
*/
|
3909 |
+
function get_fields_in_group( $group_id ) {
|
3910 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3911 |
+
if ( isset( $array['in_group'] ) && $array['in_group'] == $group_id ) {
|
3912 |
+
$results[ $key ] = $array;
|
3913 |
+
}
|
3914 |
+
}
|
3915 |
+
|
3916 |
+
return ( isset ( $results ) ) ? $results : '';
|
3917 |
+
}
|
3918 |
+
|
3919 |
+
|
3920 |
+
/**
|
3921 |
+
* Get fields in column
|
3922 |
+
*
|
3923 |
+
* @param array $fields
|
3924 |
+
* @param integer $col_number
|
3925 |
+
*
|
3926 |
+
* @return mixed
|
3927 |
+
*/
|
3928 |
+
function get_fields_in_column( $fields, $col_number ) {
|
3929 |
+
foreach ( $fields as $key => $array ) {
|
3930 |
+
if ( isset( $array['in_column'] ) && $array['in_column'] == $col_number ) {
|
3931 |
+
$results[ $key ] = $array;
|
3932 |
+
}
|
3933 |
+
}
|
3934 |
+
|
3935 |
+
return ( isset ( $results ) ) ? $results : '';
|
3936 |
+
}
|
3937 |
+
|
3938 |
+
|
3939 |
+
/**
|
3940 |
+
* Display fields
|
3941 |
+
*
|
3942 |
+
* @param string $mode
|
3943 |
+
* @param array $args
|
3944 |
+
*
|
3945 |
+
* @return string|null
|
3946 |
+
* @throws \Exception
|
3947 |
+
*/
|
3948 |
+
function display( $mode, $args ) {
|
3949 |
+
$output = null;
|
3950 |
+
|
3951 |
+
$this->global_args = $args;
|
3952 |
+
|
3953 |
+
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
3954 |
+
|
3955 |
+
$this->set_mode = $mode;
|
3956 |
+
|
3957 |
+
if ( 'profile' === $mode ) {
|
3958 |
+
UM()->form()->nonce = wp_create_nonce( 'um-profile-nonce' . UM()->user()->target_id );
|
3959 |
+
}
|
3960 |
+
|
3961 |
+
$this->set_id = $this->global_args['form_id'];
|
3962 |
+
|
3963 |
+
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
3964 |
+
|
3965 |
+
// start output here
|
3966 |
+
$this->get_fields = $this->get_fields();
|
3967 |
+
|
3968 |
+
if ( ! empty( $this->get_fields ) ) {
|
3969 |
+
|
3970 |
+
// find rows
|
3971 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3972 |
+
if ( $array['type'] == 'row' ) {
|
3973 |
+
$this->rows[ $key ] = $array;
|
3974 |
+
unset( $this->get_fields[ $key ] ); // not needed anymore
|
3975 |
+
}
|
3976 |
+
}
|
3977 |
+
|
3978 |
+
// rows fallback
|
3979 |
+
if ( ! isset( $this->rows ) ) {
|
3980 |
+
$this->rows = array(
|
3981 |
+
'_um_row_1' => array(
|
3982 |
+
'type' => 'row',
|
3983 |
+
'id' => '_um_row_1',
|
3984 |
+
'sub_rows' => 1,
|
3985 |
+
'cols' => 1,
|
3986 |
+
),
|
3987 |
+
);
|
3988 |
+
}
|
3989 |
+
|
3990 |
+
// master rows
|
3991 |
+
foreach ( $this->rows as $row_id => $row_array ) {
|
3992 |
+
|
3993 |
+
$row_fields = $this->get_fields_by_row( $row_id );
|
3994 |
+
if ( $row_fields ) {
|
3995 |
+
|
3996 |
+
$output .= $this->new_row_output( $row_id, $row_array );
|
3997 |
+
|
3998 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
3999 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4000 |
+
|
4001 |
+
// cols
|
4002 |
+
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4003 |
+
if ( is_numeric( $cols ) ) {
|
4004 |
+
$cols_num = (int) $cols;
|
4005 |
+
} else {
|
4006 |
+
if ( strstr( $cols, ':' ) ) {
|
4007 |
+
$col_split = explode( ':', $cols );
|
4008 |
+
} else {
|
4009 |
+
$col_split = array( $cols );
|
4010 |
+
}
|
4011 |
+
$cols_num = $col_split[ $c ];
|
4012 |
+
}
|
4013 |
+
|
4014 |
+
// sub row fields
|
4015 |
+
$subrow_fields = null;
|
4016 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4017 |
+
|
4018 |
+
if ( is_array( $subrow_fields ) ) {
|
4019 |
+
|
4020 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4021 |
+
|
4022 |
+
if ( $cols_num == 1 ) {
|
4023 |
+
|
4024 |
+
$output .= '<div class="um-col-1">';
|
4025 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4026 |
+
if ( $col1_fields ) {
|
4027 |
+
foreach ( $col1_fields as $key => $data ) {
|
4028 |
+
$output .= $this->edit_field( $key, $data );
|
4029 |
+
}
|
4030 |
+
}
|
4031 |
+
$output .= '</div>';
|
4032 |
+
|
4033 |
+
} else if ($cols_num == 2) {
|
4034 |
+
|
4035 |
+
$output .= '<div class="um-col-121">';
|
4036 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4037 |
+
if ( $col1_fields ) {
|
4038 |
+
foreach ( $col1_fields as $key => $data ) {
|
4039 |
+
$output .= $this->edit_field( $key, $data );
|
4040 |
+
}
|
4041 |
+
}
|
4042 |
+
$output .= '</div>';
|
4043 |
+
|
4044 |
+
$output .= '<div class="um-col-122">';
|
4045 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4046 |
+
if ( $col2_fields ) {
|
4047 |
+
foreach ( $col2_fields as $key => $data ) {
|
4048 |
+
$output .= $this->edit_field( $key, $data );
|
4049 |
+
}
|
4050 |
+
}
|
4051 |
+
$output .= '</div><div class="um-clear"></div>';
|
4052 |
+
|
4053 |
+
} else {
|
4054 |
+
|
4055 |
+
$output .= '<div class="um-col-131">';
|
4056 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4057 |
+
if ( $col1_fields ) {
|
4058 |
+
foreach ( $col1_fields as $key => $data ) {
|
4059 |
+
$output .= $this->edit_field( $key, $data );
|
4060 |
+
}
|
4061 |
+
}
|
4062 |
+
$output .= '</div>';
|
4063 |
+
|
4064 |
+
$output .= '<div class="um-col-132">';
|
4065 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4066 |
+
if ( $col2_fields ) {
|
4067 |
+
foreach ( $col2_fields as $key => $data ) {
|
4068 |
+
$output .= $this->edit_field( $key, $data );
|
4069 |
+
}
|
4070 |
+
}
|
4071 |
+
$output .= '</div>';
|
4072 |
+
|
4073 |
+
$output .= '<div class="um-col-133">';
|
4074 |
+
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4075 |
+
if ( $col3_fields ) {
|
4076 |
+
foreach ( $col3_fields as $key => $data ) {
|
4077 |
+
$output .= $this->edit_field( $key, $data );
|
4078 |
+
}
|
4079 |
+
}
|
4080 |
+
$output .= '</div><div class="um-clear"></div>';
|
4081 |
+
|
4082 |
+
}
|
4083 |
+
|
4084 |
+
}
|
4085 |
+
|
4086 |
+
}
|
4087 |
+
|
4088 |
+
$output .= '</div>';
|
4089 |
+
|
4090 |
+
}
|
4091 |
+
|
4092 |
+
}
|
4093 |
+
|
4094 |
+
}
|
4095 |
+
|
4096 |
+
return $output;
|
4097 |
+
}
|
4098 |
+
|
4099 |
+
|
4100 |
+
/**
|
4101 |
+
* Gets a field in `view mode`
|
4102 |
+
*
|
4103 |
+
* @param string $key
|
4104 |
+
* @param array $data
|
4105 |
+
* @param bool $rule
|
4106 |
+
*
|
4107 |
+
* @return string|null
|
4108 |
+
* @throws \Exception
|
4109 |
+
*/
|
4110 |
+
function view_field( $key, $data, $rule = false ) {
|
4111 |
+
$output = '';
|
4112 |
+
|
4113 |
+
// get whole field data
|
4114 |
+
if ( is_array( $data ) ) {
|
4115 |
+
$data = $this->get_field( $key );
|
4116 |
+
|
4117 |
+
if ( is_array( $data ) ) {
|
4118 |
+
/**
|
4119 |
+
* @var $visibility
|
4120 |
+
* @var $type
|
4121 |
+
* @var $default
|
4122 |
+
* @var $classes
|
4123 |
+
* @var $conditional
|
4124 |
+
* @var $content
|
4125 |
+
* @var $divider_text
|
4126 |
+
* @var $spacing
|
4127 |
+
* @var $borderwidth
|
4128 |
+
* @var $borderstyle
|
4129 |
+
* @var $bordercolor
|
4130 |
+
* @var $label
|
4131 |
+
*/
|
4132 |
+
extract( $data );
|
4133 |
+
}
|
4134 |
+
}
|
4135 |
+
|
4136 |
+
//hide if empty type
|
4137 |
+
if ( ! isset( $data['type'] ) ) {
|
4138 |
+
return '';
|
4139 |
+
}
|
4140 |
+
|
4141 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
4142 |
+
return '';
|
4143 |
+
}
|
4144 |
+
|
4145 |
+
//invisible on profile page
|
4146 |
+
if ( $visibility == 'edit' || $type == 'password' ) {
|
4147 |
+
return '';
|
4148 |
+
}
|
4149 |
+
|
4150 |
+
//hide if empty
|
4151 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4152 |
+
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4153 |
+
$_field_value = $this->field_value( $key, $default, $data );
|
4154 |
+
|
4155 |
+
if ( ! isset( $_field_value ) || $_field_value == '' ) {
|
4156 |
+
return '';
|
4157 |
+
}
|
4158 |
+
}
|
4159 |
+
|
4160 |
+
if ( ! um_can_view_field( $data ) ) {
|
4161 |
+
return '';
|
4162 |
+
}
|
4163 |
+
|
4164 |
+
// disable these fields in profile view only
|
4165 |
+
if ( in_array( $key, array( 'user_password' ) ) && $this->set_mode == 'profile' ) {
|
4166 |
+
return '';
|
4167 |
+
}
|
4168 |
+
|
4169 |
+
if ( ! um_field_conditions_are_met( $data ) ) {
|
4170 |
+
return '';
|
4171 |
+
}
|
4172 |
+
|
4173 |
+
|
4174 |
+
if ( isset( $data['classes'] ) ) {
|
4175 |
+
$classes = explode( " ", $data['classes'] );
|
4176 |
+
}
|
4177 |
+
|
4178 |
+
switch ( $type ) {
|
4179 |
+
|
4180 |
+
/* Default */
|
4181 |
+
default:
|
4182 |
+
|
4183 |
+
$_field_value = $this->field_value( $key, $default, $data );
|
4184 |
+
|
4185 |
+
if ( ! in_array( $type, $fields_without_metakey ) && ( ! isset( $_field_value ) || $_field_value == '' ) ) {
|
4186 |
+
$output = '';
|
4187 |
+
} else {
|
4188 |
+
|
4189 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4190 |
+
|
4191 |
+
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4192 |
+
|
4193 |
+
if ( ! isset( $data['label'] ) ) {
|
4194 |
+
$data['label'] = '';
|
4195 |
+
}
|
4196 |
+
|
4197 |
+
$output .= $this->field_label( $data['label'], $key, $data );
|
4198 |
+
}
|
4199 |
+
|
4200 |
+
$res = $this->field_value( $key, $default, $data );
|
4201 |
+
|
4202 |
+
if ( ! empty( $res ) ) {
|
4203 |
+
$res = stripslashes( $res );
|
4204 |
+
}
|
4205 |
+
if ( 'description' === $data['metakey'] ) {
|
4206 |
+
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
4207 |
+
$res = make_clickable( wpautop( wp_kses_post( $res ) ) );
|
4208 |
+
} else {
|
4209 |
+
$res = esc_html( $res );
|
4210 |
+
}
|
4211 |
+
|
4212 |
+
$res = nl2br( $res );
|
4213 |
+
}
|
4214 |
+
|
4215 |
+
$data['is_view_field'] = true;
|
4216 |
+
/**
|
4217 |
+
* UM hook
|
4218 |
+
*
|
4219 |
+
* @type filter
|
4220 |
+
* @title um_view_field
|
4221 |
+
* @description Change field HTML on view mode
|
4222 |
+
* @input_vars
|
4223 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4224 |
+
* {"var":"$data","type":"string","desc":"Field Data"},
|
4225 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
4226 |
+
* @change_log
|
4227 |
+
* ["Since: 2.0"]
|
4228 |
+
* @usage add_filter( 'um_view_field', 'function_name', 10, 3 );
|
4229 |
+
* @example
|
4230 |
+
* <?php
|
4231 |
+
* add_filter( 'um_view_field', 'my_view_field', 10, 3 );
|
4232 |
+
* function my_form_edit_field( $output, $data, $type ) {
|
4233 |
+
* // your code here
|
4234 |
+
* return $output;
|
4235 |
+
* }
|
4236 |
+
* ?>
|
4237 |
+
*/
|
4238 |
+
$res = apply_filters( 'um_view_field', $res, $data, $type );
|
4239 |
+
/**
|
4240 |
+
* UM hook
|
4241 |
+
*
|
4242 |
+
* @type filter
|
4243 |
+
* @title um_view_field_value_{$type}
|
4244 |
+
* @description Change field HTML on view mode by field type
|
4245 |
+
* @input_vars
|
4246 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4247 |
+
* {"var":"$data","type":"string","desc":"Field Data"}]
|
4248 |
+
* @change_log
|
4249 |
+
* ["Since: 2.0"]
|
4250 |
+
* @usage add_filter( 'um_view_field_value_{$type}', 'function_name', 10, 2 );
|
4251 |
+
* @example
|
4252 |
+
* <?php
|
4253 |
+
* add_filter( 'um_view_field_value_{$type}', 'my_view_field', 10, 2 );
|
4254 |
+
* function my_form_edit_field( $output, $data ) {
|
4255 |
+
* // your code here
|
4256 |
+
* return $output;
|
4257 |
+
* }
|
4258 |
+
* ?>
|
4259 |
+
*/
|
4260 |
+
$res = apply_filters( "um_view_field_value_{$type}", $res, $data );
|
4261 |
+
|
4262 |
+
$id_attr = '';
|
4263 |
+
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4264 |
+
$id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
4265 |
+
}
|
4266 |
+
|
4267 |
+
if ( empty( $res ) ) {
|
4268 |
+
$output = '';
|
4269 |
+
} else {
|
4270 |
+
$output .= '<div class="um-field-area">';
|
4271 |
+
$output .= '<div class="um-field-value"' . $id_attr . '>' . $res . '</div>';
|
4272 |
+
$output .= '</div>';
|
4273 |
+
|
4274 |
+
$output .= '</div>';
|
4275 |
+
}
|
4276 |
+
}
|
4277 |
+
|
4278 |
+
break;
|
4279 |
+
|
4280 |
+
/* HTML */
|
4281 |
+
case 'block':
|
4282 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4283 |
+
break;
|
4284 |
+
|
4285 |
+
/* Shortcode */
|
4286 |
+
case 'shortcode':
|
4287 |
+
|
4288 |
+
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
4289 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
4290 |
+
$content = do_shortcode( $content );
|
4291 |
+
} else {
|
4292 |
+
$content = apply_shortcodes( $content );
|
4293 |
+
}
|
4294 |
+
|
4295 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4296 |
+
break;
|
4297 |
+
|
4298 |
+
/* Gap/Space */
|
4299 |
+
case 'spacing':
|
4300 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
4301 |
+
break;
|
4302 |
+
|
4303 |
+
/* A line divider */
|
4304 |
+
case 'divider':
|
4305 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
4306 |
+
if ( $divider_text ) {
|
4307 |
+
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
|
4308 |
+
}
|
4309 |
+
$output .= '</div>';
|
4310 |
+
break;
|
4311 |
+
|
4312 |
+
/* Rating */
|
4313 |
+
case 'rating':
|
4314 |
+
|
4315 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4316 |
+
|
4317 |
+
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4318 |
+
$output .= $this->field_label( $label, $key, $data );
|
4319 |
+
}
|
4320 |
+
|
4321 |
+
ob_start(); ?>
|
4322 |
+
|
4323 |
+
<div class="um-field-area">
|
4324 |
+
<div class="um-field-value">
|
4325 |
+
<div class="um-rating-readonly um-raty" id="<?php echo esc_attr( $key ) ?>"
|
4326 |
+
data-key="<?php echo esc_attr( $key ) ?>" data-number="<?php echo esc_attr( $data['number'] ) ?>"
|
4327 |
+
data-score="<?php echo $this->field_value( $key, $default, $data ) ?>"></div>
|
4328 |
+
</div>
|
4329 |
+
</div>
|
4330 |
+
|
4331 |
+
<?php $output .= ob_get_clean();
|
4332 |
+
$output .= '</div>';
|
4333 |
+
|
4334 |
+
break;
|
4335 |
+
|
4336 |
+
}
|
4337 |
+
|
4338 |
+
// Custom filter for field output
|
4339 |
+
if ( isset( $this->set_mode ) ) {
|
4340 |
+
/**
|
4341 |
+
* UM hook
|
4342 |
+
*
|
4343 |
+
* @type filter
|
4344 |
+
* @title um_{$key}_form_show_field
|
4345 |
+
* @description Change field HTML by field $key
|
4346 |
+
* @input_vars
|
4347 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4348 |
+
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4349 |
+
* @change_log
|
4350 |
+
* ["Since: 2.0"]
|
4351 |
+
* @usage add_filter( 'um_{$key}_form_show_field', 'function_name', 10, 2 );
|
4352 |
+
* @example
|
4353 |
+
* <?php
|
4354 |
+
* add_filter( 'um_{$key}_form_show_field', 'my_form_show_field', 10, 2 );
|
4355 |
+
* function my_form_show_field( $output, $mode ) {
|
4356 |
+
* // your code here
|
4357 |
+
* return $output;
|
4358 |
+
* }
|
4359 |
+
* ?>
|
4360 |
+
*/
|
4361 |
+
$output = apply_filters( "um_{$key}_form_show_field", $output, $this->set_mode );
|
4362 |
+
/**
|
4363 |
+
* UM hook
|
4364 |
+
*
|
4365 |
+
* @type filter
|
4366 |
+
* @title um_{$type}_form_show_field
|
4367 |
+
* @description Change field HTML by field $type
|
4368 |
+
* @input_vars
|
4369 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4370 |
+
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4371 |
+
* @change_log
|
4372 |
+
* ["Since: 2.0"]
|
4373 |
+
* @usage add_filter( 'um_{$type}_form_show_field', 'function_name', 10, 2 );
|
4374 |
+
* @example
|
4375 |
+
* <?php
|
4376 |
+
* add_filter( 'um_{$type}_form_show_field', 'my_form_show_field', 10, 2 );
|
4377 |
+
* function my_form_show_field( $output, $mode ) {
|
4378 |
+
* // your code here
|
4379 |
+
* return $output;
|
4380 |
+
* }
|
4381 |
+
* ?>
|
4382 |
+
*/
|
4383 |
+
$output = apply_filters( "um_{$type}_form_show_field", $output, $this->set_mode );
|
4384 |
+
}
|
4385 |
+
|
4386 |
+
return $output;
|
4387 |
+
}
|
4388 |
+
|
4389 |
+
|
4390 |
+
/**
|
4391 |
+
* Filter field data
|
4392 |
+
*
|
4393 |
+
* @param array $data
|
4394 |
+
*
|
4395 |
+
* @return array
|
4396 |
+
*/
|
4397 |
+
function view_field_output( $data ) {
|
4398 |
+
/**
|
4399 |
+
* UM hook
|
4400 |
+
*
|
4401 |
+
* @type filter
|
4402 |
+
* @title um_view_field_output_{$type}
|
4403 |
+
* @description Change field data output by $type
|
4404 |
+
* @input_vars
|
4405 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
4406 |
+
* @change_log
|
4407 |
+
* ["Since: 2.0"]
|
4408 |
+
* @usage add_filter( 'um_view_field_output_{$type}', 'function_name', 10, 1 );
|
4409 |
+
* @example
|
4410 |
+
* <?php
|
4411 |
+
* add_filter( 'um_view_field_output_{$type}', 'my_view_field_output', 10, 1 );
|
4412 |
+
* function my_view_field_output( $data ) {
|
4413 |
+
* // your code here
|
4414 |
+
* return $data;
|
4415 |
+
* }
|
4416 |
+
* ?>
|
4417 |
+
*/
|
4418 |
+
return apply_filters( "um_view_field_output_" . $data['type'], $data );
|
4419 |
+
}
|
4420 |
+
|
4421 |
+
|
4422 |
+
/**
|
4423 |
+
* Display fields ( view mode )
|
4424 |
+
*
|
4425 |
+
* @param string $mode
|
4426 |
+
* @param array $args
|
4427 |
+
*
|
4428 |
+
* @return string|null
|
4429 |
+
* @throws \Exception
|
4430 |
+
*/
|
4431 |
+
function display_view( $mode, $args ) {
|
4432 |
+
$output = null;
|
4433 |
+
|
4434 |
+
$this->global_args = $args;
|
4435 |
+
|
4436 |
+
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
4437 |
+
|
4438 |
+
$this->set_mode = $mode;
|
4439 |
+
$this->set_id = $this->global_args['form_id'];
|
4440 |
+
|
4441 |
+
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
4442 |
+
|
4443 |
+
// start output here
|
4444 |
+
$this->get_fields = $this->get_fields();
|
4445 |
+
|
4446 |
+
if ( UM()->options()->get( 'profile_empty_text' ) ) {
|
4447 |
+
|
4448 |
+
$emo = UM()->options()->get( 'profile_empty_text_emo' );
|
4449 |
+
if ( $emo ) {
|
4450 |
+
$emo = '<i class="um-faicon-frown-o"></i>';
|
4451 |
+
} else {
|
4452 |
+
$emo = false;
|
4453 |
+
}
|
4454 |
+
|
4455 |
+
if ( um_is_myprofile() ) {
|
4456 |
+
$output .= '<p class="um-profile-note">' . $emo . '<span>' . sprintf( __( 'Your profile is looking a little empty. Why not <a href="%s">add</a> some information!', 'ultimate-member' ), esc_url( um_edit_profile_url() ) ) . '</span></p>';
|
4457 |
+
} else {
|
4458 |
+
$output .= '<p class="um-profile-note">' . $emo . '<span>' . __( 'This user has not added any information to their profile yet.', 'ultimate-member' ) . '</span></p>';
|
4459 |
+
}
|
4460 |
+
}
|
4461 |
+
|
4462 |
+
if ( ! empty( $this->get_fields ) ) {
|
4463 |
+
|
4464 |
+
// find rows
|
4465 |
+
foreach ( $this->get_fields as $key => $array ) {
|
4466 |
+
if ( $array['type'] == 'row' ) {
|
4467 |
+
$this->rows[ $key ] = $array;
|
4468 |
+
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4469 |
+
}
|
4470 |
+
}
|
4471 |
+
|
4472 |
+
// rows fallback
|
4473 |
+
if ( ! isset( $this->rows ) ) {
|
4474 |
+
$this->rows = array(
|
4475 |
+
'_um_row_1' => array(
|
4476 |
+
'type' => 'row',
|
4477 |
+
'id' => '_um_row_1',
|
4478 |
+
'sub_rows' => 1,
|
4479 |
+
'cols' => 1,
|
4480 |
+
),
|
4481 |
+
);
|
4482 |
+
}
|
4483 |
+
|
4484 |
+
// master rows
|
4485 |
+
foreach ( $this->rows as $row_id => $row_array ) {
|
4486 |
+
|
4487 |
+
$row_fields = $this->get_fields_by_row( $row_id );
|
4488 |
+
|
4489 |
+
if ( $row_fields ) {
|
4490 |
+
|
4491 |
+
$output .= $this->new_row_output( $row_id, $row_array );
|
4492 |
+
|
4493 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4494 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4495 |
+
|
4496 |
+
// cols
|
4497 |
+
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4498 |
+
if ( is_numeric( $cols ) ) {
|
4499 |
+
$cols_num = (int) $cols;
|
4500 |
+
} else {
|
4501 |
+
if ( strstr( $cols, ':' ) ) {
|
4502 |
+
$col_split = explode( ':', $cols );
|
4503 |
+
} else {
|
4504 |
+
$col_split = array( $cols );
|
4505 |
+
}
|
4506 |
+
$cols_num = $col_split[ $c ];
|
4507 |
+
}
|
4508 |
+
|
4509 |
+
// sub row fields
|
4510 |
+
$subrow_fields = null;
|
4511 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4512 |
+
|
4513 |
+
if ( is_array( $subrow_fields ) ) {
|
4514 |
+
|
4515 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4516 |
+
|
4517 |
+
if ( $cols_num == 1 ) {
|
4518 |
+
|
4519 |
+
$output .= '<div class="um-col-1">';
|
4520 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4521 |
+
if ( $col1_fields ) {
|
4522 |
+
foreach ( $col1_fields as $key => $data ) {
|
4523 |
+
|
4524 |
+
$data = $this->view_field_output( $data );
|
4525 |
+
$output .= $this->view_field( $key, $data );
|
4526 |
+
|
4527 |
+
}
|
4528 |
+
}
|
4529 |
+
$output .= '</div>';
|
4530 |
+
|
4531 |
+
} elseif ( $cols_num == 2 ) {
|
4532 |
+
|
4533 |
+
$output .= '<div class="um-col-121">';
|
4534 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4535 |
+
if ( $col1_fields ) {
|
4536 |
+
foreach ( $col1_fields as $key => $data ) {
|
4537 |
+
|
4538 |
+
$data = $this->view_field_output( $data );
|
4539 |
+
$output .= $this->view_field( $key, $data );
|
4540 |
+
|
4541 |
+
}
|
4542 |
+
}
|
4543 |
+
$output .= '</div>';
|
4544 |
+
|
4545 |
+
$output .= '<div class="um-col-122">';
|
4546 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4547 |
+
if ( $col2_fields ) {
|
4548 |
+
foreach ( $col2_fields as $key => $data ) {
|
4549 |
+
|
4550 |
+
$data = $this->view_field_output( $data );
|
4551 |
+
$output .= $this->view_field( $key, $data );
|
4552 |
+
|
4553 |
+
}
|
4554 |
+
}
|
4555 |
+
$output .= '</div><div class="um-clear"></div>';
|
4556 |
+
|
4557 |
+
} else {
|
4558 |
+
|
4559 |
+
$output .= '<div class="um-col-131">';
|
4560 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4561 |
+
if ( $col1_fields ) {
|
4562 |
+
foreach ( $col1_fields as $key => $data ) {
|
4563 |
+
|
4564 |
+
$data = $this->view_field_output( $data );
|
4565 |
+
$output .= $this->view_field( $key, $data );
|
4566 |
+
|
4567 |
+
}
|
4568 |
+
}
|
4569 |
+
$output .= '</div>';
|
4570 |
+
|
4571 |
+
$output .= '<div class="um-col-132">';
|
4572 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4573 |
+
if ( $col2_fields ) {
|
4574 |
+
foreach ( $col2_fields as $key => $data ) {
|
4575 |
+
|
4576 |
+
$data = $this->view_field_output( $data );
|
4577 |
+
$output .= $this->view_field( $key, $data );
|
4578 |
+
|
4579 |
+
}
|
4580 |
+
}
|
4581 |
+
$output .= '</div>';
|
4582 |
+
|
4583 |
+
$output .= '<div class="um-col-133">';
|
4584 |
+
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4585 |
+
if ( $col3_fields ) {
|
4586 |
+
foreach ( $col3_fields as $key => $data ) {
|
4587 |
+
|
4588 |
+
$data = $this->view_field_output( $data );
|
4589 |
+
$output .= $this->view_field( $key, $data );
|
4590 |
+
|
4591 |
+
}
|
4592 |
+
}
|
4593 |
+
$output .= '</div><div class="um-clear"></div>';
|
4594 |
+
|
4595 |
+
}
|
4596 |
+
|
4597 |
+
}
|
4598 |
+
|
4599 |
+
}
|
4600 |
+
|
4601 |
+
$output .= '</div>';
|
4602 |
+
|
4603 |
+
}
|
4604 |
+
|
4605 |
+
}
|
4606 |
+
|
4607 |
+
}
|
4608 |
+
|
4609 |
+
return $output;
|
4610 |
+
}
|
4611 |
+
|
4612 |
+
|
4613 |
+
/**
|
4614 |
+
* Get new row in form
|
4615 |
+
*
|
4616 |
+
* @param string $row_id
|
4617 |
+
* @param array $row_array
|
4618 |
+
*
|
4619 |
+
* @return string
|
4620 |
+
*/
|
4621 |
+
function new_row_output( $row_id, $row_array ) {
|
4622 |
+
$output = null;
|
4623 |
+
extract( $row_array );
|
4624 |
+
|
4625 |
+
$padding = ( isset( $padding ) ) ? $padding : '';
|
4626 |
+
$margin = ( isset( $margin ) ) ? $margin : '';
|
4627 |
+
$background = ( isset( $background ) ) ? $background : '';
|
4628 |
+
$text_color = ( isset( $text_color ) ) ? $text_color : '';
|
4629 |
+
$borderradius = ( isset( $borderradius ) ) ? $borderradius : '';
|
4630 |
+
$border = ( isset( $border ) ) ? $border : '';
|
4631 |
+
$bordercolor = ( isset( $bordercolor ) ) ? $bordercolor : '';
|
4632 |
+
$borderstyle = ( isset( $borderstyle ) ) ? $borderstyle : '';
|
4633 |
+
$heading = ( isset( $heading ) ) ? $heading : '';
|
4634 |
+
$css_class = ( isset( $css_class ) ) ? $css_class : '';
|
4635 |
+
|
4636 |
+
$css_padding = '';
|
4637 |
+
$css_margin = '';
|
4638 |
+
$css_background = '';
|
4639 |
+
$css_borderradius = '';
|
4640 |
+
$css_border = '';
|
4641 |
+
$css_bordercolor = '';
|
4642 |
+
$css_borderstyle = '';
|
4643 |
+
$css_heading_background_color = '';
|
4644 |
+
$css_heading_padding = '';
|
4645 |
+
$css_heading_text_color = '';
|
4646 |
+
$css_heading_borderradius = '';
|
4647 |
+
$css_text_color = '';
|
4648 |
+
|
4649 |
+
// row css rules
|
4650 |
+
if ( $padding ) {
|
4651 |
+
$css_padding = 'padding: ' . $padding . ';';
|
4652 |
+
}
|
4653 |
+
if ( $margin ) {
|
4654 |
+
$css_margin = 'margin: ' . $margin . ';';
|
4655 |
+
} else {
|
4656 |
+
$css_margin = 'margin: 0 0 30px 0;';
|
4657 |
+
}
|
4658 |
+
|
4659 |
+
if ( $background ) {
|
4660 |
+
$css_background = 'background-color: ' . $background . ';';
|
4661 |
+
}
|
4662 |
+
if ( $borderradius ) {
|
4663 |
+
$css_borderradius = 'border-radius: 0px 0px ' . $borderradius . ' ' . $borderradius . ';';
|
4664 |
+
}
|
4665 |
+
if ( $border ) {
|
4666 |
+
$css_border = 'border-width: ' . $border . ';';
|
4667 |
+
}
|
4668 |
+
if ( $bordercolor ) {
|
4669 |
+
$css_bordercolor = 'border-color: ' . $bordercolor . ';';
|
4670 |
+
}
|
4671 |
+
if ( $borderstyle ) {
|
4672 |
+
$css_borderstyle = 'border-style: ' . $borderstyle . ';';
|
4673 |
+
}
|
4674 |
+
if ( $text_color ) {
|
4675 |
+
$css_text_color = 'color: ' . $text_color . ' !important;';
|
4676 |
+
$css_class .= ' um-customized-row';
|
4677 |
+
}
|
4678 |
+
|
4679 |
+
// show the heading
|
4680 |
+
if ( $heading ) {
|
4681 |
+
|
4682 |
+
if ( ! empty( $heading_background_color ) ) {
|
4683 |
+
$css_heading_background_color = "background-color: $heading_background_color;";
|
4684 |
+
$css_heading_padding = 'padding: 10px 15px;';
|
4685 |
+
}
|
4686 |
+
|
4687 |
+
$css_heading_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius $borderradius 0px 0px;";
|
4688 |
+
$css_heading_border = $css_border . $css_borderstyle . $css_bordercolor . $css_heading_borderradius . 'border-bottom-width: 0px;';
|
4689 |
+
$css_heading_margin = $css_margin . 'margin-bottom: 0px;';
|
4690 |
+
$css_heading_text_color = empty( $heading_text_color ) ? '' : "color: $heading_text_color;";
|
4691 |
+
$css_icon_color = empty( $icon_color ) ? '' : "color: $icon_color;";
|
4692 |
+
|
4693 |
+
$output .= '<div class="um-row-heading" style="' . $css_heading_margin . $css_heading_padding . $css_heading_border . $css_heading_background_color . $css_heading_text_color . '">';
|
4694 |
+
|
4695 |
+
if ( ! empty( $icon ) ) {
|
4696 |
+
$output .= '<span class="um-row-heading-icon" style="' . $css_icon_color . '"><i class="' . $icon . '"></i></span>';
|
4697 |
+
}
|
4698 |
+
if ( ! empty( $heading_text ) ) {
|
4699 |
+
$output .= htmlspecialchars( $heading_text );
|
4700 |
+
}
|
4701 |
+
|
4702 |
+
$output .= '</div>';
|
4703 |
+
|
4704 |
+
$css_border .= 'border-top-width: 0px;';
|
4705 |
+
$css_margin .= 'margin-top: 0px;';
|
4706 |
+
|
4707 |
+
} else {
|
4708 |
+
|
4709 |
+
// no heading
|
4710 |
+
$css_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius;";
|
4711 |
+
|
4712 |
+
}
|
4713 |
+
|
4714 |
+
$output .= '<div class="um-row ' . $row_id . ' ' . $css_class . '" style="' . $css_padding . $css_background . $css_margin . $css_border . $css_borderstyle . $css_bordercolor . $css_borderradius . $css_text_color . '">';
|
4715 |
+
|
4716 |
+
return $output;
|
4717 |
+
}
|
4718 |
+
|
4719 |
+
|
4720 |
+
/**
|
4721 |
+
*
|
4722 |
+
*/
|
4723 |
+
function do_ajax_action() {
|
4724 |
+
UM()->admin()->check_ajax_nonce();
|
4725 |
+
|
4726 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
4727 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
4728 |
+
}
|
4729 |
+
|
4730 |
+
/**
|
4731 |
+
* @var $in_row
|
4732 |
+
* @var $in_sub_row
|
4733 |
+
* @var $in_column
|
4734 |
+
* @var $in_group
|
4735 |
+
* @var $act_id
|
4736 |
+
* @var $arg1
|
4737 |
+
* @var $arg2
|
4738 |
+
*/
|
4739 |
+
extract( $_POST );
|
4740 |
+
|
4741 |
+
$output = null;
|
4742 |
+
|
4743 |
+
$position = array();
|
4744 |
+
if ( ! empty( $in_column ) ) {
|
4745 |
+
$position['in_row'] = '_um_row_' . ( (int) $in_row + 1 );
|
4746 |
+
$position['in_sub_row'] = $in_sub_row;
|
4747 |
+
$position['in_column'] = $in_column;
|
4748 |
+
$position['in_group'] = $in_group;
|
4749 |
+
}
|
4750 |
+
|
4751 |
+
switch ( $act_id ) {
|
4752 |
+
|
4753 |
+
case 'um_admin_duplicate_field':
|
4754 |
+
$this->duplicate_field( $arg1, $arg2 );
|
4755 |
+
break;
|
4756 |
+
|
4757 |
+
case 'um_admin_remove_field_global':
|
4758 |
+
$this->delete_field_from_db( $arg1 );
|
4759 |
+
break;
|
4760 |
+
|
4761 |
+
case 'um_admin_remove_field':
|
4762 |
+
$this->delete_field_from_form( $arg1, $arg2 );
|
4763 |
+
break;
|
4764 |
+
|
4765 |
+
case 'um_admin_add_field_from_predefined':
|
4766 |
+
$this->add_field_from_predefined( $arg1, $arg2, $position );
|
4767 |
+
break;
|
4768 |
+
|
4769 |
+
case 'um_admin_add_field_from_list':
|
4770 |
+
$this->add_field_from_list( $arg1, $arg2, $position );
|
4771 |
+
break;
|
4772 |
+
|
4773 |
+
}
|
4774 |
+
|
4775 |
+
if ( is_array( $output ) ) {
|
4776 |
+
print_r( $output );
|
4777 |
+
} else {
|
4778 |
+
echo $output;
|
4779 |
+
}
|
4780 |
+
die;
|
4781 |
+
|
4782 |
+
}
|
4783 |
+
|
4784 |
+
|
4785 |
+
|
4786 |
+
/**
|
4787 |
+
* Get rendered field attributes
|
4788 |
+
*
|
4789 |
+
* @since 2.1.2
|
4790 |
+
*
|
4791 |
+
* @param string $key
|
4792 |
+
* @param array $classes
|
4793 |
+
* @param string $conditional
|
4794 |
+
* @param array $data
|
4795 |
+
* @param array $field_style
|
4796 |
+
*
|
4797 |
+
* @return string/html
|
4798 |
+
*/
|
4799 |
+
function get_atts( $key, $classes, $conditional, $data, $field_style = array() ) {
|
4800 |
+
|
4801 |
+
array_unshift( $classes, 'um-field-' . $data['type'] );
|
4802 |
+
array_unshift( $classes, 'um-field' );
|
4803 |
+
|
4804 |
+
$field_atts = array(
|
4805 |
+
'id' => array(
|
4806 |
+
"um_field_{$this->set_id}_{$key}",
|
4807 |
+
),
|
4808 |
+
'class' => $classes,
|
4809 |
+
'data-key' => array(
|
4810 |
+
esc_attr( $key )
|
4811 |
+
)
|
4812 |
+
);
|
4813 |
+
|
4814 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4815 |
+
|
4816 |
+
if ( in_array( $data['type'], $fields_without_metakey ) ) {
|
4817 |
+
unset( $field_atts['id'] );
|
4818 |
+
|
4819 |
+
if ( empty( $field_atts['data-key'] ) ) {
|
4820 |
+
unset( $field_atts['data-key'] );
|
4821 |
+
}
|
4822 |
+
}
|
4823 |
+
|
4824 |
+
if ( ! empty( $field_style ) && is_array( $field_style ) ) {
|
4825 |
+
|
4826 |
+
$arr_inline_style = '';
|
4827 |
+
foreach ( $field_style as $style_attr => $style_value ) {
|
4828 |
+
$arr_inline_style .= esc_attr( $style_attr ) . ':' . esc_attr( $style_value ) . ';';
|
4829 |
+
}
|
4830 |
+
$field_atts['style'] = array( $arr_inline_style );
|
4831 |
+
}
|
4832 |
+
|
4833 |
+
/**
|
4834 |
+
* UM hook
|
4835 |
+
*
|
4836 |
+
* @type filter
|
4837 |
+
* @title um_field_extra_atts
|
4838 |
+
* @description user for adding extra field attributes
|
4839 |
+
* @input_vars
|
4840 |
+
* [{"var":"$field_atts","type":"array","desc":"Field attributes"},
|
4841 |
+
* [{"var":"$key","type":"string","desc":"Field id"},
|
4842 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
4843 |
+
* @change_log
|
4844 |
+
* ["Since: 2.0.57"]
|
4845 |
+
* @usage add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4846 |
+
* @example
|
4847 |
+
* <?php
|
4848 |
+
* add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4849 |
+
* function function_name( $field_atts, $key, $data ) {
|
4850 |
+
* // your code here
|
4851 |
+
* return $array_extra_atts;
|
4852 |
+
* }
|
4853 |
+
* ?>
|
4854 |
+
*/
|
4855 |
+
$field_atts = apply_filters( 'um_field_extra_atts', $field_atts, $key, $data );
|
4856 |
+
|
4857 |
+
$html_atts = '';
|
4858 |
+
foreach ( $field_atts as $att_name => $att_values ) {
|
4859 |
+
$att_values = implode( " ", $att_values );
|
4860 |
+
$html_atts .= " {$att_name}=\"" . esc_attr( $att_values ) . "\"";
|
4861 |
+
}
|
4862 |
+
|
4863 |
+
$html_atts .= $conditional;
|
4864 |
+
|
4865 |
+
return $html_atts;
|
4866 |
+
}
|
4867 |
+
}
|
4868 |
+
}
|
includes/core/um-filters-fields.php
CHANGED
@@ -1,901 +1,901 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
-
exit;
|
3 |
-
}
|
4 |
-
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Field is required?
|
8 |
-
*
|
9 |
-
* @param $label
|
10 |
-
* @param $data
|
11 |
-
*
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
function um_edit_label_all_fields( $label, $data ) {
|
15 |
-
$asterisk = UM()->options()->get( 'form_asterisk' );
|
16 |
-
if ( $asterisk && isset( $data['required'] ) && $data['required'] == 1 ) {
|
17 |
-
$label = $label . '<span class="um-req" title="' . esc_attr__( 'Required', 'ultimate-member' ) . '">*</span>';
|
18 |
-
}
|
19 |
-
|
20 |
-
return $label;
|
21 |
-
}
|
22 |
-
add_filter( 'um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2 );
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Outputs a SoundCloud track
|
27 |
-
*
|
28 |
-
* @param string $value
|
29 |
-
* @param array $data
|
30 |
-
*
|
31 |
-
* @return string
|
32 |
-
*/
|
33 |
-
function um_profile_field_filter_hook__soundcloud_track( $value, $data ) {
|
34 |
-
|
35 |
-
if ( ! is_numeric( $value ) ) {
|
36 |
-
# if we're passed a track url:
|
37 |
-
if ( preg_match( '/https:\/\/soundcloud.com\/.*/', $value ) ) {
|
38 |
-
$value = '<div class="um-soundcloud">
|
39 |
-
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=' . esc_attr( urlencode( $value ) ) . '&color=ff6600&auto_play=false&show_artwork=true"></iframe>
|
40 |
-
</div>';
|
41 |
-
return $value;
|
42 |
-
} else {
|
43 |
-
# neither a track id nor url:
|
44 |
-
return __( 'Invalid SoundCloud track ID', 'ultimate-member' );
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
# if we're passed a track id:
|
49 |
-
$value = '<div class="um-soundcloud">
|
50 |
-
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . esc_attr( $value ) . '&color=ff6600&auto_play=false&show_artwork=true"></iframe>
|
51 |
-
</div>';
|
52 |
-
|
53 |
-
return $value;
|
54 |
-
}
|
55 |
-
add_filter( 'um_profile_field_filter_hook__soundcloud_track', 'um_profile_field_filter_hook__soundcloud_track', 99, 2 );
|
56 |
-
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Outputs a youtube video
|
60 |
-
*
|
61 |
-
* @param $value
|
62 |
-
* @param $data
|
63 |
-
*
|
64 |
-
* @return bool|string
|
65 |
-
*/
|
66 |
-
function um_profile_field_filter_hook__youtube_video( $value, $data ) {
|
67 |
-
if ( empty( $value ) ) {
|
68 |
-
return '';
|
69 |
-
}
|
70 |
-
$value = ( strstr( $value, 'http' ) || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
|
71 |
-
$value = '<div class="um-youtube">
|
72 |
-
<iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
|
73 |
-
</div>';
|
74 |
-
|
75 |
-
return $value;
|
76 |
-
}
|
77 |
-
add_filter( 'um_profile_field_filter_hook__youtube_video', 'um_profile_field_filter_hook__youtube_video', 99, 2 );
|
78 |
-
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Outputs a vimeo video
|
82 |
-
*
|
83 |
-
* @param $value
|
84 |
-
* @param $data
|
85 |
-
*
|
86 |
-
* @return int|string
|
87 |
-
*/
|
88 |
-
function um_profile_field_filter_hook__vimeo_video( $value, $data ) {
|
89 |
-
if ( empty( $value ) ) {
|
90 |
-
return '';
|
91 |
-
}
|
92 |
-
|
93 |
-
$value = ! is_numeric( $value ) ? (int) substr( parse_url( $value, PHP_URL_PATH ), 1 ) : $value;
|
94 |
-
$value = '<div class="um-vimeo">
|
95 |
-
<iframe src="https://player.vimeo.com/video/' . $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
|
96 |
-
</div>';
|
97 |
-
return $value;
|
98 |
-
}
|
99 |
-
add_filter( 'um_profile_field_filter_hook__vimeo_video', 'um_profile_field_filter_hook__vimeo_video', 99, 2 );
|
100 |
-
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Outputs a viber link
|
104 |
-
*
|
105 |
-
* @param $value
|
106 |
-
* @param $data
|
107 |
-
*
|
108 |
-
* @return int|string
|
109 |
-
*/
|
110 |
-
function um_profile_field_filter_hook__viber( $value, $data ) {
|
111 |
-
$value = str_replace('+', '', $value);
|
112 |
-
$value = '<a href="viber://chat?number=%2B' . esc_attr( $value ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
113 |
-
return $value;
|
114 |
-
}
|
115 |
-
add_filter( 'um_profile_field_filter_hook__viber', 'um_profile_field_filter_hook__viber', 99, 2 );
|
116 |
-
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Outputs a whatsapp link
|
120 |
-
*
|
121 |
-
* @param $value
|
122 |
-
* @param $data
|
123 |
-
*
|
124 |
-
* @return int|string
|
125 |
-
*/
|
126 |
-
function um_profile_field_filter_hook__whatsapp( $value, $data ) {
|
127 |
-
$value = str_replace('+', '', $value);
|
128 |
-
$value = '<a href="https://api.whatsapp.com/send?phone=' . esc_attr( $value ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
129 |
-
return $value;
|
130 |
-
}
|
131 |
-
add_filter( 'um_profile_field_filter_hook__whatsapp', 'um_profile_field_filter_hook__whatsapp', 99, 2 );
|
132 |
-
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Outputs a google map
|
136 |
-
*
|
137 |
-
* @param $value
|
138 |
-
* @param $data
|
139 |
-
*
|
140 |
-
* @return string
|
141 |
-
*/
|
142 |
-
function um_profile_field_filter_hook__googlemap( $value, $data ) {
|
143 |
-
if ( ! $value ) {
|
144 |
-
return '';
|
145 |
-
}
|
146 |
-
$value = '<div class="um-googlemap">
|
147 |
-
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://maps.google.it/maps?q=' . urlencode( $value ) . '&output=embed"></iframe>
|
148 |
-
</div>';
|
149 |
-
return $value;
|
150 |
-
}
|
151 |
-
add_filter( 'um_profile_field_filter_hook__googlemap', 'um_profile_field_filter_hook__googlemap', 99, 2 );
|
152 |
-
|
153 |
-
|
154 |
-
/**
|
155 |
-
* User's registration date
|
156 |
-
*
|
157 |
-
* @param $value
|
158 |
-
* @param $data
|
159 |
-
*
|
160 |
-
* @return false|int|string
|
161 |
-
*/
|
162 |
-
|
163 |
-
function um_profile_field_filter_hook__user_registered( $value, $data ) {
|
164 |
-
if ( ! $value ) {
|
165 |
-
return '';
|
166 |
-
}
|
167 |
-
$value = strtotime( $value );
|
168 |
-
$value = sprintf( __( 'Joined %s', 'ultimate-member' ), date_i18n( get_option( 'date_format' ), $value ) );
|
169 |
-
return $value;
|
170 |
-
}
|
171 |
-
add_filter( 'um_profile_field_filter_hook__user_registered', 'um_profile_field_filter_hook__user_registered', 99, 2 );
|
172 |
-
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Last login date
|
176 |
-
*
|
177 |
-
* @param $value
|
178 |
-
* @param $data
|
179 |
-
*
|
180 |
-
* @return string
|
181 |
-
*/
|
182 |
-
function um_profile_field_filter_hook__last_login( $value, $data ) {
|
183 |
-
if ( ! $value ) {
|
184 |
-
return '';
|
185 |
-
}
|
186 |
-
//$value = sprintf( __('Last login: %s','ultimate-member'), um_user_last_login( um_user('ID') ) );
|
187 |
-
$value = um_user_last_login( um_user( 'ID' ) );
|
188 |
-
return $value;
|
189 |
-
}
|
190 |
-
add_filter( 'um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
|
191 |
-
add_filter( 'um_profile_field_filter_hook___um_last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
|
192 |
-
|
193 |
-
|
194 |
-
/**
|
195 |
-
* URLs in textarea
|
196 |
-
*
|
197 |
-
* @param $value
|
198 |
-
* @param $data
|
199 |
-
*
|
200 |
-
* @return mixed|string|void
|
201 |
-
*/
|
202 |
-
function um_profile_field_filter_hook__textarea( $value, $data ) {
|
203 |
-
if ( ! $value ) {
|
204 |
-
return '';
|
205 |
-
}
|
206 |
-
if ( isset( $data['html'] ) && $data['html'] == 1 ) {
|
207 |
-
return $value;
|
208 |
-
}
|
209 |
-
|
210 |
-
$value = wp_kses( $value, 'strip' );
|
211 |
-
$value = html_entity_decode( $value );
|
212 |
-
$value = preg_replace('$(https?://[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', ' <a href="$1" target="_blank">$1</a> ', $value." ");
|
213 |
-
$value = preg_replace('$(www\.[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', '<a target="_blank" href="http://$1">$1</a> ', $value." ");
|
214 |
-
|
215 |
-
if ( ! ( isset( $data['metakey'] ) && 'description' === $data['metakey'] ) ) {
|
216 |
-
$value = wpautop( $value );
|
217 |
-
}
|
218 |
-
|
219 |
-
return $value;
|
220 |
-
}
|
221 |
-
add_filter( 'um_profile_field_filter_hook__textarea', 'um_profile_field_filter_hook__textarea', 99, 2 );
|
222 |
-
|
223 |
-
/***
|
224 |
-
*** @urls in description
|
225 |
-
***/
|
226 |
-
/* add_filter('um_profile_field_filter_hook__description', 'um_profile_field_filter_hook__description', 99, 2);
|
227 |
-
function um_profile_field_filter_hook__description( $value, $data ) {
|
228 |
-
|
229 |
-
if ( isset( $data ) && isset( $data['html'] ) && $data['html'] == 1 )
|
230 |
-
return $value;
|
231 |
-
|
232 |
-
$value = esc_textarea( $value );
|
233 |
-
$value = preg_replace('$(https?://[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', ' <a href="$1" target="_blank">$1</a> ', $value." ");
|
234 |
-
$value = preg_replace('$(www\.[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', '<a target="_blank" href="http://$1">$1</a> ', $value." ");
|
235 |
-
|
236 |
-
return $value;
|
237 |
-
}*/
|
238 |
-
|
239 |
-
|
240 |
-
/**
|
241 |
-
* Time field
|
242 |
-
*
|
243 |
-
* @param $value
|
244 |
-
* @param $data
|
245 |
-
*
|
246 |
-
* @return mixed|string
|
247 |
-
*/
|
248 |
-
function um_profile_field_filter_hook__time( $value, $data ) {
|
249 |
-
if ( ! $value ) {
|
250 |
-
return '';
|
251 |
-
}
|
252 |
-
$value = UM()->datetime()->format( $value, $data['format'] );
|
253 |
-
|
254 |
-
$value = str_replace( 'am', 'a.m.', $value );
|
255 |
-
$value = str_replace( 'pm', 'p.m.', $value );
|
256 |
-
|
257 |
-
return $value;
|
258 |
-
}
|
259 |
-
add_filter( 'um_profile_field_filter_hook__time', 'um_profile_field_filter_hook__time', 99, 2 );
|
260 |
-
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Date field
|
264 |
-
*
|
265 |
-
* @param $value
|
266 |
-
* @param $data
|
267 |
-
*
|
268 |
-
* @return string
|
269 |
-
*/
|
270 |
-
function um_profile_field_filter_hook__date( $value, $data ) {
|
271 |
-
if ( ! $value ) {
|
272 |
-
return '';
|
273 |
-
}
|
274 |
-
if ( isset( $data['pretty_format'] ) && $data['pretty_format'] == 1 ) {
|
275 |
-
$value = UM()->datetime()->get_age( $value );
|
276 |
-
} else {
|
277 |
-
$format = empty( $data['format_custom'] ) ? $data['format'] : $data['format_custom'];
|
278 |
-
$value = date_i18n( $format, strtotime( $value ) );
|
279 |
-
}
|
280 |
-
|
281 |
-
return $value;
|
282 |
-
}
|
283 |
-
add_filter( 'um_profile_field_filter_hook__date', 'um_profile_field_filter_hook__date', 99, 2 );
|
284 |
-
|
285 |
-
|
286 |
-
/**
|
287 |
-
* File field
|
288 |
-
* @param $value
|
289 |
-
* @param $data
|
290 |
-
*
|
291 |
-
* @return string
|
292 |
-
*/
|
293 |
-
function um_profile_field_filter_hook__file( $value, $data ) {
|
294 |
-
if ( ! $value ) {
|
295 |
-
return '';
|
296 |
-
}
|
297 |
-
$file_type = wp_check_filetype( $value );
|
298 |
-
$uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) );
|
299 |
-
|
300 |
-
$removed = false;
|
301 |
-
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) {
|
302 |
-
if ( is_multisite() ) {
|
303 |
-
//multisite fix for old customers
|
304 |
-
$file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value );
|
305 |
-
if ( ! file_exists( $file_path ) ) {
|
306 |
-
$removed = true;
|
307 |
-
}
|
308 |
-
} else {
|
309 |
-
$removed = true;
|
310 |
-
}
|
311 |
-
}
|
312 |
-
|
313 |
-
if ( $removed ) {
|
314 |
-
$value = __( 'This file has been removed.', 'ultimate-member' );
|
315 |
-
} else {
|
316 |
-
$file_info = um_user( $data['metakey'] . "_metadata" );
|
317 |
-
if ( ! empty( $file_info['original_name'] ) ) {
|
318 |
-
$value = $file_info['original_name'];
|
319 |
-
}
|
320 |
-
$value = '<div class="um-single-file-preview show">
|
321 |
-
<div class="um-single-fileinfo">
|
322 |
-
<a href="' . esc_attr( $uri ) . '" target="_blank">
|
323 |
-
<span class="icon" style="background:'. UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . '"><i class="'. UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) .'"></i></span>
|
324 |
-
<span class="filename">' . esc_attr( $value ) . '</span>
|
325 |
-
</a>
|
326 |
-
</div>
|
327 |
-
</div>';
|
328 |
-
}
|
329 |
-
|
330 |
-
return $value;
|
331 |
-
}
|
332 |
-
add_filter( 'um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file', 99, 2 );
|
333 |
-
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Image field
|
337 |
-
*
|
338 |
-
* @param $value
|
339 |
-
* @param $data
|
340 |
-
*
|
341 |
-
* @return string
|
342 |
-
*/
|
343 |
-
function um_profile_field_filter_hook__image( $value, $data ) {
|
344 |
-
if ( ! $value ) {
|
345 |
-
return '';
|
346 |
-
}
|
347 |
-
$uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) );
|
348 |
-
$title = ( isset( $data['title'] ) ) ? $data['title'] : __( 'Untitled photo', 'ultimate-member' );
|
349 |
-
|
350 |
-
$removed = false;
|
351 |
-
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) {
|
352 |
-
if ( is_multisite() ) {
|
353 |
-
//multisite fix for old customers
|
354 |
-
$file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value );
|
355 |
-
if ( ! file_exists( $file_path ) ) {
|
356 |
-
$removed = true;
|
357 |
-
}
|
358 |
-
} else {
|
359 |
-
$removed = true;
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
// if value is an image tag
|
364 |
-
if( preg_match( '/\<img.*src=\"([^"]+).*/', $value, $matches ) ) {
|
365 |
-
$uri = $matches[1];
|
366 |
-
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . esc_attr( $uri ) . '"><img src="' . esc_attr( $uri ) . '" alt="' . esc_attr( $title ) . '" title="' . esc_attr( $title ) . '" class="" /></a></div>';
|
367 |
-
} else if ( ! $removed ) {
|
368 |
-
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . esc_attr( $uri ) . '"><img src="' . esc_attr( $uri ) . '" alt="' . esc_attr( $title ) . '" title="' . esc_attr( $title ) . '" class="" /></a></div>';
|
369 |
-
} else {
|
370 |
-
$value = '';
|
371 |
-
}
|
372 |
-
|
373 |
-
return $value;
|
374 |
-
}
|
375 |
-
add_filter( 'um_profile_field_filter_hook__image', 'um_profile_field_filter_hook__image', 99, 2 );
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Global sanitize
|
379 |
-
*
|
380 |
-
* @param $value
|
381 |
-
* @param $data
|
382 |
-
* @param string $type
|
383 |
-
*
|
384 |
-
* @return string
|
385 |
-
*/
|
386 |
-
function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
387 |
-
if ( ! $value ) {
|
388 |
-
return '';
|
389 |
-
}
|
390 |
-
|
391 |
-
if ( isset( $data['type'] ) && 'text' === $data['type'] && isset( $data['validate'] ) && 'skype' === $data['validate'] ) {
|
392 |
-
$alt = ! empty( $data['url_text'] ) ? $data['url_text'] : $value;
|
393 |
-
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
394 |
-
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
395 |
-
|
396 |
-
if ( false === strstr( $value, 'join.skype.com' ) ) {
|
397 |
-
$value = 'skype:' . $value . '?chat';
|
398 |
-
}
|
399 |
-
|
400 |
-
$value = '<a href="'. esc_attr( $value ) .'" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . '>' . esc_html( $alt ) . '</a>';
|
401 |
-
} else {
|
402 |
-
if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
403 |
-
$alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
404 |
-
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
405 |
-
if ( ! strstr( $value, 'http' )
|
406 |
-
&& !strstr( $value, '://' )
|
407 |
-
&& !strstr( $value, 'www.' )
|
408 |
-
&& !strstr( $value, '.com' )
|
409 |
-
&& !strstr( $value, '.net' )
|
410 |
-
&& !strstr( $value, '.org' )
|
411 |
-
&& !strstr( $value, '.me' )
|
412 |
-
) {
|
413 |
-
if ( $data['validate'] == 'soundcloud_url' ) $value = 'https://soundcloud.com/' . $value;
|
414 |
-
if ( $data['validate'] == 'youtube_url' ) $value = 'https://youtube.com/user/' . $value;
|
415 |
-
if ( $data['validate'] == 'telegram_url' ) $value = 'https://t.me/' . $value;
|
416 |
-
if ( $data['validate'] == 'facebook_url' ) $value = 'https://facebook.com/' . $value;
|
417 |
-
if ( $data['validate'] == 'twitter_url' ) $value = 'https://twitter.com/' . $value;
|
418 |
-
if ( $data['validate'] == 'linkedin_url' ) $value = 'https://linkedin.com/' . $value;
|
419 |
-
if ( $data['validate'] == 'googleplus_url' ) $value = 'https://plus.google.com/' . $value;
|
420 |
-
if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value;
|
421 |
-
if ( $data['validate'] == 'vk_url' ) $value = 'https://vk.com/' . $value;
|
422 |
-
}
|
423 |
-
|
424 |
-
if ( strpos( $value, 'http://' ) !== 0 ) {
|
425 |
-
$value = 'http://' . $value;
|
426 |
-
}
|
427 |
-
|
428 |
-
$value = str_replace('https://https://','https://',$value);
|
429 |
-
$value = str_replace('http://https://','https://',$value);
|
430 |
-
|
431 |
-
$onclick_alert = '';
|
432 |
-
if ( $value !== wp_validate_redirect( $value ) ) {
|
433 |
-
$onclick_alert = ' onclick="return confirm( \'' . sprintf( __( 'This link leads to a 3rd-party website. Make sure the link is safe and you really want to go to this website: `%s`', 'ultimate-member' ), $value ) . '\' );"';
|
434 |
-
}
|
435 |
-
|
436 |
-
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
437 |
-
$value = '<a href="'. esc_url( $value ) .'" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . $onclick_alert . '>' . esc_html( $alt ) . '</a>';
|
438 |
-
}
|
439 |
-
}
|
440 |
-
|
441 |
-
if ( ! is_array( $value ) ) {
|
442 |
-
if ( is_email( $value ) ) {
|
443 |
-
$value = '<a href="mailto:'. $value.'" title="'.$value.'">'.$value.'</a>';
|
444 |
-
}
|
445 |
-
} else {
|
446 |
-
$value = implode( ', ', $value );
|
447 |
-
}
|
448 |
-
|
449 |
-
$value = str_replace('https://https://','https://',$value);
|
450 |
-
$value = str_replace('http://https://','https://',$value);
|
451 |
-
//$value = UM()->shortcodes()->emotize( $value );
|
452 |
-
return $value;
|
453 |
-
|
454 |
-
}
|
455 |
-
add_filter( 'um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 3 );
|
456 |
-
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Get form fields
|
460 |
-
*
|
461 |
-
* @param $array
|
462 |
-
*
|
463 |
-
* @return mixed|string
|
464 |
-
*/
|
465 |
-
function um_get_form_fields( $array ) {
|
466 |
-
|
467 |
-
$form_id = (isset ( UM()->fields()->set_id ) ) ? UM()->fields()->set_id : null;
|
468 |
-
$mode = (isset( UM()->fields()->set_mode ) ) ? UM()->fields()->set_mode : null;
|
469 |
-
|
470 |
-
if ( $form_id && $mode ) {
|
471 |
-
$array = UM()->query()->get_attr('custom_fields', $form_id );
|
472 |
-
} else {
|
473 |
-
$array = '';
|
474 |
-
}
|
475 |
-
|
476 |
-
return $array;
|
477 |
-
|
478 |
-
}
|
479 |
-
add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 );
|
480 |
-
|
481 |
-
|
482 |
-
/**
|
483 |
-
* Validate conditional logic
|
484 |
-
*
|
485 |
-
* @param $array
|
486 |
-
* @param $fields
|
487 |
-
* @return mixed
|
488 |
-
*/
|
489 |
-
function um_get_custom_field_array( $array, $fields ) {
|
490 |
-
|
491 |
-
if ( ! empty( $array['conditions'] ) ) {
|
492 |
-
foreach ( $array['conditions'] as $key => $value ) {
|
493 |
-
if ( ! isset( $value[1] ) ) {
|
494 |
-
continue;
|
495 |
-
}
|
496 |
-
|
497 |
-
if ( empty( $fields[ $value[1] ] ) ) {
|
498 |
-
continue;
|
499 |
-
}
|
500 |
-
|
501 |
-
if ( empty( $fields[ $value[1] ]['metakey'] ) ) {
|
502 |
-
continue;
|
503 |
-
}
|
504 |
-
|
505 |
-
$condition_metakey = $fields[ $value[1] ]['metakey'];
|
506 |
-
|
507 |
-
if ( isset( $_POST[ $condition_metakey ] ) ) {
|
508 |
-
$cond_value = ( $fields[ $value[1] ]['type'] === 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
|
509 |
-
list( $visibility, $parent_key, $op, $parent_value ) = $value;
|
510 |
-
|
511 |
-
if ( $visibility == 'hide' ) {
|
512 |
-
if ( $op == 'empty' ) {
|
513 |
-
if ( empty( $cond_value ) ) {
|
514 |
-
$array['required'] = 0;
|
515 |
-
}
|
516 |
-
} elseif ( $op == 'not empty' ) {
|
517 |
-
if ( ! empty( $cond_value ) ) {
|
518 |
-
$array['required'] = 0;
|
519 |
-
}
|
520 |
-
} elseif ( $op == 'equals to' ) {
|
521 |
-
if ( $cond_value == $parent_value ) {
|
522 |
-
$array['required'] = 0;
|
523 |
-
}
|
524 |
-
} elseif ( $op == 'not equals' ) {
|
525 |
-
if ( $cond_value != $parent_value ) {
|
526 |
-
$array['required'] = 0;
|
527 |
-
}
|
528 |
-
} elseif ( $op == 'greater than' ) {
|
529 |
-
if ( $cond_value > $parent_value ) {
|
530 |
-
$array['required'] = 0;
|
531 |
-
}
|
532 |
-
} elseif ( $op == 'less than' ) {
|
533 |
-
if ( $cond_value < $parent_value ) {
|
534 |
-
$array['required'] = 0;
|
535 |
-
}
|
536 |
-
} elseif ( $op == 'contains' ) {
|
537 |
-
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
538 |
-
$array['required'] = 0;
|
539 |
-
}
|
540 |
-
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
541 |
-
$array['required'] = 0;
|
542 |
-
}
|
543 |
-
}
|
544 |
-
} elseif ( $visibility == 'show' ) {
|
545 |
-
if ( $op == 'empty' ) {
|
546 |
-
if ( ! empty( $cond_value ) ) {
|
547 |
-
$array['required'] = 0;
|
548 |
-
}
|
549 |
-
} elseif ( $op == 'not empty' ) {
|
550 |
-
if ( empty( $cond_value ) ) {
|
551 |
-
$array['required'] = 0;
|
552 |
-
}
|
553 |
-
} elseif ( $op == 'equals to' ) {
|
554 |
-
if ( $cond_value != $parent_value ) {
|
555 |
-
$array['required'] = 0;
|
556 |
-
}
|
557 |
-
} elseif ( $op == 'not equals' ) {
|
558 |
-
if ( $cond_value == $parent_value ) {
|
559 |
-
$array['required'] = 0;
|
560 |
-
}
|
561 |
-
} elseif ( $op == 'greater than' ) {
|
562 |
-
if ( $cond_value <= $parent_value ) {
|
563 |
-
$array['required'] = 0;
|
564 |
-
}
|
565 |
-
} elseif ( $op == 'less than' ) {
|
566 |
-
if ( $cond_value >= $parent_value ) {
|
567 |
-
$array['required'] = 0;
|
568 |
-
}
|
569 |
-
} elseif ( $op == 'contains' ) {
|
570 |
-
if( is_string( $cond_value ) && !strstr( $cond_value, $parent_value ) ) {
|
571 |
-
$array['required'] = 0;
|
572 |
-
}
|
573 |
-
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
574 |
-
$array['required'] = 0;
|
575 |
-
}
|
576 |
-
}
|
577 |
-
}
|
578 |
-
}
|
579 |
-
}
|
580 |
-
}
|
581 |
-
|
582 |
-
return $array;
|
583 |
-
}
|
584 |
-
add_filter( 'um_get_custom_field_array', 'um_get_custom_field_array', 99, 2 );
|
585 |
-
|
586 |
-
|
587 |
-
/**
|
588 |
-
* Force fields to use UTF-8 encoding
|
589 |
-
*
|
590 |
-
* @param mixed $value
|
591 |
-
* @param array $data
|
592 |
-
* @param string $type
|
593 |
-
*
|
594 |
-
* @return mixed
|
595 |
-
*/
|
596 |
-
function um_force_utf8_fields( $value, $data, $type = '' ) {
|
597 |
-
|
598 |
-
if( ! UM()->options()->get('um_force_utf8_strings') )
|
599 |
-
return $value;
|
600 |
-
|
601 |
-
$value = um_force_utf8_string( $value );
|
602 |
-
|
603 |
-
return $value;
|
604 |
-
|
605 |
-
}
|
606 |
-
add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 9, 3 );
|
607 |
-
|
608 |
-
|
609 |
-
/**
|
610 |
-
* Filter profile data value
|
611 |
-
* @param mixed $value
|
612 |
-
* @return mixed
|
613 |
-
* @uses hook filter: um_is_selected_filter_value
|
614 |
-
*/
|
615 |
-
function um_is_selected_filter_value( $value ) {
|
616 |
-
if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) {
|
617 |
-
return $value;
|
618 |
-
}
|
619 |
-
|
620 |
-
$value = um_force_utf8_string( $value );
|
621 |
-
|
622 |
-
return $value;
|
623 |
-
}
|
624 |
-
add_filter( 'um_is_selected_filter_value','um_is_selected_filter_value', 9, 1 );
|
625 |
-
add_filter( 'um_select_dropdown_dynamic_option_value','um_is_selected_filter_value', 10, 1 );
|
626 |
-
|
627 |
-
/**
|
628 |
-
* Filter select dropdown to use UTF-8 encoding
|
629 |
-
*
|
630 |
-
* @param array $options
|
631 |
-
* @param array $data
|
632 |
-
* @return array
|
633 |
-
* @uses hook filter: um_select_dropdown_dynamic_options
|
634 |
-
*/
|
635 |
-
function um_select_dropdown_dynamic_options_to_utf8( $options, $data ) {
|
636 |
-
if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) {
|
637 |
-
return $options;
|
638 |
-
}
|
639 |
-
|
640 |
-
foreach ( $options as $key => $value ) {
|
641 |
-
$options[ $key ] = um_force_utf8_string( $value );
|
642 |
-
}
|
643 |
-
|
644 |
-
return $options;
|
645 |
-
}
|
646 |
-
add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_options_to_utf8', 10, 2 );
|
647 |
-
|
648 |
-
|
649 |
-
/**
|
650 |
-
* Filter non-UTF8 strings
|
651 |
-
* @param string $value
|
652 |
-
* @return string
|
653 |
-
* @uses hook filter: um_field_non_utf8_value
|
654 |
-
*/
|
655 |
-
function um_field_non_utf8_value( $value ) {
|
656 |
-
|
657 |
-
if ( function_exists( 'mb_detect_encoding' ) ) {
|
658 |
-
$encoding = mb_detect_encoding( $value, 'utf-8, iso-8859-1, ascii', true );
|
659 |
-
if ( strcasecmp( $encoding, 'UTF-8' ) !== 0 ) {
|
660 |
-
$value = iconv( $encoding, 'utf-8', $value );
|
661 |
-
}
|
662 |
-
}
|
663 |
-
|
664 |
-
return $value;
|
665 |
-
}
|
666 |
-
add_filter( 'um_field_non_utf8_value', 'um_field_non_utf8_value' );
|
667 |
-
|
668 |
-
|
669 |
-
/**
|
670 |
-
* Returns dropdown/multi-select options from a callback function
|
671 |
-
* @param $options array
|
672 |
-
* @param $data array
|
673 |
-
* @return array
|
674 |
-
* @uses hook filter: um_select_dropdown_dynamic_options, um_multiselect_options
|
675 |
-
*/
|
676 |
-
function um_select_dropdown_dynamic_callback_options( $options, $data ) {
|
677 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) ) {
|
678 |
-
$options = call_user_func( $data['custom_dropdown_options_source'] );
|
679 |
-
}
|
680 |
-
|
681 |
-
return $options;
|
682 |
-
}
|
683 |
-
add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_callback_options', 10, 2 );
|
684 |
-
add_filter( 'um_multiselect_options','um_select_dropdown_dynamic_callback_options', 10, 2 );
|
685 |
-
|
686 |
-
|
687 |
-
/**
|
688 |
-
* Pair dropdown/multi-select options from a callback function
|
689 |
-
*
|
690 |
-
* @param $value string
|
691 |
-
* @param $data array
|
692 |
-
* @return string
|
693 |
-
* @uses hook filter: um_profile_field_filter_hook__
|
694 |
-
*/
|
695 |
-
|
696 |
-
function um_option_match_callback_view_field( $value, $data ) {
|
697 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
698 |
-
return UM()->fields()->get_option_value_from_callback( $value, $data, $data['type'] );
|
699 |
-
}
|
700 |
-
|
701 |
-
return $value;
|
702 |
-
}
|
703 |
-
add_filter('um_profile_field_filter_hook__select','um_option_match_callback_view_field', 10, 2);
|
704 |
-
add_filter('um_profile_field_filter_hook__multiselect','um_option_match_callback_view_field', 10, 2);
|
705 |
-
add_filter('um_field_select_default_value','um_option_match_callback_view_field', 10, 2);
|
706 |
-
add_filter('um_field_multiselect_default_value','um_option_match_callback_view_field', 10, 2);
|
707 |
-
|
708 |
-
|
709 |
-
/**
|
710 |
-
* Apply textdomain in select/multi-select options
|
711 |
-
*
|
712 |
-
* @param $value string
|
713 |
-
* @param $data array
|
714 |
-
* @return string
|
715 |
-
* @uses hook filters: um_profile_field_filter_hook__select, um_profile_field_filter_hook__multiselect
|
716 |
-
*/
|
717 |
-
|
718 |
-
function um_profile_field__select_translate( $value, $data ) {
|
719 |
-
|
720 |
-
if ( empty( $value ) ) return $value;
|
721 |
-
|
722 |
-
$options = explode(", ", $value );
|
723 |
-
$arr_options = array();
|
724 |
-
if( is_array( $options ) ){
|
725 |
-
foreach ( $options as $item ) {
|
726 |
-
$arr_options[] = __( $item, 'ultimate-member' );
|
727 |
-
}
|
728 |
-
}
|
729 |
-
|
730 |
-
$value = implode(", ", $arr_options);
|
731 |
-
|
732 |
-
return $value;
|
733 |
-
}
|
734 |
-
add_filter( 'um_profile_field_filter_hook__select','um_profile_field__select_translate', 10, 2 );
|
735 |
-
add_filter( 'um_profile_field_filter_hook__multiselect','um_profile_field__select_translate', 10, 2 );
|
736 |
-
|
737 |
-
|
738 |
-
/**
|
739 |
-
* Cleaning on XSS injection
|
740 |
-
* @param $value string
|
741 |
-
* @param $data array
|
742 |
-
* @param string $type
|
743 |
-
* @return string $value
|
744 |
-
* @uses hook filters: um_profile_field_filter_hook__
|
745 |
-
*/
|
746 |
-
function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) {
|
747 |
-
if ( ! empty( $value ) && is_string( $value ) ) {
|
748 |
-
$value = stripslashes( $value );
|
749 |
-
$data['validate'] = isset( $data['validate'] ) ? $data['validate'] : '';
|
750 |
-
|
751 |
-
if ( 'text' == $type && ! in_array( $data['validate'], array( 'unique_email' ) ) || 'password' == $type ) {
|
752 |
-
$value = esc_attr( $value );
|
753 |
-
} elseif ( $type == 'url' ) {
|
754 |
-
$value = esc_url( $value );
|
755 |
-
} elseif ( 'textarea' == $type ) {
|
756 |
-
if ( empty( $data['html'] ) ) {
|
757 |
-
$value = wp_kses_post( $value );
|
758 |
-
}
|
759 |
-
} elseif ( 'rating' == $type ) {
|
760 |
-
if ( ! is_numeric( $value ) ) {
|
761 |
-
$value = 0;
|
762 |
-
} else {
|
763 |
-
if ( $data['number'] == 5 ) {
|
764 |
-
if ( ! in_array( $value, range( 1, 5 ) ) ) {
|
765 |
-
$value = 0;
|
766 |
-
}
|
767 |
-
} elseif ( $data['number'] == 10 ) {
|
768 |
-
if ( ! in_array( $value, range( 1, 10 ) ) ) {
|
769 |
-
$value = 0;
|
770 |
-
}
|
771 |
-
}
|
772 |
-
}
|
773 |
-
} elseif ( 'select' == $type || 'radio' == $type ) {
|
774 |
-
|
775 |
-
/**
|
776 |
-
* UM hook
|
777 |
-
*
|
778 |
-
* @type filter
|
779 |
-
* @title um_select_option_value
|
780 |
-
* @description Enable options pair by field $data
|
781 |
-
* @input_vars
|
782 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
783 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
784 |
-
*/
|
785 |
-
$option_pairs = apply_filters( 'um_select_options_pair', null, $data );
|
786 |
-
|
787 |
-
$array = empty( $data['options'] ) ? array() : $data['options'];
|
788 |
-
|
789 |
-
if ( $data['metakey'] == 'country' && empty( $array ) ) {
|
790 |
-
$array = UM()->builtin()->get( 'countries' );
|
791 |
-
}
|
792 |
-
|
793 |
-
if ( $option_pairs ) {
|
794 |
-
$arr = array_keys( $array );
|
795 |
-
} else {
|
796 |
-
$arr = $array;
|
797 |
-
}
|
798 |
-
|
799 |
-
if ( ! empty( $arr ) && ! in_array( $value, array_map( 'trim', $arr ) ) && empty( $data['custom_dropdown_options_source'] ) ) {
|
800 |
-
$value = '';
|
801 |
-
} else {
|
802 |
-
if ( $option_pairs && is_array( $array ) && isset( $array[ $value ] ) ) {
|
803 |
-
$value = $array[ $value ];
|
804 |
-
}
|
805 |
-
}
|
806 |
-
}
|
807 |
-
} elseif ( ! empty( $value ) && is_array( $value ) ) {
|
808 |
-
if ( 'multiselect' == $type || 'checkbox' == $type ) {
|
809 |
-
|
810 |
-
/**
|
811 |
-
* UM hook
|
812 |
-
*
|
813 |
-
* @type filter
|
814 |
-
* @title um_select_option_value
|
815 |
-
* @description Enable options pair by field $data
|
816 |
-
* @input_vars
|
817 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
818 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
819 |
-
*/
|
820 |
-
$option_pairs = apply_filters( 'um_select_options_pair', null, $data );
|
821 |
-
|
822 |
-
$arr = $data['options'];
|
823 |
-
if ( $option_pairs ) {
|
824 |
-
$arr = array_keys( $data['options'] );
|
825 |
-
}
|
826 |
-
|
827 |
-
if ( ! empty( $arr ) && empty( $data['custom_dropdown_options_source'] ) ) {
|
828 |
-
$arr = wp_unslash( $arr );
|
829 |
-
$arr = wp_slash( array_map( 'trim', $arr ) );
|
830 |
-
$value = array_intersect( $value, $arr );
|
831 |
-
}
|
832 |
-
|
833 |
-
if ( $option_pairs ) {
|
834 |
-
foreach ( $value as &$val ) {
|
835 |
-
$val = $data['options'][ $val ];
|
836 |
-
}
|
837 |
-
}
|
838 |
-
}
|
839 |
-
}
|
840 |
-
|
841 |
-
return $value;
|
842 |
-
}
|
843 |
-
add_filter( 'um_profile_field_filter_hook__', 'um_profile_field_filter_xss_validation', 10, 3 );
|
844 |
-
|
845 |
-
|
846 |
-
/**
|
847 |
-
* Trim All form POST submitted data
|
848 |
-
*
|
849 |
-
* @param $post_form
|
850 |
-
* @param $mode
|
851 |
-
*
|
852 |
-
* @return mixed
|
853 |
-
*/
|
854 |
-
function um_submit_form_data_trim_fields( $post_form, $mode ) {
|
855 |
-
foreach ( $post_form as $key => $field ) {
|
856 |
-
if ( is_string( $field ) ) {
|
857 |
-
$post_form[ $key ] = trim( $field );
|
858 |
-
}
|
859 |
-
}
|
860 |
-
|
861 |
-
return $post_form;
|
862 |
-
}
|
863 |
-
add_filter( 'um_submit_form_data', 'um_submit_form_data_trim_fields', 9, 2 );
|
864 |
-
|
865 |
-
|
866 |
-
/**
|
867 |
-
* add role_select and role_radio to the $post_form
|
868 |
-
* It is necessary for that if on these fields the conditional logic
|
869 |
-
* @param $post_form array
|
870 |
-
* @param $mode
|
871 |
-
*
|
872 |
-
* @return $post_form
|
873 |
-
* @uses hook filters: um_submit_form_data
|
874 |
-
*/
|
875 |
-
function um_submit_form_data_role_fields( $post_form, $mode ) {
|
876 |
-
$custom_fields = unserialize( $post_form['custom_fields'] );
|
877 |
-
if ( ! empty( $post_form['role'] ) && array_key_exists( 'role_select', $custom_fields ) ) {
|
878 |
-
$post_form['role_select'] = $post_form['role'];
|
879 |
-
}
|
880 |
-
if (! empty( $post_form['role'] ) && array_key_exists( 'role_radio', $custom_fields ) ) {
|
881 |
-
$post_form['role_radio'] = $post_form['role'];
|
882 |
-
}
|
883 |
-
|
884 |
-
return $post_form;
|
885 |
-
}
|
886 |
-
add_filter( 'um_submit_form_data', 'um_submit_form_data_role_fields', 10, 2 );
|
887 |
-
|
888 |
-
|
889 |
-
/**
|
890 |
-
* Cleaning on XSS injection for url editing field
|
891 |
-
* @param $value string
|
892 |
-
* @param $key string
|
893 |
-
*
|
894 |
-
* @return string $value
|
895 |
-
* @uses hook filters: um_edit_url_field_value
|
896 |
-
*/
|
897 |
-
function um_edit_url_field_value( $value, $key ) {
|
898 |
-
$value = esc_attr( $value );
|
899 |
-
return $value;
|
900 |
-
}
|
901 |
-
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
+
}
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Field is required?
|
8 |
+
*
|
9 |
+
* @param $label
|
10 |
+
* @param $data
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
function um_edit_label_all_fields( $label, $data ) {
|
15 |
+
$asterisk = UM()->options()->get( 'form_asterisk' );
|
16 |
+
if ( $asterisk && isset( $data['required'] ) && $data['required'] == 1 ) {
|
17 |
+
$label = $label . '<span class="um-req" title="' . esc_attr__( 'Required', 'ultimate-member' ) . '">*</span>';
|
18 |
+
}
|
19 |
+
|
20 |
+
return $label;
|
21 |
+
}
|
22 |
+
add_filter( 'um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2 );
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Outputs a SoundCloud track
|
27 |
+
*
|
28 |
+
* @param string $value
|
29 |
+
* @param array $data
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
function um_profile_field_filter_hook__soundcloud_track( $value, $data ) {
|
34 |
+
|
35 |
+
if ( ! is_numeric( $value ) ) {
|
36 |
+
# if we're passed a track url:
|
37 |
+
if ( preg_match( '/https:\/\/soundcloud.com\/.*/', $value ) ) {
|
38 |
+
$value = '<div class="um-soundcloud">
|
39 |
+
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=' . esc_attr( urlencode( $value ) ) . '&color=ff6600&auto_play=false&show_artwork=true"></iframe>
|
40 |
+
</div>';
|
41 |
+
return $value;
|
42 |
+
} else {
|
43 |
+
# neither a track id nor url:
|
44 |
+
return __( 'Invalid SoundCloud track ID', 'ultimate-member' );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
# if we're passed a track id:
|
49 |
+
$value = '<div class="um-soundcloud">
|
50 |
+
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . esc_attr( $value ) . '&color=ff6600&auto_play=false&show_artwork=true"></iframe>
|
51 |
+
</div>';
|
52 |
+
|
53 |
+
return $value;
|
54 |
+
}
|
55 |
+
add_filter( 'um_profile_field_filter_hook__soundcloud_track', 'um_profile_field_filter_hook__soundcloud_track', 99, 2 );
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Outputs a youtube video
|
60 |
+
*
|
61 |
+
* @param $value
|
62 |
+
* @param $data
|
63 |
+
*
|
64 |
+
* @return bool|string
|
65 |
+
*/
|
66 |
+
function um_profile_field_filter_hook__youtube_video( $value, $data ) {
|
67 |
+
if ( empty( $value ) ) {
|
68 |
+
return '';
|
69 |
+
}
|
70 |
+
$value = ( strstr( $value, 'http' ) || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
|
71 |
+
$value = '<div class="um-youtube">
|
72 |
+
<iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
|
73 |
+
</div>';
|
74 |
+
|
75 |
+
return $value;
|
76 |
+
}
|
77 |
+
add_filter( 'um_profile_field_filter_hook__youtube_video', 'um_profile_field_filter_hook__youtube_video', 99, 2 );
|
78 |
+
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Outputs a vimeo video
|
82 |
+
*
|
83 |
+
* @param $value
|
84 |
+
* @param $data
|
85 |
+
*
|
86 |
+
* @return int|string
|
87 |
+
*/
|
88 |
+
function um_profile_field_filter_hook__vimeo_video( $value, $data ) {
|
89 |
+
if ( empty( $value ) ) {
|
90 |
+
return '';
|
91 |
+
}
|
92 |
+
|
93 |
+
$value = ! is_numeric( $value ) ? (int) substr( parse_url( $value, PHP_URL_PATH ), 1 ) : $value;
|
94 |
+
$value = '<div class="um-vimeo">
|
95 |
+
<iframe src="https://player.vimeo.com/video/' . $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
|
96 |
+
</div>';
|
97 |
+
return $value;
|
98 |
+
}
|
99 |
+
add_filter( 'um_profile_field_filter_hook__vimeo_video', 'um_profile_field_filter_hook__vimeo_video', 99, 2 );
|
100 |
+
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Outputs a viber link
|
104 |
+
*
|
105 |
+
* @param $value
|
106 |
+
* @param $data
|
107 |
+
*
|
108 |
+
* @return int|string
|
109 |
+
*/
|
110 |
+
function um_profile_field_filter_hook__viber( $value, $data ) {
|
111 |
+
$value = str_replace('+', '', $value);
|
112 |
+
$value = '<a href="viber://chat?number=%2B' . esc_attr( $value ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
113 |
+
return $value;
|
114 |
+
}
|
115 |
+
add_filter( 'um_profile_field_filter_hook__viber', 'um_profile_field_filter_hook__viber', 99, 2 );
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Outputs a whatsapp link
|
120 |
+
*
|
121 |
+
* @param $value
|
122 |
+
* @param $data
|
123 |
+
*
|
124 |
+
* @return int|string
|
125 |
+
*/
|
126 |
+
function um_profile_field_filter_hook__whatsapp( $value, $data ) {
|
127 |
+
$value = str_replace('+', '', $value);
|
128 |
+
$value = '<a href="https://api.whatsapp.com/send?phone=' . esc_attr( $value ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
129 |
+
return $value;
|
130 |
+
}
|
131 |
+
add_filter( 'um_profile_field_filter_hook__whatsapp', 'um_profile_field_filter_hook__whatsapp', 99, 2 );
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Outputs a google map
|
136 |
+
*
|
137 |
+
* @param $value
|
138 |
+
* @param $data
|
139 |
+
*
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
function um_profile_field_filter_hook__googlemap( $value, $data ) {
|
143 |
+
if ( ! $value ) {
|
144 |
+
return '';
|
145 |
+
}
|
146 |
+
$value = '<div class="um-googlemap">
|
147 |
+
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://maps.google.it/maps?q=' . urlencode( $value ) . '&output=embed"></iframe>
|
148 |
+
</div>';
|
149 |
+
return $value;
|
150 |
+
}
|
151 |
+
add_filter( 'um_profile_field_filter_hook__googlemap', 'um_profile_field_filter_hook__googlemap', 99, 2 );
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* User's registration date
|
156 |
+
*
|
157 |
+
* @param $value
|
158 |
+
* @param $data
|
159 |
+
*
|
160 |
+
* @return false|int|string
|
161 |
+
*/
|
162 |
+
|
163 |
+
function um_profile_field_filter_hook__user_registered( $value, $data ) {
|
164 |
+
if ( ! $value ) {
|
165 |
+
return '';
|
166 |
+
}
|
167 |
+
$value = strtotime( $value );
|
168 |
+
$value = sprintf( __( 'Joined %s', 'ultimate-member' ), date_i18n( get_option( 'date_format' ), $value ) );
|
169 |
+
return $value;
|
170 |
+
}
|
171 |
+
add_filter( 'um_profile_field_filter_hook__user_registered', 'um_profile_field_filter_hook__user_registered', 99, 2 );
|
172 |
+
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Last login date
|
176 |
+
*
|
177 |
+
* @param $value
|
178 |
+
* @param $data
|
179 |
+
*
|
180 |
+
* @return string
|
181 |
+
*/
|
182 |
+
function um_profile_field_filter_hook__last_login( $value, $data ) {
|
183 |
+
if ( ! $value ) {
|
184 |
+
return '';
|
185 |
+
}
|
186 |
+
//$value = sprintf( __('Last login: %s','ultimate-member'), um_user_last_login( um_user('ID') ) );
|
187 |
+
$value = um_user_last_login( um_user( 'ID' ) );
|
188 |
+
return $value;
|
189 |
+
}
|
190 |
+
add_filter( 'um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
|
191 |
+
add_filter( 'um_profile_field_filter_hook___um_last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* URLs in textarea
|
196 |
+
*
|
197 |
+
* @param $value
|
198 |
+
* @param $data
|
199 |
+
*
|
200 |
+
* @return mixed|string|void
|
201 |
+
*/
|
202 |
+
function um_profile_field_filter_hook__textarea( $value, $data ) {
|
203 |
+
if ( ! $value ) {
|
204 |
+
return '';
|
205 |
+
}
|
206 |
+
if ( isset( $data['html'] ) && $data['html'] == 1 ) {
|
207 |
+
return $value;
|
208 |
+
}
|
209 |
+
|
210 |
+
$value = wp_kses( $value, 'strip' );
|
211 |
+
$value = html_entity_decode( $value );
|
212 |
+
$value = preg_replace('$(https?://[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', ' <a href="$1" target="_blank">$1</a> ', $value." ");
|
213 |
+
$value = preg_replace('$(www\.[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', '<a target="_blank" href="http://$1">$1</a> ', $value." ");
|
214 |
+
|
215 |
+
if ( ! ( isset( $data['metakey'] ) && 'description' === $data['metakey'] ) ) {
|
216 |
+
$value = wpautop( $value );
|
217 |
+
}
|
218 |
+
|
219 |
+
return $value;
|
220 |
+
}
|
221 |
+
add_filter( 'um_profile_field_filter_hook__textarea', 'um_profile_field_filter_hook__textarea', 99, 2 );
|
222 |
+
|
223 |
+
/***
|
224 |
+
*** @urls in description
|
225 |
+
***/
|
226 |
+
/* add_filter('um_profile_field_filter_hook__description', 'um_profile_field_filter_hook__description', 99, 2);
|
227 |
+
function um_profile_field_filter_hook__description( $value, $data ) {
|
228 |
+
|
229 |
+
if ( isset( $data ) && isset( $data['html'] ) && $data['html'] == 1 )
|
230 |
+
return $value;
|
231 |
+
|
232 |
+
$value = esc_textarea( $value );
|
233 |
+
$value = preg_replace('$(https?://[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', ' <a href="$1" target="_blank">$1</a> ', $value." ");
|
234 |
+
$value = preg_replace('$(www\.[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', '<a target="_blank" href="http://$1">$1</a> ', $value." ");
|
235 |
+
|
236 |
+
return $value;
|
237 |
+
}*/
|
238 |
+
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Time field
|
242 |
+
*
|
243 |
+
* @param $value
|
244 |
+
* @param $data
|
245 |
+
*
|
246 |
+
* @return mixed|string
|
247 |
+
*/
|
248 |
+
function um_profile_field_filter_hook__time( $value, $data ) {
|
249 |
+
if ( ! $value ) {
|
250 |
+
return '';
|
251 |
+
}
|
252 |
+
$value = UM()->datetime()->format( $value, $data['format'] );
|
253 |
+
|
254 |
+
$value = str_replace( 'am', 'a.m.', $value );
|
255 |
+
$value = str_replace( 'pm', 'p.m.', $value );
|
256 |
+
|
257 |
+
return $value;
|
258 |
+
}
|
259 |
+
add_filter( 'um_profile_field_filter_hook__time', 'um_profile_field_filter_hook__time', 99, 2 );
|
260 |
+
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Date field
|
264 |
+
*
|
265 |
+
* @param $value
|
266 |
+
* @param $data
|
267 |
+
*
|
268 |
+
* @return string
|
269 |
+
*/
|
270 |
+
function um_profile_field_filter_hook__date( $value, $data ) {
|
271 |
+
if ( ! $value ) {
|
272 |
+
return '';
|
273 |
+
}
|
274 |
+
if ( isset( $data['pretty_format'] ) && $data['pretty_format'] == 1 ) {
|
275 |
+
$value = UM()->datetime()->get_age( $value );
|
276 |
+
} else {
|
277 |
+
$format = empty( $data['format_custom'] ) ? $data['format'] : $data['format_custom'];
|
278 |
+
$value = date_i18n( $format, strtotime( $value ) );
|
279 |
+
}
|
280 |
+
|
281 |
+
return $value;
|
282 |
+
}
|
283 |
+
add_filter( 'um_profile_field_filter_hook__date', 'um_profile_field_filter_hook__date', 99, 2 );
|
284 |
+
|
285 |
+
|
286 |
+
/**
|
287 |
+
* File field
|
288 |
+
* @param $value
|
289 |
+
* @param $data
|
290 |
+
*
|
291 |
+
* @return string
|
292 |
+
*/
|
293 |
+
function um_profile_field_filter_hook__file( $value, $data ) {
|
294 |
+
if ( ! $value ) {
|
295 |
+
return '';
|
296 |
+
}
|
297 |
+
$file_type = wp_check_filetype( $value );
|
298 |
+
$uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) );
|
299 |
+
|
300 |
+
$removed = false;
|
301 |
+
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) {
|
302 |
+
if ( is_multisite() ) {
|
303 |
+
//multisite fix for old customers
|
304 |
+
$file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value );
|
305 |
+
if ( ! file_exists( $file_path ) ) {
|
306 |
+
$removed = true;
|
307 |
+
}
|
308 |
+
} else {
|
309 |
+
$removed = true;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
if ( $removed ) {
|
314 |
+
$value = __( 'This file has been removed.', 'ultimate-member' );
|
315 |
+
} else {
|
316 |
+
$file_info = um_user( $data['metakey'] . "_metadata" );
|
317 |
+
if ( ! empty( $file_info['original_name'] ) ) {
|
318 |
+
$value = $file_info['original_name'];
|
319 |
+
}
|
320 |
+
$value = '<div class="um-single-file-preview show">
|
321 |
+
<div class="um-single-fileinfo">
|
322 |
+
<a href="' . esc_attr( $uri ) . '" target="_blank">
|
323 |
+
<span class="icon" style="background:'. UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . '"><i class="'. UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) .'"></i></span>
|
324 |
+
<span class="filename">' . esc_attr( $value ) . '</span>
|
325 |
+
</a>
|
326 |
+
</div>
|
327 |
+
</div>';
|
328 |
+
}
|
329 |
+
|
330 |
+
return $value;
|
331 |
+
}
|
332 |
+
add_filter( 'um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file', 99, 2 );
|
333 |
+
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Image field
|
337 |
+
*
|
338 |
+
* @param $value
|
339 |
+
* @param $data
|
340 |
+
*
|
341 |
+
* @return string
|
342 |
+
*/
|
343 |
+
function um_profile_field_filter_hook__image( $value, $data ) {
|
344 |
+
if ( ! $value ) {
|
345 |
+
return '';
|
346 |
+
}
|
347 |
+
$uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) );
|
348 |
+
$title = ( isset( $data['title'] ) ) ? $data['title'] : __( 'Untitled photo', 'ultimate-member' );
|
349 |
+
|
350 |
+
$removed = false;
|
351 |
+
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) {
|
352 |
+
if ( is_multisite() ) {
|
353 |
+
//multisite fix for old customers
|
354 |
+
$file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value );
|
355 |
+
if ( ! file_exists( $file_path ) ) {
|
356 |
+
$removed = true;
|
357 |
+
}
|
358 |
+
} else {
|
359 |
+
$removed = true;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
// if value is an image tag
|
364 |
+
if( preg_match( '/\<img.*src=\"([^"]+).*/', $value, $matches ) ) {
|
365 |
+
$uri = $matches[1];
|
366 |
+
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . esc_attr( $uri ) . '"><img src="' . esc_attr( $uri ) . '" alt="' . esc_attr( $title ) . '" title="' . esc_attr( $title ) . '" class="" /></a></div>';
|
367 |
+
} else if ( ! $removed ) {
|
368 |
+
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . esc_attr( $uri ) . '"><img src="' . esc_attr( $uri ) . '" alt="' . esc_attr( $title ) . '" title="' . esc_attr( $title ) . '" class="" /></a></div>';
|
369 |
+
} else {
|
370 |
+
$value = '';
|
371 |
+
}
|
372 |
+
|
373 |
+
return $value;
|
374 |
+
}
|
375 |
+
add_filter( 'um_profile_field_filter_hook__image', 'um_profile_field_filter_hook__image', 99, 2 );
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Global sanitize
|
379 |
+
*
|
380 |
+
* @param $value
|
381 |
+
* @param $data
|
382 |
+
* @param string $type
|
383 |
+
*
|
384 |
+
* @return string
|
385 |
+
*/
|
386 |
+
function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
387 |
+
if ( ! $value ) {
|
388 |
+
return '';
|
389 |
+
}
|
390 |
+
|
391 |
+
if ( isset( $data['type'] ) && 'text' === $data['type'] && isset( $data['validate'] ) && 'skype' === $data['validate'] ) {
|
392 |
+
$alt = ! empty( $data['url_text'] ) ? $data['url_text'] : $value;
|
393 |
+
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
394 |
+
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
395 |
+
|
396 |
+
if ( false === strstr( $value, 'join.skype.com' ) ) {
|
397 |
+
$value = 'skype:' . $value . '?chat';
|
398 |
+
}
|
399 |
+
|
400 |
+
$value = '<a href="'. esc_attr( $value ) .'" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . '>' . esc_html( $alt ) . '</a>';
|
401 |
+
} else {
|
402 |
+
if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
403 |
+
$alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
404 |
+
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
405 |
+
if ( ! strstr( $value, 'http' )
|
406 |
+
&& !strstr( $value, '://' )
|
407 |
+
&& !strstr( $value, 'www.' )
|
408 |
+
&& !strstr( $value, '.com' )
|
409 |
+
&& !strstr( $value, '.net' )
|
410 |
+
&& !strstr( $value, '.org' )
|
411 |
+
&& !strstr( $value, '.me' )
|
412 |
+
) {
|
413 |
+
if ( $data['validate'] == 'soundcloud_url' ) $value = 'https://soundcloud.com/' . $value;
|
414 |
+
if ( $data['validate'] == 'youtube_url' ) $value = 'https://youtube.com/user/' . $value;
|
415 |
+
if ( $data['validate'] == 'telegram_url' ) $value = 'https://t.me/' . $value;
|
416 |
+
if ( $data['validate'] == 'facebook_url' ) $value = 'https://facebook.com/' . $value;
|
417 |
+
if ( $data['validate'] == 'twitter_url' ) $value = 'https://twitter.com/' . $value;
|
418 |
+
if ( $data['validate'] == 'linkedin_url' ) $value = 'https://linkedin.com/' . $value;
|
419 |
+
if ( $data['validate'] == 'googleplus_url' ) $value = 'https://plus.google.com/' . $value;
|
420 |
+
if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value;
|
421 |
+
if ( $data['validate'] == 'vk_url' ) $value = 'https://vk.com/' . $value;
|
422 |
+
}
|
423 |
+
|
424 |
+
if ( strpos( $value, 'http://' ) !== 0 ) {
|
425 |
+
$value = 'http://' . $value;
|
426 |
+
}
|
427 |
+
|
428 |
+
$value = str_replace('https://https://','https://',$value);
|
429 |
+
$value = str_replace('http://https://','https://',$value);
|
430 |
+
|
431 |
+
$onclick_alert = '';
|
432 |
+
if ( $value !== wp_validate_redirect( $value ) ) {
|
433 |
+
$onclick_alert = ' onclick="return confirm( \'' . sprintf( __( 'This link leads to a 3rd-party website. Make sure the link is safe and you really want to go to this website: `%s`', 'ultimate-member' ), $value ) . '\' );"';
|
434 |
+
}
|
435 |
+
|
436 |
+
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
437 |
+
$value = '<a href="'. esc_url( $value ) .'" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . $onclick_alert . '>' . esc_html( $alt ) . '</a>';
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
if ( ! is_array( $value ) ) {
|
442 |
+
if ( is_email( $value ) ) {
|
443 |
+
$value = '<a href="mailto:'. $value.'" title="'.$value.'">'.$value.'</a>';
|
444 |
+
}
|
445 |
+
} else {
|
446 |
+
$value = implode( ', ', $value );
|
447 |
+
}
|
448 |
+
|
449 |
+
$value = str_replace('https://https://','https://',$value);
|
450 |
+
$value = str_replace('http://https://','https://',$value);
|
451 |
+
//$value = UM()->shortcodes()->emotize( $value );
|
452 |
+
return $value;
|
453 |
+
|
454 |
+
}
|
455 |
+
add_filter( 'um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 3 );
|
456 |
+
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Get form fields
|
460 |
+
*
|
461 |
+
* @param $array
|
462 |
+
*
|
463 |
+
* @return mixed|string
|
464 |
+
*/
|
465 |
+
function um_get_form_fields( $array ) {
|
466 |
+
|
467 |
+
$form_id = (isset ( UM()->fields()->set_id ) ) ? UM()->fields()->set_id : null;
|
468 |
+
$mode = (isset( UM()->fields()->set_mode ) ) ? UM()->fields()->set_mode : null;
|
469 |
+
|
470 |
+
if ( $form_id && $mode ) {
|
471 |
+
$array = UM()->query()->get_attr('custom_fields', $form_id );
|
472 |
+
} else {
|
473 |
+
$array = '';
|
474 |
+
}
|
475 |
+
|
476 |
+
return $array;
|
477 |
+
|
478 |
+
}
|
479 |
+
add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 );
|
480 |
+
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Validate conditional logic
|
484 |
+
*
|
485 |
+
* @param $array
|
486 |
+
* @param $fields
|
487 |
+
* @return mixed
|
488 |
+
*/
|
489 |
+
function um_get_custom_field_array( $array, $fields ) {
|
490 |
+
|
491 |
+
if ( ! empty( $array['conditions'] ) ) {
|
492 |
+
foreach ( $array['conditions'] as $key => $value ) {
|
493 |
+
if ( ! isset( $value[1] ) ) {
|
494 |
+
continue;
|
495 |
+
}
|
496 |
+
|
497 |
+
if ( empty( $fields[ $value[1] ] ) ) {
|
498 |
+
continue;
|
499 |
+
}
|
500 |
+
|
501 |
+
if ( empty( $fields[ $value[1] ]['metakey'] ) ) {
|
502 |
+
continue;
|
503 |
+
}
|
504 |
+
|
505 |
+
$condition_metakey = $fields[ $value[1] ]['metakey'];
|
506 |
+
|
507 |
+
if ( isset( $_POST[ $condition_metakey ] ) ) {
|
508 |
+
$cond_value = ( $fields[ $value[1] ]['type'] === 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
|
509 |
+
list( $visibility, $parent_key, $op, $parent_value ) = $value;
|
510 |
+
|
511 |
+
if ( $visibility == 'hide' ) {
|
512 |
+
if ( $op == 'empty' ) {
|
513 |
+
if ( empty( $cond_value ) ) {
|
514 |
+
$array['required'] = 0;
|
515 |
+
}
|
516 |
+
} elseif ( $op == 'not empty' ) {
|
517 |
+
if ( ! empty( $cond_value ) ) {
|
518 |
+
$array['required'] = 0;
|
519 |
+
}
|
520 |
+
} elseif ( $op == 'equals to' ) {
|
521 |
+
if ( $cond_value == $parent_value ) {
|
522 |
+
$array['required'] = 0;
|
523 |
+
}
|
524 |
+
} elseif ( $op == 'not equals' ) {
|
525 |
+
if ( $cond_value != $parent_value ) {
|
526 |
+
$array['required'] = 0;
|
527 |
+
}
|
528 |
+
} elseif ( $op == 'greater than' ) {
|
529 |
+
if ( $cond_value > $parent_value ) {
|
530 |
+
$array['required'] = 0;
|
531 |
+
}
|
532 |
+
} elseif ( $op == 'less than' ) {
|
533 |
+
if ( $cond_value < $parent_value ) {
|
534 |
+
$array['required'] = 0;
|
535 |
+
}
|
536 |
+
} elseif ( $op == 'contains' ) {
|
537 |
+
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
538 |
+
$array['required'] = 0;
|
539 |
+
}
|
540 |
+
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
541 |
+
$array['required'] = 0;
|
542 |
+
}
|
543 |
+
}
|
544 |
+
} elseif ( $visibility == 'show' ) {
|
545 |
+
if ( $op == 'empty' ) {
|
546 |
+
if ( ! empty( $cond_value ) ) {
|
547 |
+
$array['required'] = 0;
|
548 |
+
}
|
549 |
+
} elseif ( $op == 'not empty' ) {
|
550 |
+
if ( empty( $cond_value ) ) {
|
551 |
+
$array['required'] = 0;
|
552 |
+
}
|
553 |
+
} elseif ( $op == 'equals to' ) {
|
554 |
+
if ( $cond_value != $parent_value ) {
|
555 |
+
$array['required'] = 0;
|
556 |
+
}
|
557 |
+
} elseif ( $op == 'not equals' ) {
|
558 |
+
if ( $cond_value == $parent_value ) {
|
559 |
+
$array['required'] = 0;
|
560 |
+
}
|
561 |
+
} elseif ( $op == 'greater than' ) {
|
562 |
+
if ( $cond_value <= $parent_value ) {
|
563 |
+
$array['required'] = 0;
|
564 |
+
}
|
565 |
+
} elseif ( $op == 'less than' ) {
|
566 |
+
if ( $cond_value >= $parent_value ) {
|
567 |
+
$array['required'] = 0;
|
568 |
+
}
|
569 |
+
} elseif ( $op == 'contains' ) {
|
570 |
+
if( is_string( $cond_value ) && !strstr( $cond_value, $parent_value ) ) {
|
571 |
+
$array['required'] = 0;
|
572 |
+
}
|
573 |
+
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
574 |
+
$array['required'] = 0;
|
575 |
+
}
|
576 |
+
}
|
577 |
+
}
|
578 |
+
}
|
579 |
+
}
|
580 |
+
}
|
581 |
+
|
582 |
+
return $array;
|
583 |
+
}
|
584 |
+
add_filter( 'um_get_custom_field_array', 'um_get_custom_field_array', 99, 2 );
|
585 |
+
|
586 |
+
|
587 |
+
/**
|
588 |
+
* Force fields to use UTF-8 encoding
|
589 |
+
*
|
590 |
+
* @param mixed $value
|
591 |
+
* @param array $data
|
592 |
+
* @param string $type
|
593 |
+
*
|
594 |
+
* @return mixed
|
595 |
+
*/
|
596 |
+
function um_force_utf8_fields( $value, $data, $type = '' ) {
|
597 |
+
|
598 |
+
if( ! UM()->options()->get('um_force_utf8_strings') )
|
599 |
+
return $value;
|
600 |
+
|
601 |
+
$value = um_force_utf8_string( $value );
|
602 |
+
|
603 |
+
return $value;
|
604 |
+
|
605 |
+
}
|
606 |
+
add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 9, 3 );
|
607 |
+
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Filter profile data value
|
611 |
+
* @param mixed $value
|
612 |
+
* @return mixed
|
613 |
+
* @uses hook filter: um_is_selected_filter_value
|
614 |
+
*/
|
615 |
+
function um_is_selected_filter_value( $value ) {
|
616 |
+
if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) {
|
617 |
+
return $value;
|
618 |
+
}
|
619 |
+
|
620 |
+
$value = um_force_utf8_string( $value );
|
621 |
+
|
622 |
+
return $value;
|
623 |
+
}
|
624 |
+
add_filter( 'um_is_selected_filter_value','um_is_selected_filter_value', 9, 1 );
|
625 |
+
add_filter( 'um_select_dropdown_dynamic_option_value','um_is_selected_filter_value', 10, 1 );
|
626 |
+
|
627 |
+
/**
|
628 |
+
* Filter select dropdown to use UTF-8 encoding
|
629 |
+
*
|
630 |
+
* @param array $options
|
631 |
+
* @param array $data
|
632 |
+
* @return array
|
633 |
+
* @uses hook filter: um_select_dropdown_dynamic_options
|
634 |
+
*/
|
635 |
+
function um_select_dropdown_dynamic_options_to_utf8( $options, $data ) {
|
636 |
+
if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) {
|
637 |
+
return $options;
|
638 |
+
}
|
639 |
+
|
640 |
+
foreach ( $options as $key => $value ) {
|
641 |
+
$options[ $key ] = um_force_utf8_string( $value );
|
642 |
+
}
|
643 |
+
|
644 |
+
return $options;
|
645 |
+
}
|
646 |
+
add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_options_to_utf8', 10, 2 );
|
647 |
+
|
648 |
+
|
649 |
+
/**
|
650 |
+
* Filter non-UTF8 strings
|
651 |
+
* @param string $value
|
652 |
+
* @return string
|
653 |
+
* @uses hook filter: um_field_non_utf8_value
|
654 |
+
*/
|
655 |
+
function um_field_non_utf8_value( $value ) {
|
656 |
+
|
657 |
+
if ( function_exists( 'mb_detect_encoding' ) ) {
|
658 |
+
$encoding = mb_detect_encoding( $value, 'utf-8, iso-8859-1, ascii', true );
|
659 |
+
if ( strcasecmp( $encoding, 'UTF-8' ) !== 0 ) {
|
660 |
+
$value = iconv( $encoding, 'utf-8', $value );
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
return $value;
|
665 |
+
}
|
666 |
+
add_filter( 'um_field_non_utf8_value', 'um_field_non_utf8_value' );
|
667 |
+
|
668 |
+
|
669 |
+
/**
|
670 |
+
* Returns dropdown/multi-select options from a callback function
|
671 |
+
* @param $options array
|
672 |
+
* @param $data array
|
673 |
+
* @return array
|
674 |
+
* @uses hook filter: um_select_dropdown_dynamic_options, um_multiselect_options
|
675 |
+
*/
|
676 |
+
function um_select_dropdown_dynamic_callback_options( $options, $data ) {
|
677 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) ) {
|
678 |
+
$options = call_user_func( $data['custom_dropdown_options_source'] );
|
679 |
+
}
|
680 |
+
|
681 |
+
return $options;
|
682 |
+
}
|
683 |
+
add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_callback_options', 10, 2 );
|
684 |
+
add_filter( 'um_multiselect_options','um_select_dropdown_dynamic_callback_options', 10, 2 );
|
685 |
+
|
686 |
+
|
687 |
+
/**
|
688 |
+
* Pair dropdown/multi-select options from a callback function
|
689 |
+
*
|
690 |
+
* @param $value string
|
691 |
+
* @param $data array
|
692 |
+
* @return string
|
693 |
+
* @uses hook filter: um_profile_field_filter_hook__
|
694 |
+
*/
|
695 |
+
|
696 |
+
function um_option_match_callback_view_field( $value, $data ) {
|
697 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
698 |
+
return UM()->fields()->get_option_value_from_callback( $value, $data, $data['type'] );
|
699 |
+
}
|
700 |
+
|
701 |
+
return $value;
|
702 |
+
}
|
703 |
+
add_filter('um_profile_field_filter_hook__select','um_option_match_callback_view_field', 10, 2);
|
704 |
+
add_filter('um_profile_field_filter_hook__multiselect','um_option_match_callback_view_field', 10, 2);
|
705 |
+
add_filter('um_field_select_default_value','um_option_match_callback_view_field', 10, 2);
|
706 |
+
add_filter('um_field_multiselect_default_value','um_option_match_callback_view_field', 10, 2);
|
707 |
+
|
708 |
+
|
709 |
+
/**
|
710 |
+
* Apply textdomain in select/multi-select options
|
711 |
+
*
|
712 |
+
* @param $value string
|
713 |
+
* @param $data array
|
714 |
+
* @return string
|
715 |
+
* @uses hook filters: um_profile_field_filter_hook__select, um_profile_field_filter_hook__multiselect
|
716 |
+
*/
|
717 |
+
|
718 |
+
function um_profile_field__select_translate( $value, $data ) {
|
719 |
+
|
720 |
+
if ( empty( $value ) ) return $value;
|
721 |
+
|
722 |
+
$options = explode(", ", $value );
|
723 |
+
$arr_options = array();
|
724 |
+
if( is_array( $options ) ){
|
725 |
+
foreach ( $options as $item ) {
|
726 |
+
$arr_options[] = __( $item, 'ultimate-member' );
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
$value = implode(", ", $arr_options);
|
731 |
+
|
732 |
+
return $value;
|
733 |
+
}
|
734 |
+
add_filter( 'um_profile_field_filter_hook__select','um_profile_field__select_translate', 10, 2 );
|
735 |
+
add_filter( 'um_profile_field_filter_hook__multiselect','um_profile_field__select_translate', 10, 2 );
|
736 |
+
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Cleaning on XSS injection
|
740 |
+
* @param $value string
|
741 |
+
* @param $data array
|
742 |
+
* @param string $type
|
743 |
+
* @return string $value
|
744 |
+
* @uses hook filters: um_profile_field_filter_hook__
|
745 |
+
*/
|
746 |
+
function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) {
|
747 |
+
if ( ! empty( $value ) && is_string( $value ) ) {
|
748 |
+
$value = stripslashes( $value );
|
749 |
+
$data['validate'] = isset( $data['validate'] ) ? $data['validate'] : '';
|
750 |
+
|
751 |
+
if ( 'text' == $type && ! in_array( $data['validate'], array( 'unique_email' ) ) || 'password' == $type ) {
|
752 |
+
$value = esc_attr( $value );
|
753 |
+
} elseif ( $type == 'url' ) {
|
754 |
+
$value = esc_url( $value );
|
755 |
+
} elseif ( 'textarea' == $type ) {
|
756 |
+
if ( empty( $data['html'] ) ) {
|
757 |
+
$value = wp_kses_post( $value );
|
758 |
+
}
|
759 |
+
} elseif ( 'rating' == $type ) {
|
760 |
+
if ( ! is_numeric( $value ) ) {
|
761 |
+
$value = 0;
|
762 |
+
} else {
|
763 |
+
if ( $data['number'] == 5 ) {
|
764 |
+
if ( ! in_array( $value, range( 1, 5 ) ) ) {
|
765 |
+
$value = 0;
|
766 |
+
}
|
767 |
+
} elseif ( $data['number'] == 10 ) {
|
768 |
+
if ( ! in_array( $value, range( 1, 10 ) ) ) {
|
769 |
+
$value = 0;
|
770 |
+
}
|
771 |
+
}
|
772 |
+
}
|
773 |
+
} elseif ( 'select' == $type || 'radio' == $type ) {
|
774 |
+
|
775 |
+
/**
|
776 |
+
* UM hook
|
777 |
+
*
|
778 |
+
* @type filter
|
779 |
+
* @title um_select_option_value
|
780 |
+
* @description Enable options pair by field $data
|
781 |
+
* @input_vars
|
782 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
783 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
784 |
+
*/
|
785 |
+
$option_pairs = apply_filters( 'um_select_options_pair', null, $data );
|
786 |
+
|
787 |
+
$array = empty( $data['options'] ) ? array() : $data['options'];
|
788 |
+
|
789 |
+
if ( $data['metakey'] == 'country' && empty( $array ) ) {
|
790 |
+
$array = UM()->builtin()->get( 'countries' );
|
791 |
+
}
|
792 |
+
|
793 |
+
if ( $option_pairs ) {
|
794 |
+
$arr = array_keys( $array );
|
795 |
+
} else {
|
796 |
+
$arr = $array;
|
797 |
+
}
|
798 |
+
|
799 |
+
if ( ! empty( $arr ) && ! in_array( $value, array_map( 'trim', $arr ) ) && empty( $data['custom_dropdown_options_source'] ) ) {
|
800 |
+
$value = '';
|
801 |
+
} else {
|
802 |
+
if ( $option_pairs && is_array( $array ) && isset( $array[ $value ] ) ) {
|
803 |
+
$value = $array[ $value ];
|
804 |
+
}
|
805 |
+
}
|
806 |
+
}
|
807 |
+
} elseif ( ! empty( $value ) && is_array( $value ) ) {
|
808 |
+
if ( 'multiselect' == $type || 'checkbox' == $type ) {
|
809 |
+
|
810 |
+
/**
|
811 |
+
* UM hook
|
812 |
+
*
|
813 |
+
* @type filter
|
814 |
+
* @title um_select_option_value
|
815 |
+
* @description Enable options pair by field $data
|
816 |
+
* @input_vars
|
817 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
818 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
819 |
+
*/
|
820 |
+
$option_pairs = apply_filters( 'um_select_options_pair', null, $data );
|
821 |
+
|
822 |
+
$arr = $data['options'];
|
823 |
+
if ( $option_pairs ) {
|
824 |
+
$arr = array_keys( $data['options'] );
|
825 |
+
}
|
826 |
+
|
827 |
+
if ( ! empty( $arr ) && empty( $data['custom_dropdown_options_source'] ) ) {
|
828 |
+
$arr = wp_unslash( $arr );
|
829 |
+
$arr = wp_slash( array_map( 'trim', $arr ) );
|
830 |
+
$value = array_intersect( $value, $arr );
|
831 |
+
}
|
832 |
+
|
833 |
+
if ( $option_pairs ) {
|
834 |
+
foreach ( $value as &$val ) {
|
835 |
+
$val = $data['options'][ $val ];
|
836 |
+
}
|
837 |
+
}
|
838 |
+
}
|
839 |
+
}
|
840 |
+
|
841 |
+
return $value;
|
842 |
+
}
|
843 |
+
add_filter( 'um_profile_field_filter_hook__', 'um_profile_field_filter_xss_validation', 10, 3 );
|
844 |
+
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Trim All form POST submitted data
|
848 |
+
*
|
849 |
+
* @param $post_form
|
850 |
+
* @param $mode
|
851 |
+
*
|
852 |
+
* @return mixed
|
853 |
+
*/
|
854 |
+
function um_submit_form_data_trim_fields( $post_form, $mode ) {
|
855 |
+
foreach ( $post_form as $key => $field ) {
|
856 |
+
if ( is_string( $field ) ) {
|
857 |
+
$post_form[ $key ] = trim( $field );
|
858 |
+
}
|
859 |
+
}
|
860 |
+
|
861 |
+
return $post_form;
|
862 |
+
}
|
863 |
+
add_filter( 'um_submit_form_data', 'um_submit_form_data_trim_fields', 9, 2 );
|
864 |
+
|
865 |
+
|
866 |
+
/**
|
867 |
+
* add role_select and role_radio to the $post_form
|
868 |
+
* It is necessary for that if on these fields the conditional logic
|
869 |
+
* @param $post_form array
|
870 |
+
* @param $mode
|
871 |
+
*
|
872 |
+
* @return $post_form
|
873 |
+
* @uses hook filters: um_submit_form_data
|
874 |
+
*/
|
875 |
+
function um_submit_form_data_role_fields( $post_form, $mode ) {
|
876 |
+
$custom_fields = unserialize( $post_form['custom_fields'] );
|
877 |
+
if ( ! empty( $post_form['role'] ) && array_key_exists( 'role_select', $custom_fields ) ) {
|
878 |
+
$post_form['role_select'] = $post_form['role'];
|
879 |
+
}
|
880 |
+
if (! empty( $post_form['role'] ) && array_key_exists( 'role_radio', $custom_fields ) ) {
|
881 |
+
$post_form['role_radio'] = $post_form['role'];
|
882 |
+
}
|
883 |
+
|
884 |
+
return $post_form;
|
885 |
+
}
|
886 |
+
add_filter( 'um_submit_form_data', 'um_submit_form_data_role_fields', 10, 2 );
|
887 |
+
|
888 |
+
|
889 |
+
/**
|
890 |
+
* Cleaning on XSS injection for url editing field
|
891 |
+
* @param $value string
|
892 |
+
* @param $key string
|
893 |
+
*
|
894 |
+
* @return string $value
|
895 |
+
* @uses hook filters: um_edit_url_field_value
|
896 |
+
*/
|
897 |
+
function um_edit_url_field_value( $value, $key ) {
|
898 |
+
$value = esc_attr( $value );
|
899 |
+
return $value;
|
900 |
+
}
|
901 |
+
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
includes/core/um-filters-login.php
CHANGED
@@ -1,107 +1,107 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
-
exit;
|
3 |
-
}
|
4 |
-
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Filter to customize errors
|
8 |
-
*
|
9 |
-
* @param $message
|
10 |
-
*
|
11 |
-
* @return string
|
12 |
-
*/
|
13 |
-
function um_custom_wp_err_messages( $message ) {
|
14 |
-
|
15 |
-
if ( ! empty( $_REQUEST['err'] ) ) {
|
16 |
-
switch ( sanitize_key( $_REQUEST['err'] ) ) {
|
17 |
-
case 'blocked_email':
|
18 |
-
$err = __( 'This email address has been blocked.', 'ultimate-member' );
|
19 |
-
break;
|
20 |
-
case 'blocked_ip':
|
21 |
-
$err = __( 'Your IP address has been blocked.', 'ultimate-member' );
|
22 |
-
break;
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
if ( isset( $err ) ) {
|
27 |
-
$message = '<div class="login" id="login_error">' . $err . '</div>';
|
28 |
-
}
|
29 |
-
|
30 |
-
return $message;
|
31 |
-
}
|
32 |
-
add_filter( 'login_message', 'um_custom_wp_err_messages' );
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Check for blocked IPs or Email on wp-login.php form
|
37 |
-
*
|
38 |
-
* @param $user
|
39 |
-
* @param $username
|
40 |
-
* @param $password
|
41 |
-
*
|
42 |
-
* @return mixed
|
43 |
-
*/
|
44 |
-
function um_wp_form_errors_hook_ip_test( $user, $username, $password ) {
|
45 |
-
if ( ! empty( $username ) ) {
|
46 |
-
do_action( 'um_submit_form_errors_hook__blockedips', array() );
|
47 |
-
do_action( 'um_submit_form_errors_hook__blockedemails', array( 'username' => $username ) );
|
48 |
-
}
|
49 |
-
|
50 |
-
return $user;
|
51 |
-
}
|
52 |
-
add_filter( 'authenticate', 'um_wp_form_errors_hook_ip_test', 10, 3 );
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Login checks thru the wordpress admin login
|
57 |
-
*
|
58 |
-
* @param $user
|
59 |
-
* @param $username
|
60 |
-
* @param $password
|
61 |
-
*
|
62 |
-
* @return WP_Error|WP_User
|
63 |
-
*/
|
64 |
-
function um_wp_form_errors_hook_logincheck( $user, $username, $password ) {
|
65 |
-
|
66 |
-
if ( isset( $user->ID ) ) {
|
67 |
-
|
68 |
-
um_fetch_user( $user->ID );
|
69 |
-
$status = um_user( 'account_status' );
|
70 |
-
|
71 |
-
switch( $status ) {
|
72 |
-
case 'inactive':
|
73 |
-
return new WP_Error( $status, __( 'Your account has been disabled.', 'ultimate-member' ) );
|
74 |
-
break;
|
75 |
-
case 'awaiting_admin_review':
|
76 |
-
return new WP_Error( $status, __( 'Your account has not been approved yet.', 'ultimate-member' ) );
|
77 |
-
break;
|
78 |
-
case 'awaiting_email_confirmation':
|
79 |
-
return new WP_Error( $status, __( 'Your account is awaiting e-mail verification.', 'ultimate-member' ) );
|
80 |
-
break;
|
81 |
-
case 'rejected':
|
82 |
-
return new WP_Error( $status, __( 'Your membership request has been rejected.', 'ultimate-member' ) );
|
83 |
-
break;
|
84 |
-
}
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
return $user;
|
89 |
-
|
90 |
-
}
|
91 |
-
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50, 3 );
|
92 |
-
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Change lost password url in UM Login form
|
96 |
-
* @param string $lostpassword_url
|
97 |
-
* @return string
|
98 |
-
*/
|
99 |
-
function um_lostpassword_url( $lostpassword_url ) {
|
100 |
-
|
101 |
-
if ( um_is_core_page( 'login' ) ) {
|
102 |
-
return um_get_core_page( 'password-reset' );
|
103 |
-
}
|
104 |
-
|
105 |
-
return $lostpassword_url;
|
106 |
-
}
|
107 |
-
add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
+
}
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Filter to customize errors
|
8 |
+
*
|
9 |
+
* @param $message
|
10 |
+
*
|
11 |
+
* @return string
|
12 |
+
*/
|
13 |
+
function um_custom_wp_err_messages( $message ) {
|
14 |
+
|
15 |
+
if ( ! empty( $_REQUEST['err'] ) ) {
|
16 |
+
switch ( sanitize_key( $_REQUEST['err'] ) ) {
|
17 |
+
case 'blocked_email':
|
18 |
+
$err = __( 'This email address has been blocked.', 'ultimate-member' );
|
19 |
+
break;
|
20 |
+
case 'blocked_ip':
|
21 |
+
$err = __( 'Your IP address has been blocked.', 'ultimate-member' );
|
22 |
+
break;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( isset( $err ) ) {
|
27 |
+
$message = '<div class="login" id="login_error">' . $err . '</div>';
|
28 |
+
}
|
29 |
+
|
30 |
+
return $message;
|
31 |
+
}
|
32 |
+
add_filter( 'login_message', 'um_custom_wp_err_messages' );
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Check for blocked IPs or Email on wp-login.php form
|
37 |
+
*
|
38 |
+
* @param $user
|
39 |
+
* @param $username
|
40 |
+
* @param $password
|
41 |
+
*
|
42 |
+
* @return mixed
|
43 |
+
*/
|
44 |
+
function um_wp_form_errors_hook_ip_test( $user, $username, $password ) {
|
45 |
+
if ( ! empty( $username ) ) {
|
46 |
+
do_action( 'um_submit_form_errors_hook__blockedips', array() );
|
47 |
+
do_action( 'um_submit_form_errors_hook__blockedemails', array( 'username' => $username ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
return $user;
|
51 |
+
}
|
52 |
+
add_filter( 'authenticate', 'um_wp_form_errors_hook_ip_test', 10, 3 );
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Login checks thru the wordpress admin login
|
57 |
+
*
|
58 |
+
* @param $user
|
59 |
+
* @param $username
|
60 |
+
* @param $password
|
61 |
+
*
|
62 |
+
* @return WP_Error|WP_User
|
63 |
+
*/
|
64 |
+
function um_wp_form_errors_hook_logincheck( $user, $username, $password ) {
|
65 |
+
|
66 |
+
if ( isset( $user->ID ) ) {
|
67 |
+
|
68 |
+
um_fetch_user( $user->ID );
|
69 |
+
$status = um_user( 'account_status' );
|
70 |
+
|
71 |
+
switch( $status ) {
|
72 |
+
case 'inactive':
|
73 |
+
return new WP_Error( $status, __( 'Your account has been disabled.', 'ultimate-member' ) );
|
74 |
+
break;
|
75 |
+
case 'awaiting_admin_review':
|
76 |
+
return new WP_Error( $status, __( 'Your account has not been approved yet.', 'ultimate-member' ) );
|
77 |
+
break;
|
78 |
+
case 'awaiting_email_confirmation':
|
79 |
+
return new WP_Error( $status, __( 'Your account is awaiting e-mail verification.', 'ultimate-member' ) );
|
80 |
+
break;
|
81 |
+
case 'rejected':
|
82 |
+
return new WP_Error( $status, __( 'Your membership request has been rejected.', 'ultimate-member' ) );
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
return $user;
|
89 |
+
|
90 |
+
}
|
91 |
+
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50, 3 );
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Change lost password url in UM Login form
|
96 |
+
* @param string $lostpassword_url
|
97 |
+
* @return string
|
98 |
+
*/
|
99 |
+
function um_lostpassword_url( $lostpassword_url ) {
|
100 |
+
|
101 |
+
if ( um_is_core_page( 'login' ) ) {
|
102 |
+
return um_get_core_page( 'password-reset' );
|
103 |
+
}
|
104 |
+
|
105 |
+
return $lostpassword_url;
|
106 |
+
}
|
107 |
+
add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
|
languages/ultimate-member.pot
CHANGED
@@ -1,8249 +1,8249 @@
|
|
1 |
-
# Copyright (C) 2022 Ultimate Member
|
2 |
-
# This file is distributed under the same license as the Ultimate Member plugin.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: Ultimate Member 2.3.1\n"
|
6 |
-
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/ultimate-member\n"
|
7 |
-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
-
"MIME-Version: 1.0\n"
|
10 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
-
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2022-02-09T00:22:18+02:00\n"
|
13 |
-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
-
"X-Generator: WP-CLI 2.5.0\n"
|
15 |
-
"X-Domain: ultimate-member\n"
|
16 |
-
|
17 |
-
#. Plugin Name of the plugin
|
18 |
-
#. Author of the plugin
|
19 |
-
#: includes/admin/core/class-admin-menu.php:147
|
20 |
-
#: includes/core/class-user.php:723
|
21 |
-
msgid "Ultimate Member"
|
22 |
-
msgstr ""
|
23 |
-
|
24 |
-
#. Plugin URI of the plugin
|
25 |
-
#. Author URI of the plugin
|
26 |
-
msgid "http://ultimatemember.com/"
|
27 |
-
msgstr ""
|
28 |
-
|
29 |
-
#. Description of the plugin
|
30 |
-
msgid "The easiest way to create powerful online communities and beautiful user profiles with WordPress"
|
31 |
-
msgstr ""
|
32 |
-
|
33 |
-
#: includes/admin/class-admin-functions.php:35
|
34 |
-
#: includes/class-functions.php:55
|
35 |
-
msgid "Wrong Nonce"
|
36 |
-
msgstr ""
|
37 |
-
|
38 |
-
#: includes/admin/class-admin.php:843
|
39 |
-
#: includes/admin/templates/directory/sorting.php:47
|
40 |
-
#: includes/core/class-member-directory.php:312
|
41 |
-
msgid "Other (Custom Field)"
|
42 |
-
msgstr ""
|
43 |
-
|
44 |
-
#: includes/admin/class-admin.php:1714
|
45 |
-
msgid "Duplicate of %s"
|
46 |
-
msgstr ""
|
47 |
-
|
48 |
-
#: includes/admin/class-admin.php:1834
|
49 |
-
msgid "Docs"
|
50 |
-
msgstr ""
|
51 |
-
|
52 |
-
#: includes/admin/class-admin.php:1835
|
53 |
-
#: includes/admin/core/class-admin-settings.php:1870
|
54 |
-
msgid "Settings"
|
55 |
-
msgstr ""
|
56 |
-
|
57 |
-
#: includes/admin/class-admin.php:1910
|
58 |
-
#: includes/admin/class-admin.php:1913
|
59 |
-
msgid "Form updated."
|
60 |
-
msgstr ""
|
61 |
-
|
62 |
-
#: includes/admin/class-admin.php:1911
|
63 |
-
msgid "Custom field updated."
|
64 |
-
msgstr ""
|
65 |
-
|
66 |
-
#: includes/admin/class-admin.php:1912
|
67 |
-
msgid "Custom field deleted."
|
68 |
-
msgstr ""
|
69 |
-
|
70 |
-
#: includes/admin/class-admin.php:1914
|
71 |
-
msgid "Form restored to revision."
|
72 |
-
msgstr ""
|
73 |
-
|
74 |
-
#: includes/admin/class-admin.php:1915
|
75 |
-
msgid "Form created."
|
76 |
-
msgstr ""
|
77 |
-
|
78 |
-
#: includes/admin/class-admin.php:1916
|
79 |
-
msgid "Form saved."
|
80 |
-
msgstr ""
|
81 |
-
|
82 |
-
#: includes/admin/class-admin.php:1917
|
83 |
-
msgid "Form submitted."
|
84 |
-
msgstr ""
|
85 |
-
|
86 |
-
#: includes/admin/class-admin.php:1918
|
87 |
-
msgid "Form scheduled."
|
88 |
-
msgstr ""
|
89 |
-
|
90 |
-
#: includes/admin/class-admin.php:1919
|
91 |
-
msgid "Form draft updated."
|
92 |
-
msgstr ""
|
93 |
-
|
94 |
-
#: includes/admin/core/class-admin-builder.php:213
|
95 |
-
#: includes/admin/core/class-admin-builder.php:215
|
96 |
-
msgid "Here you can setup conditional logic to show/hide this field based on specific fields value or conditions"
|
97 |
-
msgstr ""
|
98 |
-
|
99 |
-
#: includes/admin/core/class-admin-builder.php:232
|
100 |
-
msgid "Use the condition operator `equals to` or `not equals` if the parent field has a single option."
|
101 |
-
msgstr ""
|
102 |
-
|
103 |
-
#: includes/admin/core/class-admin-builder.php:233
|
104 |
-
msgid "Use the condition operator `greater than` or `less than` if the parent field is a number."
|
105 |
-
msgstr ""
|
106 |
-
|
107 |
-
#: includes/admin/core/class-admin-builder.php:234
|
108 |
-
msgid "Use the condition operator `contains` if the parent field has multiple options."
|
109 |
-
msgstr ""
|
110 |
-
|
111 |
-
#: includes/admin/core/class-admin-builder.php:237
|
112 |
-
msgid "Add new rule"
|
113 |
-
msgstr ""
|
114 |
-
|
115 |
-
#: includes/admin/core/class-admin-builder.php:238
|
116 |
-
msgid "Reset all rules"
|
117 |
-
msgstr ""
|
118 |
-
|
119 |
-
#: includes/admin/core/class-admin-builder.php:292
|
120 |
-
#: includes/admin/core/class-admin-builder.php:612
|
121 |
-
#: includes/admin/core/class-admin-builder.php:776
|
122 |
-
#: includes/admin/core/class-admin-dragdrop.php:33
|
123 |
-
#: includes/admin/core/class-admin-menu.php:106
|
124 |
-
#: includes/core/class-fields.php:4721
|
125 |
-
msgid "Please login as administrator"
|
126 |
-
msgstr ""
|
127 |
-
|
128 |
-
#: includes/admin/core/class-admin-builder.php:399
|
129 |
-
#: includes/admin/core/class-admin-builder.php:469
|
130 |
-
#: includes/admin/core/class-admin-dragdrop.php:176
|
131 |
-
msgid "Add Row"
|
132 |
-
msgstr ""
|
133 |
-
|
134 |
-
#: includes/admin/core/class-admin-builder.php:400
|
135 |
-
#: includes/admin/core/class-admin-builder.php:470
|
136 |
-
#: includes/admin/core/class-admin-dragdrop.php:177
|
137 |
-
msgid "Edit Row"
|
138 |
-
msgstr ""
|
139 |
-
|
140 |
-
#: includes/admin/core/class-admin-builder.php:473
|
141 |
-
#: includes/admin/core/class-admin-dragdrop.php:179
|
142 |
-
#: includes/admin/core/class-admin-dragdrop.php:194
|
143 |
-
#: includes/admin/core/class-admin-dragdrop.php:219
|
144 |
-
msgid "Delete Row"
|
145 |
-
msgstr ""
|
146 |
-
|
147 |
-
#: includes/admin/core/class-admin-builder.php:546
|
148 |
-
msgid "(no title)"
|
149 |
-
msgstr ""
|
150 |
-
|
151 |
-
#: includes/admin/core/class-admin-builder.php:551
|
152 |
-
#: includes/admin/core/list-tables/roles-list-table.php:353
|
153 |
-
msgid "Edit"
|
154 |
-
msgstr ""
|
155 |
-
|
156 |
-
#: includes/admin/core/class-admin-builder.php:553
|
157 |
-
#: includes/admin/core/class-admin-columns.php:102
|
158 |
-
msgid "Duplicate"
|
159 |
-
msgstr ""
|
160 |
-
|
161 |
-
#: includes/admin/core/class-admin-builder.php:557
|
162 |
-
msgid "Delete Group"
|
163 |
-
msgstr ""
|
164 |
-
|
165 |
-
#: includes/admin/core/class-admin-builder.php:560
|
166 |
-
#: includes/admin/core/class-admin-enqueue.php:502
|
167 |
-
#: includes/admin/core/list-tables/roles-list-table.php:356
|
168 |
-
#: includes/admin/core/list-tables/roles-list-table.php:422
|
169 |
-
msgid "Delete"
|
170 |
-
msgstr ""
|
171 |
-
|
172 |
-
#: includes/admin/core/class-admin-builder.php:854
|
173 |
-
msgid "Search Icons..."
|
174 |
-
msgstr ""
|
175 |
-
|
176 |
-
#: includes/admin/core/class-admin-builder.php:874
|
177 |
-
msgid "Setup New Field"
|
178 |
-
msgstr ""
|
179 |
-
|
180 |
-
#: includes/admin/core/class-admin-builder.php:891
|
181 |
-
msgid "Predefined Fields"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: includes/admin/core/class-admin-builder.php:903
|
185 |
-
#: includes/core/class-builtin.php:1447
|
186 |
-
msgid "None"
|
187 |
-
msgstr ""
|
188 |
-
|
189 |
-
#: includes/admin/core/class-admin-builder.php:908
|
190 |
-
msgid "Custom Fields"
|
191 |
-
msgstr ""
|
192 |
-
|
193 |
-
#: includes/admin/core/class-admin-builder.php:918
|
194 |
-
#: includes/admin/core/class-admin-metabox.php:2198
|
195 |
-
#: includes/admin/core/class-admin-metabox.php:2204
|
196 |
-
msgid "Meta Key"
|
197 |
-
msgstr ""
|
198 |
-
|
199 |
-
#: includes/admin/core/class-admin-builder.php:922
|
200 |
-
msgid "You did not create any custom fields"
|
201 |
-
msgstr ""
|
202 |
-
|
203 |
-
#: includes/admin/core/class-admin-builder.php:954
|
204 |
-
#: includes/admin/core/class-admin-builder.php:1028
|
205 |
-
msgid "This field type is not setup correcty."
|
206 |
-
msgstr ""
|
207 |
-
|
208 |
-
#: includes/admin/core/class-admin-builder.php:1207
|
209 |
-
#: includes/core/class-form.php:202
|
210 |
-
#: includes/core/class-form.php:473
|
211 |
-
#: includes/core/class-password.php:528
|
212 |
-
#: includes/core/um-actions-profile.php:601
|
213 |
-
msgid "This is not possible for security reasons."
|
214 |
-
msgstr ""
|
215 |
-
|
216 |
-
#: includes/admin/core/class-admin-columns.php:50
|
217 |
-
msgid "Status"
|
218 |
-
msgstr ""
|
219 |
-
|
220 |
-
#: includes/admin/core/class-admin-columns.php:151
|
221 |
-
#: includes/admin/core/class-admin-metabox.php:2173
|
222 |
-
#: includes/admin/templates/role/role-edit.php:217
|
223 |
-
#: includes/widgets/class-um-search-widget.php:94
|
224 |
-
msgid "Title"
|
225 |
-
msgstr ""
|
226 |
-
|
227 |
-
#: includes/admin/core/class-admin-columns.php:152
|
228 |
-
msgid "ID"
|
229 |
-
msgstr ""
|
230 |
-
|
231 |
-
#: includes/admin/core/class-admin-columns.php:154
|
232 |
-
#: includes/admin/core/class-admin-metabox.php:813
|
233 |
-
#: includes/admin/core/class-admin-metabox.php:975
|
234 |
-
msgid "Shortcode"
|
235 |
-
msgstr ""
|
236 |
-
|
237 |
-
#: includes/admin/core/class-admin-columns.php:155
|
238 |
-
msgid "Date"
|
239 |
-
msgstr ""
|
240 |
-
|
241 |
-
#: includes/admin/core/class-admin-columns.php:186
|
242 |
-
#: includes/admin/core/class-admin-columns.php:219
|
243 |
-
#: includes/admin/core/class-admin-settings.php:1075
|
244 |
-
#: includes/admin/core/class-admin-settings.php:1178
|
245 |
-
#: includes/admin/core/list-tables/roles-list-table.php:383
|
246 |
-
#: includes/admin/core/list-tables/roles-list-table.php:391
|
247 |
-
#: includes/admin/templates/form/login_customize.php:27
|
248 |
-
#: includes/admin/templates/form/login_customize.php:75
|
249 |
-
#: includes/admin/templates/form/login_customize.php:94
|
250 |
-
#: includes/admin/templates/form/login_customize.php:105
|
251 |
-
#: includes/admin/templates/form/profile_customize.php:42
|
252 |
-
#: includes/admin/templates/form/profile_customize.php:108
|
253 |
-
#: includes/admin/templates/form/profile_customize.php:127
|
254 |
-
#: includes/admin/templates/form/profile_customize.php:162
|
255 |
-
#: includes/admin/templates/form/profile_customize.php:183
|
256 |
-
#: includes/admin/templates/form/profile_customize.php:194
|
257 |
-
#: includes/admin/templates/form/profile_customize.php:205
|
258 |
-
#: includes/admin/templates/form/profile_customize.php:216
|
259 |
-
#: includes/admin/templates/form/register_customize.php:33
|
260 |
-
#: includes/admin/templates/form/register_customize.php:89
|
261 |
-
#: includes/admin/templates/form/register_gdpr.php:31
|
262 |
-
#: includes/admin/templates/role/profile.php:53
|
263 |
-
#: includes/core/class-builtin.php:1228
|
264 |
-
#: includes/core/class-builtin.php:1247
|
265 |
-
#: includes/core/class-builtin.php:1263
|
266 |
-
#: includes/core/class-builtin.php:1266
|
267 |
-
#: includes/core/um-actions-account.php:326
|
268 |
-
msgid "No"
|
269 |
-
msgstr ""
|
270 |
-
|
271 |
-
#: includes/admin/core/class-admin-columns.php:186
|
272 |
-
#: includes/admin/core/class-admin-columns.php:219
|
273 |
-
#: includes/admin/core/class-admin-settings.php:1076
|
274 |
-
#: includes/admin/core/class-admin-settings.php:1179
|
275 |
-
#: includes/admin/core/list-tables/roles-list-table.php:383
|
276 |
-
#: includes/admin/core/list-tables/roles-list-table.php:391
|
277 |
-
#: includes/admin/core/packages/2.1.3-beta3/functions.php:75
|
278 |
-
#: includes/admin/core/packages/2.1.3-beta3/functions.php:76
|
279 |
-
#: includes/admin/templates/form/login_customize.php:28
|
280 |
-
#: includes/admin/templates/form/login_customize.php:76
|
281 |
-
#: includes/admin/templates/form/login_customize.php:95
|
282 |
-
#: includes/admin/templates/form/login_customize.php:106
|
283 |
-
#: includes/admin/templates/form/profile_customize.php:43
|
284 |
-
#: includes/admin/templates/form/profile_customize.php:109
|
285 |
-
#: includes/admin/templates/form/profile_customize.php:128
|
286 |
-
#: includes/admin/templates/form/profile_customize.php:163
|
287 |
-
#: includes/admin/templates/form/profile_customize.php:184
|
288 |
-
#: includes/admin/templates/form/profile_customize.php:195
|
289 |
-
#: includes/admin/templates/form/profile_customize.php:206
|
290 |
-
#: includes/admin/templates/form/profile_customize.php:217
|
291 |
-
#: includes/admin/templates/form/register_customize.php:34
|
292 |
-
#: includes/admin/templates/form/register_customize.php:90
|
293 |
-
#: includes/admin/templates/form/register_gdpr.php:32
|
294 |
-
#: includes/admin/templates/role/profile.php:54
|
295 |
-
#: includes/core/class-builtin.php:1229
|
296 |
-
#: includes/core/class-builtin.php:1248
|
297 |
-
#: includes/core/class-builtin.php:1265
|
298 |
-
#: includes/core/class-user.php:223
|
299 |
-
#: includes/core/class-user.php:224
|
300 |
-
#: includes/core/um-actions-account.php:321
|
301 |
-
msgid "Yes"
|
302 |
-
msgstr ""
|
303 |
-
|
304 |
-
#: includes/admin/core/class-admin-enqueue.php:195
|
305 |
-
msgid "e.g. Member Directory"
|
306 |
-
msgstr ""
|
307 |
-
|
308 |
-
#: includes/admin/core/class-admin-enqueue.php:197
|
309 |
-
msgid "e.g. New Registration Form"
|
310 |
-
msgstr ""
|
311 |
-
|
312 |
-
#: includes/admin/core/class-admin-enqueue.php:490
|
313 |
-
#: includes/core/class-builtin.php:732
|
314 |
-
#: includes/core/class-builtin.php:735
|
315 |
-
#: includes/core/class-builtin.php:1272
|
316 |
-
#: includes/core/class-builtin.php:1275
|
317 |
-
#: includes/core/um-actions-account.php:617
|
318 |
-
#: includes/core/um-actions-account.php:689
|
319 |
-
msgid "Password"
|
320 |
-
msgstr ""
|
321 |
-
|
322 |
-
#: includes/admin/core/class-admin-enqueue.php:494
|
323 |
-
#: includes/admin/core/class-admin-metabox.php:2304
|
324 |
-
#: includes/core/class-account.php:109
|
325 |
-
msgid "Privacy"
|
326 |
-
msgstr ""
|
327 |
-
|
328 |
-
#: includes/admin/core/class-admin-enqueue.php:498
|
329 |
-
#: includes/core/class-account.php:115
|
330 |
-
msgid "Notifications"
|
331 |
-
msgstr ""
|
332 |
-
|
333 |
-
#: includes/admin/core/class-admin-enqueue.php:548
|
334 |
-
msgid "Ultimate Member Blocks"
|
335 |
-
msgstr ""
|
336 |
-
|
337 |
-
#: includes/admin/core/class-admin-forms.php:318
|
338 |
-
#: includes/core/um-filters-fields.php:17
|
339 |
-
msgid "Required"
|
340 |
-
msgstr ""
|
341 |
-
|
342 |
-
#: includes/admin/core/class-admin-forms.php:526
|
343 |
-
#: includes/admin/core/class-admin-metabox.php:1463
|
344 |
-
#: includes/admin/core/class-admin-metabox.php:1491
|
345 |
-
msgid "Choose Icon"
|
346 |
-
msgstr ""
|
347 |
-
|
348 |
-
#: includes/admin/core/class-admin-forms.php:532
|
349 |
-
#: includes/admin/core/class-admin-metabox.php:1465
|
350 |
-
#: includes/admin/core/class-admin-metabox.php:1493
|
351 |
-
#: includes/admin/assets/js/um-admin-modal.js:415
|
352 |
-
#: includes/admin/assets/js/um-admin-modal.js:419
|
353 |
-
msgid "No Icon"
|
354 |
-
msgstr ""
|
355 |
-
|
356 |
-
#: includes/admin/core/class-admin-forms.php:895
|
357 |
-
#: includes/admin/core/class-admin-upgrade.php:255
|
358 |
-
msgid "Run"
|
359 |
-
msgstr ""
|
360 |
-
|
361 |
-
#: includes/admin/core/class-admin-forms.php:1035
|
362 |
-
#: includes/admin/core/class-admin-forms.php:1054
|
363 |
-
#: includes/admin/core/class-admin-forms.php:1181
|
364 |
-
#: includes/admin/core/class-admin-forms.php:1190
|
365 |
-
#: includes/admin/core/class-admin-forms.php:1430
|
366 |
-
#: includes/admin/core/class-admin-forms.php:1444
|
367 |
-
#: includes/admin/core/class-admin-forms.php:1540
|
368 |
-
#: includes/admin/core/class-admin-forms.php:1562
|
369 |
-
#: includes/admin/core/class-admin-notices.php:401
|
370 |
-
#: includes/core/um-actions-profile.php:841
|
371 |
-
#: includes/admin/assets/js/um-admin-forms.js:201
|
372 |
-
#: includes/admin/assets/js/um-admin-forms.js:266
|
373 |
-
#: includes/admin/assets/js/um-admin-forms.js:543
|
374 |
-
#: includes/admin/assets/js/um-admin-forms.js:576
|
375 |
-
msgid "Remove"
|
376 |
-
msgstr ""
|
377 |
-
|
378 |
-
#: includes/admin/core/class-admin-forms.php:1237
|
379 |
-
msgid "Select media"
|
380 |
-
msgstr ""
|
381 |
-
|
382 |
-
#: includes/admin/core/class-admin-forms.php:1260
|
383 |
-
#: includes/admin/assets/js/um-admin-forms.js:624
|
384 |
-
msgid "Select"
|
385 |
-
msgstr ""
|
386 |
-
|
387 |
-
#: includes/admin/core/class-admin-forms.php:1261
|
388 |
-
msgid "Clear"
|
389 |
-
msgstr ""
|
390 |
-
|
391 |
-
#: includes/admin/core/class-admin-forms.php:1541
|
392 |
-
#: includes/admin/core/class-admin-forms.php:1563
|
393 |
-
#: includes/admin/templates/directory/sorting.php:22
|
394 |
-
#: includes/admin/assets/js/um-admin-forms.js:203
|
395 |
-
msgid "Meta key"
|
396 |
-
msgstr ""
|
397 |
-
|
398 |
-
#: includes/admin/core/class-admin-forms.php:1542
|
399 |
-
#: includes/admin/core/class-admin-forms.php:1564
|
400 |
-
#: includes/admin/core/class-admin-metabox.php:2265
|
401 |
-
#: includes/admin/assets/js/um-admin-forms.js:204
|
402 |
-
msgid "Label"
|
403 |
-
msgstr ""
|
404 |
-
|
405 |
-
#: includes/admin/core/class-admin-gdpr.php:42
|
406 |
-
msgid "Privacy Policy"
|
407 |
-
msgstr ""
|
408 |
-
|
409 |
-
#: includes/admin/core/class-admin-gdpr.php:57
|
410 |
-
msgid "Account Status"
|
411 |
-
msgstr ""
|
412 |
-
|
413 |
-
#: includes/admin/core/class-admin-gdpr.php:58
|
414 |
-
msgid "Submitted data on Registration"
|
415 |
-
msgstr ""
|
416 |
-
|
417 |
-
#: includes/admin/core/class-admin-gdpr.php:59
|
418 |
-
msgid "Registration Form ID"
|
419 |
-
msgstr ""
|
420 |
-
|
421 |
-
#: includes/admin/core/class-admin-gdpr.php:60
|
422 |
-
msgid "Registration Timestamp"
|
423 |
-
msgstr ""
|
424 |
-
|
425 |
-
#: includes/admin/core/class-admin-gdpr.php:61
|
426 |
-
msgid "Registration Request"
|
427 |
-
msgstr ""
|
428 |
-
|
429 |
-
#: includes/admin/core/class-admin-gdpr.php:62
|
430 |
-
msgid "Registration Nonce"
|
431 |
-
msgstr ""
|
432 |
-
|
433 |
-
#: includes/admin/core/class-admin-gdpr.php:63
|
434 |
-
msgid "Registration HTTP referer"
|
435 |
-
msgstr ""
|
436 |
-
|
437 |
-
#: includes/admin/core/class-admin-gdpr.php:64
|
438 |
-
msgid "Community Role"
|
439 |
-
msgstr ""
|
440 |
-
|
441 |
-
#: includes/admin/core/class-admin-gdpr.php:65
|
442 |
-
msgid "Profile Slug \"Username\""
|
443 |
-
msgstr ""
|
444 |
-
|
445 |
-
#: includes/admin/core/class-admin-gdpr.php:66
|
446 |
-
msgid "Profile Slug \"First and Last Name with '.'\""
|
447 |
-
msgstr ""
|
448 |
-
|
449 |
-
#: includes/admin/core/class-admin-gdpr.php:67
|
450 |
-
msgid "Profile Slug \"First and Last Name with '-'\""
|
451 |
-
msgstr ""
|
452 |
-
|
453 |
-
#: includes/admin/core/class-admin-gdpr.php:68
|
454 |
-
msgid "Profile Slug \"First and Last Name with '+'\""
|
455 |
-
msgstr ""
|
456 |
-
|
457 |
-
#: includes/admin/core/class-admin-gdpr.php:69
|
458 |
-
msgid "Profile Slug \"User ID\""
|
459 |
-
msgstr ""
|
460 |
-
|
461 |
-
#: includes/admin/core/class-admin-gdpr.php:70
|
462 |
-
msgid "Last Login Timestamp"
|
463 |
-
msgstr ""
|
464 |
-
|
465 |
-
#: includes/admin/core/class-admin-gdpr.php:73
|
466 |
-
msgid "Private Content Post ID"
|
467 |
-
msgstr ""
|
468 |
-
|
469 |
-
#: includes/admin/core/class-admin-gdpr.php:76
|
470 |
-
msgid "Verified Account"
|
471 |
-
msgstr ""
|
472 |
-
|
473 |
-
#: includes/admin/core/class-admin-gdpr.php:79
|
474 |
-
msgid "Terms&Conditions Agreement"
|
475 |
-
msgstr ""
|
476 |
-
|
477 |
-
#: includes/admin/core/class-admin-gdpr.php:82
|
478 |
-
msgid "Privacy Policy Agreement"
|
479 |
-
msgstr ""
|
480 |
-
|
481 |
-
#: includes/admin/core/class-admin-gdpr.php:298
|
482 |
-
msgid "Your %s was unable to be removed at this time."
|
483 |
-
msgstr ""
|
484 |
-
|
485 |
-
#: includes/admin/core/class-admin-menu.php:65
|
486 |
-
msgid "Thanks :)"
|
487 |
-
msgstr ""
|
488 |
-
|
489 |
-
#: includes/admin/core/class-admin-menu.php:72
|
490 |
-
msgid "If you like Ultimate Member please consider leaving a %s review. It will help us to grow the plugin and make it more popular. Thank you."
|
491 |
-
msgstr ""
|
492 |
-
|
493 |
-
#: includes/admin/core/class-admin-menu.php:151
|
494 |
-
msgid "Dashboard"
|
495 |
-
msgstr ""
|
496 |
-
|
497 |
-
#: includes/admin/core/class-admin-menu.php:159
|
498 |
-
#: includes/admin/templates/gdpr.php:7
|
499 |
-
#: includes/core/class-common.php:58
|
500 |
-
msgid "Forms"
|
501 |
-
msgstr ""
|
502 |
-
|
503 |
-
#: includes/admin/core/class-admin-menu.php:161
|
504 |
-
#: includes/admin/core/list-tables/roles-list-table.php:495
|
505 |
-
msgid "User Roles"
|
506 |
-
msgstr ""
|
507 |
-
|
508 |
-
#: includes/admin/core/class-admin-menu.php:164
|
509 |
-
#: includes/core/class-common.php:88
|
510 |
-
msgid "Member Directories"
|
511 |
-
msgstr ""
|
512 |
-
|
513 |
-
#: includes/admin/core/class-admin-menu.php:206
|
514 |
-
#: includes/admin/core/class-admin-settings.php:1724
|
515 |
-
msgid "Extensions"
|
516 |
-
msgstr ""
|
517 |
-
|
518 |
-
#: includes/admin/core/class-admin-menu.php:219
|
519 |
-
msgid "Users Overview"
|
520 |
-
msgstr ""
|
521 |
-
|
522 |
-
#: includes/admin/core/class-admin-menu.php:221
|
523 |
-
msgid "Purge Temp Files"
|
524 |
-
msgstr ""
|
525 |
-
|
526 |
-
#: includes/admin/core/class-admin-menu.php:223
|
527 |
-
msgid "User Cache"
|
528 |
-
msgstr ""
|
529 |
-
|
530 |
-
#: includes/admin/core/class-admin-menu.php:228
|
531 |
-
msgid "Upgrade's Manual Request"
|
532 |
-
msgstr ""
|
533 |
-
|
534 |
-
#: includes/admin/core/class-admin-metabox.php:237
|
535 |
-
#: includes/admin/assets/js/um-admin-blocks.js:68
|
536 |
-
msgid "Ultimate Member: Content Restriction"
|
537 |
-
msgstr ""
|
538 |
-
|
539 |
-
#: includes/admin/core/class-admin-metabox.php:391
|
540 |
-
#: includes/admin/core/class-admin-metabox.php:542
|
541 |
-
msgid "Restrict access to this term and its posts?"
|
542 |
-
msgstr ""
|
543 |
-
|
544 |
-
#: includes/admin/core/class-admin-metabox.php:392
|
545 |
-
#: includes/admin/core/class-admin-metabox.php:543
|
546 |
-
msgid "Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings"
|
547 |
-
msgstr ""
|
548 |
-
|
549 |
-
#: includes/admin/core/class-admin-metabox.php:398
|
550 |
-
#: includes/admin/core/class-admin-metabox.php:549
|
551 |
-
msgid "Who can access this term and its posts?"
|
552 |
-
msgstr ""
|
553 |
-
|
554 |
-
#: includes/admin/core/class-admin-metabox.php:401
|
555 |
-
#: includes/admin/core/class-admin-metabox.php:552
|
556 |
-
#: includes/admin/core/class-admin-metabox.php:2294
|
557 |
-
#: includes/admin/core/class-admin-navmenu.php:81
|
558 |
-
#: includes/admin/core/class-admin-navmenu.php:242
|
559 |
-
#: includes/admin/templates/access/restrict_content.php:65
|
560 |
-
#: includes/core/class-builtin.php:696
|
561 |
-
#: includes/admin/assets/js/um-admin-blocks.js:100
|
562 |
-
msgid "Everyone"
|
563 |
-
msgstr ""
|
564 |
-
|
565 |
-
#: includes/admin/core/class-admin-metabox.php:402
|
566 |
-
#: includes/admin/core/class-admin-metabox.php:553
|
567 |
-
#: includes/admin/templates/access/restrict_content.php:66
|
568 |
-
#: includes/admin/assets/js/um-admin-blocks.js:108
|
569 |
-
msgid "Logged out users"
|
570 |
-
msgstr ""
|
571 |
-
|
572 |
-
#: includes/admin/core/class-admin-metabox.php:403
|
573 |
-
#: includes/admin/core/class-admin-metabox.php:554
|
574 |
-
#: includes/admin/templates/access/restrict_content.php:67
|
575 |
-
#: includes/admin/assets/js/um-admin-blocks.js:104
|
576 |
-
msgid "Logged in users"
|
577 |
-
msgstr ""
|
578 |
-
|
579 |
-
#: includes/admin/core/class-admin-metabox.php:410
|
580 |
-
#: includes/admin/core/class-admin-metabox.php:561
|
581 |
-
msgid "Select which roles can access this term and its posts"
|
582 |
-
msgstr ""
|
583 |
-
|
584 |
-
#: includes/admin/core/class-admin-metabox.php:411
|
585 |
-
#: includes/admin/core/class-admin-metabox.php:562
|
586 |
-
msgid "Leave empty if you want to display a term for all logged in users"
|
587 |
-
msgstr ""
|
588 |
-
|
589 |
-
#: includes/admin/core/class-admin-metabox.php:419
|
590 |
-
#: includes/admin/core/class-admin-metabox.php:571
|
591 |
-
#: includes/admin/templates/access/restrict_content.php:84
|
592 |
-
msgid "Hide from queries"
|
593 |
-
msgstr ""
|
594 |
-
|
595 |
-
#: includes/admin/core/class-admin-metabox.php:419
|
596 |
-
#: includes/admin/core/class-admin-metabox.php:571
|
597 |
-
msgid "Would you like to display 404 error on the term's archive page and terms' posts single pages when users haven't access?"
|
598 |
-
msgstr ""
|
599 |
-
|
600 |
-
#: includes/admin/core/class-admin-metabox.php:420
|
601 |
-
#: includes/admin/core/class-admin-metabox.php:572
|
602 |
-
#: includes/admin/templates/access/restrict_content.php:85
|
603 |
-
msgid "Exclude only from WP queries results"
|
604 |
-
msgstr ""
|
605 |
-
|
606 |
-
#: includes/admin/core/class-admin-metabox.php:420
|
607 |
-
#: includes/admin/core/class-admin-metabox.php:572
|
608 |
-
msgid "Recommended to be enabled. Restricted term's archive page and all terms' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site"
|
609 |
-
msgstr ""
|
610 |
-
|
611 |
-
#: includes/admin/core/class-admin-metabox.php:427
|
612 |
-
#: includes/admin/core/class-admin-metabox.php:579
|
613 |
-
msgid "What happens when users without access try to view the term's post?"
|
614 |
-
msgstr ""
|
615 |
-
|
616 |
-
#: includes/admin/core/class-admin-metabox.php:428
|
617 |
-
#: includes/admin/core/class-admin-metabox.php:580
|
618 |
-
msgid "Action when users without access tries to view the term's post"
|
619 |
-
msgstr ""
|
620 |
-
|
621 |
-
#: includes/admin/core/class-admin-metabox.php:431
|
622 |
-
#: includes/admin/core/class-admin-metabox.php:583
|
623 |
-
#: includes/admin/templates/access/restrict_content.php:96
|
624 |
-
msgid "Show access restricted message"
|
625 |
-
msgstr ""
|
626 |
-
|
627 |
-
#: includes/admin/core/class-admin-metabox.php:432
|
628 |
-
#: includes/admin/core/class-admin-metabox.php:584
|
629 |
-
#: includes/admin/templates/access/restrict_content.php:97
|
630 |
-
msgid "Redirect user"
|
631 |
-
msgstr ""
|
632 |
-
|
633 |
-
#: includes/admin/core/class-admin-metabox.php:439
|
634 |
-
#: includes/admin/core/class-admin-metabox.php:591
|
635 |
-
#: includes/admin/templates/access/restrict_content.php:104
|
636 |
-
msgid "Restricted access message type"
|
637 |
-
msgstr ""
|
638 |
-
|
639 |
-
#: includes/admin/core/class-admin-metabox.php:440
|
640 |
-
#: includes/admin/core/class-admin-metabox.php:592
|
641 |
-
msgid "Would you like to use the global default message or apply a custom message to this term's post?"
|
642 |
-
msgstr ""
|
643 |
-
|
644 |
-
#: includes/admin/core/class-admin-metabox.php:443
|
645 |
-
#: includes/admin/core/class-admin-metabox.php:595
|
646 |
-
#: includes/admin/templates/access/restrict_content.php:108
|
647 |
-
msgid "Global default message"
|
648 |
-
msgstr ""
|
649 |
-
|
650 |
-
#: includes/admin/core/class-admin-metabox.php:444
|
651 |
-
#: includes/admin/core/class-admin-metabox.php:596
|
652 |
-
#: includes/admin/templates/access/restrict_content.php:109
|
653 |
-
msgid "Custom message"
|
654 |
-
msgstr ""
|
655 |
-
|
656 |
-
#: includes/admin/core/class-admin-metabox.php:451
|
657 |
-
#: includes/admin/core/class-admin-metabox.php:603
|
658 |
-
#: includes/admin/templates/access/restrict_content.php:116
|
659 |
-
#: includes/admin/assets/js/um-admin-blocks.js:179
|
660 |
-
msgid "Custom restricted access message"
|
661 |
-
msgstr ""
|
662 |
-
|
663 |
-
#: includes/admin/core/class-admin-metabox.php:452
|
664 |
-
#: includes/admin/core/class-admin-metabox.php:604
|
665 |
-
#: includes/admin/templates/access/restrict_content.php:117
|
666 |
-
msgid "You may replace global restricted access message here"
|
667 |
-
msgstr ""
|
668 |
-
|
669 |
-
#: includes/admin/core/class-admin-metabox.php:459
|
670 |
-
#: includes/admin/core/class-admin-metabox.php:611
|
671 |
-
#: includes/admin/templates/access/restrict_content.php:124
|
672 |
-
msgid "Where should users be redirected to?"
|
673 |
-
msgstr ""
|
674 |
-
|
675 |
-
#: includes/admin/core/class-admin-metabox.php:460
|
676 |
-
#: includes/admin/core/class-admin-metabox.php:612
|
677 |
-
msgid "Select redirect to page when user hasn't access to the term's post"
|
678 |
-
msgstr ""
|
679 |
-
|
680 |
-
#: includes/admin/core/class-admin-metabox.php:464
|
681 |
-
#: includes/admin/core/class-admin-metabox.php:615
|
682 |
-
#: includes/admin/templates/access/restrict_content.php:128
|
683 |
-
msgid "Login page"
|
684 |
-
msgstr ""
|
685 |
-
|
686 |
-
#: includes/admin/core/class-admin-metabox.php:465
|
687 |
-
#: includes/admin/core/class-admin-metabox.php:616
|
688 |
-
#: includes/admin/templates/access/restrict_content.php:129
|
689 |
-
msgid "Custom URL"
|
690 |
-
msgstr ""
|
691 |
-
|
692 |
-
#: includes/admin/core/class-admin-metabox.php:471
|
693 |
-
#: includes/admin/core/class-admin-metabox.php:623
|
694 |
-
#: includes/admin/templates/access/restrict_content.php:136
|
695 |
-
msgid "Redirect URL"
|
696 |
-
msgstr ""
|
697 |
-
|
698 |
-
#: includes/admin/core/class-admin-metabox.php:472
|
699 |
-
#: includes/admin/core/class-admin-metabox.php:624
|
700 |
-
#: includes/admin/templates/access/restrict_content.php:137
|
701 |
-
msgid "Set full URL where do you want to redirect the user"
|
702 |
-
msgstr ""
|
703 |
-
|
704 |
-
#: includes/admin/core/class-admin-metabox.php:808
|
705 |
-
msgid "General Options"
|
706 |
-
msgstr ""
|
707 |
-
|
708 |
-
#: includes/admin/core/class-admin-metabox.php:809
|
709 |
-
msgid "Sorting"
|
710 |
-
msgstr ""
|
711 |
-
|
712 |
-
#: includes/admin/core/class-admin-metabox.php:810
|
713 |
-
msgid "Profile Card"
|
714 |
-
msgstr ""
|
715 |
-
|
716 |
-
#: includes/admin/core/class-admin-metabox.php:811
|
717 |
-
msgid "Search Options"
|
718 |
-
msgstr ""
|
719 |
-
|
720 |
-
#: includes/admin/core/class-admin-metabox.php:812
|
721 |
-
msgid "Results & Pagination"
|
722 |
-
msgstr ""
|
723 |
-
|
724 |
-
#: includes/admin/core/class-admin-metabox.php:814
|
725 |
-
msgid "Styling: General"
|
726 |
-
msgstr ""
|
727 |
-
|
728 |
-
#: includes/admin/core/class-admin-metabox.php:827
|
729 |
-
msgid "Administrative Permissions"
|
730 |
-
msgstr ""
|
731 |
-
|
732 |
-
#: includes/admin/core/class-admin-metabox.php:835
|
733 |
-
msgid "General Permissions"
|
734 |
-
msgstr ""
|
735 |
-
|
736 |
-
#: includes/admin/core/class-admin-metabox.php:843
|
737 |
-
msgid "Profile Access"
|
738 |
-
msgstr ""
|
739 |
-
|
740 |
-
#: includes/admin/core/class-admin-metabox.php:854
|
741 |
-
msgid "Homepage Options"
|
742 |
-
msgstr ""
|
743 |
-
|
744 |
-
#: includes/admin/core/class-admin-metabox.php:865
|
745 |
-
msgid "Registration Options"
|
746 |
-
msgstr ""
|
747 |
-
|
748 |
-
#: includes/admin/core/class-admin-metabox.php:873
|
749 |
-
msgid "Login Options"
|
750 |
-
msgstr ""
|
751 |
-
|
752 |
-
#: includes/admin/core/class-admin-metabox.php:881
|
753 |
-
msgid "Logout Options"
|
754 |
-
msgstr ""
|
755 |
-
|
756 |
-
#: includes/admin/core/class-admin-metabox.php:889
|
757 |
-
msgid "Delete Options"
|
758 |
-
msgstr ""
|
759 |
-
|
760 |
-
#: includes/admin/core/class-admin-metabox.php:897
|
761 |
-
msgid "Publish"
|
762 |
-
msgstr ""
|
763 |
-
|
764 |
-
#: includes/admin/core/class-admin-metabox.php:946
|
765 |
-
msgid "WP Capabilities"
|
766 |
-
msgstr ""
|
767 |
-
|
768 |
-
#: includes/admin/core/class-admin-metabox.php:973
|
769 |
-
msgid "Select Form Type"
|
770 |
-
msgstr ""
|
771 |
-
|
772 |
-
#: includes/admin/core/class-admin-metabox.php:974
|
773 |
-
msgid "Form Builder"
|
774 |
-
msgstr ""
|
775 |
-
|
776 |
-
#: includes/admin/core/class-admin-metabox.php:977
|
777 |
-
#: includes/admin/core/class-admin-metabox.php:998
|
778 |
-
#: includes/admin/core/class-admin-metabox.php:1020
|
779 |
-
msgid "Customize this form"
|
780 |
-
msgstr ""
|
781 |
-
|
782 |
-
#: includes/admin/core/class-admin-metabox.php:999
|
783 |
-
msgid "User Meta"
|
784 |
-
msgstr ""
|
785 |
-
|
786 |
-
#: includes/admin/core/class-admin-metabox.php:1021
|
787 |
-
msgid "Options"
|
788 |
-
msgstr ""
|
789 |
-
|
790 |
-
#: includes/admin/core/class-admin-metabox.php:1073
|
791 |
-
msgid "Directory #%s"
|
792 |
-
msgstr ""
|
793 |
-
|
794 |
-
#: includes/admin/core/class-admin-metabox.php:1169
|
795 |
-
msgid "Form #%s"
|
796 |
-
msgstr ""
|
797 |
-
|
798 |
-
#: includes/admin/core/class-admin-metabox.php:1284
|
799 |
-
msgid "Visibility"
|
800 |
-
msgstr ""
|
801 |
-
|
802 |
-
#: includes/admin/core/class-admin-metabox.php:1284
|
803 |
-
msgid "Select where this field should appear. This option should only be changed on the profile form and allows you to show a field in one mode only (edit or view) or in both modes."
|
804 |
-
msgstr ""
|
805 |
-
|
806 |
-
#: includes/admin/core/class-admin-metabox.php:1286
|
807 |
-
msgid "View everywhere"
|
808 |
-
msgstr ""
|
809 |
-
|
810 |
-
#: includes/admin/core/class-admin-metabox.php:1287
|
811 |
-
msgid "Edit mode only"
|
812 |
-
msgstr ""
|
813 |
-
|
814 |
-
#: includes/admin/core/class-admin-metabox.php:1288
|
815 |
-
msgid "View mode only"
|
816 |
-
msgstr ""
|
817 |
-
|
818 |
-
#: includes/admin/core/class-admin-metabox.php:1393
|
819 |
-
msgid "Value"
|
820 |
-
msgstr ""
|
821 |
-
|
822 |
-
#: includes/admin/core/class-admin-metabox.php:1402
|
823 |
-
msgid "Validate"
|
824 |
-
msgstr ""
|
825 |
-
|
826 |
-
#: includes/admin/core/class-admin-metabox.php:1402
|
827 |
-
msgid "Does this field require a special validation"
|
828 |
-
msgstr ""
|
829 |
-
|
830 |
-
#: includes/admin/core/class-admin-metabox.php:1403
|
831 |
-
msgid "Select a validation type..."
|
832 |
-
msgstr ""
|
833 |
-
|
834 |
-
#: includes/admin/core/class-admin-metabox.php:1447
|
835 |
-
msgid "Custom Action"
|
836 |
-
msgstr ""
|
837 |
-
|
838 |
-
#: includes/admin/core/class-admin-metabox.php:1447
|
839 |
-
msgid "If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details."
|
840 |
-
msgstr ""
|
841 |
-
|
842 |
-
#: includes/admin/core/class-admin-metabox.php:1461
|
843 |
-
#: includes/admin/core/class-admin-metabox.php:1489
|
844 |
-
msgid "Icon"
|
845 |
-
msgstr ""
|
846 |
-
|
847 |
-
#: includes/admin/core/class-admin-metabox.php:1461
|
848 |
-
#: includes/admin/core/class-admin-metabox.php:1489
|
849 |
-
msgid "Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field."
|
850 |
-
msgstr ""
|
851 |
-
|
852 |
-
#: includes/admin/core/class-admin-metabox.php:1516
|
853 |
-
msgid "CSS Class"
|
854 |
-
msgstr ""
|
855 |
-
|
856 |
-
#: includes/admin/core/class-admin-metabox.php:1516
|
857 |
-
msgid "Specify a custom CSS class to be applied to this element"
|
858 |
-
msgstr ""
|
859 |
-
|
860 |
-
#: includes/admin/core/class-admin-metabox.php:1526
|
861 |
-
msgid "Thickness (in pixels)"
|
862 |
-
msgstr ""
|
863 |
-
|
864 |
-
#: includes/admin/core/class-admin-metabox.php:1526
|
865 |
-
msgid "This is the width in pixels, e.g. 4 or 2, etc"
|
866 |
-
msgstr ""
|
867 |
-
|
868 |
-
#: includes/admin/core/class-admin-metabox.php:1536
|
869 |
-
msgid "Optional Text"
|
870 |
-
msgstr ""
|
871 |
-
|
872 |
-
#: includes/admin/core/class-admin-metabox.php:1536
|
873 |
-
msgid "Optional text to include with the divider"
|
874 |
-
msgstr ""
|
875 |
-
|
876 |
-
#: includes/admin/core/class-admin-metabox.php:1546
|
877 |
-
msgid "Padding"
|
878 |
-
msgstr ""
|
879 |
-
|
880 |
-
#: includes/admin/core/class-admin-metabox.php:1546
|
881 |
-
msgid "Set padding for this section"
|
882 |
-
msgstr ""
|
883 |
-
|
884 |
-
#: includes/admin/core/class-admin-metabox.php:1556
|
885 |
-
msgid "Margin"
|
886 |
-
msgstr ""
|
887 |
-
|
888 |
-
#: includes/admin/core/class-admin-metabox.php:1556
|
889 |
-
msgid "Set margin for this section"
|
890 |
-
msgstr ""
|
891 |
-
|
892 |
-
#: includes/admin/core/class-admin-metabox.php:1566
|
893 |
-
msgid "Border"
|
894 |
-
msgstr ""
|
895 |
-
|
896 |
-
#: includes/admin/core/class-admin-metabox.php:1566
|
897 |
-
msgid "Set border for this section"
|
898 |
-
msgstr ""
|
899 |
-
|
900 |
-
#: includes/admin/core/class-admin-metabox.php:1576
|
901 |
-
#: includes/admin/core/class-admin-metabox.php:1747
|
902 |
-
msgid "Style"
|
903 |
-
msgstr ""
|
904 |
-
|
905 |
-
#: includes/admin/core/class-admin-metabox.php:1576
|
906 |
-
msgid "Choose the border style"
|
907 |
-
msgstr ""
|
908 |
-
|
909 |
-
#: includes/admin/core/class-admin-metabox.php:1578
|
910 |
-
#: includes/admin/core/class-admin-metabox.php:1749
|
911 |
-
msgid "Solid"
|
912 |
-
msgstr ""
|
913 |
-
|
914 |
-
#: includes/admin/core/class-admin-metabox.php:1579
|
915 |
-
#: includes/admin/core/class-admin-metabox.php:1750
|
916 |
-
msgid "Dotted"
|
917 |
-
msgstr ""
|
918 |
-
|
919 |
-
#: includes/admin/core/class-admin-metabox.php:1580
|
920 |
-
#: includes/admin/core/class-admin-metabox.php:1751
|
921 |
-
msgid "Dashed"
|
922 |
-
msgstr ""
|
923 |
-
|
924 |
-
#: includes/admin/core/class-admin-metabox.php:1581
|
925 |
-
#: includes/admin/core/class-admin-metabox.php:1752
|
926 |
-
msgid "Double"
|
927 |
-
msgstr ""
|
928 |
-
|
929 |
-
#: includes/admin/core/class-admin-metabox.php:1591
|
930 |
-
msgid "Border Radius"
|
931 |
-
msgstr ""
|
932 |
-
|
933 |
-
#: includes/admin/core/class-admin-metabox.php:1591
|
934 |
-
msgid "Rounded corners can be applied by setting a pixels value here. e.g. 5px"
|
935 |
-
msgstr ""
|
936 |
-
|
937 |
-
#: includes/admin/core/class-admin-metabox.php:1601
|
938 |
-
msgid "Border Color"
|
939 |
-
msgstr ""
|
940 |
-
|
941 |
-
#: includes/admin/core/class-admin-metabox.php:1601
|
942 |
-
msgid "Give a color to this border"
|
943 |
-
msgstr ""
|
944 |
-
|
945 |
-
#: includes/admin/core/class-admin-metabox.php:1611
|
946 |
-
msgid "Enable Row Heading"
|
947 |
-
msgstr ""
|
948 |
-
|
949 |
-
#: includes/admin/core/class-admin-metabox.php:1611
|
950 |
-
msgid "Whether to enable a heading for this row"
|
951 |
-
msgstr ""
|
952 |
-
|
953 |
-
#: includes/admin/core/class-admin-metabox.php:1621
|
954 |
-
msgid "Heading Text"
|
955 |
-
msgstr ""
|
956 |
-
|
957 |
-
#: includes/admin/core/class-admin-metabox.php:1621
|
958 |
-
msgid "Enter the row heading text here"
|
959 |
-
msgstr ""
|
960 |
-
|
961 |
-
#: includes/admin/core/class-admin-metabox.php:1631
|
962 |
-
msgid "Background Color"
|
963 |
-
msgstr ""
|
964 |
-
|
965 |
-
#: includes/admin/core/class-admin-metabox.php:1631
|
966 |
-
msgid "This will be the background of entire section"
|
967 |
-
msgstr ""
|
968 |
-
|
969 |
-
#: includes/admin/core/class-admin-metabox.php:1641
|
970 |
-
msgid "Heading Background Color"
|
971 |
-
msgstr ""
|
972 |
-
|
973 |
-
#: includes/admin/core/class-admin-metabox.php:1641
|
974 |
-
msgid "This will be the background of the heading section"
|
975 |
-
msgstr ""
|
976 |
-
|
977 |
-
#: includes/admin/core/class-admin-metabox.php:1651
|
978 |
-
msgid "Heading Text Color"
|
979 |
-
msgstr ""
|
980 |
-
|
981 |
-
#: includes/admin/core/class-admin-metabox.php:1651
|
982 |
-
msgid "This will be the text color of heading part only"
|
983 |
-
msgstr ""
|
984 |
-
|
985 |
-
#: includes/admin/core/class-admin-metabox.php:1661
|
986 |
-
msgid "Text Color"
|
987 |
-
msgstr ""
|
988 |
-
|
989 |
-
#: includes/admin/core/class-admin-metabox.php:1661
|
990 |
-
msgid "This will be the text color of entire section"
|
991 |
-
msgstr ""
|
992 |
-
|
993 |
-
#: includes/admin/core/class-admin-metabox.php:1671
|
994 |
-
msgid "Icon Color"
|
995 |
-
msgstr ""
|
996 |
-
|
997 |
-
#: includes/admin/core/class-admin-metabox.php:1671
|
998 |
-
msgid "This will be the color of selected icon. By default It will be the same color as heading text color"
|
999 |
-
msgstr ""
|
1000 |
-
|
1001 |
-
#: includes/admin/core/class-admin-metabox.php:1681
|
1002 |
-
msgid "Color"
|
1003 |
-
msgstr ""
|
1004 |
-
|
1005 |
-
#: includes/admin/core/class-admin-metabox.php:1681
|
1006 |
-
msgid "Select a color for this divider"
|
1007 |
-
msgstr ""
|
1008 |
-
|
1009 |
-
#: includes/admin/core/class-admin-metabox.php:1691
|
1010 |
-
msgid "URL Alt Text"
|
1011 |
-
msgstr ""
|
1012 |
-
|
1013 |
-
#: includes/admin/core/class-admin-metabox.php:1691
|
1014 |
-
msgid "Entering custom text here will replace the url with a text link"
|
1015 |
-
msgstr ""
|
1016 |
-
|
1017 |
-
#: includes/admin/core/class-admin-metabox.php:1701
|
1018 |
-
msgid "Link Target"
|
1019 |
-
msgstr ""
|
1020 |
-
|
1021 |
-
#: includes/admin/core/class-admin-metabox.php:1701
|
1022 |
-
msgid "Choose whether to open this link in same window or in a new window"
|
1023 |
-
msgstr ""
|
1024 |
-
|
1025 |
-
#: includes/admin/core/class-admin-metabox.php:1703
|
1026 |
-
msgid "Open in new window"
|
1027 |
-
msgstr ""
|
1028 |
-
|
1029 |
-
#: includes/admin/core/class-admin-metabox.php:1704
|
1030 |
-
msgid "Same window"
|
1031 |
-
msgstr ""
|
1032 |
-
|
1033 |
-
#: includes/admin/core/class-admin-metabox.php:1714
|
1034 |
-
msgid "SEO Follow"
|
1035 |
-
msgstr ""
|
1036 |
-
|
1037 |
-
#: includes/admin/core/class-admin-metabox.php:1714
|
1038 |
-
msgid "Whether to follow or nofollow this link by search engines"
|
1039 |
-
msgstr ""
|
1040 |
-
|
1041 |
-
#: includes/admin/core/class-admin-metabox.php:1716
|
1042 |
-
msgid "Follow"
|
1043 |
-
msgstr ""
|
1044 |
-
|
1045 |
-
#: includes/admin/core/class-admin-metabox.php:1717
|
1046 |
-
msgid "No-Follow"
|
1047 |
-
msgstr ""
|
1048 |
-
|
1049 |
-
#: includes/admin/core/class-admin-metabox.php:1727
|
1050 |
-
msgid "Force strong password?"
|
1051 |
-
msgstr ""
|
1052 |
-
|
1053 |
-
#: includes/admin/core/class-admin-metabox.php:1727
|
1054 |
-
msgid "Turn on to force users to create a strong password (A combination of one lowercase letter, one uppercase letter, and one number). If turned on this option is only applied to register forms and not to login forms."
|
1055 |
-
msgstr ""
|
1056 |
-
|
1057 |
-
#: includes/admin/core/class-admin-metabox.php:1737
|
1058 |
-
msgid "Automatically add a confirm password field?"
|
1059 |
-
msgstr ""
|
1060 |
-
|
1061 |
-
#: includes/admin/core/class-admin-metabox.php:1737
|
1062 |
-
msgid "Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms."
|
1063 |
-
msgstr ""
|
1064 |
-
|
1065 |
-
#: includes/admin/core/class-admin-metabox.php:1747
|
1066 |
-
msgid "This is the line-style of divider"
|
1067 |
-
msgstr ""
|
1068 |
-
|
1069 |
-
#: includes/admin/core/class-admin-metabox.php:1763
|
1070 |
-
msgid "Time Intervals (in minutes)"
|
1071 |
-
msgstr ""
|
1072 |
-
|
1073 |
-
#: includes/admin/core/class-admin-metabox.php:1763
|
1074 |
-
msgid "Choose the minutes interval between each time in the time picker."
|
1075 |
-
msgstr ""
|
1076 |
-
|
1077 |
-
#: includes/admin/core/class-admin-metabox.php:1764
|
1078 |
-
msgid "e.g. 30, 60, 120"
|
1079 |
-
msgstr ""
|
1080 |
-
|
1081 |
-
#: includes/admin/core/class-admin-metabox.php:1776
|
1082 |
-
msgid "Date User-Friendly Format"
|
1083 |
-
msgstr ""
|
1084 |
-
|
1085 |
-
#: includes/admin/core/class-admin-metabox.php:1776
|
1086 |
-
msgid "The display format of the date which is visible to user."
|
1087 |
-
msgstr ""
|
1088 |
-
|
1089 |
-
#: includes/admin/core/class-admin-metabox.php:1787
|
1090 |
-
msgid "Time Format"
|
1091 |
-
msgstr ""
|
1092 |
-
|
1093 |
-
#: includes/admin/core/class-admin-metabox.php:1787
|
1094 |
-
msgid "Choose the displayed time-format for this field"
|
1095 |
-
msgstr ""
|
1096 |
-
|
1097 |
-
#: includes/admin/core/class-admin-metabox.php:1789
|
1098 |
-
#: includes/admin/core/class-admin-metabox.php:1790
|
1099 |
-
msgid "( 12-hr format )"
|
1100 |
-
msgstr ""
|
1101 |
-
|
1102 |
-
#: includes/admin/core/class-admin-metabox.php:1791
|
1103 |
-
msgid "( 24-hr format )"
|
1104 |
-
msgstr ""
|
1105 |
-
|
1106 |
-
#: includes/admin/core/class-admin-metabox.php:1802
|
1107 |
-
msgid "Use custom Date format"
|
1108 |
-
msgstr ""
|
1109 |
-
|
1110 |
-
#: includes/admin/core/class-admin-metabox.php:1802
|
1111 |
-
msgid "This option overrides \"Date User-Friendly Format\" option. See https://www.php.net/manual/en/function.date.php"
|
1112 |
-
msgstr ""
|
1113 |
-
|
1114 |
-
#: includes/admin/core/class-admin-metabox.php:1812
|
1115 |
-
msgid "Displayed Date Format"
|
1116 |
-
msgstr ""
|
1117 |
-
|
1118 |
-
#: includes/admin/core/class-admin-metabox.php:1812
|
1119 |
-
msgid "Whether you wish to show the date in full or only show the years e.g. 25 Years"
|
1120 |
-
msgstr ""
|
1121 |
-
|
1122 |
-
#: includes/admin/core/class-admin-metabox.php:1814
|
1123 |
-
msgid "Show full date"
|
1124 |
-
msgstr ""
|
1125 |
-
|
1126 |
-
#: includes/admin/core/class-admin-metabox.php:1815
|
1127 |
-
msgid "Show years only"
|
1128 |
-
msgstr ""
|
1129 |
-
|
1130 |
-
#: includes/admin/core/class-admin-metabox.php:1831
|
1131 |
-
msgid "Disable specific weekdays"
|
1132 |
-
msgstr ""
|
1133 |
-
|
1134 |
-
#: includes/admin/core/class-admin-metabox.php:1831
|
1135 |
-
msgid "Disable specific week days from being available for selection in this date picker"
|
1136 |
-
msgstr ""
|
1137 |
-
|
1138 |
-
#: includes/admin/core/class-admin-metabox.php:1833
|
1139 |
-
msgid "Sunday"
|
1140 |
-
msgstr ""
|
1141 |
-
|
1142 |
-
#: includes/admin/core/class-admin-metabox.php:1834
|
1143 |
-
msgid "Monday"
|
1144 |
-
msgstr ""
|
1145 |
-
|
1146 |
-
#: includes/admin/core/class-admin-metabox.php:1835
|
1147 |
-
msgid "Tuesday"
|
1148 |
-
msgstr ""
|
1149 |
-
|
1150 |
-
#: includes/admin/core/class-admin-metabox.php:1836
|
1151 |
-
msgid "Wednesday"
|
1152 |
-
msgstr ""
|
1153 |
-
|
1154 |
-
#: includes/admin/core/class-admin-metabox.php:1837
|
1155 |
-
msgid "Thursday"
|
1156 |
-
msgstr ""
|
1157 |
-
|
1158 |
-
#: includes/admin/core/class-admin-metabox.php:1838
|
1159 |
-
msgid "Friday"
|
1160 |
-
msgstr ""
|
1161 |
-
|
1162 |
-
#: includes/admin/core/class-admin-metabox.php:1839
|
1163 |
-
msgid "Saturday"
|
1164 |
-
msgstr ""
|
1165 |
-
|
1166 |
-
#: includes/admin/core/class-admin-metabox.php:1849
|
1167 |
-
msgid "Number of Years to pick from"
|
1168 |
-
msgstr ""
|
1169 |
-
|
1170 |
-
#: includes/admin/core/class-admin-metabox.php:1849
|
1171 |
-
msgid "Number of years available for the date selection. Default to last 50 years"
|
1172 |
-
msgstr ""
|
1173 |
-
|
1174 |
-
#: includes/admin/core/class-admin-metabox.php:1859
|
1175 |
-
msgid "Years Selection"
|
1176 |
-
msgstr ""
|
1177 |
-
|
1178 |
-
#: includes/admin/core/class-admin-metabox.php:1859
|
1179 |
-
msgid "This decides which years should be shown relative to today date"
|
1180 |
-
msgstr ""
|
1181 |
-
|
1182 |
-
#: includes/admin/core/class-admin-metabox.php:1861
|
1183 |
-
msgid "Equal years before / after today"
|
1184 |
-
msgstr ""
|
1185 |
-
|
1186 |
-
#: includes/admin/core/class-admin-metabox.php:1862
|
1187 |
-
msgid "Past years only"
|
1188 |
-
msgstr ""
|
1189 |
-
|
1190 |
-
#: includes/admin/core/class-admin-metabox.php:1863
|
1191 |
-
msgid "Future years only"
|
1192 |
-
msgstr ""
|
1193 |
-
|
1194 |
-
#: includes/admin/core/class-admin-metabox.php:1873
|
1195 |
-
msgid "Date Range Start"
|
1196 |
-
msgstr ""
|
1197 |
-
|
1198 |
-
#: includes/admin/core/class-admin-metabox.php:1873
|
1199 |
-
msgid "Set the minimum date/day in range in the format YYYY/MM/DD"
|
1200 |
-
msgstr ""
|
1201 |
-
|
1202 |
-
#: includes/admin/core/class-admin-metabox.php:1874
|
1203 |
-
#: includes/admin/core/class-admin-metabox.php:1884
|
1204 |
-
msgid "YYYY/MM/DD"
|
1205 |
-
msgstr ""
|
1206 |
-
|
1207 |
-
#: includes/admin/core/class-admin-metabox.php:1883
|
1208 |
-
msgid "Date Range End"
|
1209 |
-
msgstr ""
|
1210 |
-
|
1211 |
-
#: includes/admin/core/class-admin-metabox.php:1883
|
1212 |
-
msgid "Set the maximum date/day in range in the format YYYY/MM/DD"
|
1213 |
-
msgstr ""
|
1214 |
-
|
1215 |
-
#: includes/admin/core/class-admin-metabox.php:1893
|
1216 |
-
msgid "Set Date Range"
|
1217 |
-
msgstr ""
|
1218 |
-
|
1219 |
-
#: includes/admin/core/class-admin-metabox.php:1893
|
1220 |
-
msgid "Whether to show a specific number of years or specify a date range to be available for the date picker."
|
1221 |
-
msgstr ""
|
1222 |
-
|
1223 |
-
#: includes/admin/core/class-admin-metabox.php:1895
|
1224 |
-
msgid "Fixed Number of Years"
|
1225 |
-
msgstr ""
|
1226 |
-
|
1227 |
-
#: includes/admin/core/class-admin-metabox.php:1896
|
1228 |
-
msgid "Specific Date Range"
|
1229 |
-
msgstr ""
|
1230 |
-
|
1231 |
-
#: includes/admin/core/class-admin-metabox.php:1909
|
1232 |
-
msgid "Enter Shortcode"
|
1233 |
-
msgstr ""
|
1234 |
-
|
1235 |
-
#: includes/admin/core/class-admin-metabox.php:1909
|
1236 |
-
msgid "Enter the shortcode in the following textarea and it will be displayed on the fields"
|
1237 |
-
msgstr ""
|
1238 |
-
|
1239 |
-
#: includes/admin/core/class-admin-metabox.php:1910
|
1240 |
-
msgid "e.g. [my_custom_shortcode]"
|
1241 |
-
msgstr ""
|
1242 |
-
|
1243 |
-
#: includes/admin/core/class-admin-metabox.php:1919
|
1244 |
-
msgid "Content Editor"
|
1245 |
-
msgstr ""
|
1246 |
-
|
1247 |
-
#: includes/admin/core/class-admin-metabox.php:1919
|
1248 |
-
msgid "Edit the content of this field here"
|
1249 |
-
msgstr ""
|
1250 |
-
|
1251 |
-
#: includes/admin/core/class-admin-metabox.php:1932
|
1252 |
-
msgid "Crop Feature"
|
1253 |
-
msgstr ""
|
1254 |
-
|
1255 |
-
#: includes/admin/core/class-admin-metabox.php:1932
|
1256 |
-
msgid "Enable/disable crop feature for this image upload and define ratio"
|
1257 |
-
msgstr ""
|
1258 |
-
|
1259 |
-
#: includes/admin/core/class-admin-metabox.php:1934
|
1260 |
-
msgid "Turn Off (Default)"
|
1261 |
-
msgstr ""
|
1262 |
-
|
1263 |
-
#: includes/admin/core/class-admin-metabox.php:1935
|
1264 |
-
msgid "Crop and force 1:1 ratio"
|
1265 |
-
msgstr ""
|
1266 |
-
|
1267 |
-
#: includes/admin/core/class-admin-metabox.php:1936
|
1268 |
-
msgid "Crop and force user-defined ratio"
|
1269 |
-
msgstr ""
|
1270 |
-
|
1271 |
-
#: includes/admin/core/class-admin-metabox.php:1953
|
1272 |
-
msgid "Allowed Image Types"
|
1273 |
-
msgstr ""
|
1274 |
-
|
1275 |
-
#: includes/admin/core/class-admin-metabox.php:1953
|
1276 |
-
#: includes/admin/core/class-admin-metabox.php:1971
|
1277 |
-
msgid "Select the image types that you want to allow to be uploaded via this field."
|
1278 |
-
msgstr ""
|
1279 |
-
|
1280 |
-
#: includes/admin/core/class-admin-metabox.php:1971
|
1281 |
-
msgid "Allowed File Types"
|
1282 |
-
msgstr ""
|
1283 |
-
|
1284 |
-
#: includes/admin/core/class-admin-metabox.php:1988
|
1285 |
-
msgid "Drag & Drop Photo"
|
1286 |
-
msgstr ""
|
1287 |
-
|
1288 |
-
#: includes/admin/core/class-admin-metabox.php:1991
|
1289 |
-
msgid "Drag & Drop File"
|
1290 |
-
msgstr ""
|
1291 |
-
|
1292 |
-
#: includes/admin/core/class-admin-metabox.php:1996
|
1293 |
-
#: includes/admin/core/class-admin-metabox.php:2016
|
1294 |
-
msgid "Upload Box Text"
|
1295 |
-
msgstr ""
|
1296 |
-
|
1297 |
-
#: includes/admin/core/class-admin-metabox.php:1996
|
1298 |
-
msgid "This is the headline that appears in the upload box for this field"
|
1299 |
-
msgstr ""
|
1300 |
-
|
1301 |
-
#: includes/admin/core/class-admin-metabox.php:2006
|
1302 |
-
msgid "Additional Instructions Text"
|
1303 |
-
msgstr ""
|
1304 |
-
|
1305 |
-
#: includes/admin/core/class-admin-metabox.php:2006
|
1306 |
-
msgid "If you need to add information or secondary line below the headline of upload box, enter it here"
|
1307 |
-
msgstr ""
|
1308 |
-
|
1309 |
-
#: includes/admin/core/class-admin-metabox.php:2016
|
1310 |
-
msgid "The text that appears on the button. e.g. Upload"
|
1311 |
-
msgstr ""
|
1312 |
-
|
1313 |
-
#: includes/admin/core/class-admin-metabox.php:2017
|
1314 |
-
#: includes/core/class-fields.php:1791
|
1315 |
-
#: includes/core/class-fields.php:1832
|
1316 |
-
#: includes/core/class-fields.php:2703
|
1317 |
-
#: includes/core/class-fields.php:2793
|
1318 |
-
msgid "Upload"
|
1319 |
-
msgstr ""
|
1320 |
-
|
1321 |
-
#: includes/admin/core/class-admin-metabox.php:2026
|
1322 |
-
msgid "Maximum Size in bytes"
|
1323 |
-
msgstr ""
|
1324 |
-
|
1325 |
-
#: includes/admin/core/class-admin-metabox.php:2026
|
1326 |
-
msgid "The maximum size for image that can be uploaded through this field. Leave empty for unlimited size."
|
1327 |
-
msgstr ""
|
1328 |
-
|
1329 |
-
#: includes/admin/core/class-admin-metabox.php:2036
|
1330 |
-
msgid "Textarea Height"
|
1331 |
-
msgstr ""
|
1332 |
-
|
1333 |
-
#: includes/admin/core/class-admin-metabox.php:2036
|
1334 |
-
msgid "The height of textarea in pixels. Default is 100 pixels"
|
1335 |
-
msgstr ""
|
1336 |
-
|
1337 |
-
#: includes/admin/core/class-admin-metabox.php:2046
|
1338 |
-
msgid "Spacing"
|
1339 |
-
msgstr ""
|
1340 |
-
|
1341 |
-
#: includes/admin/core/class-admin-metabox.php:2046
|
1342 |
-
msgid "This is the required spacing in pixels. e.g. 20px"
|
1343 |
-
msgstr ""
|
1344 |
-
|
1345 |
-
#: includes/admin/core/class-admin-metabox.php:2056
|
1346 |
-
msgid "Allow multiple selections"
|
1347 |
-
msgstr ""
|
1348 |
-
|
1349 |
-
#: includes/admin/core/class-admin-metabox.php:2056
|
1350 |
-
msgid "Enable/disable multiple selections for this field"
|
1351 |
-
msgstr ""
|
1352 |
-
|
1353 |
-
#: includes/admin/core/class-admin-metabox.php:2066
|
1354 |
-
msgid "Maximum number of selections"
|
1355 |
-
msgstr ""
|
1356 |
-
|
1357 |
-
#: includes/admin/core/class-admin-metabox.php:2066
|
1358 |
-
msgid "Enter a number here to force a maximum number of selections by user for this field"
|
1359 |
-
msgstr ""
|
1360 |
-
|
1361 |
-
#: includes/admin/core/class-admin-metabox.php:2076
|
1362 |
-
msgid "Minimum number of selections"
|
1363 |
-
msgstr ""
|
1364 |
-
|
1365 |
-
#: includes/admin/core/class-admin-metabox.php:2076
|
1366 |
-
msgid "Enter a number here to force a minimum number of selections by user for this field"
|
1367 |
-
msgstr ""
|
1368 |
-
|
1369 |
-
#: includes/admin/core/class-admin-metabox.php:2086
|
1370 |
-
msgid "Maximum number of entries"
|
1371 |
-
msgstr ""
|
1372 |
-
|
1373 |
-
#: includes/admin/core/class-admin-metabox.php:2086
|
1374 |
-
msgid "This is the max number of entries the user can add via field group."
|
1375 |
-
msgstr ""
|
1376 |
-
|
1377 |
-
#: includes/admin/core/class-admin-metabox.php:2096
|
1378 |
-
msgid "Maximum allowed words"
|
1379 |
-
msgstr ""
|
1380 |
-
|
1381 |
-
#: includes/admin/core/class-admin-metabox.php:2096
|
1382 |
-
msgid "If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting"
|
1383 |
-
msgstr ""
|
1384 |
-
|
1385 |
-
#: includes/admin/core/class-admin-metabox.php:2106
|
1386 |
-
msgid "Minimum Number"
|
1387 |
-
msgstr ""
|
1388 |
-
|
1389 |
-
#: includes/admin/core/class-admin-metabox.php:2106
|
1390 |
-
msgid "Minimum number that can be entered in this field"
|
1391 |
-
msgstr ""
|
1392 |
-
|
1393 |
-
#: includes/admin/core/class-admin-metabox.php:2116
|
1394 |
-
msgid "Maximum Number"
|
1395 |
-
msgstr ""
|
1396 |
-
|
1397 |
-
#: includes/admin/core/class-admin-metabox.php:2116
|
1398 |
-
msgid "Maximum number that can be entered in this field"
|
1399 |
-
msgstr ""
|
1400 |
-
|
1401 |
-
#: includes/admin/core/class-admin-metabox.php:2126
|
1402 |
-
msgid "Minimum length"
|
1403 |
-
msgstr ""
|
1404 |
-
|
1405 |
-
#: includes/admin/core/class-admin-metabox.php:2126
|
1406 |
-
msgid "If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting"
|
1407 |
-
msgstr ""
|
1408 |
-
|
1409 |
-
#: includes/admin/core/class-admin-metabox.php:2136
|
1410 |
-
msgid "Maximum length"
|
1411 |
-
msgstr ""
|
1412 |
-
|
1413 |
-
#: includes/admin/core/class-admin-metabox.php:2136
|
1414 |
-
msgid "If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting"
|
1415 |
-
msgstr ""
|
1416 |
-
|
1417 |
-
#: includes/admin/core/class-admin-metabox.php:2146
|
1418 |
-
msgid "Does this textarea accept HTML?"
|
1419 |
-
msgstr ""
|
1420 |
-
|
1421 |
-
#: includes/admin/core/class-admin-metabox.php:2146
|
1422 |
-
msgid "Turn on/off HTML tags for this textarea"
|
1423 |
-
msgstr ""
|
1424 |
-
|
1425 |
-
#: includes/admin/core/class-admin-metabox.php:2163
|
1426 |
-
msgid "Edit Choices"
|
1427 |
-
msgstr ""
|
1428 |
-
|
1429 |
-
#: includes/admin/core/class-admin-metabox.php:2163
|
1430 |
-
msgid "Enter one choice per line. This will represent the available choices or selections available for user."
|
1431 |
-
msgstr ""
|
1432 |
-
|
1433 |
-
#: includes/admin/core/class-admin-metabox.php:2173
|
1434 |
-
msgid "This is the title of the field for your reference in the backend. The title will not appear on the front-end of your website."
|
1435 |
-
msgstr ""
|
1436 |
-
|
1437 |
-
#: includes/admin/core/class-admin-metabox.php:2184
|
1438 |
-
msgid "Unique ID"
|
1439 |
-
msgstr ""
|
1440 |
-
|
1441 |
-
#: includes/admin/core/class-admin-metabox.php:2198
|
1442 |
-
msgid "The meta key cannot be changed for duplicated fields or when editing an existing field. If you require a different meta key please create a new field."
|
1443 |
-
msgstr ""
|
1444 |
-
|
1445 |
-
#: includes/admin/core/class-admin-metabox.php:2204
|
1446 |
-
msgid "A meta key is required to store the entered info in this field in the database. The meta key should be unique to this field and be written in lowercase with an underscore ( _ ) separating words e.g country_list or job_title"
|
1447 |
-
msgstr ""
|
1448 |
-
|
1449 |
-
#: includes/admin/core/class-admin-metabox.php:2217
|
1450 |
-
msgid "Help Text"
|
1451 |
-
msgstr ""
|
1452 |
-
|
1453 |
-
#: includes/admin/core/class-admin-metabox.php:2217
|
1454 |
-
msgid "This is the text that appears in a tooltip when a user hovers over the info icon. Help text is useful for providing users with more information about what they should enter in the field. Leave blank if no help text is needed for field."
|
1455 |
-
msgstr ""
|
1456 |
-
|
1457 |
-
#: includes/admin/core/class-admin-metabox.php:2229
|
1458 |
-
msgid "Default Text"
|
1459 |
-
msgstr ""
|
1460 |
-
|
1461 |
-
#: includes/admin/core/class-admin-metabox.php:2229
|
1462 |
-
msgid "Text to display by default in this field"
|
1463 |
-
msgstr ""
|
1464 |
-
|
1465 |
-
#: includes/admin/core/class-admin-metabox.php:2235
|
1466 |
-
msgid "Default Date"
|
1467 |
-
msgstr ""
|
1468 |
-
|
1469 |
-
#: includes/admin/core/class-admin-metabox.php:2235
|
1470 |
-
#: includes/admin/core/class-admin-metabox.php:2241
|
1471 |
-
msgid "You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day"
|
1472 |
-
msgstr ""
|
1473 |
-
|
1474 |
-
#: includes/admin/core/class-admin-metabox.php:2241
|
1475 |
-
msgid "Default Time"
|
1476 |
-
msgstr ""
|
1477 |
-
|
1478 |
-
#: includes/admin/core/class-admin-metabox.php:2247
|
1479 |
-
msgid "Default Rating"
|
1480 |
-
msgstr ""
|
1481 |
-
|
1482 |
-
#: includes/admin/core/class-admin-metabox.php:2247
|
1483 |
-
msgid "If you wish the rating field to be prefilled with a number of stars, enter it here."
|
1484 |
-
msgstr ""
|
1485 |
-
|
1486 |
-
#: includes/admin/core/class-admin-metabox.php:2253
|
1487 |
-
msgid "Default Value"
|
1488 |
-
msgstr ""
|
1489 |
-
|
1490 |
-
#: includes/admin/core/class-admin-metabox.php:2253
|
1491 |
-
msgid "This option allows you to pre-fill the field with a default value prior to the user entering a value in the field. Leave blank to have no default value"
|
1492 |
-
msgstr ""
|
1493 |
-
|
1494 |
-
#: includes/admin/core/class-admin-metabox.php:2265
|
1495 |
-
msgid "The field label is the text that appears above the field on your front-end form. Leave blank to not show a label above field."
|
1496 |
-
msgstr ""
|
1497 |
-
|
1498 |
-
#: includes/admin/core/class-admin-metabox.php:2275
|
1499 |
-
msgid "Confirm password field label"
|
1500 |
-
msgstr ""
|
1501 |
-
|
1502 |
-
#: includes/admin/core/class-admin-metabox.php:2275
|
1503 |
-
msgid "This label is the text that appears above the confirm password field. Leave blank to show default label."
|
1504 |
-
msgstr ""
|
1505 |
-
|
1506 |
-
#: includes/admin/core/class-admin-metabox.php:2285
|
1507 |
-
msgid "Placeholder"
|
1508 |
-
msgstr ""
|
1509 |
-
|
1510 |
-
#: includes/admin/core/class-admin-metabox.php:2285
|
1511 |
-
msgid "This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text."
|
1512 |
-
msgstr ""
|
1513 |
-
|
1514 |
-
#: includes/admin/core/class-admin-metabox.php:2295
|
1515 |
-
#: includes/class-config.php:134
|
1516 |
-
#: includes/class-config.php:800
|
1517 |
-
msgid "Members"
|
1518 |
-
msgstr ""
|
1519 |
-
|
1520 |
-
#: includes/admin/core/class-admin-metabox.php:2296
|
1521 |
-
msgid "Only visible to profile owner and users who can edit other member accounts"
|
1522 |
-
msgstr ""
|
1523 |
-
|
1524 |
-
#: includes/admin/core/class-admin-metabox.php:2297
|
1525 |
-
msgid "Only visible to profile owner and specific roles"
|
1526 |
-
msgstr ""
|
1527 |
-
|
1528 |
-
#: includes/admin/core/class-admin-metabox.php:2298
|
1529 |
-
msgid "Only specific member roles"
|
1530 |
-
msgstr ""
|
1531 |
-
|
1532 |
-
#: includes/admin/core/class-admin-metabox.php:2304
|
1533 |
-
msgid "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."
|
1534 |
-
msgstr ""
|
1535 |
-
|
1536 |
-
#: includes/admin/core/class-admin-metabox.php:2327
|
1537 |
-
msgid "Select member roles"
|
1538 |
-
msgstr ""
|
1539 |
-
|
1540 |
-
#: includes/admin/core/class-admin-metabox.php:2327
|
1541 |
-
msgid "Select the member roles that can view this field on the front-end."
|
1542 |
-
msgstr ""
|
1543 |
-
|
1544 |
-
#: includes/admin/core/class-admin-metabox.php:2353
|
1545 |
-
msgid "Is this field required?"
|
1546 |
-
msgstr ""
|
1547 |
-
|
1548 |
-
#: includes/admin/core/class-admin-metabox.php:2353
|
1549 |
-
msgid "This option allows you to set whether the field must be filled in before the form can be processed."
|
1550 |
-
msgstr ""
|
1551 |
-
|
1552 |
-
#: includes/admin/core/class-admin-metabox.php:2367
|
1553 |
-
msgid "Can user edit this field?"
|
1554 |
-
msgstr ""
|
1555 |
-
|
1556 |
-
#: includes/admin/core/class-admin-metabox.php:2367
|
1557 |
-
msgid "This option allows you to set whether or not the user can edit the information in this field. The site admin can edit all fields regardless of the option set here."
|
1558 |
-
msgstr ""
|
1559 |
-
|
1560 |
-
#: includes/admin/core/class-admin-metabox.php:2380
|
1561 |
-
msgid "Rating System"
|
1562 |
-
msgstr ""
|
1563 |
-
|
1564 |
-
#: includes/admin/core/class-admin-metabox.php:2380
|
1565 |
-
msgid "Choose whether you want a 5-stars or 10-stars ratings based here."
|
1566 |
-
msgstr ""
|
1567 |
-
|
1568 |
-
#: includes/admin/core/class-admin-metabox.php:2382
|
1569 |
-
msgid "5 stars rating system"
|
1570 |
-
msgstr ""
|
1571 |
-
|
1572 |
-
#: includes/admin/core/class-admin-metabox.php:2383
|
1573 |
-
msgid "10 stars rating system"
|
1574 |
-
msgstr ""
|
1575 |
-
|
1576 |
-
#: includes/admin/core/class-admin-metabox.php:2393
|
1577 |
-
msgid "Choices Callback"
|
1578 |
-
msgstr ""
|
1579 |
-
|
1580 |
-
#: includes/admin/core/class-admin-metabox.php:2393
|
1581 |
-
msgid "Add a callback source to retrieve choices."
|
1582 |
-
msgstr ""
|
1583 |
-
|
1584 |
-
#: includes/admin/core/class-admin-metabox.php:2404
|
1585 |
-
msgid "Parent Option"
|
1586 |
-
msgstr ""
|
1587 |
-
|
1588 |
-
#: includes/admin/core/class-admin-metabox.php:2404
|
1589 |
-
msgid "Dynamically populates the option based from selected parent option."
|
1590 |
-
msgstr ""
|
1591 |
-
|
1592 |
-
#: includes/admin/core/class-admin-metabox.php:2406
|
1593 |
-
msgid "No Selected"
|
1594 |
-
msgstr ""
|
1595 |
-
|
1596 |
-
#: includes/admin/core/class-admin-navmenu.php:28
|
1597 |
-
msgid "Display Mode"
|
1598 |
-
msgstr ""
|
1599 |
-
|
1600 |
-
#: includes/admin/core/class-admin-navmenu.php:29
|
1601 |
-
msgid "By Role"
|
1602 |
-
msgstr ""
|
1603 |
-
|
1604 |
-
#: includes/admin/core/class-admin-navmenu.php:75
|
1605 |
-
#: includes/admin/core/class-admin-navmenu.php:125
|
1606 |
-
#: includes/admin/core/class-admin-navmenu.php:234
|
1607 |
-
msgid "Ultimate Member Menu Settings"
|
1608 |
-
msgstr ""
|
1609 |
-
|
1610 |
-
#: includes/admin/core/class-admin-navmenu.php:79
|
1611 |
-
#: includes/admin/core/class-admin-navmenu.php:238
|
1612 |
-
msgid "Who can see this menu link?"
|
1613 |
-
msgstr ""
|
1614 |
-
|
1615 |
-
#: includes/admin/core/class-admin-navmenu.php:82
|
1616 |
-
#: includes/admin/core/class-admin-navmenu.php:245
|
1617 |
-
msgid "Logged Out Users"
|
1618 |
-
msgstr ""
|
1619 |
-
|
1620 |
-
#: includes/admin/core/class-admin-navmenu.php:83
|
1621 |
-
#: includes/admin/core/class-admin-navmenu.php:248
|
1622 |
-
msgid "Logged In Users"
|
1623 |
-
msgstr ""
|
1624 |
-
|
1625 |
-
#: includes/admin/core/class-admin-navmenu.php:88
|
1626 |
-
#: includes/admin/core/class-admin-navmenu.php:254
|
1627 |
-
msgid "Select the member roles that can see this link"
|
1628 |
-
msgstr ""
|
1629 |
-
|
1630 |
-
#: includes/admin/core/class-admin-notices.php:288
|
1631 |
-
msgid "<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href=\"%s\" target=\"_blank\">doc</a>."
|
1632 |
-
msgstr ""
|
1633 |
-
|
1634 |
-
#: includes/admin/core/class-admin-notices.php:309
|
1635 |
-
msgid "%s needs to create several pages (User Profiles, Account, Registration, Login, Password Reset, Logout, Member Directory) to function correctly."
|
1636 |
-
msgstr ""
|
1637 |
-
|
1638 |
-
#: includes/admin/core/class-admin-notices.php:313
|
1639 |
-
msgid "Create Pages"
|
1640 |
-
msgstr ""
|
1641 |
-
|
1642 |
-
#: includes/admin/core/class-admin-notices.php:315
|
1643 |
-
msgid "No thanks"
|
1644 |
-
msgstr ""
|
1645 |
-
|
1646 |
-
#: includes/admin/core/class-admin-notices.php:335
|
1647 |
-
msgid "Ultimate Member Setup Error: User page can not be a child page."
|
1648 |
-
msgstr ""
|
1649 |
-
|
1650 |
-
#: includes/admin/core/class-admin-notices.php:345
|
1651 |
-
msgid "Ultimate Member Setup Error: Account page can not be a child page."
|
1652 |
-
msgstr ""
|
1653 |
-
|
1654 |
-
#: includes/admin/core/class-admin-notices.php:363
|
1655 |
-
msgid "Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href=\"%s\">Hide this notice</a>"
|
1656 |
-
msgstr ""
|
1657 |
-
|
1658 |
-
#: includes/admin/core/class-admin-notices.php:400
|
1659 |
-
msgid "Are you sure you want to delete the selected user(s)? The following users will be deleted: <p>%s</p> <strong>This cannot be undone!</strong>"
|
1660 |
-
msgstr ""
|
1661 |
-
|
1662 |
-
#: includes/admin/core/class-admin-notices.php:401
|
1663 |
-
msgid "Undo"
|
1664 |
-
msgstr ""
|
1665 |
-
|
1666 |
-
#: includes/admin/core/class-admin-notices.php:406
|
1667 |
-
msgid "Your translation files have been updated successfully."
|
1668 |
-
msgstr ""
|
1669 |
-
|
1670 |
-
#: includes/admin/core/class-admin-notices.php:410
|
1671 |
-
msgid "Your temp uploads directory is now clean."
|
1672 |
-
msgstr ""
|
1673 |
-
|
1674 |
-
#: includes/admin/core/class-admin-notices.php:414
|
1675 |
-
msgid "Your user cache is now removed."
|
1676 |
-
msgstr ""
|
1677 |
-
|
1678 |
-
#: includes/admin/core/class-admin-notices.php:418
|
1679 |
-
msgid "You have the latest updates."
|
1680 |
-
msgstr ""
|
1681 |
-
|
1682 |
-
#: includes/admin/core/class-admin-notices.php:422
|
1683 |
-
msgid "Try again later. You can run this action once daily."
|
1684 |
-
msgstr ""
|
1685 |
-
|
1686 |
-
#: includes/admin/core/class-admin-notices.php:426
|
1687 |
-
msgid "The form has been duplicated successfully."
|
1688 |
-
msgstr ""
|
1689 |
-
|
1690 |
-
#: includes/admin/core/class-admin-notices.php:430
|
1691 |
-
msgid "Settings have been saved successfully."
|
1692 |
-
msgstr ""
|
1693 |
-
|
1694 |
-
#: includes/admin/core/class-admin-notices.php:434
|
1695 |
-
msgid "User has been updated."
|
1696 |
-
msgstr ""
|
1697 |
-
|
1698 |
-
#: includes/admin/core/class-admin-notices.php:438
|
1699 |
-
msgid "Users have been updated."
|
1700 |
-
msgstr ""
|
1701 |
-
|
1702 |
-
#: includes/admin/core/class-admin-notices.php:442
|
1703 |
-
msgid "Changed roles."
|
1704 |
-
msgstr ""
|
1705 |
-
|
1706 |
-
#: includes/admin/core/class-admin-notices.php:446
|
1707 |
-
msgid "Super administrators cannot be modified."
|
1708 |
-
msgstr ""
|
1709 |
-
|
1710 |
-
#: includes/admin/core/class-admin-notices.php:447
|
1711 |
-
msgid "Other users have been updated."
|
1712 |
-
msgstr ""
|
1713 |
-
|
1714 |
-
#: includes/admin/core/class-admin-notices.php:484
|
1715 |
-
msgid "You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>\"ultimate-member\"</strong>."
|
1716 |
-
msgstr ""
|
1717 |
-
|
1718 |
-
#: includes/admin/core/class-admin-notices.php:514
|
1719 |
-
msgid "There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href=\"%s\">www.ultimatemember.com</a>."
|
1720 |
-
msgstr ""
|
1721 |
-
|
1722 |
-
#: includes/admin/core/class-admin-notices.php:521
|
1723 |
-
msgid "You have %d invalid or expired license keys for %s. Please go to the <a href=\"%s\">Licenses page</a> to correct this issue."
|
1724 |
-
msgstr ""
|
1725 |
-
|
1726 |
-
#: includes/admin/core/class-admin-notices.php:535
|
1727 |
-
msgid "<strong>%s version %s</strong> needs to be updated to work correctly.<br />It is necessary to update the structure of the database and options that are associated with <strong>%s %s</strong>.<br />Please visit <a href=\"%s\">\"Upgrade\"</a> page and run the upgrade process."
|
1728 |
-
msgstr ""
|
1729 |
-
|
1730 |
-
#: includes/admin/core/class-admin-notices.php:539
|
1731 |
-
msgid "Visit Upgrade Page"
|
1732 |
-
msgstr ""
|
1733 |
-
|
1734 |
-
#: includes/admin/core/class-admin-notices.php:554
|
1735 |
-
msgid "Settings successfully upgraded"
|
1736 |
-
msgstr ""
|
1737 |
-
|
1738 |
-
#: includes/admin/core/class-admin-notices.php:559
|
1739 |
-
msgid "<strong>%s %s</strong> Successfully Upgraded"
|
1740 |
-
msgstr ""
|
1741 |
-
|
1742 |
-
#: includes/admin/core/class-admin-notices.php:586
|
1743 |
-
msgid "Hey there! It's been one month since you installed %s. How have you found the plugin so far?"
|
1744 |
-
msgstr ""
|
1745 |
-
|
1746 |
-
#: includes/admin/core/class-admin-notices.php:589
|
1747 |
-
msgid "I love it!"
|
1748 |
-
msgstr ""
|
1749 |
-
|
1750 |
-
#: includes/admin/core/class-admin-notices.php:590
|
1751 |
-
msgid "It's good but could be better"
|
1752 |
-
msgstr ""
|
1753 |
-
|
1754 |
-
#: includes/admin/core/class-admin-notices.php:591
|
1755 |
-
msgid "I don't like the plugin"
|
1756 |
-
msgstr ""
|
1757 |
-
|
1758 |
-
#: includes/admin/core/class-admin-notices.php:600
|
1759 |
-
msgid "Leave Review"
|
1760 |
-
msgstr ""
|
1761 |
-
|
1762 |
-
#: includes/admin/core/class-admin-notices.php:609
|
1763 |
-
#: includes/admin/core/class-admin-notices.php:618
|
1764 |
-
msgid "Provide Feedback"
|
1765 |
-
msgstr ""
|
1766 |
-
|
1767 |
-
#: includes/admin/core/class-admin-notices.php:640
|
1768 |
-
msgid "<strong>%s</strong> future plans! Detailed future list is <a href=\"%s\" target=\"_blank\">here</a>"
|
1769 |
-
msgstr ""
|
1770 |
-
|
1771 |
-
#: includes/admin/core/class-admin-notices.php:656
|
1772 |
-
msgid "Wrong Data"
|
1773 |
-
msgstr ""
|
1774 |
-
|
1775 |
-
#: includes/admin/core/class-admin-notices.php:684
|
1776 |
-
#: includes/admin/core/class-admin-settings.php:2152
|
1777 |
-
msgid "Security Check"
|
1778 |
-
msgstr ""
|
1779 |
-
|
1780 |
-
#: includes/admin/core/class-admin-settings.php:98
|
1781 |
-
msgid "Wrong callback"
|
1782 |
-
msgstr ""
|
1783 |
-
|
1784 |
-
#: includes/admin/core/class-admin-settings.php:201
|
1785 |
-
#: includes/admin/core/packages/2.1.3-beta3/functions.php:24
|
1786 |
-
#: includes/admin/core/packages/2.3.0/functions.php:89
|
1787 |
-
msgid "Wrong data"
|
1788 |
-
msgstr ""
|
1789 |
-
|
1790 |
-
#: includes/admin/core/class-admin-settings.php:236
|
1791 |
-
msgid "Metadata from %1$s to %2$s was upgraded successfully..."
|
1792 |
-
msgstr ""
|
1793 |
-
|
1794 |
-
#. translators: %s: Page title
|
1795 |
-
#: includes/admin/core/class-admin-settings.php:270
|
1796 |
-
#: includes/admin/core/class-admin-settings.php:280
|
1797 |
-
msgid "%s page"
|
1798 |
-
msgstr ""
|
1799 |
-
|
1800 |
-
#. translators: %s: Page title
|
1801 |
-
#: includes/admin/core/class-admin-settings.php:271
|
1802 |
-
msgid "Add page ID"
|
1803 |
-
msgstr ""
|
1804 |
-
|
1805 |
-
#: includes/admin/core/class-admin-settings.php:282
|
1806 |
-
msgid "Choose a page..."
|
1807 |
-
msgstr ""
|
1808 |
-
|
1809 |
-
#: includes/admin/core/class-admin-settings.php:298
|
1810 |
-
msgid "Enable profile menu"
|
1811 |
-
msgstr ""
|
1812 |
-
|
1813 |
-
#. translators: %s: Tab title
|
1814 |
-
#: includes/admin/core/class-admin-settings.php:327
|
1815 |
-
#: includes/admin/core/class-admin-settings.php:343
|
1816 |
-
msgid "%s Tab"
|
1817 |
-
msgstr ""
|
1818 |
-
|
1819 |
-
#. translators: %s: Tab title
|
1820 |
-
#: includes/admin/core/class-admin-settings.php:351
|
1821 |
-
msgid "Who can see %s Tab?"
|
1822 |
-
msgstr ""
|
1823 |
-
|
1824 |
-
#. translators: %s: Tab title
|
1825 |
-
#: includes/admin/core/class-admin-settings.php:352
|
1826 |
-
msgid "Select which users can view this tab."
|
1827 |
-
msgstr ""
|
1828 |
-
|
1829 |
-
#: includes/admin/core/class-admin-settings.php:361
|
1830 |
-
msgid "Allowed roles"
|
1831 |
-
msgstr ""
|
1832 |
-
|
1833 |
-
#: includes/admin/core/class-admin-settings.php:362
|
1834 |
-
msgid "Select the the user roles allowed to view this tab."
|
1835 |
-
msgstr ""
|
1836 |
-
|
1837 |
-
#: includes/admin/core/class-admin-settings.php:364
|
1838 |
-
msgid "Choose user roles..."
|
1839 |
-
msgstr ""
|
1840 |
-
|
1841 |
-
#: includes/admin/core/class-admin-settings.php:392
|
1842 |
-
msgid "Profile menu default tab"
|
1843 |
-
msgstr ""
|
1844 |
-
|
1845 |
-
#: includes/admin/core/class-admin-settings.php:393
|
1846 |
-
msgid "This will be the default tab on user profile page"
|
1847 |
-
msgstr ""
|
1848 |
-
|
1849 |
-
#: includes/admin/core/class-admin-settings.php:409
|
1850 |
-
msgid "Enable menu icons in desktop view"
|
1851 |
-
msgstr ""
|
1852 |
-
|
1853 |
-
#: includes/admin/core/class-admin-settings.php:469
|
1854 |
-
msgid "Global Site Access"
|
1855 |
-
msgstr ""
|
1856 |
-
|
1857 |
-
#: includes/admin/core/class-admin-settings.php:470
|
1858 |
-
msgid "Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item."
|
1859 |
-
msgstr ""
|
1860 |
-
|
1861 |
-
#: includes/admin/core/class-admin-settings.php:472
|
1862 |
-
msgid "Site accessible to Everyone"
|
1863 |
-
msgstr ""
|
1864 |
-
|
1865 |
-
#: includes/admin/core/class-admin-settings.php:473
|
1866 |
-
msgid "Site accessible to Logged In Users"
|
1867 |
-
msgstr ""
|
1868 |
-
|
1869 |
-
#: includes/admin/core/class-admin-settings.php:480
|
1870 |
-
msgid "Custom Redirect URL"
|
1871 |
-
msgstr ""
|
1872 |
-
|
1873 |
-
#: includes/admin/core/class-admin-settings.php:481
|
1874 |
-
msgid "A logged out user will be redirected to this url If he is not permitted to access the site"
|
1875 |
-
msgstr ""
|
1876 |
-
|
1877 |
-
#: includes/admin/core/class-admin-settings.php:487
|
1878 |
-
msgid "Exclude the following URLs"
|
1879 |
-
msgstr ""
|
1880 |
-
|
1881 |
-
#: includes/admin/core/class-admin-settings.php:488
|
1882 |
-
msgid "Here you can exclude URLs beside the redirect URI to be accessible to everyone"
|
1883 |
-
msgstr ""
|
1884 |
-
|
1885 |
-
#: includes/admin/core/class-admin-settings.php:489
|
1886 |
-
msgid "Add New URL"
|
1887 |
-
msgstr ""
|
1888 |
-
|
1889 |
-
#: includes/admin/core/class-admin-settings.php:496
|
1890 |
-
msgid "Allow Homepage to be accessible"
|
1891 |
-
msgstr ""
|
1892 |
-
|
1893 |
-
#: includes/admin/core/class-admin-settings.php:502
|
1894 |
-
msgid "Allow Category pages to be accessible"
|
1895 |
-
msgstr ""
|
1896 |
-
|
1897 |
-
#: includes/admin/core/class-admin-settings.php:508
|
1898 |
-
msgid "Replace the restricted Post Title"
|
1899 |
-
msgstr ""
|
1900 |
-
|
1901 |
-
#: includes/admin/core/class-admin-settings.php:509
|
1902 |
-
msgid "Allow to replace the restricted post title to users that do not have permission to view the content"
|
1903 |
-
msgstr ""
|
1904 |
-
|
1905 |
-
#: includes/admin/core/class-admin-settings.php:514
|
1906 |
-
msgid "Restricted Access Post Title"
|
1907 |
-
msgstr ""
|
1908 |
-
|
1909 |
-
#: includes/admin/core/class-admin-settings.php:515
|
1910 |
-
msgid "This is the post title shown to users that do not have permission to view the content"
|
1911 |
-
msgstr ""
|
1912 |
-
|
1913 |
-
#: includes/admin/core/class-admin-settings.php:521
|
1914 |
-
msgid "Restricted Access Message"
|
1915 |
-
msgstr ""
|
1916 |
-
|
1917 |
-
#: includes/admin/core/class-admin-settings.php:522
|
1918 |
-
msgid "This is the message shown to users that do not have permission to view the content"
|
1919 |
-
msgstr ""
|
1920 |
-
|
1921 |
-
#: includes/admin/core/class-admin-settings.php:564
|
1922 |
-
msgid "Enable the \"Content Restriction\" settings for the Gutenberg Blocks"
|
1923 |
-
msgstr ""
|
1924 |
-
|
1925 |
-
#: includes/admin/core/class-admin-settings.php:569
|
1926 |
-
msgid "Restricted Access Block Message"
|
1927 |
-
msgstr ""
|
1928 |
-
|
1929 |
-
#: includes/admin/core/class-admin-settings.php:570
|
1930 |
-
msgid "This is the message shown to users that do not have permission to view the block's content"
|
1931 |
-
msgstr ""
|
1932 |
-
|
1933 |
-
#: includes/admin/core/class-admin-settings.php:600
|
1934 |
-
msgid "Enable the \"Content Restriction\" settings for post types"
|
1935 |
-
msgstr ""
|
1936 |
-
|
1937 |
-
#: includes/admin/core/class-admin-settings.php:601
|
1938 |
-
msgid "Check post types for which you plan to use the \"Content Restriction\" settings"
|
1939 |
-
msgstr ""
|
1940 |
-
|
1941 |
-
#: includes/admin/core/class-admin-settings.php:610
|
1942 |
-
msgid "Enable the \"Content Restriction\" settings for taxonomies"
|
1943 |
-
msgstr ""
|
1944 |
-
|
1945 |
-
#: includes/admin/core/class-admin-settings.php:611
|
1946 |
-
msgid "Check taxonomies for which you plan to use the \"Content Restriction\" settings"
|
1947 |
-
msgstr ""
|
1948 |
-
|
1949 |
-
#: includes/admin/core/class-admin-settings.php:638
|
1950 |
-
msgid "Enable custom table for usermeta"
|
1951 |
-
msgstr ""
|
1952 |
-
|
1953 |
-
#: includes/admin/core/class-admin-settings.php:639
|
1954 |
-
msgid "Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches."
|
1955 |
-
msgstr ""
|
1956 |
-
|
1957 |
-
#: includes/admin/core/class-admin-settings.php:644
|
1958 |
-
msgid "We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete."
|
1959 |
-
msgstr ""
|
1960 |
-
|
1961 |
-
#: includes/admin/core/class-admin-settings.php:645
|
1962 |
-
msgid "After clicking the <strong>\"Run\"</strong> button, the update process will start. All information will be displayed in the field below."
|
1963 |
-
msgstr ""
|
1964 |
-
|
1965 |
-
#: includes/admin/core/class-admin-settings.php:646
|
1966 |
-
#: includes/admin/core/class-admin-upgrade.php:251
|
1967 |
-
msgid "If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed."
|
1968 |
-
msgstr ""
|
1969 |
-
|
1970 |
-
#: includes/admin/core/class-admin-settings.php:954
|
1971 |
-
msgid "General"
|
1972 |
-
msgstr ""
|
1973 |
-
|
1974 |
-
#: includes/admin/core/class-admin-settings.php:957
|
1975 |
-
msgid "Pages"
|
1976 |
-
msgstr ""
|
1977 |
-
|
1978 |
-
#: includes/admin/core/class-admin-settings.php:961
|
1979 |
-
#: includes/admin/templates/dashboard/users.php:15
|
1980 |
-
msgid "Users"
|
1981 |
-
msgstr ""
|
1982 |
-
|
1983 |
-
#: includes/admin/core/class-admin-settings.php:967
|
1984 |
-
msgid "Profile Permalink Base"
|
1985 |
-
msgstr ""
|
1986 |
-
|
1987 |
-
#. translators: %s: Profile page URL
|
1988 |
-
#: includes/admin/core/class-admin-settings.php:969
|
1989 |
-
msgid "Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/"
|
1990 |
-
msgstr ""
|
1991 |
-
|
1992 |
-
#: includes/admin/core/class-admin-settings.php:971
|
1993 |
-
#: includes/admin/core/class-admin-settings.php:988
|
1994 |
-
#: includes/core/class-builtin.php:708
|
1995 |
-
#: includes/core/class-builtin.php:711
|
1996 |
-
#: includes/core/class-member-directory.php:298
|
1997 |
-
msgid "Username"
|
1998 |
-
msgstr ""
|
1999 |
-
|
2000 |
-
#: includes/admin/core/class-admin-settings.php:972
|
2001 |
-
msgid "First and Last Name with '.'"
|
2002 |
-
msgstr ""
|
2003 |
-
|
2004 |
-
#: includes/admin/core/class-admin-settings.php:973
|
2005 |
-
msgid "First and Last Name with '-'"
|
2006 |
-
msgstr ""
|
2007 |
-
|
2008 |
-
#: includes/admin/core/class-admin-settings.php:974
|
2009 |
-
msgid "First and Last Name with '+'"
|
2010 |
-
msgstr ""
|
2011 |
-
|
2012 |
-
#: includes/admin/core/class-admin-settings.php:975
|
2013 |
-
msgid "User ID"
|
2014 |
-
msgstr ""
|
2015 |
-
|
2016 |
-
#: includes/admin/core/class-admin-settings.php:977
|
2017 |
-
#: includes/admin/core/class-admin-settings.php:996
|
2018 |
-
msgid "Select..."
|
2019 |
-
msgstr ""
|
2020 |
-
|
2021 |
-
#: includes/admin/core/class-admin-settings.php:983
|
2022 |
-
msgid "User Display Name"
|
2023 |
-
msgstr ""
|
2024 |
-
|
2025 |
-
#: includes/admin/core/class-admin-settings.php:984
|
2026 |
-
msgid "This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists"
|
2027 |
-
msgstr ""
|
2028 |
-
|
2029 |
-
#: includes/admin/core/class-admin-settings.php:986
|
2030 |
-
msgid "Default WP Display Name"
|
2031 |
-
msgstr ""
|
2032 |
-
|
2033 |
-
#: includes/admin/core/class-admin-settings.php:987
|
2034 |
-
#: includes/core/class-builtin.php:767
|
2035 |
-
#: includes/core/class-builtin.php:770
|
2036 |
-
#: includes/core/class-member-directory.php:299
|
2037 |
-
#: includes/core/class-member-directory.php:328
|
2038 |
-
msgid "Nickname"
|
2039 |
-
msgstr ""
|
2040 |
-
|
2041 |
-
#: includes/admin/core/class-admin-settings.php:989
|
2042 |
-
msgid "First name & last name"
|
2043 |
-
msgstr ""
|
2044 |
-
|
2045 |
-
#: includes/admin/core/class-admin-settings.php:990
|
2046 |
-
msgid "Last name & first name"
|
2047 |
-
msgstr ""
|
2048 |
-
|
2049 |
-
#: includes/admin/core/class-admin-settings.php:991
|
2050 |
-
msgid "First name & first initial of last name"
|
2051 |
-
msgstr ""
|
2052 |
-
|
2053 |
-
#: includes/admin/core/class-admin-settings.php:992
|
2054 |
-
msgid "First initial of first name & last name"
|
2055 |
-
msgstr ""
|
2056 |
-
|
2057 |
-
#: includes/admin/core/class-admin-settings.php:993
|
2058 |
-
msgid "First name only"
|
2059 |
-
msgstr ""
|
2060 |
-
|
2061 |
-
#: includes/admin/core/class-admin-settings.php:994
|
2062 |
-
msgid "Custom field(s)"
|
2063 |
-
msgstr ""
|
2064 |
-
|
2065 |
-
#: includes/admin/core/class-admin-settings.php:1001
|
2066 |
-
msgid "Display Name Custom Field(s)"
|
2067 |
-
msgstr ""
|
2068 |
-
|
2069 |
-
#: includes/admin/core/class-admin-settings.php:1002
|
2070 |
-
msgid "Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site"
|
2071 |
-
msgstr ""
|
2072 |
-
|
2073 |
-
#: includes/admin/core/class-admin-settings.php:1008
|
2074 |
-
msgid "Automatically redirect author page to their profile?"
|
2075 |
-
msgstr ""
|
2076 |
-
|
2077 |
-
#: includes/admin/core/class-admin-settings.php:1009
|
2078 |
-
msgid "If enabled, author pages will automatically redirect to the user's profile page"
|
2079 |
-
msgstr ""
|
2080 |
-
|
2081 |
-
#: includes/admin/core/class-admin-settings.php:1014
|
2082 |
-
msgid "Enable Members Directory"
|
2083 |
-
msgstr ""
|
2084 |
-
|
2085 |
-
#: includes/admin/core/class-admin-settings.php:1015
|
2086 |
-
msgid "Control whether to enable or disable member directories on this site"
|
2087 |
-
msgstr ""
|
2088 |
-
|
2089 |
-
#: includes/admin/core/class-admin-settings.php:1020
|
2090 |
-
msgid "Use Gravatars?"
|
2091 |
-
msgstr ""
|
2092 |
-
|
2093 |
-
#: includes/admin/core/class-admin-settings.php:1021
|
2094 |
-
msgid "Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)"
|
2095 |
-
msgstr ""
|
2096 |
-
|
2097 |
-
#: includes/admin/core/class-admin-settings.php:1026
|
2098 |
-
msgid "Use Gravatar builtin image"
|
2099 |
-
msgstr ""
|
2100 |
-
|
2101 |
-
#: includes/admin/core/class-admin-settings.php:1027
|
2102 |
-
msgid "Gravatar has a number of built in options which you can also use as defaults"
|
2103 |
-
msgstr ""
|
2104 |
-
|
2105 |
-
#: includes/admin/core/class-admin-settings.php:1029
|
2106 |
-
#: includes/admin/core/class-admin-settings.php:1621
|
2107 |
-
#: includes/admin/templates/form/login_settings.php:19
|
2108 |
-
#: includes/admin/templates/form/register_customize.php:9
|
2109 |
-
#: includes/admin/templates/form/register_customize.php:42
|
2110 |
-
#: includes/admin/templates/role/profile.php:52
|
2111 |
-
msgid "Default"
|
2112 |
-
msgstr ""
|
2113 |
-
|
2114 |
-
#: includes/admin/core/class-admin-settings.php:1030
|
2115 |
-
msgid "404 ( File Not Found response )"
|
2116 |
-
msgstr ""
|
2117 |
-
|
2118 |
-
#: includes/admin/core/class-admin-settings.php:1031
|
2119 |
-
msgid "Mystery Man"
|
2120 |
-
msgstr ""
|
2121 |
-
|
2122 |
-
#: includes/admin/core/class-admin-settings.php:1032
|
2123 |
-
msgid "Identicon"
|
2124 |
-
msgstr ""
|
2125 |
-
|
2126 |
-
#: includes/admin/core/class-admin-settings.php:1033
|
2127 |
-
msgid "Monsterid"
|
2128 |
-
msgstr ""
|
2129 |
-
|
2130 |
-
#: includes/admin/core/class-admin-settings.php:1034
|
2131 |
-
msgid "Wavatar"
|
2132 |
-
msgstr ""
|
2133 |
-
|
2134 |
-
#: includes/admin/core/class-admin-settings.php:1035
|
2135 |
-
msgid "Retro"
|
2136 |
-
msgstr ""
|
2137 |
-
|
2138 |
-
#: includes/admin/core/class-admin-settings.php:1036
|
2139 |
-
msgid "Blank ( a transparent PNG image )"
|
2140 |
-
msgstr ""
|
2141 |
-
|
2142 |
-
#: includes/admin/core/class-admin-settings.php:1044
|
2143 |
-
msgid "Use Default plugin avatar as Gravatar's Default avatar"
|
2144 |
-
msgstr ""
|
2145 |
-
|
2146 |
-
#: includes/admin/core/class-admin-settings.php:1045
|
2147 |
-
msgid "Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)"
|
2148 |
-
msgstr ""
|
2149 |
-
|
2150 |
-
#: includes/admin/core/class-admin-settings.php:1051
|
2151 |
-
msgid "Require a strong password?"
|
2152 |
-
msgstr ""
|
2153 |
-
|
2154 |
-
#: includes/admin/core/class-admin-settings.php:1052
|
2155 |
-
msgid "Enable or disable a strong password rules common for all Ultimate Member forms."
|
2156 |
-
msgstr ""
|
2157 |
-
|
2158 |
-
#: includes/admin/core/class-admin-settings.php:1057
|
2159 |
-
msgid "Password minimum length"
|
2160 |
-
msgstr ""
|
2161 |
-
|
2162 |
-
#: inclu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|