Ultimate Member – User Profile & Membership Plugin - Version 2.2.1

Version Description

Download this release

Release Info

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

Code changes from version 2.2.0 to 2.2.1

assets/dynamic_css/dynamic_global.php CHANGED
@@ -1,17 +1,17 @@
1
- <style type="text/css">
2
- <?php
3
-
4
- if ( isset( $max_width ) && $max_width) {
5
- print ".um-$form_id.um {
6
- max-width: $max_width;
7
- }";
8
- }
9
-
10
- if ( isset( $align ) && in_array( $align, array( 'left', 'right' ) ) ) {
11
- print ".um-$form_id.um {
12
- margin-$align: 0px !important;
13
- }";
14
- }
15
-
16
- ?>
17
- </style>
1
+ <style type="text/css">
2
+ <?php
3
+
4
+ if ( isset( $max_width ) && $max_width ) {
5
+ print ".um-$form_id.um {
6
+ max-width: {$max_width};
7
+ }";
8
+ }
9
+
10
+ if ( isset( $align ) && in_array( $align, array( 'left', 'right' ) ) ) {
11
+ print ".um-$form_id.um {
12
+ margin-$align: 0px !important;
13
+ }";
14
+ }
15
+
16
+ ?>
17
+ </style>
assets/js/um-members.js CHANGED
@@ -1,1777 +1,1779 @@
1
- var um_members_directory_busy = [];
2
-
3
- var um_member_directories = [];
4
-
5
- var um_member_directory_last_data = [];
6
-
7
- function um_parse_current_url() {
8
- var data = {};
9
-
10
- var query = window.location.search.substring(1);
11
- var attrs = query.split( '&' );
12
- jQuery.each( attrs, function( i ) {
13
- var attr = attrs[ i ].split( '=' );
14
- data[ attr[0] ] = attr[1];
15
- });
16
- return data;
17
- }
18
-
19
-
20
- function um_get_data_for_directory( directory, search_key ) {
21
- var hash = um_members_get_hash( directory );
22
- var data = {};
23
-
24
- var url_data = um_parse_current_url();
25
- jQuery.each( url_data, function( key ) {
26
- if ( key.indexOf( '_' + hash ) !== -1 && url_data[ key ] !== '' ) {
27
- data[ key.replace( '_' + hash, '' ) ] = url_data[ key ];
28
- }
29
- });
30
-
31
- if ( ! search_key ) {
32
- return data;
33
- } else {
34
- if ( typeof data[ search_key ] !== 'undefined' ) {
35
- try {
36
- //data[ search_key ] = decodeURI( data[ search_key ] );
37
- data[ search_key ] = decodeURIComponent( data[ search_key ] );
38
- } catch(e) { // catches a malformed URI
39
- console.error(e);
40
- }
41
- }
42
-
43
- return data[ search_key ];
44
- }
45
- }
46
-
47
-
48
- function um_set_url_from_data( directory, key, value ) {
49
- var hash = um_members_get_hash( directory );
50
- var data = um_get_data_for_directory( directory );
51
-
52
- var other_directories = um_member_directories;
53
-
54
- var new_data = {};
55
-
56
- if ( Array.isArray( value ) ) {
57
- jQuery.each( value, function( i ) {
58
- value[ i ] = encodeURIComponent( value[ i ] );
59
- });
60
- value = value.join( '||' );
61
- } else if ( ! jQuery.isNumeric( value ) ) {
62
- value = value.split( '||' );
63
- jQuery.each( value, function( i ) {
64
- value[ i ] = encodeURIComponent( value[ i ] );
65
- });
66
- value = value.join( '||' );
67
- }
68
-
69
- if ( value !== '' ) {
70
- new_data[ key + '_' + hash ] = value;
71
- }
72
- jQuery.each( data, function( data_key ) {
73
- if ( key === data_key ) {
74
- if ( value !== '' ) {
75
- new_data[ data_key + '_' + hash ] = value;
76
- }
77
- } else {
78
- new_data[ data_key + '_' + hash ] = data[ data_key ];
79
- }
80
- });
81
-
82
- // added data of other directories to the url
83
- jQuery.each( um_member_directories, function( k ) {
84
- var dir_hash = um_member_directories[ k ];
85
- if ( dir_hash !== hash ) {
86
- var other_directory = jQuery( '.um-directory[data-hash="' + dir_hash + '"]' );
87
- var dir_data = um_get_data_for_directory( other_directory );
88
-
89
- jQuery.each( dir_data, function( data_key ) {
90
- new_data[ data_key + '_' + dir_hash ] = dir_data[ data_key ];
91
- });
92
- }
93
- });
94
-
95
- var query_strings = [];
96
- jQuery.each( new_data, function( data_key ) {
97
- query_strings.push( data_key + '=' + new_data[ data_key ] );
98
- });
99
-
100
- query_strings = wp.hooks.applyFilters( 'um_member_directory_url_attrs', query_strings );
101
-
102
- var query_string = '?' + query_strings.join( '&' );
103
- if ( query_string === '?' ) {
104
- query_string = '';
105
- }
106
-
107
- window.history.pushState("string", "UM Member Directory", window.location.origin + window.location.pathname + query_string );
108
- }
109
-
110
-
111
- function um_members_get_hash( directory ) {
112
- return directory.data( 'hash' );
113
- }
114
-
115
- function um_is_directory_busy( directory ) {
116
- var hash = um_members_get_hash( directory );
117
- return typeof um_members_directory_busy[ hash ] != 'undefined' && um_members_directory_busy[ hash ];
118
- }
119
-
120
-
121
- function um_members_show_preloader( directory ) {
122
- um_members_directory_busy[ um_members_get_hash( directory ) ] = true;
123
- directory.find('.um-members-overlay').show();
124
- }
125
-
126
-
127
- function um_members_hide_preloader( directory ) {
128
- um_members_directory_busy[ um_members_get_hash( directory ) ] = false;
129
- directory.find('.um-members-overlay').hide();
130
- }
131
-
132
-
133
- function um_set_range_label( slider, ui ) {
134
- var placeholder = '';
135
- var placeholder_s = slider.siblings( '.um-slider-range' ).data( 'placeholder-s' );
136
- var placeholder_p = slider.siblings( '.um-slider-range' ).data( 'placeholder-p' );
137
-
138
- if ( ui ) {
139
- if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
140
- placeholder = placeholder_s.replace( '\{value\}', ui.values[ 0 ] )
141
- .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
142
- .data('label') );
143
- } else {
144
- placeholder = placeholder_p.replace( '\{min_range\}', ui.values[ 0 ] )
145
- .replace( '\{max_range\}', ui.values[ 1 ] )
146
- .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
147
- .data('label') );
148
- }
149
- } else {
150
- if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
151
- placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
152
- .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
153
- .data('label') );
154
- } else {
155
- placeholder = placeholder_p.replace( '\{min_range\}', slider.slider( "values", 0 ) )
156
- .replace( '\{max_range\}', slider.slider( "values", 1 ) )
157
- .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
158
- .data('label') );
159
- }
160
- }
161
- slider.siblings( '.um-slider-range' ).html( placeholder );
162
-
163
- slider.siblings( ".um_range_min" ).val( slider.slider( "values", 0 ) );
164
- slider.siblings( ".um_range_max" ).val( slider.slider( "values", 1 ) );
165
- }
166
-
167
-
168
- function um_get_search( directory ) {
169
- if ( directory.find('.um-search-line').length ) {
170
- return directory.find( '.um-search-line' ).val();
171
- } else {
172
- return '';
173
- }
174
- }
175
-
176
- function um_get_sort( directory ) {
177
- return directory.data( 'sorting' );
178
- }
179
-
180
- function um_get_current_page( directory ) {
181
- var page = directory.data( 'page' );
182
- if ( ! page || typeof page == 'undefined' ) {
183
- page = 1;
184
- }
185
- return page;
186
- }
187
-
188
- function um_time_convert( time, range ) {
189
- var hours = Math.floor( time / 60 );
190
- var minutes = time % 60;
191
-
192
- if ( minutes >= 60 ) {
193
- minutes = 0;
194
- hours = hours + 1;
195
-
196
- if ( hours >= 24 ) {
197
- hours = 0;
198
- }
199
- }
200
-
201
- if ( minutes < 10 ) {
202
- minutes = '0' + minutes;
203
- }
204
-
205
- return hours + ":" + minutes;
206
- }
207
-
208
- function um_ajax_get_members( directory, args ) {
209
-
210
- /**
211
- * Operates with the next data:
212
- *
213
- * 1) Page - getting from directory data 'page'
214
- * 2) Sort - getting from 'um-member-directory-sorting-options' field value
215
- * 3) Search - getting from 'um-search-line' field value
216
- * 4) Filters - getting from URL data by 'um_get_data_for_directory' function
217
- *
218
- */
219
-
220
- var hash = um_members_get_hash( directory );
221
-
222
- var allow = wp.hooks.applyFilters( 'um_member_directory_get_members_allow', true, hash, directory );
223
- if ( ! allow ) {
224
- setTimeout( um_ajax_get_members, 600, directory, args );
225
- return;
226
- }
227
-
228
- var page = um_get_current_page( directory );
229
- var search = um_get_search( directory );
230
- var sorting = um_get_sort( directory );
231
-
232
- var local_date = new Date();
233
- var gmt_hours = -local_date.getTimezoneOffset() / 60;
234
-
235
- var request = {
236
- directory_id: hash,
237
- page: page,
238
- search: search,
239
- sorting: sorting,
240
- gmt_offset: gmt_hours,
241
- post_refferer: directory.data('base-post'),
242
- nonce: um_scripts.nonce
243
- };
244
-
245
- if ( directory.find('.um-search-filter').length ) {
246
- directory.find('.um-search-filter').each( function() {
247
- var filter = jQuery(this);
248
-
249
- if ( filter.find( '.um-slider' ).length ) {
250
- var filter_name = filter.find( '.um-slider' ).data('field_name');
251
-
252
- var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
253
- var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
254
- if ( typeof value_from != 'undefined' || typeof value_to != 'undefined' ) {
255
- request[ filter_name ] = [ value_from, value_to ];
256
- }
257
- } else if ( filter.find( '.um-datepicker-filter' ).length ) {
258
- var filter_name = filter.find( '.um-datepicker-filter' ).data('filter_name');
259
- var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
260
- var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
261
- if ( typeof value_from != 'undefined' || typeof value_to != 'undefined') {
262
- request[ filter_name ] = [ value_from, value_to ];
263
- }
264
- } else if ( filter.find( '.um-timepicker-filter' ).length ) {
265
- var filter_name = filter.find( '.um-timepicker-filter' ).data('filter_name');
266
- var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
267
- var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
268
-
269
- if ( typeof value_from != 'undefined' ) {
270
- var value_from = value_from.split(':');
271
- var hours = value_from[0]*1;
272
- if ( hours < 10 ) {
273
- hours = '0' + hours;
274
- }
275
-
276
- var minutes = value_from[1]*1;
277
- if ( minutes < 10 ) {
278
- minutes = '0' + minutes;
279
- }
280
-
281
- value_from = hours + ':' + minutes + ':00';
282
- }
283
- if ( typeof value_to != 'undefined' ) {
284
- var val_to = value_to.split(':');
285
- var minutes = val_to[1]*1;
286
-
287
- var hours = val_to[0]*1;
288
- if ( hours < 10 ) {
289
- hours = '0' + hours;
290
- }
291
-
292
- if ( minutes < 10 ) {
293
- minutes = '0' + minutes;
294
- }
295
-
296
- value_to = hours + ':' + minutes + ':59';
297
- }
298
-
299
- if ( typeof value_from != 'undefined' || typeof value_to != 'undefined' ) {
300
- request[ filter_name ] = [ value_from, value_to ];
301
- }
302
- } else if ( filter.find( 'select' ).length ) {
303
- var filter_name = filter.find('select').attr('name');
304
- var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
305
- if ( typeof value != 'undefined' ) {
306
- request[ filter_name ] = value.split( '||' );
307
- }
308
- } else if ( filter.hasClass( 'um-text-filter-type' ) && filter.find('input[type="text"]').length ) {
309
- var filter_name = filter.find('input[type="text"]').attr('name');
310
- var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
311
- if ( typeof value != 'undefined' ) {
312
- request[ filter_name ] = value;
313
- }
314
- } else {
315
- request = wp.hooks.applyFilters( 'um_member_directory_custom_filter_handler', request, filter, directory );
316
- }
317
- });
318
- }
319
-
320
- request = wp.hooks.applyFilters( 'um_member_directory_filter_request', request );
321
-
322
- wp.ajax.send( 'um_get_members', {
323
- data: request,
324
- success: function( answer ) {
325
- //set last data hard for using on layouts reloading
326
- um_member_directory_last_data[ hash ] = answer;
327
-
328
- um_build_template( directory, answer );
329
-
330
- var pagination_template = wp.template( 'um-members-pagination' );
331
- directory.find('.um-members-pagination-box').html( pagination_template( answer ) );
332
-
333
- directory.data( 'total_pages', answer.pagination.total_pages );
334
-
335
- if ( answer.pagination.total_pages ) {
336
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
337
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
338
- } else {
339
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
340
- directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
341
- }
342
-
343
- //args.directory = directory;
344
- wp.hooks.doAction( 'um_member_directory_loaded', directory, answer );
345
- //jQuery( document ).trigger('um_members_rendered', [ directory, answer ] );
346
-
347
- um_init_new_dropdown();
348
-
349
- um_members_hide_preloader( directory );
350
- },
351
- error: function( data ) {
352
- console.log( data );
353
-
354
- um_members_hide_preloader( directory );
355
- }
356
- });
357
- }
358
-
359
-
360
- function um_build_template( directory, data ) {
361
- var layout = directory.data('view_type');
362
- var template = wp.template( 'um-member-' + layout + '-' + um_members_get_hash( directory ) );
363
-
364
- directory.find('.um-members-grid, .um-members-list').remove();
365
- directory.find('.um-members-wrapper').prepend( template( data.users ) );
366
-
367
- var header_template = wp.template( 'um-members-header' );
368
- directory.find('.um-members-intro').remove();
369
-
370
- var generate_header = wp.hooks.applyFilters( 'um_member_directory_generate_header', false, directory );
371
-
372
- if ( ( typeof data.is_search != 'undefined' && data.is_search ) || generate_header ) {
373
- directory.find('.um-members-wrapper').prepend( header_template( data ) );
374
- }
375
-
376
- directory.addClass('um-loaded');
377
-
378
- if ( directory.find('.um-members.um-members-grid').length ) {
379
- UM_Member_Grid( directory.find('.um-members.um-members-grid') );
380
- }
381
-
382
- jQuery( document ).trigger( 'um_build_template', [ directory, data ] );
383
- jQuery( window ).trigger( 'resize' );
384
-
385
- init_tipsy();
386
- }
387
-
388
-
389
-
390
- function UM_Member_Grid( container ) {
391
- if ( container.find( '.um-member' ).length ) {
392
- container.imagesLoaded( function() {
393
-
394
- var masonry_args = wp.hooks.applyFilters( 'um_member_directory_grid_masonry_attrs', {
395
- itemSelector: '.um-member',
396
- columnWidth: '.um-member',
397
- gutter: '.um-gutter-sizer'
398
- }, container );
399
-
400
- var $grid = container.masonry( masonry_args );
401
-
402
- $grid.on( 'layoutComplete', function( event, laidOutItems ) {
403
- jQuery( document ).trigger( "um_grid_initialized", [ event, laidOutItems ] );
404
- });
405
- });
406
- }
407
- }
408
-
409
-
410
- function um_get_filters_data( directory ) {
411
- var filters_data = [];
412
-
413
- directory.find('.um-search-filter').each( function() {
414
-
415
- var filter = jQuery(this);
416
- var filter_name,
417
- filter_title;
418
-
419
- var filter_type;
420
- if ( filter.find('input.um-datepicker-filter').length ) {
421
- filter_type = 'datepicker';
422
-
423
- filter.find('input.um-datepicker-filter').each( function() {
424
- var range = jQuery(this).data('range');
425
- if ( range === 'to' ) {
426
- return;
427
- }
428
-
429
- var filter_name = jQuery(this).data('filter_name');
430
-
431
- var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
432
- var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
433
- if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
434
- return;
435
- }
436
-
437
- var from_val = jQuery(this).val();
438
- var to_val = directory.find('input.um-datepicker-filter[data-range="to"][data-filter_name="' + filter_name + '"]').val();
439
-
440
- var value;
441
- if ( from_val === to_val ) {
442
- value = to_val;
443
- } else if ( from_val !== '' && to_val !== '' ) {
444
- value = from_val + ' - ' + to_val;
445
- } else if ( from_val === '' ) {
446
- value = 'before ' + to_val;
447
- } else if ( to_val === '' ) {
448
- value = 'since ' + from_val;
449
- }
450
-
451
- filters_data.push( {'name':filter_name, 'label':jQuery(this).data('filter-label'), 'value_label': value, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
452
- });
453
-
454
- } else if( filter.find('input.um-timepicker-filter').length ) {
455
- filter_type = 'timepicker';
456
-
457
- filter.find('input.um-timepicker-filter').each( function() {
458
- var range = jQuery(this).data('range');
459
- if ( range === 'to' ) {
460
- return;
461
- }
462
-
463
- var filter_name = jQuery(this).data('filter_name');
464
-
465
- var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
466
- var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
467
- if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
468
- return;
469
- }
470
-
471
- var from_val = jQuery(this).val();
472
- var to_val = directory.find('input.um-timepicker-filter[data-range="to"][data-filter_name="' + filter_name + '"]').val();
473
-
474
- var value;
475
- if ( from_val === to_val ) {
476
- value = to_val;
477
- } else if ( from_val !== '' && to_val !== '' ) {
478
- value = from_val + ' - ' + to_val;
479
- } else if ( from_val === '' ) {
480
- value = 'before ' + to_val;
481
- } else if ( to_val === '' ) {
482
- value = 'since ' + from_val;
483
- }
484
-
485
- filters_data.push( {'name':filter_name, 'label':jQuery(this).data('filter-label'), 'value_label': value, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
486
- });
487
- } else if( filter.find('select').length ) {
488
-
489
- filter_type = 'select';
490
- filter_name = filter.find('select').attr('name');
491
- filter_title = filter.find('select').data('placeholder');
492
-
493
- var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
494
- if ( typeof filter_value == 'undefined' ) {
495
- filter_value = [];
496
- } else {
497
- filter_value = filter_value.split( '||' );
498
- }
499
-
500
- jQuery.each( filter_value, function(i) {
501
- var filter_value_title = filter.find('select option[value="' + filter_value[ i ] + '"]').data('value_label');
502
- filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value_title, 'value':filter_value[ i ], 'type':filter_type} );
503
- });
504
-
505
- } else if( filter.hasClass('um-text-filter-type') && filter.find('input[type="text"]').length ) {
506
-
507
- filter_type = 'text';
508
- filter_name = filter.find('input[type="text"]').attr('name');
509
- filter_title = filter.find('input[type="text"]').attr('placeholder');
510
-
511
- var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
512
- if ( typeof filter_value == 'undefined' ) {
513
- filter_value = '';
514
- }
515
-
516
- if ( filter_value != '' ) {
517
- filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value, 'value':filter_value, 'type':filter_type} );
518
- }
519
-
520
- } else if( filter.find('div.ui-slider').length ) {
521
- filter_type = 'slider';
522
-
523
- filter_name = filter.find('div.ui-slider').data( 'field_name' );
524
- var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
525
- var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
526
-
527
- if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
528
- return;
529
- }
530
-
531
- var filter_value_title;
532
- if ( filter_value_from === filter_value_to ) {
533
- filter_value_title = filter.find('div.um-slider-range').data( 'placeholder-s' ).replace( '\{value\}', filter_value_from )
534
- .replace( '\{field_label\}', filter.find('div.um-slider-range').data('label') );
535
- } else {
536
- filter_value_title = filter.find('div.um-slider-range').data( 'placeholder-p' ).replace( '\{min_range\}', filter_value_from )
537
- .replace( '\{max_range\}', filter_value_to )
538
- .replace( '\{field_label\}', filter.find('div.um-slider-range').data('label') );
539
- }
540
-
541
- filter_title = filter.find('div.um-slider-range').data('label');
542
-
543
- filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value_title, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
544
- } else {
545
-
546
- filters_data = wp.hooks.applyFilters( 'um_member_directory_get_filter_data', filters_data, directory, filter );
547
-
548
- }
549
- });
550
-
551
- return filters_data;
552
- }
553
-
554
-
555
- function um_change_tag( directory ) {
556
- var filters_data = um_get_filters_data( directory );
557
-
558
- directory.find('.um-members-filter-tag').remove();
559
-
560
- var filtered_line = directory.find('.um-filtered-line');
561
- if ( filtered_line.length ) {
562
- var filters_template = wp.template( 'um-members-filtered-line' );
563
- filtered_line.prepend( filters_template( {'filters': filters_data} ) );
564
-
565
- if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
566
- directory.find('.um-clear-filters').hide();
567
- directory.find('.um-clear-filters').parents('.um-member-directory-header-row').addClass( 'um-header-row-invisible' );
568
- } else {
569
- directory.find('.um-clear-filters').show();
570
- directory.find('.um-clear-filters').parents('.um-member-directory-header-row').removeClass( 'um-header-row-invisible' );
571
- }
572
- }
573
-
574
-
575
- }
576
-
577
-
578
-
579
- function um_run_search( directory ) {
580
- if ( um_is_directory_busy( directory ) ) {
581
- return;
582
- }
583
- um_members_show_preloader( directory );
584
-
585
- var pre_search = um_get_data_for_directory( directory, 'search' );
586
-
587
- var search = directory.find('.um-search-line').val();
588
- if ( search === pre_search || ( search === '' && typeof pre_search == 'undefined' ) ) {
589
- um_members_hide_preloader( directory );
590
- return;
591
- }
592
-
593
- directory.data( 'general_search', search );
594
- um_set_url_from_data( directory, 'search', search );
595
-
596
- //set 1st page after search
597
- directory.data( 'page', 1 );
598
- um_set_url_from_data( directory, 'page', '' );
599
-
600
-
601
- var ignore_after_search = false;
602
- ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
603
-
604
- if ( ! ignore_after_search ) {
605
- var show_after_search = directory.data('must-search');
606
- if ( show_after_search === 1 ) {
607
- search = um_get_search( directory );
608
- if ( directory.find( '.um-members-filter-remove' ).length === 0 && ! search ) {
609
- directory.data( 'searched', 0 );
610
- directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
611
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
612
- directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
613
-
614
- wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
615
-
616
- um_members_hide_preloader( directory );
617
- return;
618
- }
619
- }
620
- }
621
-
622
- directory.data( 'searched', 1 );
623
-
624
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
625
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
626
-
627
- um_ajax_get_members( directory );
628
- }
629
-
630
-
631
- jQuery(document.body).ready( function() {
632
-
633
-
634
- jQuery( '.um-directory .um-search-filter select' ).each( function() {
635
- if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
636
- jQuery(this).prop('disabled', true);
637
- }
638
-
639
- var obj = jQuery(this);
640
- obj.select2('destroy').select2({
641
- dropdownParent: obj.parent()
642
- });
643
- });
644
-
645
- /**
646
- * Change View Type Handlers
647
- */
648
-
649
-
650
- //UI for change view type button
651
- jQuery( document.body ).on( 'mouseover', '.um-directory .um-member-directory-view-type', function() {
652
- if ( jQuery(this).hasClass('um-disabled') ) {
653
- return;
654
- }
655
-
656
- var $obj = jQuery(this).find('.um-member-directory-view-type-a:visible');
657
-
658
- $obj.hide();
659
-
660
- if ( $obj.next().length ) {
661
- $obj.next().show().tipsy('show');
662
- } else {
663
- jQuery(this).find( '.um-member-directory-view-type-a:first' ).show().tipsy('show');
664
- }
665
- }).on( 'mouseout', '.um-directory .um-member-directory-view-type', function() {
666
- if ( jQuery(this).hasClass('um-disabled') ) {
667
- return;
668
- }
669
-
670
- jQuery(this).find('.um-member-directory-view-type-a').hide().tipsy('hide');
671
- jQuery(this).find('.um-member-directory-view-type-a[data-type="' + jQuery(this).parents( '.um-directory' ).data('view_type') + '"]').show();
672
- });
673
-
674
- //change layout handler
675
- jQuery( document.body ).on( 'click', '.um-directory .um-member-directory-view-type-a', function() {
676
- var directory = jQuery(this).parents('.um-directory');
677
- if ( um_is_directory_busy( directory ) ) {
678
- return false;
679
- }
680
-
681
- var $this = jQuery(this);
682
- var views = $this.parents('.um-member-directory-view-type');
683
-
684
- if ( views.hasClass('um-disabled') ) {
685
- return;
686
- }
687
-
688
- um_members_show_preloader( directory );
689
-
690
- var $obj = views.find('.um-member-directory-view-type-a:visible');
691
-
692
- $obj.hide();
693
-
694
- if ( $obj.next().length ) {
695
- $obj.next().show().tipsy('show');
696
- } else {
697
- views.find( '.um-member-directory-view-type-a:first' ).show().tipsy('show');
698
- }
699
-
700
- var data = um_member_directory_last_data[ um_members_get_hash( directory ) ];
701
- if ( data !== null ) {
702
- var layout = $this.data('type');
703
-
704
- um_set_url_from_data( directory, 'view_type', layout );
705
- directory.data( 'view_type', layout );
706
-
707
- um_build_template( directory, data );
708
-
709
- um_init_new_dropdown();
710
- }
711
- um_members_hide_preloader( directory );
712
- });
713
-
714
-
715
- /**
716
- * END: Change View Type Handlers
717
- */
718
-
719
-
720
- /**
721
- * General Search
722
- */
723
-
724
-
725
- //searching
726
- jQuery( document.body ).on( 'click', '.um-directory .um-do-search', function() {
727
- var directory = jQuery(this).parents('.um-directory');
728
- um_run_search( directory );
729
- });
730
-
731
-
732
- //make search on Enter click
733
- jQuery( document.body ).on( 'keypress', '.um-directory .um-search-line', function(e) {
734
- if ( e.which === 13 ) {
735
- var directory = jQuery(this).parents('.um-directory');
736
- um_run_search( directory );
737
- }
738
- });
739
-
740
-
741
- /**
742
- * END: General Search
743
- */
744
-
745
-
746
-
747
- /**
748
- * Sorting
749
- */
750
-
751
- jQuery( document.body ).on( 'click', '.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a', function() {
752
- if ( jQuery( this ).data('selected') === 1 ) {
753
- return;
754
- }
755
-
756
- var directory_hash = jQuery(this).data('directory-hash');
757
- var directory = jQuery('.um-directory[data-hash="' + directory_hash + '"]');
758
-
759
- if ( um_is_directory_busy( directory ) ) {
760
- return;
761
- }
762
-
763
- um_members_show_preloader( directory );
764
-
765
- var sorting_label = jQuery( this ).html();
766
- var sort = jQuery(this).data('value');
767
-
768
- directory.data( 'sorting', sort );
769
- um_set_url_from_data( directory, 'sort', sort );
770
-
771
- um_ajax_get_members( directory );
772
-
773
- directory.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find('a').data('selected', 0).prop('data-selected', 0).attr('data-selected', 0);
774
- directory.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"] a[data-value="' + sort + '"]').data('selected', 1).prop('data-selected', 1).attr('data-selected', 1);
775
- directory.find('.um-member-directory-sorting-a').find('> a').html( sorting_label );
776
- });
777
-
778
- /**
779
- * END: Sorting
780
- */
781
-
782
-
783
-
784
- /**
785
- * Pagination
786
- */
787
-
788
-
789
- jQuery( document.body ).on( 'click', '.um-directory .pagi:not(.current)', function() {
790
- if ( jQuery(this).hasClass('disabled') ) {
791
- return;
792
- }
793
-
794
- var directory = jQuery(this).parents('.um-directory');
795
- if ( um_is_directory_busy( directory ) ) {
796
- return;
797
- }
798
-
799
- um_members_show_preloader( directory );
800
-
801
- var page;
802
- if ( 'first' === jQuery(this).data('page') ) {
803
- page = 1;
804
- } else if ( 'prev' === jQuery(this).data('page') ) {
805
- page = directory.data( 'page' )*1 - 1;
806
- } else if ( 'next' === jQuery(this).data('page') ) {
807
- page = directory.data( 'page' )*1 + 1;
808
- } else if ( 'last' === jQuery(this).data('page') ) {
809
- page = parseInt( directory.data( 'total_pages' ) );
810
- } else {
811
- page = parseInt( jQuery(this).data('page') );
812
- }
813
-
814
- if ( page === 1 ) {
815
- directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass('disabled');
816
- directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
817
- } else if ( page === parseInt( directory.data( 'total_pages' ) ) ) {
818
- directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass('disabled');
819
- directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass('disabled');
820
- } else {
821
- directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
822
- directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass('disabled');
823
- }
824
-
825
- directory.find('.pagi').removeClass('current');
826
- directory.find('.pagi[data-page="' + page + '"]').addClass('current');
827
-
828
- directory.data( 'page', page );
829
- if ( page === 1 ) {
830
- um_set_url_from_data( directory, 'page', '' );
831
- } else {
832
- um_set_url_from_data( directory, 'page', page );
833
- }
834
-
835
- um_ajax_get_members( directory );
836
- });
837
-
838
-
839
- //mobile pagination
840
- jQuery( document.body ).on( 'change', '.um-directory .um-members-pagi-dropdown', function() {
841
- var directory = jQuery(this).parents('.um-directory');
842
-
843
- if ( um_is_directory_busy( directory ) ) {
844
- return;
845
- }
846
-
847
- um_members_show_preloader( directory );
848
-
849
- var page = jQuery(this).val();
850
-
851
- directory.find('.pagi').removeClass('current');
852
- directory.find('.pagi[data-page="' + page + '"]').addClass('current');
853
-
854
- directory.data( 'page', page );
855
- if ( page === 1 ) {
856
- um_set_url_from_data( directory, 'page', '' );
857
- } else {
858
- um_set_url_from_data( directory, 'page', page );
859
- }
860
-
861
- um_ajax_get_members( directory );
862
- });
863
-
864
-
865
- /**
866
- * END: Pagination
867
- */
868
-
869
-
870
- /**
871
- * Profile Cards actions
872
- */
873
-
874
- jQuery( document.body ).on('click', '.um-directory .um-members.um-members-list .um-member-more a', function(e){
875
- e.preventDefault();
876
-
877
- var block = jQuery(this).parents('.um-member');
878
-
879
- block.find('.um-member-more').hide();
880
- block.find('.um-member-meta-main').slideDown();
881
- block.find('.um-member-less').fadeIn();
882
-
883
- return false;
884
- });
885
-
886
- jQuery( document.body ).on('click', '.um-directory .um-members.um-members-list .um-member-less a', function(e){
887
- e.preventDefault();
888
-
889
- var block = jQuery(this).parents('.um-member');
890
-
891
- block.find('.um-member-less').hide();
892
- block.find('.um-member-meta-main').slideUp();
893
- block.find('.um-member-more').fadeIn();
894
-
895
- return false;
896
- });
897
-
898
-
899
- jQuery( document.body ).on('click', '.um-directory .um-members.um-members-grid .um-member-more a', function(e){
900
- e.preventDefault();
901
-
902
- var block = jQuery(this).parents('.um-member');
903
- var container = jQuery(this).parents('.um-members');
904
- block.find('.um-member-more').hide();
905
- block.find('.um-member-meta').slideDown( function(){ UM_Member_Grid( container ) } );
906
- block.find('.um-member-less').fadeIn( );
907
-
908
- setTimeout(function(){ UM_Member_Grid( container ) }, 100);
909
-
910
- return false;
911
- });
912
-
913
- jQuery( document.body ).on('click', '.um-directory .um-members.um-members-grid .um-member-less a', function(e){
914
- e.preventDefault();
915
-
916
- var block = jQuery(this).parents('.um-member');
917
- var container = jQuery(this).parents('.um-members');
918
- block.find('.um-member-less').hide();
919
- block.find('.um-member-meta').slideUp( function() {
920
- block.find('.um-member-more').fadeIn();
921
- UM_Member_Grid( container );
922
- });
923
-
924
- return false;
925
- });
926
-
927
- /**
928
- * END: Profile Cards actions
929
- */
930
-
931
-
932
- //filters controls
933
- jQuery('.um-member-directory-filters-a').on( 'click', function() {
934
- var obj = jQuery(this);
935
- var search_bar = obj.parents('.um-directory').find('.um-search');
936
-
937
- if ( search_bar.is( ':visible' ) ) {
938
- search_bar.slideUp( 250, function(){
939
- obj.toggleClass('um-member-directory-filters-visible');
940
- search_bar.parents('.um-member-directory-header-row').toggleClass('um-header-row-invisible');
941
- });
942
- } else {
943
- search_bar.slideDown({
944
- duration: 250,
945
- start: function() {
946
- jQuery(this).css({
947
- display: "grid"
948
- });
949
- obj.toggleClass('um-member-directory-filters-visible');
950
- search_bar.parents('.um-member-directory-header-row').toggleClass('um-header-row-invisible');
951
- }
952
- } );
953
- }
954
- });
955
-
956
-
957
- //filtration process
958
- jQuery( document.body ).on( 'change', '.um-directory .um-search-filter select', function() {
959
- if ( jQuery(this).val() === '' ) {
960
- return;
961
- }
962
-
963
- var directory = jQuery(this).parents('.um-directory');
964
-
965
- if ( um_is_directory_busy( directory ) ) {
966
- return;
967
- }
968
-
969
- um_members_show_preloader( directory );
970
-
971
- var filter_name = jQuery(this).prop('name');
972
-
973
- var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
974
- if ( typeof current_value == 'undefined' ) {
975
- current_value = [];
976
- } else {
977
- current_value = current_value.split( '||' );
978
- }
979
-
980
- if ( -1 === jQuery.inArray( jQuery(this).val(), current_value ) ) {
981
- current_value.push( jQuery(this).val() );
982
- current_value = current_value.join( '||' );
983
-
984
- um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
985
-
986
- //set 1st page after filtration
987
- directory.data( 'page', 1 );
988
- um_set_url_from_data( directory, 'page', '' );
989
- }
990
-
991
- //disable options and disable select if all options are disabled
992
- jQuery(this).find('option[value="' + jQuery(this).val() + '"]').prop('disabled', true).hide();
993
- if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
994
- jQuery(this).prop('disabled', true);
995
- }
996
-
997
- var obj = jQuery(this);
998
- obj.select2('destroy').select2({
999
- dropdownParent: obj.parent()
1000
- });
1001
- obj.val('').trigger( 'change' );
1002
-
1003
- um_ajax_get_members( directory );
1004
-
1005
- um_change_tag( directory );
1006
-
1007
- directory.data( 'searched', 1 );
1008
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1009
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1010
- // if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
1011
- // jQuery(this).trigger('change');
1012
- // }
1013
- });
1014
-
1015
-
1016
- jQuery( document.body ).on( 'blur', '.um-directory .um-search-filter.um-text-filter-type input[type="text"]', function() {
1017
- var directory = jQuery(this).parents('.um-directory');
1018
-
1019
- if ( um_is_directory_busy( directory ) ) {
1020
- return;
1021
- }
1022
-
1023
- var current_value = jQuery(this).val();
1024
- var filter_name = jQuery(this).prop('name');
1025
- var url_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1026
-
1027
- if ( typeof url_value == 'undefined' ) {
1028
- url_value = '';
1029
- }
1030
-
1031
- if ( current_value === url_value ) {
1032
- return;
1033
- }
1034
-
1035
- um_members_show_preloader( directory );
1036
- um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1037
-
1038
- //set 1st page after filtration
1039
- directory.data( 'page', 1 );
1040
- um_set_url_from_data( directory, 'page', '' );
1041
-
1042
- um_ajax_get_members( directory );
1043
-
1044
- um_change_tag( directory );
1045
-
1046
- directory.data( 'searched', 1 );
1047
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1048
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1049
- });
1050
-
1051
-
1052
- //make search on Enter click
1053
- jQuery( document.body ).on( 'keypress', '.um-directory .um-search-filter.um-text-filter-type input[type="text"]', function(e) {
1054
- if ( e.which === 13 ) {
1055
- var directory = jQuery(this).parents('.um-directory');
1056
-
1057
- if ( um_is_directory_busy( directory ) ) {
1058
- return;
1059
- }
1060
-
1061
- var current_value = jQuery(this).val();
1062
- var filter_name = jQuery(this).prop('name');
1063
- var url_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1064
-
1065
- if ( typeof url_value == 'undefined' ) {
1066
- url_value = '';
1067
- }
1068
-
1069
- if ( current_value === url_value ) {
1070
- return;
1071
- }
1072
-
1073
- um_members_show_preloader( directory );
1074
- um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1075
-
1076
- //set 1st page after filtration
1077
- directory.data( 'page', 1 );
1078
- um_set_url_from_data( directory, 'page', '' );
1079
-
1080
- um_ajax_get_members( directory );
1081
-
1082
- um_change_tag( directory );
1083
-
1084
- directory.data( 'searched', 1 );
1085
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1086
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1087
- }
1088
- });
1089
-
1090
-
1091
-
1092
- jQuery( document.body ).on( 'click', '.um-directory .um-members-filter-remove', function() {
1093
- var directory = jQuery(this).parents('.um-directory');
1094
-
1095
- if ( um_is_directory_busy(directory) || ! directory ) {
1096
- return;
1097
- }
1098
-
1099
- um_members_show_preloader( directory );
1100
-
1101
- var removeItem = jQuery(this).data('value');
1102
- var filter_name = jQuery(this).data('name');
1103
-
1104
- var type = jQuery(this).data('type');
1105
- if ( type === 'text' ) {
1106
- um_set_url_from_data( directory, 'filter_' + filter_name,'' );
1107
-
1108
- jQuery( '.um-search-filter input[name="' + filter_name + '"]' ).val('');
1109
-
1110
- } else if ( type === 'select' ) {
1111
-
1112
- var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1113
- if ( typeof current_value == 'undefined' ) {
1114
- current_value = [];
1115
- } else {
1116
- current_value = current_value.split( '||' );
1117
- }
1118
-
1119
- if ( -1 !== jQuery.inArray( removeItem.toString(), current_value ) ) {
1120
- current_value = jQuery.grep( current_value, function( value ) {
1121
- return value !== removeItem.toString();
1122
- });
1123
- }
1124
-
1125
- if ( ! current_value.length ) {
1126
- current_value = '';
1127
- }
1128
-
1129
- um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1130
-
1131
- var select = jQuery( '.um-search-filter select[name="' + filter_name + '"]' );
1132
- select.find('option[value="' + removeItem + '"]').prop('disabled', false).show();
1133
-
1134
- //disable options and disable select if all options are disabled
1135
- if ( select.find('option:not(:disabled)').length > 1 ) {
1136
- select.prop('disabled', false);
1137
- }
1138
-
1139
- select.select2('destroy').select2({
1140
- dropdownParent: select.parent()
1141
- });
1142
-
1143
- if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
1144
- select.trigger('change');
1145
- }
1146
-
1147
- } else if ( type === 'slider' ) {
1148
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1149
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1150
-
1151
-
1152
- var $slider = jQuery( '.um-search-filter #' + filter_name + '_min' ).siblings('.um-slider');
1153
- var options = $slider.slider( 'option' );
1154
-
1155
- $slider.slider( 'values', [ options.min, options.max ] );
1156
-
1157
- jQuery( '.um-search-filter #' + filter_name + '_min' ).val('');
1158
- jQuery( '.um-search-filter #' + filter_name + '_max' ).val('');
1159
-
1160
- um_set_range_label( $slider );
1161
- } else if ( type === 'datepicker' ) {
1162
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1163
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1164
-
1165
- jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1166
- jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1167
- } else if ( type === 'timepicker' ) {
1168
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1169
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1170
-
1171
- jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1172
- jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1173
- } else {
1174
- wp.hooks.doAction( 'um_member_directory_filter_remove', type, directory, filter_name, removeItem );
1175
- }
1176
-
1177
-
1178
- //set 1st page after filtration
1179
- directory.data( 'page', 1 );
1180
- um_set_url_from_data( directory, 'page', '' );
1181
-
1182
- jQuery(this).tipsy('hide');
1183
- jQuery(this).parents('.um-members-filter-tag').remove();
1184
-
1185
- if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
1186
- directory.find('.um-clear-filters').hide();
1187
- } else {
1188
- directory.find('.um-clear-filters').show();
1189
- }
1190
-
1191
- var ignore_after_search = false;
1192
- ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1193
-
1194
- if ( ! ignore_after_search ) {
1195
- var show_after_search = directory.data('must-search');
1196
- if ( show_after_search === 1 ) {
1197
- var search = um_get_search( directory );
1198
- if ( directory.find( '.um-members-filter-remove' ).length === 0 && ! search ) {
1199
- directory.data( 'searched', 0 );
1200
- directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
1201
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
1202
- directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
1203
-
1204
- wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
1205
-
1206
- um_members_hide_preloader( directory );
1207
- return;
1208
- }
1209
- }
1210
- }
1211
-
1212
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1213
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1214
-
1215
- um_ajax_get_members( directory );
1216
- });
1217
-
1218
-
1219
- jQuery( document.body ).on( 'click', '.um-directory .um-clear-filters-a', function() {
1220
- var directory = jQuery(this).parents('.um-directory');
1221
- if ( um_is_directory_busy( directory ) ) {
1222
- return;
1223
- }
1224
-
1225
- um_members_show_preloader( directory );
1226
-
1227
- directory.find( '.um-members-filter-remove' ).each( function() {
1228
- var removeItem = jQuery(this).data('value');
1229
- var filter_name = jQuery(this).data('name');
1230
-
1231
- var type = jQuery(this).data('type');
1232
- if ( type === 'text' ) {
1233
- um_set_url_from_data( directory, 'filter_' + filter_name,'' );
1234
-
1235
- jQuery( '.um-search-filter input[name="' + filter_name + '"]' ).val('');
1236
-
1237
- } else if ( type === 'select' ) {
1238
-
1239
- var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1240
- if ( typeof current_value == 'undefined' ) {
1241
- current_value = [];
1242
- } else {
1243
- current_value = current_value.split( '||' );
1244
- }
1245
-
1246
- if ( -1 !== jQuery.inArray( removeItem.toString(), current_value ) ) {
1247
- current_value = jQuery.grep( current_value, function( value ) {
1248
- return value !== removeItem.toString();
1249
- });
1250
- }
1251
-
1252
- if ( ! current_value.length ) {
1253
- current_value = '';
1254
- }
1255
-
1256
- um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1257
-
1258
- var select = jQuery( '.um-search-filter select[name="' + filter_name + '"]' );
1259
- select.find('option[value="' + removeItem + '"]').prop('disabled', false).show();
1260
-
1261
- //disable options and disable select if all options are disabled
1262
- if ( select.find('option:not(:disabled)').length > 1 ) {
1263
- select.prop('disabled', false);
1264
- }
1265
- select.select2('destroy').select2({
1266
- dropdownParent: select.parent()
1267
- });
1268
-
1269
- if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
1270
- select.trigger('change');
1271
- }
1272
-
1273
- } else if ( type === 'slider' ) {
1274
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1275
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1276
-
1277
- var $slider = jQuery( '.um-search-filter #' + filter_name + '_min' ).siblings('.um-slider');
1278
- var options = $slider.slider( 'option' );
1279
-
1280
- $slider.slider( 'values', [ options.min, options.max ] );
1281
-
1282
- jQuery( '.um-search-filter #' + filter_name + '_min' ).val('');
1283
- jQuery( '.um-search-filter #' + filter_name + '_max' ).val('');
1284
-
1285
- um_set_range_label( $slider );
1286
- } else if ( type === 'datepicker' ) {
1287
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1288
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1289
-
1290
- jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1291
- jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1292
- } else if ( type === 'timepicker' ) {
1293
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1294
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1295
-
1296
- jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1297
- jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1298
- } else {
1299
- wp.hooks.doAction( 'um_member_directory_clear_filters', type, directory, filter_name, removeItem );
1300
- }
1301
- });
1302
-
1303
- //set 1st page after filtration
1304
- directory.data( 'page', 1 );
1305
- um_set_url_from_data( directory, 'page', '' );
1306
- directory.find('.um-members-filter-tag').remove();
1307
-
1308
- //jQuery(this).hide();
1309
- if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
1310
- directory.find('.um-clear-filters').hide();
1311
- directory.find('.um-clear-filters').parents('.um-member-directory-header-row').addClass( 'um-header-row-invisible' );
1312
- } else {
1313
- directory.find('.um-clear-filters').show();
1314
- directory.find('.um-clear-filters').parents('.um-member-directory-header-row').removeClass( 'um-header-row-invisible' );
1315
- }
1316
-
1317
- var ignore_after_search = false;
1318
- ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1319
-
1320
- if ( ! ignore_after_search ) {
1321
- var show_after_search = directory.data('must-search');
1322
- if ( show_after_search === 1 ) {
1323
- var search = um_get_search( directory );
1324
- if ( ! search ) {
1325
- directory.data( 'searched', 0 );
1326
- directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
1327
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
1328
- directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
1329
-
1330
- wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
1331
-
1332
- um_members_hide_preloader( directory );
1333
- return;
1334
- }
1335
- }
1336
- }
1337
-
1338
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1339
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1340
-
1341
- um_ajax_get_members( directory );
1342
- });
1343
-
1344
-
1345
- /**
1346
- * First Page Loading
1347
- */
1348
-
1349
- wp.hooks.doAction( 'um_member_directory_on_first_pages_loading' );
1350
-
1351
- //Init Directories
1352
- jQuery( '.um-directory' ).each( function() {
1353
- var directory = jQuery(this);
1354
- var hash = um_members_get_hash( directory );
1355
-
1356
- um_member_directories.push( hash );
1357
-
1358
- // slideup/slidedown animation fix for grid filters bar
1359
- if ( directory.find('.um-search').length ) {
1360
- if ( ! directory.find('.um-search').is(':visible') ) {
1361
- directory.find('.um-search').css({
1362
- display: "grid"
1363
- }).slideUp( 1 );
1364
- }
1365
- }
1366
-
1367
- //slider filter
1368
- directory.find('.um-slider').each( function() {
1369
- var slider = jQuery( this );
1370
- var directory = slider.parents('.um-directory');
1371
-
1372
- var filter_name = slider.data('field_name');
1373
-
1374
- var min_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1375
- var max_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1376
- if ( typeof min_default_value == 'undefined' ) {
1377
- min_default_value = parseInt( slider.data('min') );
1378
- }
1379
-
1380
- if ( typeof max_default_value == 'undefined' ) {
1381
- max_default_value = parseInt( slider.data('max') );
1382
- }
1383
-
1384
- var default_value = [ min_default_value, max_default_value ];
1385
-
1386
- slider.slider({
1387
- range: true,
1388
- min: parseInt( slider.data('min') ),
1389
- max: parseInt( slider.data('max') ),
1390
- values: default_value,
1391
- create: function( event, ui ) {
1392
- //console.log( ui );
1393
- },
1394
- step: 1,
1395
- slide: function( event, ui ) {
1396
- um_set_range_label( jQuery( this ), ui );
1397
- },
1398
- stop: function( event, ui ) {
1399
- if ( ! um_is_directory_busy( directory ) ) {
1400
-
1401
- um_members_show_preloader( directory );
1402
-
1403
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from', ui.values[0] );
1404
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', ui.values[1] );
1405
-
1406
- //set 1st page after filtration
1407
- directory.data( 'page', 1 );
1408
- um_set_url_from_data( directory, 'page', '' );
1409
- um_ajax_get_members( directory );
1410
-
1411
- um_change_tag( directory );
1412
-
1413
- directory.data( 'searched', 1 );
1414
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1415
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1416
- }
1417
- }
1418
- });
1419
-
1420
- um_set_range_label( slider );
1421
- });
1422
-
1423
-
1424
- //datepicker filter
1425
- directory.find('.um-datepicker-filter').each( function() {
1426
- var elem = jQuery(this);
1427
-
1428
- var min = new Date( elem.data('date_min')*1000 );
1429
- var max = new Date( elem.data('date_max')*1000 );
1430
-
1431
- var $input = elem.pickadate({
1432
- selectYears: true,
1433
- min: min,
1434
- max: max,
1435
- formatSubmit: 'yyyy/mm/dd',
1436
- hiddenName: true,
1437
- onOpen: function() {
1438
- elem.blur();
1439
- },
1440
- onClose: function() {
1441
- elem.blur();
1442
- },
1443
- onSet: function( context ) {
1444
-
1445
- if ( ! context.select ) {
1446
- return;
1447
- }
1448
-
1449
- var directory = elem.parents('.um-directory');
1450
-
1451
- if ( um_is_directory_busy( directory ) ) {
1452
- return;
1453
- }
1454
-
1455
- um_members_show_preloader( directory );
1456
-
1457
- var filter_name = elem.data( 'filter_name' );
1458
- var range = elem.data( 'range' );
1459
-
1460
- var current_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1461
- var current_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1462
- if ( typeof current_value_from === "undefined" ) {
1463
- current_value_from = min / 1000;
1464
- }
1465
- if ( typeof current_value_to === "undefined" ) {
1466
- current_value_to = max / 1000;
1467
- }
1468
-
1469
- var select_val = context.select / 1000;
1470
- var change_val = elem.val();
1471
-
1472
- if ( range === 'from' ) {
1473
- current_value_from = select_val;
1474
- } else if ( range === 'to' ) {
1475
- current_value_to = select_val;
1476
- }
1477
-
1478
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from', current_value_from );
1479
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', current_value_to );
1480
-
1481
- //set 1st page after filtration
1482
- directory.data( 'page', 1 );
1483
- um_set_url_from_data( directory, 'page', '' );
1484
-
1485
- um_ajax_get_members( directory );
1486
-
1487
- um_change_tag( directory );
1488
-
1489
- directory.data( 'searched', 1 );
1490
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1491
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1492
- }
1493
- });
1494
-
1495
- var $picker = $input.pickadate('picker');
1496
- var $fname = elem.data('filter_name');
1497
- var $frange = elem.data('range');
1498
- var $directory = elem.parents('.um-directory');
1499
-
1500
- var query_value = um_get_data_for_directory( $directory, 'filter_' + $fname + '_' + $frange );
1501
- if ( typeof query_value !== 'undefined' ) {
1502
- $picker.set( 'select', query_value*1000 );
1503
- }
1504
-
1505
- });
1506
-
1507
-
1508
- //timepicker filter
1509
- directory.find('.um-timepicker-filter').each( function() {
1510
- var elem = jQuery(this);
1511
- var elemID = elem.attr('id');
1512
- var elem_filter_name = elem.data('filter_name');
1513
-
1514
- //using arrays formatted as [HOUR,MINUTE]
1515
- var min = elem.attr('data-min');
1516
- var max = elem.attr('data-max');
1517
-
1518
- var picker_min = min.split(':');
1519
- var picker_max = max.split(':');
1520
-
1521
- var $input = elem.pickatime({
1522
- format: elem.data('format'),
1523
- interval: parseInt( elem.data('intervals') ),
1524
- min: [picker_min[0],picker_min[1]],
1525
- max: [picker_max[0],picker_max[1]],
1526
- formatSubmit: 'HH:i',
1527
- hiddenName: true,
1528
- onOpen: function() { elem.blur(); },
1529
- onClose: function() { elem.blur(); },
1530
- onSet: function( context ) {
1531
-
1532
- if ( ! context.select ) {
1533
- return;
1534
- }
1535
-
1536
- var directory = elem.parents('.um-directory');
1537
-
1538
- if ( um_is_directory_busy( directory ) ) {
1539
- return;
1540
- }
1541
-
1542
- um_members_show_preloader( directory );
1543
-
1544
- var filter_name = elem.data( 'filter_name' );
1545
- var range = elem.data( 'range' );
1546
-
1547
- var current_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1548
- var current_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1549
- if ( typeof current_value_from === "undefined" ) {
1550
- current_value_from = min;
1551
- }
1552
- if ( typeof current_value_to === "undefined" ) {
1553
- current_value_to = max;
1554
- }
1555
-
1556
- if ( typeof context.select !== 'undefined' ) {
1557
- var select_val = um_time_convert( context.select, range );
1558
-
1559
- //var select_val = context.select / 60;
1560
-
1561
- if ( range === 'from' ) {
1562
- current_value_from = select_val;
1563
- } else if ( range === 'to' ) {
1564
- current_value_to = select_val;
1565
- }
1566
- } else {
1567
- if ( range === 'from' ) {
1568
- current_value_from = min;
1569
- } else if ( range === 'to' ) {
1570
- current_value_to = max;
1571
- }
1572
- }
1573
-
1574
- var time = jQuery( '#' + elemID ).val();
1575
-
1576
- if ( elem.data('range') === 'from' ) {
1577
- jQuery( '#' + elem_filter_name + '_to' ).pickatime('picker').set('min', time);
1578
- } else {
1579
- jQuery( '#' + elem_filter_name + '_from').pickatime('picker').set('max', time);
1580
- }
1581
-
1582
- um_set_url_from_data( directory, 'filter_' + filter_name + '_from', current_value_from );
1583
- um_set_url_from_data( directory, 'filter_' + filter_name + '_to', current_value_to );
1584
-
1585
- //set 1st page after filtration
1586
- directory.data( 'page', 1 );
1587
- um_set_url_from_data( directory, 'page', '' );
1588
-
1589
- um_ajax_get_members( directory );
1590
-
1591
- um_change_tag( directory );
1592
-
1593
- directory.data( 'searched', 1 );
1594
- directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1595
- directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1596
-
1597
- }
1598
- });
1599
-
1600
- // first loading timepicker select
1601
- var $picker = $input.pickatime('picker');
1602
- var $fname = elem.data('filter_name');
1603
- var $frange = elem.data('range');
1604
- var $directory = elem.parents('.um-directory');
1605
-
1606
- var query_value = um_get_data_for_directory( $directory, 'filter_' + $fname + '_' + $frange );
1607
- if ( typeof query_value !== 'undefined' ) {
1608
- var arr = query_value.split(':');
1609
- $picker.set( 'select', arr[0]*60 + arr[1]*1 );
1610
- }
1611
-
1612
- });
1613
-
1614
- wp.hooks.doAction( 'um_member_directory_on_init', directory, hash );
1615
-
1616
- var ignore_after_search = false;
1617
- ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1618
-
1619
- if ( ! ignore_after_search ) {
1620
- var show_after_search = directory.data('must-search');
1621
- if ( show_after_search === 1 ) {
1622
- var search = um_get_search( directory );
1623
- var filters_data = um_get_filters_data( directory );
1624
- if ( ! filters_data.length && ! search ) {
1625
- return;
1626
- }
1627
- }
1628
- }
1629
-
1630
- var prevent_default = wp.hooks.applyFilters( 'um_member_directory_prevent_default_first_loading', false, directory, hash );
1631
-
1632
- if ( ! prevent_default ) {
1633
- um_members_show_preloader( directory );
1634
- um_ajax_get_members( directory, {first_load:true} );
1635
- um_change_tag( directory );
1636
- }
1637
- });
1638
-
1639
-
1640
- //history events when back/forward and change window.location.hash
1641
- window.addEventListener( "popstate", function(e) {
1642
- jQuery( '.um-directory' ).each( function() {
1643
- var directory = jQuery(this);
1644
- var hash = um_members_get_hash( directory );
1645
- um_member_directories.push( hash );
1646
-
1647
- um_members_show_preloader( directory );
1648
-
1649
- // clear layout and header
1650
- directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
1651
-
1652
- // set search from history
1653
- if ( directory.find( '.um-member-directory-search-line' ).length ) {
1654
- var search = um_get_data_for_directory( directory, 'search' );
1655
- if ( typeof search == 'undefined' ) {
1656
- search = '';
1657
- }
1658
- directory.data( 'general_search', search );
1659
- directory.find('.um-search-line').val( search );
1660
- }
1661
-
1662
- var page = um_get_data_for_directory( directory, 'page' );
1663
- if ( typeof page == 'undefined' ) {
1664
- page = 1;
1665
- } else if ( page > directory.data( 'total_pages' ) ) {
1666
- page = directory.data( 'total_pages' );
1667
- }
1668
-
1669
- directory.data( 'page', page ).attr( 'data-page', page );
1670
-
1671
- //sorting from history
1672
- if ( directory.find( '.um-member-directory-sorting' ).length ) {
1673
- var sort = um_get_data_for_directory( directory, 'sort' );
1674
- if ( typeof sort == 'undefined' ) {
1675
- sort = directory.find( '.um-new-dropdown[data-element=".um-member-directory-sorting-a"]' ).find('a[data-default="1"]').data('value');
1676
- }
1677
- directory.data( 'sorting', sort );
1678
-
1679
- var sort_dropdown = directory.find( '.um-new-dropdown[data-element=".um-member-directory-sorting-a"]' );
1680
- sort_dropdown.find('a').data('selected', 0).prop('data-selected', 0).attr('data-selected', 0);
1681
- sort_dropdown.find('a[data-value="' + sort + '"]').data('selected', 1).prop('data-selected', 1).attr('data-selected', 1);
1682
- directory.find('.um-member-directory-sorting-a').find('> a').html( sort_dropdown.find('a[data-value="' + sort + '"]').html() );
1683
- }
1684
-
1685
- //view type from history
1686
- if ( directory.find( '.um-member-directory-view-type' ).length ) {
1687
- var layout = um_get_data_for_directory( directory, 'view_type' );
1688
- if ( typeof layout == 'undefined' ) {
1689
- layout = directory.find( '.um-member-directory-view-type-a[data-default="1"]' ).data('type');
1690
- }
1691
- directory.data( 'view_type', layout );
1692
-
1693
- directory.find('.um-member-directory-view-type .um-member-directory-view-type-a').hide();
1694
- directory.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="' + layout + '"]').show();
1695
- }
1696
-
1697
- //datepicker filter
1698
- directory.find('.um-datepicker-filter').each( function() {
1699
- var elem = jQuery(this);
1700
-
1701
- var $picker = elem.pickadate('picker');
1702
- var $fname = elem.data('filter_name');
1703
- var $frange = elem.data('range');
1704
-
1705
- var query_value = um_get_data_for_directory( directory, 'filter_' + $fname + '_' + $frange );
1706
- if ( typeof query_value !== 'undefined' ) {
1707
- $picker.set( 'select', query_value*1000 );
1708
- } else {
1709
- $picker.clear();
1710
- }
1711
- });
1712
-
1713
- directory.find('.um-slider').each( function() {
1714
- var slider = jQuery( this );
1715
- var filter_name = slider.data('field_name');
1716
-
1717
- var min_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1718
- var max_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1719
- if ( typeof min_default_value == 'undefined' ) {
1720
- min_default_value = slider.data('min');
1721
- }
1722
- min_default_value = parseInt( min_default_value );
1723
-
1724
- if ( typeof max_default_value == 'undefined' ) {
1725
- max_default_value = slider.data('max');
1726
- }
1727
- max_default_value = parseInt( max_default_value );
1728
-
1729
- slider.slider( 'values', [min_default_value, max_default_value] );
1730
- um_set_range_label( slider );
1731
- });
1732
-
1733
- //timepicker filter
1734
- directory.find('.um-timepicker-filter').each( function() {
1735
- var elem = jQuery(this);
1736
-
1737
- var $picker = elem.pickatime('picker');
1738
- var $fname = elem.data('filter_name');
1739
- var $frange = elem.data('range');
1740
-
1741
- var query_value = um_get_data_for_directory( directory, 'filter_' + $fname + '_' + $frange );
1742
- if ( typeof query_value !== 'undefined' ) {
1743
- var arr = query_value.split(':');
1744
- $picker.set( 'select', arr[0]*60 );
1745
- } else {
1746
- $picker.clear();
1747
- }
1748
- });
1749
-
1750
- var ignore_after_search = false;
1751
- ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1752
-
1753
- if ( ! ignore_after_search ) {
1754
- var show_after_search = directory.data('must-search');
1755
- if ( show_after_search === 1 ) {
1756
- var search = um_get_search( directory );
1757
- var filters_data = um_get_filters_data( directory );
1758
- if ( ! filters_data.length && ! search ) {
1759
- directory.data( 'searched', 0 );
1760
- um_members_hide_preloader( directory );
1761
- return;
1762
- } else {
1763
- directory.data( 'searched', 1 );
1764
- }
1765
- }
1766
- }
1767
-
1768
- var prevent_default = wp.hooks.applyFilters( 'um_member_directory_prevent_default_first_loading', false, directory, hash );
1769
-
1770
- if ( ! prevent_default ) {
1771
- um_ajax_get_members( directory );
1772
- um_change_tag( directory );
1773
- }
1774
- });
1775
- });
1776
-
1777
- });
 
 
1
+ var um_members_directory_busy = [];
2
+
3
+ var um_member_directories = [];
4
+
5
+ var um_member_directory_last_data = [];
6
+
7
+ function um_parse_current_url() {
8
+ var data = {};
9
+
10
+ var query = window.location.search.substring(1);
11
+ var attrs = query.split( '&' );
12
+ jQuery.each( attrs, function( i ) {
13
+ var attr = attrs[ i ].split( '=' );
14
+ data[ attr[0] ] = attr[1];
15
+ });
16
+ return data;
17
+ }
18
+
19
+
20
+ function um_get_data_for_directory( directory, search_key ) {
21
+ var hash = um_members_get_hash( directory );
22
+ var data = {};
23
+
24
+ var url_data = um_parse_current_url();
25
+ jQuery.each( url_data, function( key ) {
26
+ if ( key.indexOf( '_' + hash ) !== -1 && url_data[ key ] !== '' ) {
27
+ data[ key.replace( '_' + hash, '' ) ] = url_data[ key ];
28
+ }
29
+ });
30
+
31
+ if ( ! search_key ) {
32
+ return data;
33
+ } else {
34
+ if ( typeof data[ search_key ] !== 'undefined' ) {
35
+ try {
36
+ //data[ search_key ] = decodeURI( data[ search_key ] );
37
+ data[ search_key ] = decodeURIComponent( data[ search_key ] );
38
+ } catch(e) { // catches a malformed URI
39
+ console.error(e);
40
+ }
41
+ }
42
+
43
+ return data[ search_key ];
44
+ }
45
+ }
46
+
47
+
48
+ function um_set_url_from_data( directory, key, value ) {
49
+ var hash = um_members_get_hash( directory );
50
+ var data = um_get_data_for_directory( directory );
51
+
52
+ var other_directories = um_member_directories;
53
+
54
+ var new_data = {};
55
+
56
+ if ( Array.isArray( value ) ) {
57
+ jQuery.each( value, function( i ) {
58
+ value[ i ] = encodeURIComponent( value[ i ] );
59
+ });
60
+ value = value.join( '||' );
61
+ } else if ( ! jQuery.isNumeric( value ) ) {
62
+ value = value.split( '||' );
63
+ jQuery.each( value, function( i ) {
64
+ value[ i ] = encodeURIComponent( value[ i ] );
65
+ });
66
+ value = value.join( '||' );
67
+ }
68
+
69
+ if ( value !== '' ) {
70
+ new_data[ key + '_' + hash ] = value;
71
+ }
72
+ jQuery.each( data, function( data_key ) {
73
+ if ( key === data_key ) {
74
+ if ( value !== '' ) {
75
+ new_data[ data_key + '_' + hash ] = value;
76
+ }
77
+ } else {
78
+ new_data[ data_key + '_' + hash ] = data[ data_key ];
79
+ }
80
+ });
81
+
82
+ // added data of other directories to the url
83
+ jQuery.each( um_member_directories, function( k ) {
84
+ var dir_hash = um_member_directories[ k ];
85
+ if ( dir_hash !== hash ) {
86
+ var other_directory = jQuery( '.um-directory[data-hash="' + dir_hash + '"]' );
87
+ var dir_data = um_get_data_for_directory( other_directory );
88
+
89
+ jQuery.each( dir_data, function( data_key ) {
90
+ new_data[ data_key + '_' + dir_hash ] = dir_data[ data_key ];
91
+ });
92
+ }
93
+ });
94
+
95
+ var query_strings = [];
96
+ jQuery.each( new_data, function( data_key ) {
97
+ query_strings.push( data_key + '=' + new_data[ data_key ] );
98
+ });
99
+
100
+ query_strings = wp.hooks.applyFilters( 'um_member_directory_url_attrs', query_strings );
101
+
102
+ var query_string = '?' + query_strings.join( '&' );
103
+ if ( query_string === '?' ) {
104
+ query_string = '';
105
+ }
106
+
107
+ window.history.pushState("string", "UM Member Directory", window.location.origin + window.location.pathname + query_string );
108
+ }
109
+
110
+
111
+ function um_members_get_hash( directory ) {
112
+ return directory.data( 'hash' );
113
+ }
114
+
115
+ function um_is_directory_busy( directory ) {
116
+ var hash = um_members_get_hash( directory );
117
+ return typeof um_members_directory_busy[ hash ] != 'undefined' && um_members_directory_busy[ hash ];
118
+ }
119
+
120
+
121
+ function um_members_show_preloader( directory ) {
122
+ um_members_directory_busy[ um_members_get_hash( directory ) ] = true;
123
+ directory.find('.um-members-overlay').show();
124
+ }
125
+
126
+
127
+ function um_members_hide_preloader( directory ) {
128
+ um_members_directory_busy[ um_members_get_hash( directory ) ] = false;
129
+ directory.find('.um-members-overlay').hide();
130
+ }
131
+
132
+
133
+ function um_set_range_label( slider, ui ) {
134
+ var placeholder = '';
135
+ var placeholder_s = slider.siblings( '.um-slider-range' ).data( 'placeholder-s' );
136
+ var placeholder_p = slider.siblings( '.um-slider-range' ).data( 'placeholder-p' );
137
+
138
+ if ( ui ) {
139
+ if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
140
+ placeholder = placeholder_s.replace( '\{value\}', ui.values[ 0 ] )
141
+ .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
142
+ .data('label') );
143
+ } else {
144
+ placeholder = placeholder_p.replace( '\{min_range\}', ui.values[ 0 ] )
145
+ .replace( '\{max_range\}', ui.values[ 1 ] )
146
+ .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
147
+ .data('label') );
148
+ }
149
+ } else {
150
+ if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
151
+ placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
152
+ .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
153
+ .data('label') );
154
+ } else {
155
+ placeholder = placeholder_p.replace( '\{min_range\}', slider.slider( "values", 0 ) )
156
+ .replace( '\{max_range\}', slider.slider( "values", 1 ) )
157
+ .replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
158
+ .data('label') );
159
+ }
160
+ }
161
+ slider.siblings( '.um-slider-range' ).html( placeholder );
162
+
163
+ slider.siblings( ".um_range_min" ).val( slider.slider( "values", 0 ) );
164
+ slider.siblings( ".um_range_max" ).val( slider.slider( "values", 1 ) );
165
+ }
166
+
167
+
168
+ function um_get_search( directory ) {
169
+ if ( directory.find('.um-search-line').length ) {
170
+ return directory.find( '.um-search-line' ).val();
171
+ } else {
172
+ return '';
173
+ }
174
+ }
175
+
176
+ function um_get_sort( directory ) {
177
+ return directory.data( 'sorting' );
178
+ }
179
+
180
+ function um_get_current_page( directory ) {
181
+ var page = directory.data( 'page' );
182
+ if ( ! page || typeof page == 'undefined' ) {
183
+ page = 1;
184
+ }
185
+ return page;
186
+ }
187
+
188
+ function um_time_convert( time, range ) {
189
+ var hours = Math.floor( time / 60 );
190
+ var minutes = time % 60;
191
+
192
+ if ( minutes >= 60 ) {
193
+ minutes = 0;
194
+ hours = hours + 1;
195
+
196
+ if ( hours >= 24 ) {
197
+ hours = 0;
198
+ }
199
+ }
200
+
201
+ if ( minutes < 10 ) {
202
+ minutes = '0' + minutes;
203
+ }
204
+
205
+ return hours + ":" + minutes;
206
+ }
207
+
208
+ function um_ajax_get_members( directory, args ) {
209
+
210
+ /**
211
+ * Operates with the next data:
212
+ *
213
+ * 1) Page - getting from directory data 'page'
214
+ * 2) Sort - getting from 'um-member-directory-sorting-options' field value
215
+ * 3) Search - getting from 'um-search-line' field value
216
+ * 4) Filters - getting from URL data by 'um_get_data_for_directory' function
217
+ *
218
+ */
219
+
220
+ var hash = um_members_get_hash( directory );
221
+
222
+ var allow = wp.hooks.applyFilters( 'um_member_directory_get_members_allow', true, hash, directory );
223
+ if ( ! allow ) {
224
+ setTimeout( um_ajax_get_members, 600, directory, args );
225
+ return;
226
+ }
227
+
228
+ var page = um_get_current_page( directory );
229
+ var search = um_get_search( directory );
230
+ var sorting = um_get_sort( directory );
231
+
232
+ var local_date = new Date();
233
+ var gmt_hours = -local_date.getTimezoneOffset() / 60;
234
+
235
+ var request = {
236
+ directory_id: hash,
237
+ page: page,
238
+ search: search,
239
+ sorting: sorting,
240
+ gmt_offset: gmt_hours,
241
+ post_refferer: directory.data('base-post'),
242
+ nonce: um_scripts.nonce
243
+ };
244
+
245
+ if ( directory.find('.um-search-filter').length ) {
246
+ directory.find('.um-search-filter').each( function() {
247
+ var filter = jQuery(this);
248
+
249
+ if ( filter.find( '.um-slider' ).length ) {
250
+ var filter_name = filter.find( '.um-slider' ).data('field_name');
251
+
252
+ var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
253
+ var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
254
+ if ( typeof value_from != 'undefined' || typeof value_to != 'undefined' ) {
255
+ request[ filter_name ] = [ value_from, value_to ];
256
+ }
257
+ } else if ( filter.find( '.um-datepicker-filter' ).length ) {
258
+ var filter_name = filter.find( '.um-datepicker-filter' ).data('filter_name');
259
+ var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
260
+ var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
261
+ if ( typeof value_from != 'undefined' || typeof value_to != 'undefined') {
262
+ request[ filter_name ] = [ value_from, value_to ];
263
+ }
264
+ } else if ( filter.find( '.um-timepicker-filter' ).length ) {
265
+ var filter_name = filter.find( '.um-timepicker-filter' ).data('filter_name');
266
+ var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
267
+ var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
268
+
269
+ if ( typeof value_from != 'undefined' ) {
270
+ var value_from = value_from.split(':');
271
+ var hours = value_from[0]*1;
272
+ if ( hours < 10 ) {
273
+ hours = '0' + hours;
274
+ }
275
+
276
+ var minutes = value_from[1]*1;
277
+ if ( minutes < 10 ) {
278
+ minutes = '0' + minutes;
279
+ }
280
+
281
+ value_from = hours + ':' + minutes + ':00';
282
+ }
283
+ if ( typeof value_to != 'undefined' ) {
284
+ var val_to = value_to.split(':');
285
+ var minutes = val_to[1]*1;
286
+
287
+ var hours = val_to[0]*1;
288
+ if ( hours < 10 ) {
289
+ hours = '0' + hours;
290
+ }
291
+
292
+ if ( minutes < 10 ) {
293
+ minutes = '0' + minutes;
294
+ }
295
+
296
+ value_to = hours + ':' + minutes + ':59';
297
+ }
298
+
299
+ if ( typeof value_from != 'undefined' || typeof value_to != 'undefined' ) {
300
+ request[ filter_name ] = [ value_from, value_to ];
301
+ }
302
+ } else if ( filter.find( 'select' ).length ) {
303
+ var filter_name = filter.find('select').attr('name');
304
+ var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
305
+ if ( typeof value != 'undefined' ) {
306
+ request[ filter_name ] = value.split( '||' );
307
+ }
308
+ } else if ( filter.hasClass( 'um-text-filter-type' ) && filter.find('input[type="text"]').length ) {
309
+ var filter_name = filter.find('input[type="text"]').attr('name');
310
+ var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
311
+ if ( typeof value != 'undefined' ) {
312
+ request[ filter_name ] = value;
313
+ }
314
+ } else {
315
+ request = wp.hooks.applyFilters( 'um_member_directory_custom_filter_handler', request, filter, directory );
316
+ }
317
+ });
318
+ }
319
+
320
+ request = wp.hooks.applyFilters( 'um_member_directory_filter_request', request );
321
+
322
+ wp.ajax.send( 'um_get_members', {
323
+ data: request,
324
+ success: function( answer ) {
325
+ //set last data hard for using on layouts reloading
326
+ um_member_directory_last_data[ hash ] = answer;
327
+
328
+ um_build_template( directory, answer );
329
+
330
+ var pagination_template = wp.template( 'um-members-pagination' );
331
+ directory.find('.um-members-pagination-box').html( pagination_template( answer ) );
332
+
333
+ directory.data( 'total_pages', answer.pagination.total_pages );
334
+
335
+ if ( answer.pagination.total_pages ) {
336
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
337
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
338
+ } else {
339
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
340
+ directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
341
+ }
342
+
343
+ //args.directory = directory;
344
+ wp.hooks.doAction( 'um_member_directory_loaded', directory, answer );
345
+ //jQuery( document ).trigger('um_members_rendered', [ directory, answer ] );
346
+
347
+ um_init_new_dropdown();
348
+
349
+ um_members_hide_preloader( directory );
350
+ },
351
+ error: function( data ) {
352
+ console.log( data );
353
+
354
+ um_members_hide_preloader( directory );
355
+ }
356
+ });
357
+ }
358
+
359
+
360
+ function um_build_template( directory, data ) {
361
+ var layout = directory.data('view_type');
362
+ var template = wp.template( 'um-member-' + layout + '-' + um_members_get_hash( directory ) );
363
+
364
+ directory.find('.um-members-grid, .um-members-list').remove();
365
+ directory.find('.um-members-wrapper').prepend( template( data.users ) );
366
+
367
+ var header_template = wp.template( 'um-members-header' );
368
+ directory.find('.um-members-intro').remove();
369
+
370
+ var generate_header = wp.hooks.applyFilters( 'um_member_directory_generate_header', false, directory );
371
+
372
+ if ( ( typeof data.is_search != 'undefined' && data.is_search ) || generate_header ) {
373
+ directory.find('.um-members-wrapper').prepend( header_template( data ) );
374
+ }
375
+
376
+ directory.addClass('um-loaded');
377
+
378
+ if ( directory.find('.um-members.um-members-grid').length ) {
379
+ UM_Member_Grid( directory.find('.um-members.um-members-grid') );
380
+ }
381
+
382
+ jQuery( document ).trigger( 'um_build_template', [ directory, data ] );
383
+ jQuery( window ).trigger( 'resize' );
384
+
385
+ init_tipsy();
386
+ }
387
+
388
+
389
+
390
+ function UM_Member_Grid( container ) {
391
+ if ( container.find( '.um-member' ).length ) {
392
+ container.imagesLoaded( function() {
393
+
394
+ var masonry_args = wp.hooks.applyFilters( 'um_member_directory_grid_masonry_attrs', {
395
+ itemSelector: '.um-member',
396
+ columnWidth: '.um-member',
397
+ gutter: '.um-gutter-sizer'
398
+ }, container );
399
+
400
+ var $grid = container.masonry( masonry_args );
401
+
402
+ $grid.on( 'layoutComplete', function( event, laidOutItems ) {
403
+ jQuery( document ).trigger( "um_grid_initialized", [ event, laidOutItems ] );
404
+ });
405
+ });
406
+ }
407
+ }
408
+
409
+
410
+ function um_get_filters_data( directory ) {
411
+ var filters_data = [];
412
+
413
+ directory.find('.um-search-filter').each( function() {
414
+
415
+ var filter = jQuery(this);
416
+ var filter_name,
417
+ filter_title;
418
+
419
+ var filter_type;
420
+ if ( filter.find('input.um-datepicker-filter').length ) {
421
+ filter_type = 'datepicker';
422
+
423
+ filter.find('input.um-datepicker-filter').each( function() {
424
+ var range = jQuery(this).data('range');
425
+ if ( range === 'to' ) {
426
+ return;
427
+ }
428
+
429
+ var filter_name = jQuery(this).data('filter_name');
430
+
431
+ var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
432
+ var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
433
+ if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
434
+ return;
435
+ }
436
+
437
+ var from_val = jQuery(this).val();
438
+ var to_val = directory.find('input.um-datepicker-filter[data-range="to"][data-filter_name="' + filter_name + '"]').val();
439
+
440
+ var value;
441
+ if ( from_val === to_val ) {
442
+ value = to_val;
443
+ } else if ( from_val !== '' && to_val !== '' ) {
444
+ value = from_val + ' - ' + to_val;
445
+ } else if ( from_val === '' ) {
446
+ value = 'before ' + to_val;
447
+ } else if ( to_val === '' ) {
448
+ value = 'since ' + from_val;
449
+ }
450
+
451
+ filters_data.push( {'name':filter_name, 'label':jQuery(this).data('filter-label'), 'value_label': value, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
452
+ });
453
+
454
+ } else if( filter.find('input.um-timepicker-filter').length ) {
455
+ filter_type = 'timepicker';
456
+
457
+ filter.find('input.um-timepicker-filter').each( function() {
458
+ var range = jQuery(this).data('range');
459
+ if ( range === 'to' ) {
460
+ return;
461
+ }
462
+
463
+ var filter_name = jQuery(this).data('filter_name');
464
+
465
+ var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
466
+ var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
467
+ if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
468
+ return;
469
+ }
470
+
471
+ var from_val = jQuery(this).val();
472
+ var to_val = directory.find('input.um-timepicker-filter[data-range="to"][data-filter_name="' + filter_name + '"]').val();
473
+
474
+ var value;
475
+ if ( from_val === to_val ) {
476
+ value = to_val;
477
+ } else if ( from_val !== '' && to_val !== '' ) {
478
+ value = from_val + ' - ' + to_val;
479
+ } else if ( from_val === '' ) {
480
+ value = 'before ' + to_val;
481
+ } else if ( to_val === '' ) {
482
+ value = 'since ' + from_val;
483
+ }
484
+
485
+ filters_data.push( {'name':filter_name, 'label':jQuery(this).data('filter-label'), 'value_label': value, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
486
+ });
487
+ } else if( filter.find('select').length ) {
488
+
489
+ filter_type = 'select';
490
+ filter_name = filter.find('select').attr('name');
491
+ filter_title = filter.find('select').data('placeholder');
492
+
493
+ var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
494
+ if ( typeof filter_value == 'undefined' ) {
495
+ filter_value = [];
496
+ } else {
497
+ filter_value = filter_value.split( '||' );
498
+ }
499
+
500
+ jQuery.each( filter_value, function(i) {
501
+ var filter_value_title = filter.find('select option[value="' + filter_value[ i ] + '"]').data('value_label');
502
+ filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value_title, 'value':filter_value[ i ], 'type':filter_type} );
503
+ });
504
+
505
+ } else if( filter.hasClass('um-text-filter-type') && filter.find('input[type="text"]').length ) {
506
+
507
+ filter_type = 'text';
508
+ filter_name = filter.find('input[type="text"]').attr('name');
509
+ filter_title = filter.find('input[type="text"]').attr('placeholder');
510
+
511
+ var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
512
+ if ( typeof filter_value == 'undefined' ) {
513
+ filter_value = '';
514
+ }
515
+
516
+ if ( filter_value != '' ) {
517
+ filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value, 'value':filter_value, 'type':filter_type} );
518
+ }
519
+
520
+ } else if( filter.find('div.ui-slider').length ) {
521
+ filter_type = 'slider';
522
+
523
+ filter_name = filter.find('div.ui-slider').data( 'field_name' );
524
+ var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
525
+ var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
526
+
527
+ if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
528
+ return;
529
+ }
530
+
531
+ var filter_value_title;
532
+ if ( filter_value_from === filter_value_to ) {
533
+ filter_value_title = filter.find('div.um-slider-range').data( 'placeholder-s' ).replace( '\{value\}', filter_value_from )
534
+ .replace( '\{field_label\}', filter.find('div.um-slider-range').data('label') );
535
+ } else {
536
+ filter_value_title = filter.find('div.um-slider-range').data( 'placeholder-p' ).replace( '\{min_range\}', filter_value_from )
537
+ .replace( '\{max_range\}', filter_value_to )
538
+ .replace( '\{field_label\}', filter.find('div.um-slider-range').data('label') );
539
+ }
540
+
541
+ filter_title = filter.find('div.um-slider-range').data('label');
542
+
543
+ filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value_title, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
544
+ } else {
545
+
546
+ filters_data = wp.hooks.applyFilters( 'um_member_directory_get_filter_data', filters_data, directory, filter );
547
+
548
+ }
549
+ });
550
+
551
+ return filters_data;
552
+ }
553
+
554
+
555
+ function um_change_tag( directory ) {
556
+ var filters_data = um_get_filters_data( directory );
557
+
558
+ directory.find('.um-members-filter-tag').remove();
559
+
560
+ var filtered_line = directory.find('.um-filtered-line');
561
+ if ( filtered_line.length ) {
562
+ var filters_template = wp.template( 'um-members-filtered-line' );
563
+ filtered_line.prepend( filters_template( {'filters': filters_data} ) );
564
+
565
+ if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
566
+ directory.find('.um-clear-filters').hide();
567
+ directory.find('.um-clear-filters').parents('.um-member-directory-header-row').addClass( 'um-header-row-invisible' );
568
+ } else {
569
+ directory.find('.um-clear-filters').show();
570
+ directory.find('.um-clear-filters').parents('.um-member-directory-header-row').removeClass( 'um-header-row-invisible' );
571
+ }
572
+ }
573
+
574
+
575
+ }
576
+
577
+
578
+
579
+ function um_run_search( directory ) {
580
+ if ( um_is_directory_busy( directory ) ) {
581
+ return;
582
+ }
583
+ um_members_show_preloader( directory );
584
+
585
+ var pre_search = um_get_data_for_directory( directory, 'search' );
586
+
587
+ var search = um_sanitize_value( directory.find('.um-search-line').val() );
588
+ if ( search === pre_search || ( search === '' && typeof pre_search == 'undefined' ) ) {
589
+ um_members_hide_preloader( directory );
590
+ return;
591
+ }
592
+
593
+ directory.data( 'general_search', search );
594
+ um_set_url_from_data( directory, 'search', search );
595
+
596
+ //set 1st page after search
597
+ directory.data( 'page', 1 );
598
+ um_set_url_from_data( directory, 'page', '' );
599
+
600
+
601
+ var ignore_after_search = false;
602
+ ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
603
+
604
+ if ( ! ignore_after_search ) {
605
+ var show_after_search = directory.data('must-search');
606
+ if ( show_after_search === 1 ) {
607
+ search = um_get_search( directory );
608
+ if ( directory.find( '.um-members-filter-remove' ).length === 0 && ! search ) {
609
+ directory.data( 'searched', 0 );
610
+ directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
611
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
612
+ directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
613
+
614
+ wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
615
+
616
+ um_members_hide_preloader( directory );
617
+ return;
618
+ }
619
+ }
620
+ }
621
+
622
+ directory.data( 'searched', 1 );
623
+
624
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
625
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
626
+
627
+ um_ajax_get_members( directory );
628
+ }
629
+
630
+
631
+ jQuery(document.body).ready( function() {
632
+
633
+
634
+ jQuery( '.um-directory .um-search-filter select' ).each( function() {
635
+ if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
636
+ jQuery(this).prop('disabled', true);
637
+ }
638
+
639
+ var obj = jQuery(this);
640
+ obj.select2('destroy').select2({
641
+ dropdownParent: obj.parent()
642
+ });
643
+ });
644
+
645
+ /**
646
+ * Change View Type Handlers
647
+ */
648
+
649
+
650
+ //UI for change view type button
651
+ jQuery( document.body ).on( 'mouseover', '.um-directory .um-member-directory-view-type', function() {
652
+ if ( jQuery(this).hasClass('um-disabled') ) {
653
+ return;
654
+ }
655
+
656
+ var $obj = jQuery(this).find('.um-member-directory-view-type-a:visible');
657
+
658
+ $obj.hide();
659
+
660
+ if ( $obj.next().length ) {
661
+ $obj.next().show().tipsy('show');
662
+ } else {
663
+ jQuery(this).find( '.um-member-directory-view-type-a:first' ).show().tipsy('show');
664
+ }
665
+ }).on( 'mouseout', '.um-directory .um-member-directory-view-type', function() {
666
+ if ( jQuery(this).hasClass('um-disabled') ) {
667
+ return;
668
+ }
669
+
670
+ jQuery(this).find('.um-member-directory-view-type-a').hide().tipsy('hide');
671
+ jQuery(this).find('.um-member-directory-view-type-a[data-type="' + jQuery(this).parents( '.um-directory' ).data('view_type') + '"]').show();
672
+ });
673
+
674
+ //change layout handler
675
+ jQuery( document.body ).on( 'click', '.um-directory .um-member-directory-view-type-a', function() {
676
+ var directory = jQuery(this).parents('.um-directory');
677
+ if ( um_is_directory_busy( directory ) ) {
678
+ return false;
679
+ }
680
+
681
+ var $this = jQuery(this);
682
+ var views = $this.parents('.um-member-directory-view-type');
683
+
684
+ if ( views.hasClass('um-disabled') ) {
685
+ return;
686
+ }
687
+
688
+ um_members_show_preloader( directory );
689
+
690
+ var $obj = views.find('.um-member-directory-view-type-a:visible');
691
+
692
+ $obj.hide();
693
+
694
+ if ( $obj.next().length ) {
695
+ $obj.next().show().tipsy('show');
696
+ } else {
697
+ views.find( '.um-member-directory-view-type-a:first' ).show().tipsy('show');
698
+ }
699
+
700
+ var data = um_member_directory_last_data[ um_members_get_hash( directory ) ];
701
+ if ( data !== null ) {
702
+ var layout = $this.data('type');
703
+
704
+ um_set_url_from_data( directory, 'view_type', layout );
705
+ directory.data( 'view_type', layout );
706
+
707
+ um_build_template( directory, data );
708
+
709
+ um_init_new_dropdown();
710
+ }
711
+ um_members_hide_preloader( directory );
712
+ });
713
+
714
+
715
+ /**
716
+ * END: Change View Type Handlers
717
+ */
718
+
719
+
720
+ /**
721
+ * General Search
722
+ */
723
+
724
+
725
+ //searching
726
+ jQuery( document.body ).on( 'click', '.um-directory .um-do-search', function() {
727
+ var directory = jQuery(this).parents('.um-directory');
728
+ um_run_search( directory );
729
+ });
730
+
731
+
732
+ //make search on Enter click
733
+ jQuery( document.body ).on( 'keypress', '.um-directory .um-search-line', function(e) {
734
+ if ( e.which === 13 ) {
735
+ var directory = jQuery(this).parents('.um-directory');
736
+ um_run_search( directory );
737
+ }
738
+ });
739
+
740
+
741
+ /**
742
+ * END: General Search
743
+ */
744
+
745
+
746
+
747
+ /**
748
+ * Sorting
749
+ */
750
+
751
+ jQuery( document.body ).on( 'click', '.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a', function() {
752
+ if ( jQuery( this ).data('selected') === 1 ) {
753
+ return;
754
+ }
755
+
756
+ var directory_hash = jQuery(this).data('directory-hash');
757
+ var directory = jQuery('.um-directory[data-hash="' + directory_hash + '"]');
758
+
759
+ if ( um_is_directory_busy( directory ) ) {
760
+ return;
761
+ }
762
+
763
+ um_members_show_preloader( directory );
764
+
765
+ var sorting_label = jQuery( this ).html();
766
+ var sort = jQuery(this).data('value');
767
+
768
+ directory.data( 'sorting', sort );
769
+ um_set_url_from_data( directory, 'sort', sort );
770
+
771
+ um_ajax_get_members( directory );
772
+
773
+ directory.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find('a').data('selected', 0).prop('data-selected', 0).attr('data-selected', 0);
774
+ directory.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"] a[data-value="' + sort + '"]').data('selected', 1).prop('data-selected', 1).attr('data-selected', 1);
775
+ directory.find('.um-member-directory-sorting-a').find('> a').html( sorting_label );
776
+ });
777
+
778
+ /**
779
+ * END: Sorting
780
+ */
781
+
782
+
783
+
784
+ /**
785
+ * Pagination
786
+ */
787
+
788
+
789
+ jQuery( document.body ).on( 'click', '.um-directory .pagi:not(.current)', function() {
790
+ if ( jQuery(this).hasClass('disabled') ) {
791
+ return;
792
+ }
793
+
794
+ var directory = jQuery(this).parents('.um-directory');
795
+ if ( um_is_directory_busy( directory ) ) {
796
+ return;
797
+ }
798
+
799
+ um_members_show_preloader( directory );
800
+
801
+ var page;
802
+ if ( 'first' === jQuery(this).data('page') ) {
803
+ page = 1;
804
+ } else if ( 'prev' === jQuery(this).data('page') ) {
805
+ page = directory.data( 'page' )*1 - 1;
806
+ } else if ( 'next' === jQuery(this).data('page') ) {
807
+ page = directory.data( 'page' )*1 + 1;
808
+ } else if ( 'last' === jQuery(this).data('page') ) {
809
+ page = parseInt( directory.data( 'total_pages' ) );
810
+ } else {
811
+ page = parseInt( jQuery(this).data('page') );
812
+ }
813
+
814
+ if ( page === 1 ) {
815
+ directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass('disabled');
816
+ directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
817
+ } else if ( page === parseInt( directory.data( 'total_pages' ) ) ) {
818
+ directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass('disabled');
819
+ directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass('disabled');
820
+ } else {
821
+ directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
822
+ directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass('disabled');
823
+ }
824
+
825
+ directory.find('.pagi').removeClass('current');
826
+ directory.find('.pagi[data-page="' + page + '"]').addClass('current');
827
+
828
+ directory.data( 'page', page );
829
+ if ( page === 1 ) {
830
+ um_set_url_from_data( directory, 'page', '' );
831
+ } else {
832
+ um_set_url_from_data( directory, 'page', page );
833
+ }
834
+
835
+ um_ajax_get_members( directory );
836
+ });
837
+
838
+
839
+ //mobile pagination
840
+ jQuery( document.body ).on( 'change', '.um-directory .um-members-pagi-dropdown', function() {
841
+ var directory = jQuery(this).parents('.um-directory');
842
+
843
+ if ( um_is_directory_busy( directory ) ) {
844
+ return;
845
+ }
846
+
847
+ um_members_show_preloader( directory );
848
+
849
+ var page = jQuery(this).val();
850
+
851
+ directory.find('.pagi').removeClass('current');
852
+ directory.find('.pagi[data-page="' + page + '"]').addClass('current');
853
+
854
+ directory.data( 'page', page );
855
+ if ( page === 1 ) {
856
+ um_set_url_from_data( directory, 'page', '' );
857
+ } else {
858
+ um_set_url_from_data( directory, 'page', page );
859
+ }
860
+
861
+ um_ajax_get_members( directory );
862
+ });
863
+
864
+
865
+ /**
866
+ * END: Pagination
867
+ */
868
+
869
+
870
+ /**
871
+ * Profile Cards actions
872
+ */
873
+
874
+ jQuery( document.body ).on('click', '.um-directory .um-members.um-members-list .um-member-more a', function(e){
875
+ e.preventDefault();
876
+
877
+ var block = jQuery(this).parents('.um-member');
878
+
879
+ block.find('.um-member-more').hide();
880
+ block.find('.um-member-meta-main').slideDown();
881
+ block.find('.um-member-less').fadeIn();
882
+
883
+ return false;
884
+ });
885
+
886
+ jQuery( document.body ).on('click', '.um-directory .um-members.um-members-list .um-member-less a', function(e){
887
+ e.preventDefault();
888
+
889
+ var block = jQuery(this).parents('.um-member');
890
+
891
+ block.find('.um-member-less').hide();
892
+ block.find('.um-member-meta-main').slideUp();
893
+ block.find('.um-member-more').fadeIn();
894
+
895
+ return false;
896
+ });
897
+
898
+
899
+ jQuery( document.body ).on('click', '.um-directory .um-members.um-members-grid .um-member-more a', function(e){
900
+ e.preventDefault();
901
+
902
+ var block = jQuery(this).parents('.um-member');
903
+ var container = jQuery(this).parents('.um-members');
904
+ block.find('.um-member-more').hide();
905
+ block.find('.um-member-meta').slideDown( function(){ UM_Member_Grid( container ) } );
906
+ block.find('.um-member-less').fadeIn( );
907
+
908
+ setTimeout(function(){ UM_Member_Grid( container ) }, 100);
909
+
910
+ return false;
911
+ });
912
+
913
+ jQuery( document.body ).on('click', '.um-directory .um-members.um-members-grid .um-member-less a', function(e){
914
+ e.preventDefault();
915
+
916
+ var block = jQuery(this).parents('.um-member');
917
+ var container = jQuery(this).parents('.um-members');
918
+ block.find('.um-member-less').hide();
919
+ block.find('.um-member-meta').slideUp( function() {
920
+ block.find('.um-member-more').fadeIn();
921
+ UM_Member_Grid( container );
922
+ });
923
+
924
+ return false;
925
+ });
926
+
927
+ /**
928
+ * END: Profile Cards actions
929
+ */
930
+
931
+
932
+ //filters controls
933
+ jQuery('.um-member-directory-filters-a').on( 'click', function() {
934
+ var obj = jQuery(this);
935
+ var search_bar = obj.parents('.um-directory').find('.um-search');
936
+
937
+ if ( search_bar.is( ':visible' ) ) {
938
+ search_bar.slideUp( 250, function(){
939
+ obj.toggleClass('um-member-directory-filters-visible');
940
+ search_bar.parents('.um-member-directory-header-row').toggleClass('um-header-row-invisible');
941
+ });
942
+ } else {
943
+ search_bar.slideDown({
944
+ duration: 250,
945
+ start: function() {
946
+ jQuery(this).css({
947
+ display: "grid"
948
+ });
949
+ obj.toggleClass('um-member-directory-filters-visible');
950
+ search_bar.parents('.um-member-directory-header-row').toggleClass('um-header-row-invisible');
951
+ }
952
+ } );
953
+ }
954
+ });
955
+
956
+
957
+ //filtration process
958
+ jQuery( document.body ).on( 'change', '.um-directory .um-search-filter select', function() {
959
+ var selected_val = um_sanitize_value( jQuery(this).val() );
960
+
961
+ if ( selected_val === '' ) {
962
+ return;
963
+ }
964
+
965
+ var directory = jQuery(this).parents('.um-directory');
966
+
967
+ if ( um_is_directory_busy( directory ) ) {
968
+ return;
969
+ }
970
+
971
+ um_members_show_preloader( directory );
972
+
973
+ var filter_name = jQuery(this).prop('name');
974
+
975
+ var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
976
+ if ( typeof current_value == 'undefined' ) {
977
+ current_value = [];
978
+ } else {
979
+ current_value = current_value.split( '||' );
980
+ }
981
+
982
+ if ( -1 === jQuery.inArray( selected_val, current_value ) ) {
983
+ current_value.push( selected_val );
984
+ current_value = current_value.join( '||' );
985
+
986
+ um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
987
+
988
+ //set 1st page after filtration
989
+ directory.data( 'page', 1 );
990
+ um_set_url_from_data( directory, 'page', '' );
991
+ }
992
+
993
+ //disable options and disable select if all options are disabled
994
+ jQuery(this).find('option[value="' + selected_val + '"]').prop('disabled', true).hide();
995
+ if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
996
+ jQuery(this).prop('disabled', true);
997
+ }
998
+
999
+ var obj = jQuery(this);
1000
+ obj.select2('destroy').select2({
1001
+ dropdownParent: obj.parent()
1002
+ });
1003
+ obj.val('').trigger( 'change' );
1004
+
1005
+ um_ajax_get_members( directory );
1006
+
1007
+ um_change_tag( directory );
1008
+
1009
+ directory.data( 'searched', 1 );
1010
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1011
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1012
+ // if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
1013
+ // jQuery(this).trigger('change');
1014
+ // }
1015
+ });
1016
+
1017
+
1018
+ jQuery( document.body ).on( 'blur', '.um-directory .um-search-filter.um-text-filter-type input[type="text"]', function() {
1019
+ var directory = jQuery(this).parents('.um-directory');
1020
+
1021
+ if ( um_is_directory_busy( directory ) ) {
1022
+ return;
1023
+ }
1024
+
1025
+ var current_value = um_sanitize_value( jQuery(this).val() );
1026
+ var filter_name = jQuery(this).prop('name');
1027
+ var url_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1028
+
1029
+ if ( typeof url_value == 'undefined' ) {
1030
+ url_value = '';
1031
+ }
1032
+
1033
+ if ( current_value === url_value ) {
1034
+ return;
1035
+ }
1036
+
1037
+ um_members_show_preloader( directory );
1038
+ um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1039
+
1040
+ //set 1st page after filtration
1041
+ directory.data( 'page', 1 );
1042
+ um_set_url_from_data( directory, 'page', '' );
1043
+
1044
+ um_ajax_get_members( directory );
1045
+
1046
+ um_change_tag( directory );
1047
+
1048
+ directory.data( 'searched', 1 );
1049
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1050
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1051
+ });
1052
+
1053
+
1054
+ //make search on Enter click
1055
+ jQuery( document.body ).on( 'keypress', '.um-directory .um-search-filter.um-text-filter-type input[type="text"]', function(e) {
1056
+ if ( e.which === 13 ) {
1057
+ var directory = jQuery(this).parents('.um-directory');
1058
+
1059
+ if ( um_is_directory_busy( directory ) ) {
1060
+ return;
1061
+ }
1062
+
1063
+ var current_value = um_sanitize_value( jQuery(this).val() );
1064
+ var filter_name = jQuery(this).prop('name');
1065
+ var url_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1066
+
1067
+ if ( typeof url_value == 'undefined' ) {
1068
+ url_value = '';
1069
+ }
1070
+
1071
+ if ( current_value === url_value ) {
1072
+ return;
1073
+ }
1074
+
1075
+ um_members_show_preloader( directory );
1076
+ um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1077
+
1078
+ //set 1st page after filtration
1079
+ directory.data( 'page', 1 );
1080
+ um_set_url_from_data( directory, 'page', '' );
1081
+
1082
+ um_ajax_get_members( directory );
1083
+
1084
+ um_change_tag( directory );
1085
+
1086
+ directory.data( 'searched', 1 );
1087
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1088
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1089
+ }
1090
+ });
1091
+
1092
+
1093
+
1094
+ jQuery( document.body ).on( 'click', '.um-directory .um-members-filter-remove', function() {
1095
+ var directory = jQuery(this).parents('.um-directory');
1096
+
1097
+ if ( um_is_directory_busy(directory) || ! directory ) {
1098
+ return;
1099
+ }
1100
+
1101
+ um_members_show_preloader( directory );
1102
+
1103
+ var removeItem = jQuery(this).data('value');
1104
+ var filter_name = jQuery(this).data('name');
1105
+
1106
+ var type = jQuery(this).data('type');
1107
+ if ( type === 'text' ) {
1108
+ um_set_url_from_data( directory, 'filter_' + filter_name,'' );
1109
+
1110
+ jQuery( '.um-search-filter input[name="' + filter_name + '"]' ).val('');
1111
+
1112
+ } else if ( type === 'select' ) {
1113
+
1114
+ var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1115
+ if ( typeof current_value == 'undefined' ) {
1116
+ current_value = [];
1117
+ } else {
1118
+ current_value = current_value.split( '||' );
1119
+ }
1120
+
1121
+ if ( -1 !== jQuery.inArray( removeItem.toString(), current_value ) ) {
1122
+ current_value = jQuery.grep( current_value, function( value ) {
1123
+ return value !== removeItem.toString();
1124
+ });
1125
+ }
1126
+
1127
+ if ( ! current_value.length ) {
1128
+ current_value = '';
1129
+ }
1130
+
1131
+ um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1132
+
1133
+ var select = jQuery( '.um-search-filter select[name="' + filter_name + '"]' );
1134
+ select.find('option[value="' + removeItem + '"]').prop('disabled', false).show();
1135
+
1136
+ //disable options and disable select if all options are disabled
1137
+ if ( select.find('option:not(:disabled)').length > 1 ) {
1138
+ select.prop('disabled', false);
1139
+ }
1140
+
1141
+ select.select2('destroy').select2({
1142
+ dropdownParent: select.parent()
1143
+ });
1144
+
1145
+ if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
1146
+ select.trigger('change');
1147
+ }
1148
+
1149
+ } else if ( type === 'slider' ) {
1150
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1151
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1152
+
1153
+
1154
+ var $slider = jQuery( '.um-search-filter #' + filter_name + '_min' ).siblings('.um-slider');
1155
+ var options = $slider.slider( 'option' );
1156
+
1157
+ $slider.slider( 'values', [ options.min, options.max ] );
1158
+
1159
+ jQuery( '.um-search-filter #' + filter_name + '_min' ).val('');
1160
+ jQuery( '.um-search-filter #' + filter_name + '_max' ).val('');
1161
+
1162
+ um_set_range_label( $slider );
1163
+ } else if ( type === 'datepicker' ) {
1164
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1165
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1166
+
1167
+ jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1168
+ jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1169
+ } else if ( type === 'timepicker' ) {
1170
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1171
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1172
+
1173
+ jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1174
+ jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1175
+ } else {
1176
+ wp.hooks.doAction( 'um_member_directory_filter_remove', type, directory, filter_name, removeItem );
1177
+ }
1178
+
1179
+
1180
+ //set 1st page after filtration
1181
+ directory.data( 'page', 1 );
1182
+ um_set_url_from_data( directory, 'page', '' );
1183
+
1184
+ jQuery(this).tipsy('hide');
1185
+ jQuery(this).parents('.um-members-filter-tag').remove();
1186
+
1187
+ if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
1188
+ directory.find('.um-clear-filters').hide();
1189
+ } else {
1190
+ directory.find('.um-clear-filters').show();
1191
+ }
1192
+
1193
+ var ignore_after_search = false;
1194
+ ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1195
+
1196
+ if ( ! ignore_after_search ) {
1197
+ var show_after_search = directory.data('must-search');
1198
+ if ( show_after_search === 1 ) {
1199
+ var search = um_get_search( directory );
1200
+ if ( directory.find( '.um-members-filter-remove' ).length === 0 && ! search ) {
1201
+ directory.data( 'searched', 0 );
1202
+ directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
1203
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
1204
+ directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
1205
+
1206
+ wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
1207
+
1208
+ um_members_hide_preloader( directory );
1209
+ return;
1210
+ }
1211
+ }
1212
+ }
1213
+
1214
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1215
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1216
+
1217
+ um_ajax_get_members( directory );
1218
+ });
1219
+
1220
+
1221
+ jQuery( document.body ).on( 'click', '.um-directory .um-clear-filters-a', function() {
1222
+ var directory = jQuery(this).parents('.um-directory');
1223
+ if ( um_is_directory_busy( directory ) ) {
1224
+ return;
1225
+ }
1226
+
1227
+ um_members_show_preloader( directory );
1228
+
1229
+ directory.find( '.um-members-filter-remove' ).each( function() {
1230
+ var removeItem = jQuery(this).data('value');
1231
+ var filter_name = jQuery(this).data('name');
1232
+
1233
+ var type = jQuery(this).data('type');
1234
+ if ( type === 'text' ) {
1235
+ um_set_url_from_data( directory, 'filter_' + filter_name,'' );
1236
+
1237
+ jQuery( '.um-search-filter input[name="' + filter_name + '"]' ).val('');
1238
+
1239
+ } else if ( type === 'select' ) {
1240
+
1241
+ var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
1242
+ if ( typeof current_value == 'undefined' ) {
1243
+ current_value = [];
1244
+ } else {
1245
+ current_value = current_value.split( '||' );
1246
+ }
1247
+
1248
+ if ( -1 !== jQuery.inArray( removeItem.toString(), current_value ) ) {
1249
+ current_value = jQuery.grep( current_value, function( value ) {
1250
+ return value !== removeItem.toString();
1251
+ });
1252
+ }
1253
+
1254
+ if ( ! current_value.length ) {
1255
+ current_value = '';
1256
+ }
1257
+
1258
+ um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
1259
+
1260
+ var select = jQuery( '.um-search-filter select[name="' + filter_name + '"]' );
1261
+ select.find('option[value="' + removeItem + '"]').prop('disabled', false).show();
1262
+
1263
+ //disable options and disable select if all options are disabled
1264
+ if ( select.find('option:not(:disabled)').length > 1 ) {
1265
+ select.prop('disabled', false);
1266
+ }
1267
+ select.select2('destroy').select2({
1268
+ dropdownParent: select.parent()
1269
+ });
1270
+
1271
+ if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
1272
+ select.trigger('change');
1273
+ }
1274
+
1275
+ } else if ( type === 'slider' ) {
1276
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1277
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1278
+
1279
+ var $slider = jQuery( '.um-search-filter #' + filter_name + '_min' ).siblings('.um-slider');
1280
+ var options = $slider.slider( 'option' );
1281
+
1282
+ $slider.slider( 'values', [ options.min, options.max ] );
1283
+
1284
+ jQuery( '.um-search-filter #' + filter_name + '_min' ).val('');
1285
+ jQuery( '.um-search-filter #' + filter_name + '_max' ).val('');
1286
+
1287
+ um_set_range_label( $slider );
1288
+ } else if ( type === 'datepicker' ) {
1289
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1290
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1291
+
1292
+ jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1293
+ jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1294
+ } else if ( type === 'timepicker' ) {
1295
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
1296
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
1297
+
1298
+ jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
1299
+ jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
1300
+ } else {
1301
+ wp.hooks.doAction( 'um_member_directory_clear_filters', type, directory, filter_name, removeItem );
1302
+ }
1303
+ });
1304
+
1305
+ //set 1st page after filtration
1306
+ directory.data( 'page', 1 );
1307
+ um_set_url_from_data( directory, 'page', '' );
1308
+ directory.find('.um-members-filter-tag').remove();
1309
+
1310
+ //jQuery(this).hide();
1311
+ if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
1312
+ directory.find('.um-clear-filters').hide();
1313
+ directory.find('.um-clear-filters').parents('.um-member-directory-header-row').addClass( 'um-header-row-invisible' );
1314
+ } else {
1315
+ directory.find('.um-clear-filters').show();
1316
+ directory.find('.um-clear-filters').parents('.um-member-directory-header-row').removeClass( 'um-header-row-invisible' );
1317
+ }
1318
+
1319
+ var ignore_after_search = false;
1320
+ ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1321
+
1322
+ if ( ! ignore_after_search ) {
1323
+ var show_after_search = directory.data('must-search');
1324
+ if ( show_after_search === 1 ) {
1325
+ var search = um_get_search( directory );
1326
+ if ( ! search ) {
1327
+ directory.data( 'searched', 0 );
1328
+ directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
1329
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
1330
+ directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
1331
+
1332
+ wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
1333
+
1334
+ um_members_hide_preloader( directory );
1335
+ return;
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1341
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1342
+
1343
+ um_ajax_get_members( directory );
1344
+ });
1345
+
1346
+
1347
+ /**
1348
+ * First Page Loading
1349
+ */
1350
+
1351
+ wp.hooks.doAction( 'um_member_directory_on_first_pages_loading' );
1352
+
1353
+ //Init Directories
1354
+ jQuery( '.um-directory' ).each( function() {
1355
+ var directory = jQuery(this);
1356
+ var hash = um_members_get_hash( directory );
1357
+
1358
+ um_member_directories.push( hash );
1359
+
1360
+ // slideup/slidedown animation fix for grid filters bar
1361
+ if ( directory.find('.um-search').length ) {
1362
+ if ( ! directory.find('.um-search').is(':visible') ) {
1363
+ directory.find('.um-search').css({
1364
+ display: "grid"
1365
+ }).slideUp( 1 );
1366
+ }
1367
+ }
1368
+
1369
+ //slider filter
1370
+ directory.find('.um-slider').each( function() {
1371
+ var slider = jQuery( this );
1372
+ var directory = slider.parents('.um-directory');
1373
+
1374
+ var filter_name = slider.data('field_name');
1375
+
1376
+ var min_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1377
+ var max_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1378
+ if ( typeof min_default_value == 'undefined' ) {
1379
+ min_default_value = parseInt( slider.data('min') );
1380
+ }
1381
+
1382
+ if ( typeof max_default_value == 'undefined' ) {
1383
+ max_default_value = parseInt( slider.data('max') );
1384
+ }
1385
+
1386
+ var default_value = [ min_default_value, max_default_value ];
1387
+
1388
+ slider.slider({
1389
+ range: true,
1390
+ min: parseInt( slider.data('min') ),
1391
+ max: parseInt( slider.data('max') ),
1392
+ values: default_value,
1393
+ create: function( event, ui ) {
1394
+ //console.log( ui );
1395
+ },
1396
+ step: 1,
1397
+ slide: function( event, ui ) {
1398
+ um_set_range_label( jQuery( this ), ui );
1399
+ },
1400
+ stop: function( event, ui ) {
1401
+ if ( ! um_is_directory_busy( directory ) ) {
1402
+
1403
+ um_members_show_preloader( directory );
1404
+
1405
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from', ui.values[0] );
1406
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', ui.values[1] );
1407
+
1408
+ //set 1st page after filtration
1409
+ directory.data( 'page', 1 );
1410
+ um_set_url_from_data( directory, 'page', '' );
1411
+ um_ajax_get_members( directory );
1412
+
1413
+ um_change_tag( directory );
1414
+
1415
+ directory.data( 'searched', 1 );
1416
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1417
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1418
+ }
1419
+ }
1420
+ });
1421
+
1422
+ um_set_range_label( slider );
1423
+ });
1424
+
1425
+
1426
+ //datepicker filter
1427
+ directory.find('.um-datepicker-filter').each( function() {
1428
+ var elem = jQuery(this);
1429
+
1430
+ var min = new Date( elem.data('date_min')*1000 );
1431
+ var max = new Date( elem.data('date_max')*1000 );
1432
+
1433
+ var $input = elem.pickadate({
1434
+ selectYears: true,
1435
+ min: min,
1436
+ max: max,
1437
+ formatSubmit: 'yyyy/mm/dd',
1438
+ hiddenName: true,
1439
+ onOpen: function() {
1440
+ elem.blur();
1441
+ },
1442
+ onClose: function() {
1443
+ elem.blur();
1444
+ },
1445
+ onSet: function( context ) {
1446
+
1447
+ if ( ! context.select ) {
1448
+ return;
1449
+ }
1450
+
1451
+ var directory = elem.parents('.um-directory');
1452
+
1453
+ if ( um_is_directory_busy( directory ) ) {
1454
+ return;
1455
+ }
1456
+
1457
+ um_members_show_preloader( directory );
1458
+
1459
+ var filter_name = elem.data( 'filter_name' );
1460
+ var range = elem.data( 'range' );
1461
+
1462
+ var current_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1463
+ var current_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1464
+ if ( typeof current_value_from === "undefined" ) {
1465
+ current_value_from = min / 1000;
1466
+ }
1467
+ if ( typeof current_value_to === "undefined" ) {
1468
+ current_value_to = max / 1000;
1469
+ }
1470
+
1471
+ var select_val = context.select / 1000;
1472
+ var change_val = elem.val();
1473
+
1474
+ if ( range === 'from' ) {
1475
+ current_value_from = select_val;
1476
+ } else if ( range === 'to' ) {
1477
+ current_value_to = select_val;
1478
+ }
1479
+
1480
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from', current_value_from );
1481
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', current_value_to );
1482
+
1483
+ //set 1st page after filtration
1484
+ directory.data( 'page', 1 );
1485
+ um_set_url_from_data( directory, 'page', '' );
1486
+
1487
+ um_ajax_get_members( directory );
1488
+
1489
+ um_change_tag( directory );
1490
+
1491
+ directory.data( 'searched', 1 );
1492
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1493
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1494
+ }
1495
+ });
1496
+
1497
+ var $picker = $input.pickadate('picker');
1498
+ var $fname = elem.data('filter_name');
1499
+ var $frange = elem.data('range');
1500
+ var $directory = elem.parents('.um-directory');
1501
+
1502
+ var query_value = um_get_data_for_directory( $directory, 'filter_' + $fname + '_' + $frange );
1503
+ if ( typeof query_value !== 'undefined' ) {
1504
+ $picker.set( 'select', query_value*1000 );
1505
+ }
1506
+
1507
+ });
1508
+
1509
+
1510
+ //timepicker filter
1511
+ directory.find('.um-timepicker-filter').each( function() {
1512
+ var elem = jQuery(this);
1513
+ var elemID = elem.attr('id');
1514
+ var elem_filter_name = elem.data('filter_name');
1515
+
1516
+ //using arrays formatted as [HOUR,MINUTE]
1517
+ var min = elem.attr('data-min');
1518
+ var max = elem.attr('data-max');
1519
+
1520
+ var picker_min = min.split(':');
1521
+ var picker_max = max.split(':');
1522
+
1523
+ var $input = elem.pickatime({
1524
+ format: elem.data('format'),
1525
+ interval: parseInt( elem.data('intervals') ),
1526
+ min: [picker_min[0],picker_min[1]],
1527
+ max: [picker_max[0],picker_max[1]],
1528
+ formatSubmit: 'HH:i',
1529
+ hiddenName: true,
1530
+ onOpen: function() { elem.blur(); },
1531
+ onClose: function() { elem.blur(); },
1532
+ onSet: function( context ) {
1533
+
1534
+ if ( ! context.select ) {
1535
+ return;
1536
+ }
1537
+
1538
+ var directory = elem.parents('.um-directory');
1539
+
1540
+ if ( um_is_directory_busy( directory ) ) {
1541
+ return;
1542
+ }
1543
+
1544
+ um_members_show_preloader( directory );
1545
+
1546
+ var filter_name = elem.data( 'filter_name' );
1547
+ var range = elem.data( 'range' );
1548
+
1549
+ var current_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1550
+ var current_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1551
+ if ( typeof current_value_from === "undefined" ) {
1552
+ current_value_from = min;
1553
+ }
1554
+ if ( typeof current_value_to === "undefined" ) {
1555
+ current_value_to = max;
1556
+ }
1557
+
1558
+ if ( typeof context.select !== 'undefined' ) {
1559
+ var select_val = um_time_convert( context.select, range );
1560
+
1561
+ //var select_val = context.select / 60;
1562
+
1563
+ if ( range === 'from' ) {
1564
+ current_value_from = select_val;
1565
+ } else if ( range === 'to' ) {
1566
+ current_value_to = select_val;
1567
+ }
1568
+ } else {
1569
+ if ( range === 'from' ) {
1570
+ current_value_from = min;
1571
+ } else if ( range === 'to' ) {
1572
+ current_value_to = max;
1573
+ }
1574
+ }
1575
+
1576
+ var time = jQuery( '#' + elemID ).val();
1577
+
1578
+ if ( elem.data('range') === 'from' ) {
1579
+ jQuery( '#' + elem_filter_name + '_to' ).pickatime('picker').set('min', time);
1580
+ } else {
1581
+ jQuery( '#' + elem_filter_name + '_from').pickatime('picker').set('max', time);
1582
+ }
1583
+
1584
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_from', current_value_from );
1585
+ um_set_url_from_data( directory, 'filter_' + filter_name + '_to', current_value_to );
1586
+
1587
+ //set 1st page after filtration
1588
+ directory.data( 'page', 1 );
1589
+ um_set_url_from_data( directory, 'page', '' );
1590
+
1591
+ um_ajax_get_members( directory );
1592
+
1593
+ um_change_tag( directory );
1594
+
1595
+ directory.data( 'searched', 1 );
1596
+ directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
1597
+ directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
1598
+
1599
+ }
1600
+ });
1601
+
1602
+ // first loading timepicker select
1603
+ var $picker = $input.pickatime('picker');
1604
+ var $fname = elem.data('filter_name');
1605
+ var $frange = elem.data('range');
1606
+ var $directory = elem.parents('.um-directory');
1607
+
1608
+ var query_value = um_get_data_for_directory( $directory, 'filter_' + $fname + '_' + $frange );
1609
+ if ( typeof query_value !== 'undefined' ) {
1610
+ var arr = query_value.split(':');
1611
+ $picker.set( 'select', arr[0]*60 + arr[1]*1 );
1612
+ }
1613
+
1614
+ });
1615
+
1616
+ wp.hooks.doAction( 'um_member_directory_on_init', directory, hash );
1617
+
1618
+ var ignore_after_search = false;
1619
+ ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1620
+
1621
+ if ( ! ignore_after_search ) {
1622
+ var show_after_search = directory.data('must-search');
1623
+ if ( show_after_search === 1 ) {
1624
+ var search = um_get_search( directory );
1625
+ var filters_data = um_get_filters_data( directory );
1626
+ if ( ! filters_data.length && ! search ) {
1627
+ return;
1628
+ }
1629
+ }
1630
+ }
1631
+
1632
+ var prevent_default = wp.hooks.applyFilters( 'um_member_directory_prevent_default_first_loading', false, directory, hash );
1633
+
1634
+ if ( ! prevent_default ) {
1635
+ um_members_show_preloader( directory );
1636
+ um_ajax_get_members( directory, {first_load:true} );
1637
+ um_change_tag( directory );
1638
+ }
1639
+ });
1640
+
1641
+
1642
+ //history events when back/forward and change window.location.hash
1643
+ window.addEventListener( "popstate", function(e) {
1644
+ jQuery( '.um-directory' ).each( function() {
1645
+ var directory = jQuery(this);
1646
+ var hash = um_members_get_hash( directory );
1647
+ um_member_directories.push( hash );
1648
+
1649
+ um_members_show_preloader( directory );
1650
+
1651
+ // clear layout and header
1652
+ directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
1653
+
1654
+ // set search from history
1655
+ if ( directory.find( '.um-member-directory-search-line' ).length ) {
1656
+ var search = um_get_data_for_directory( directory, 'search' );
1657
+ if ( typeof search == 'undefined' ) {
1658
+ search = '';
1659
+ }
1660
+ directory.data( 'general_search', search );
1661
+ directory.find('.um-search-line').val( search );
1662
+ }
1663
+
1664
+ var page = um_get_data_for_directory( directory, 'page' );
1665
+ if ( typeof page == 'undefined' ) {
1666
+ page = 1;
1667
+ } else if ( page > directory.data( 'total_pages' ) ) {
1668
+ page = directory.data( 'total_pages' );
1669
+ }
1670
+
1671
+ directory.data( 'page', page ).attr( 'data-page', page );
1672
+
1673
+ //sorting from history
1674
+ if ( directory.find( '.um-member-directory-sorting' ).length ) {
1675
+ var sort = um_get_data_for_directory( directory, 'sort' );
1676
+ if ( typeof sort == 'undefined' ) {
1677
+ sort = directory.find( '.um-new-dropdown[data-element=".um-member-directory-sorting-a"]' ).find('a[data-default="1"]').data('value');
1678
+ }
1679
+ directory.data( 'sorting', sort );
1680
+
1681
+ var sort_dropdown = directory.find( '.um-new-dropdown[data-element=".um-member-directory-sorting-a"]' );
1682
+ sort_dropdown.find('a').data('selected', 0).prop('data-selected', 0).attr('data-selected', 0);
1683
+ sort_dropdown.find('a[data-value="' + sort + '"]').data('selected', 1).prop('data-selected', 1).attr('data-selected', 1);
1684
+ directory.find('.um-member-directory-sorting-a').find('> a').html( sort_dropdown.find('a[data-value="' + sort + '"]').html() );
1685
+ }
1686
+
1687
+ //view type from history
1688
+ if ( directory.find( '.um-member-directory-view-type' ).length ) {
1689
+ var layout = um_get_data_for_directory( directory, 'view_type' );
1690
+ if ( typeof layout == 'undefined' ) {
1691
+ layout = directory.find( '.um-member-directory-view-type-a[data-default="1"]' ).data('type');
1692
+ }
1693
+ directory.data( 'view_type', layout );
1694
+
1695
+ directory.find('.um-member-directory-view-type .um-member-directory-view-type-a').hide();
1696
+ directory.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="' + layout + '"]').show();
1697
+ }
1698
+
1699
+ //datepicker filter
1700
+ directory.find('.um-datepicker-filter').each( function() {
1701
+ var elem = jQuery(this);
1702
+
1703
+ var $picker = elem.pickadate('picker');
1704
+ var $fname = elem.data('filter_name');
1705
+ var $frange = elem.data('range');
1706
+
1707
+ var query_value = um_get_data_for_directory( directory, 'filter_' + $fname + '_' + $frange );
1708
+ if ( typeof query_value !== 'undefined' ) {
1709
+ $picker.set( 'select', query_value*1000 );
1710
+ } else {
1711
+ $picker.clear();
1712
+ }
1713
+ });
1714
+
1715
+ directory.find('.um-slider').each( function() {
1716
+ var slider = jQuery( this );
1717
+ var filter_name = slider.data('field_name');
1718
+
1719
+ var min_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
1720
+ var max_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
1721
+ if ( typeof min_default_value == 'undefined' ) {
1722
+ min_default_value = slider.data('min');
1723
+ }
1724
+ min_default_value = parseInt( min_default_value );
1725
+
1726
+ if ( typeof max_default_value == 'undefined' ) {
1727
+ max_default_value = slider.data('max');
1728
+ }
1729
+ max_default_value = parseInt( max_default_value );
1730
+
1731
+ slider.slider( 'values', [min_default_value, max_default_value] );
1732
+ um_set_range_label( slider );
1733
+ });
1734
+
1735
+ //timepicker filter
1736
+ directory.find('.um-timepicker-filter').each( function() {
1737
+ var elem = jQuery(this);
1738
+
1739
+ var $picker = elem.pickatime('picker');
1740
+ var $fname = elem.data('filter_name');
1741
+ var $frange = elem.data('range');
1742
+
1743
+ var query_value = um_get_data_for_directory( directory, 'filter_' + $fname + '_' + $frange );
1744
+ if ( typeof query_value !== 'undefined' ) {
1745
+ var arr = query_value.split(':');
1746
+ $picker.set( 'select', arr[0]*60 );
1747
+ } else {
1748
+ $picker.clear();
1749
+ }
1750
+ });
1751
+
1752
+ var ignore_after_search = false;
1753
+ ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
1754
+
1755
+ if ( ! ignore_after_search ) {
1756
+ var show_after_search = directory.data('must-search');
1757
+ if ( show_after_search === 1 ) {
1758
+ var search = um_get_search( directory );
1759
+ var filters_data = um_get_filters_data( directory );
1760
+ if ( ! filters_data.length && ! search ) {
1761
+ directory.data( 'searched', 0 );
1762
+ um_members_hide_preloader( directory );
1763
+ return;
1764
+ } else {
1765
+ directory.data( 'searched', 1 );
1766
+ }
1767
+ }
1768
+ }
1769
+
1770
+ var prevent_default = wp.hooks.applyFilters( 'um_member_directory_prevent_default_first_loading', false, directory, hash );
1771
+
1772
+ if ( ! prevent_default ) {
1773
+ um_ajax_get_members( directory );
1774
+ um_change_tag( directory );
1775
+ }
1776
+ });
1777
+ });
1778
+
1779
+ });
assets/js/um-members.min.js CHANGED
@@ -1 +1 @@
1
- var um_members_directory_busy=[],um_member_directories=[],um_member_directory_last_data=[];function um_parse_current_url(){var t={},a=window.location.search.substring(1).split("&");return jQuery.each(a,function(e){var r=a[e].split("=");t[r[0]]=r[1]}),t}function um_get_data_for_directory(e,r){var t=um_members_get_hash(e),a={},i=um_parse_current_url();if(jQuery.each(i,function(e){-1!==e.indexOf("_"+t)&&""!==i[e]&&(a[e.replace("_"+t,"")]=i[e])}),r){if(void 0!==a[r])try{a[r]=decodeURIComponent(a[r])}catch(e){console.error(e)}return a[r]}return a}function um_set_url_from_data(e,r,t){var a=um_members_get_hash(e),i=um_get_data_for_directory(e),m={};Array.isArray(t)?(jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")):jQuery.isNumeric(t)||(t=t.split("||"),jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")),""!==t&&(m[r+"_"+a]=t),jQuery.each(i,function(e){r===e?""!==t&&(m[e+"_"+a]=t):m[e+"_"+a]=i[e]}),jQuery.each(um_member_directories,function(e){var r=um_member_directories[e];if(r!==a){var t=um_get_data_for_directory(jQuery('.um-directory[data-hash="'+r+'"]'));jQuery.each(t,function(e){m[e+"_"+r]=t[e]})}});var d=[];jQuery.each(m,function(e){d.push(e+"="+m[e])});var s="?"+(d=wp.hooks.applyFilters("um_member_directory_url_attrs",d)).join("&");"?"===s&&(s=""),window.history.pushState("string","UM Member Directory",window.location.origin+window.location.pathname+s)}function um_members_get_hash(e){return e.data("hash")}function um_is_directory_busy(e){var r=um_members_get_hash(e);return void 0!==um_members_directory_busy[r]&&um_members_directory_busy[r]}function um_members_show_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!0,e.find(".um-members-overlay").show()}function um_members_hide_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!1,e.find(".um-members-overlay").hide()}function um_set_range_label(e,r){var t="",a=e.siblings(".um-slider-range").data("placeholder-s"),i=e.siblings(".um-slider-range").data("placeholder-p");t=r?r.values[0]===r.values[1]?a.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):e.slider("values",0)===e.slider("values",1)?a.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),e.siblings(".um-slider-range").html(t),e.siblings(".um_range_min").val(e.slider("values",0)),e.siblings(".um_range_max").val(e.slider("values",1))}function um_get_search(e){return e.find(".um-search-line").length?e.find(".um-search-line").val():""}function um_get_sort(e){return e.data("sorting")}function um_get_current_page(e){var r=e.data("page");return r&&void 0!==r||(r=1),r}function um_time_convert(e,r){var t=Math.floor(e/60),a=e%60;return 60<=a&&(a=0,24<=(t+=1)&&(t=0)),a<10&&(a="0"+a),t+":"+a}function um_ajax_get_members(u,e){var t=um_members_get_hash(u);if(wp.hooks.applyFilters("um_member_directory_get_members_allow",!0,t,u)){var r=um_get_current_page(u),a=um_get_search(u),i=um_get_sort(u),m=-(new Date).getTimezoneOffset()/60,_={directory_id:t,page:r,search:a,sorting:i,gmt_offset:m,post_refferer:u.data("base-post"),nonce:um_scripts.nonce};u.find(".um-search-filter").length&&u.find(".um-search-filter").each(function(){var e=jQuery(this);if(e.find(".um-slider").length){var r=e.find(".um-slider").data("field_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-datepicker-filter").length){r=e.find(".um-datepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-timepicker-filter").length){r=e.find(".um-timepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");if(void 0!==t)(i=1*(t=t.split(":"))[0])<10&&(i="0"+i),(d=1*t[1])<10&&(d="0"+d),t=i+":"+d+":00";if(void 0!==a){var i,m=a.split(":"),d=1*m[1];(i=1*m[0])<10&&(i="0"+i),d<10&&(d="0"+d),a=i+":"+d+":59"}void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find("select").length){r=e.find("select").attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(_[r]=s.split("||"))}else if(e.hasClass("um-text-filter-type")&&e.find('input[type="text"]').length){var s;r=e.find('input[type="text"]').attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(_[r]=s)}else _=wp.hooks.applyFilters("um_member_directory_custom_filter_handler",_,e,u)}),_=wp.hooks.applyFilters("um_member_directory_filter_request",_),wp.ajax.send("um_get_members",{data:_,success:function(e){um_member_directory_last_data[t]=e,um_build_template(u,e);var r=wp.template("um-members-pagination");u.find(".um-members-pagination-box").html(r(e)),u.data("total_pages",e.pagination.total_pages),e.pagination.total_pages?(u.find(".um-member-directory-sorting-options").prop("disabled",!1),u.find(".um-member-directory-view-type").removeClass("um-disabled")):(u.find(".um-member-directory-sorting-options").prop("disabled",!0),u.find(".um-member-directory-view-type").addClass("um-disabled")),wp.hooks.doAction("um_member_directory_loaded",u,e),um_init_new_dropdown(),um_members_hide_preloader(u)},error:function(e){console.log(e),um_members_hide_preloader(u)}})}else setTimeout(um_ajax_get_members,600,u,e)}function um_build_template(e,r){var t=e.data("view_type"),a=wp.template("um-member-"+t+"-"+um_members_get_hash(e));e.find(".um-members-grid, .um-members-list").remove(),e.find(".um-members-wrapper").prepend(a(r.users));var i=wp.template("um-members-header");e.find(".um-members-intro").remove();var m=wp.hooks.applyFilters("um_member_directory_generate_header",!1,e);(void 0!==r.is_search&&r.is_search||m)&&e.find(".um-members-wrapper").prepend(i(r)),e.addClass("um-loaded"),e.find(".um-members.um-members-grid").length&&UM_Member_Grid(e.find(".um-members.um-members-grid")),jQuery(document).trigger("um_build_template",[e,r]),jQuery(window).trigger("resize"),init_tipsy()}function UM_Member_Grid(r){r.find(".um-member").length&&r.imagesLoaded(function(){var e=wp.hooks.applyFilters("um_member_directory_grid_masonry_attrs",{itemSelector:".um-member",columnWidth:".um-member",gutter:".um-gutter-sizer"},r);r.masonry(e).on("layoutComplete",function(e,r){jQuery(document).trigger("um_grid_initialized",[e,r])})})}function um_get_filters_data(u){var _=[];return u.find(".um-search-filter").each(function(){var t,a,d,i=jQuery(this);if(i.find("input.um-datepicker-filter").length)d="datepicker",i.find("input.um-datepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-datepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("input.um-timepicker-filter").length)d="timepicker",i.find("input.um-timepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-timepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("select").length){d="select",t=i.find("select").attr("name"),a=i.find("select").data("placeholder"),m=void 0===(m=um_get_data_for_directory(u,"filter_"+t))?[]:m.split("||"),jQuery.each(m,function(e){var r=i.find('select option[value="'+m[e]+'"]').data("value_label");_.push({name:t,label:a,value_label:r,value:m[e],type:d})})}else if(i.hasClass("um-text-filter-type")&&i.find('input[type="text"]').length){var m;d="text",t=i.find('input[type="text"]').attr("name"),a=i.find('input[type="text"]').attr("placeholder"),void 0===(m=um_get_data_for_directory(u,"filter_"+t))&&(m=""),""!=m&&_.push({name:t,label:a,value_label:m,value:m,type:d})}else if(i.find("div.ui-slider").length){d="slider",t=i.find("div.ui-slider").data("field_name");var e,r=um_get_data_for_directory(u,"filter_"+t+"_from"),s=um_get_data_for_directory(u,"filter_"+t+"_to");if(void 0===r&&void 0===s)return;e=r===s?i.find("div.um-slider-range").data("placeholder-s").replace("{value}",r).replace("{field_label}",i.find("div.um-slider-range").data("label")):i.find("div.um-slider-range").data("placeholder-p").replace("{min_range}",r).replace("{max_range}",s).replace("{field_label}",i.find("div.um-slider-range").data("label")),a=i.find("div.um-slider-range").data("label"),_.push({name:t,label:a,value_label:e,value:[r,s],type:d})}else _=wp.hooks.applyFilters("um_member_directory_get_filter_data",_,u,i)}),_}function um_change_tag(e){var r=um_get_filters_data(e);e.find(".um-members-filter-tag").remove();var t=e.find(".um-filtered-line");if(t.length){var a=wp.template("um-members-filtered-line");t.prepend(a({filters:r})),0===e.find(".um-members-filter-remove").length?(e.find(".um-clear-filters").hide(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(e.find(".um-clear-filters").show(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"))}}function um_run_search(e){if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=um_get_data_for_directory(e,"search"),t=e.find(".um-search-line").val();if(t===r||""===t&&void 0===r)um_members_hide_preloader(e);else{e.data("general_search",t),um_set_url_from_data(e,"search",t),e.data("page",1),um_set_url_from_data(e,"page","");var a=!1;if(!(a=wp.hooks.applyFilters("um_member_directory_ignore_after_search",a,e)))if(1===e.data("must-search")&&(t=um_get_search(e),0===e.find(".um-members-filter-remove").length&&!t))return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e);e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}}jQuery(document.body).ready(function(){jQuery(".um-directory .um-search-filter select").each(function(){1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var e=jQuery(this);e.select2("destroy").select2({dropdownParent:e.parent()})}),jQuery(document.body).on("mouseover",".um-directory .um-member-directory-view-type",function(){if(!jQuery(this).hasClass("um-disabled")){var e=jQuery(this).find(".um-member-directory-view-type-a:visible");e.hide(),e.next().length?e.next().show().tipsy("show"):jQuery(this).find(".um-member-directory-view-type-a:first").show().tipsy("show")}}).on("mouseout",".um-directory .um-member-directory-view-type",function(){jQuery(this).hasClass("um-disabled")||(jQuery(this).find(".um-member-directory-view-type-a").hide().tipsy("hide"),jQuery(this).find('.um-member-directory-view-type-a[data-type="'+jQuery(this).parents(".um-directory").data("view_type")+'"]').show())}),jQuery(document.body).on("click",".um-directory .um-member-directory-view-type-a",function(){var e=jQuery(this).parents(".um-directory");if(um_is_directory_busy(e))return!1;var r=jQuery(this),t=r.parents(".um-member-directory-view-type");if(!t.hasClass("um-disabled")){um_members_show_preloader(e);var a=t.find(".um-member-directory-view-type-a:visible");a.hide(),a.next().length?a.next().show().tipsy("show"):t.find(".um-member-directory-view-type-a:first").show().tipsy("show");var i=um_member_directory_last_data[um_members_get_hash(e)];if(null!==i){var m=r.data("type");um_set_url_from_data(e,"view_type",m),e.data("view_type",m),um_build_template(e,i),um_init_new_dropdown()}um_members_hide_preloader(e)}}),jQuery(document.body).on("click",".um-directory .um-do-search",function(){um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("keypress",".um-directory .um-search-line",function(e){13===e.which&&um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("click",'.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a',function(){if(1!==jQuery(this).data("selected")){var e=jQuery(this).data("directory-hash"),r=jQuery('.um-directory[data-hash="'+e+'"]');if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=jQuery(this).html(),a=jQuery(this).data("value");r.data("sorting",a),um_set_url_from_data(r,"sort",a),um_ajax_get_members(r),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"] a[data-value="'+a+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),r.find(".um-member-directory-sorting-a").find("> a").html(t)}}}),jQuery(document.body).on("click",".um-directory .pagi:not(.current)",function(){if(!jQuery(this).hasClass("disabled")){var e,r=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(r))um_members_show_preloader(r),1===(e="first"===jQuery(this).data("page")?1:"prev"===jQuery(this).data("page")?1*r.data("page")-1:"next"===jQuery(this).data("page")?1*r.data("page")+1:"last"===jQuery(this).data("page")?parseInt(r.data("total_pages")):parseInt(jQuery(this).data("page")))?(r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass("disabled"),r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled")):(e===parseInt(r.data("total_pages"))?r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass("disabled"):r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled"),r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass("disabled")),r.find(".pagi").removeClass("current"),r.find('.pagi[data-page="'+e+'"]').addClass("current"),r.data("page",e),um_set_url_from_data(r,"page",1===e?"":e),um_ajax_get_members(r)}}),jQuery(document.body).on("change",".um-directory .um-members-pagi-dropdown",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=jQuery(this).val();e.find(".pagi").removeClass("current"),e.find('.pagi[data-page="'+r+'"]').addClass("current"),e.data("page",r),um_set_url_from_data(e,"page",1===r?"":r),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-more").hide(),r.find(".um-member-meta-main").slideDown(),r.find(".um-member-less").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-less").hide(),r.find(".um-member-meta-main").slideUp(),r.find(".um-member-more").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-more").hide(),r.find(".um-member-meta").slideDown(function(){UM_Member_Grid(t)}),r.find(".um-member-less").fadeIn(),setTimeout(function(){UM_Member_Grid(t)},100),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-less").hide(),r.find(".um-member-meta").slideUp(function(){r.find(".um-member-more").fadeIn(),UM_Member_Grid(t)}),!1}),jQuery(".um-member-directory-filters-a").on("click",function(){var e=jQuery(this),r=e.parents(".um-directory").find(".um-search");r.is(":visible")?r.slideUp(250,function(){e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}):r.slideDown({duration:250,start:function(){jQuery(this).css({display:"grid"}),e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}})}),jQuery(document.body).on("change",".um-directory .um-search-filter select",function(){if(""!==jQuery(this).val()){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=jQuery(this).prop("name"),t=um_get_data_for_directory(e,"filter_"+r);t=void 0===t?[]:t.split("||"),-1===jQuery.inArray(jQuery(this).val(),t)&&(t.push(jQuery(this).val()),um_set_url_from_data(e,"filter_"+r,t=t.join("||")),e.data("page",1),um_set_url_from_data(e,"page","")),jQuery(this).find('option[value="'+jQuery(this).val()+'"]').prop("disabled",!0).hide(),1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var a=jQuery(this);a.select2("destroy").select2({dropdownParent:a.parent()}),a.val("").trigger("change"),um_ajax_get_members(e),um_change_tag(e),e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled")}}}),jQuery(document.body).on("blur",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){var r=jQuery(this).val(),t=jQuery(this).prop("name"),a=um_get_data_for_directory(e,"filter_"+t);void 0===a&&(a=""),r!==a&&(um_members_show_preloader(e),um_set_url_from_data(e,"filter_"+t,r),e.data("page",1),um_set_url_from_data(e,"page",""),um_ajax_get_members(e),um_change_tag(e),e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),jQuery(document.body).on("keypress",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(e){if(13===e.which){var r=jQuery(this).parents(".um-directory");if(um_is_directory_busy(r))return;var t=jQuery(this).val(),a=jQuery(this).prop("name"),i=um_get_data_for_directory(r,"filter_"+a);if(void 0===i&&(i=""),t===i)return;um_members_show_preloader(r),um_set_url_from_data(r,"filter_"+a,t),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}),jQuery(document.body).on("click",".um-directory .um-members-filter-remove",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)&&e){um_members_show_preloader(e);var r=jQuery(this).data("value"),t=jQuery(this).data("name"),a=jQuery(this).data("type");if("text"===a)um_set_url_from_data(e,"filter_"+t,""),jQuery('.um-search-filter input[name="'+t+'"]').val("");else if("select"===a){var i=um_get_data_for_directory(e,"filter_"+t);i=void 0===i?[]:i.split("||"),-1!==jQuery.inArray(r.toString(),i)&&(i=jQuery.grep(i,function(e){return e!==r.toString()})),i.length||(i=""),um_set_url_from_data(e,"filter_"+t,i);var m=jQuery('.um-search-filter select[name="'+t+'"]');m.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<m.find("option:not(:disabled)").length&&m.prop("disabled",!1),m.select2("destroy").select2({dropdownParent:m.parent()}),0<e.find('.um-search-filter select[data-um-parent="'+t+'"]').length&&m.trigger("change")}else if("slider"===a){um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to","");var d=jQuery(".um-search-filter #"+t+"_min").siblings(".um-slider"),s=d.slider("option");d.slider("values",[s.min,s.max]),jQuery(".um-search-filter #"+t+"_min").val(""),jQuery(".um-search-filter #"+t+"_max").val(""),um_set_range_label(d)}else"datepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):"timepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):wp.hooks.doAction("um_member_directory_filter_remove",a,e,t,r);e.data("page",1),um_set_url_from_data(e,"page",""),jQuery(this).tipsy("hide"),jQuery(this).parents(".um-members-filter-tag").remove(),0===e.find(".um-members-filter-remove").length?e.find(".um-clear-filters").hide():e.find(".um-clear-filters").show();var u=!1;if(!(u=wp.hooks.applyFilters("um_member_directory_ignore_after_search",u,e)))if(1===e.data("must-search")){var _=um_get_search(e);if(0===e.find(".um-members-filter-remove").length&&!_)return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e)}e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-clear-filters-a",function(){var s=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(s)){um_members_show_preloader(s),s.find(".um-members-filter-remove").each(function(){var r=jQuery(this).data("value"),e=jQuery(this).data("name"),t=jQuery(this).data("type");if("text"===t)um_set_url_from_data(s,"filter_"+e,""),jQuery('.um-search-filter input[name="'+e+'"]').val("");else if("select"===t){var a=um_get_data_for_directory(s,"filter_"+e);a=void 0===a?[]:a.split("||"),-1!==jQuery.inArray(r.toString(),a)&&(a=jQuery.grep(a,function(e){return e!==r.toString()})),a.length||(a=""),um_set_url_from_data(s,"filter_"+e,a);var i=jQuery('.um-search-filter select[name="'+e+'"]');i.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<i.find("option:not(:disabled)").length&&i.prop("disabled",!1),i.select2("destroy").select2({dropdownParent:i.parent()}),0<s.find('.um-search-filter select[data-um-parent="'+e+'"]').length&&i.trigger("change")}else if("slider"===t){um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to","");var m=jQuery(".um-search-filter #"+e+"_min").siblings(".um-slider"),d=m.slider("option");m.slider("values",[d.min,d.max]),jQuery(".um-search-filter #"+e+"_min").val(""),jQuery(".um-search-filter #"+e+"_max").val(""),um_set_range_label(m)}else"datepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):"timepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):wp.hooks.doAction("um_member_directory_clear_filters",t,s,e,r)}),s.data("page",1),um_set_url_from_data(s,"page",""),s.find(".um-members-filter-tag").remove(),0===s.find(".um-members-filter-remove").length?(s.find(".um-clear-filters").hide(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(s.find(".um-clear-filters").show(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"));var e=!1;if(!(e=wp.hooks.applyFilters("um_member_directory_ignore_after_search",e,s)))if(1===s.data("must-search"))if(!um_get_search(s))return s.data("searched",0),s.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),s.find(".um-member-directory-sorting-options").prop("disabled",!0),s.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",s),void um_members_hide_preloader(s);s.find(".um-member-directory-sorting-options").prop("disabled",!1),s.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(s)}}),wp.hooks.doAction("um_member_directory_on_first_pages_loading"),jQuery(".um-directory").each(function(){var e=jQuery(this),r=um_members_get_hash(e);um_member_directories.push(r),e.find(".um-search").length&&(e.find(".um-search").is(":visible")||e.find(".um-search").css({display:"grid"}).slideUp(1)),e.find(".um-slider").each(function(){var e=jQuery(this),t=e.parents(".um-directory"),a=e.data("field_name"),r=um_get_data_for_directory(t,"filter_"+a+"_from"),i=um_get_data_for_directory(t,"filter_"+a+"_to");void 0===r&&(r=parseInt(e.data("min"))),void 0===i&&(i=parseInt(e.data("max")));var m=[r,i];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:m,create:function(e,r){},step:1,slide:function(e,r){um_set_range_label(jQuery(this),r)},stop:function(e,r){um_is_directory_busy(t)||(um_members_show_preloader(t),um_set_url_from_data(t,"filter_"+a+"_from",r.values[0]),um_set_url_from_data(t,"filter_"+a+"_to",r.values[1]),t.data("page",1),um_set_url_from_data(t,"page",""),um_ajax_get_members(t),um_change_tag(t),t.data("searched",1),t.find(".um-member-directory-sorting-options").prop("disabled",!1),t.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),um_set_range_label(e)}),e.find(".um-datepicker-filter").each(function(){var s=jQuery(this),u=new Date(1e3*s.data("date_min")),_=new Date(1e3*s.data("date_max")),e=s.pickadate({selectYears:!0,min:u,max:_,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){s.blur()},onClose:function(){s.blur()},onSet:function(e){if(e.select){var r=s.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=s.data("filter_name"),a=s.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");void 0===i&&(i=u/1e3),void 0===m&&(m=_/1e3);var d=e.select/1e3;s.val();"from"===a?i=d:"to"===a&&(m=d),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickadate("picker"),r=s.data("filter_name"),t=s.data("range"),a=um_get_data_for_directory(s.parents(".um-directory"),"filter_"+r+"_"+t);void 0!==a&&e.set("select",1e3*a)}),e.find(".um-timepicker-filter").each(function(){var u=jQuery(this),_=u.attr("id"),o=u.data("filter_name"),n=u.attr("data-min"),l=u.attr("data-max"),e=n.split(":"),r=l.split(":"),t=u.pickatime({format:u.data("format"),interval:parseInt(u.data("intervals")),min:[e[0],e[1]],max:[r[0],r[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){u.blur()},onClose:function(){u.blur()},onSet:function(e){if(e.select){var r=u.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=u.data("filter_name"),a=u.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");if(void 0===i&&(i=n),void 0===m&&(m=l),void 0!==e.select){var d=um_time_convert(e.select,a);"from"===a?i=d:"to"===a&&(m=d)}else"from"===a?i=n:"to"===a&&(m=l);var s=jQuery("#"+_).val();"from"===u.data("range")?jQuery("#"+o+"_to").pickatime("picker").set("min",s):jQuery("#"+o+"_from").pickatime("picker").set("max",s),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickatime("picker"),a=u.data("filter_name"),i=u.data("range"),m=um_get_data_for_directory(u.parents(".um-directory"),"filter_"+a+"_"+i);if(void 0!==m){var d=m.split(":");t.set("select",60*d[0]+1*d[1])}}),wp.hooks.doAction("um_member_directory_on_init",e,r);var t=!1;if(!(t=wp.hooks.applyFilters("um_member_directory_ignore_after_search",t,e))&&1===e.data("must-search")){var a=um_get_search(e);if(!um_get_filters_data(e).length&&!a)return}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,e,r)||(um_members_show_preloader(e),um_ajax_get_members(e,{first_load:!0}),um_change_tag(e))}),window.addEventListener("popstate",function(e){jQuery(".um-directory").each(function(){var d=jQuery(this),e=um_members_get_hash(d);(um_member_directories.push(e),um_members_show_preloader(d),d.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),d.find(".um-member-directory-search-line").length)&&(void 0===(s=um_get_data_for_directory(d,"search"))&&(s=""),d.data("general_search",s),d.find(".um-search-line").val(s));var r=um_get_data_for_directory(d,"page");if(void 0===r?r=1:r>d.data("total_pages")&&(r=d.data("total_pages")),d.data("page",r).attr("data-page",r),d.find(".um-member-directory-sorting").length){var t=um_get_data_for_directory(d,"sort");void 0===t&&(t=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find('a[data-default="1"]').data("value")),d.data("sorting",t);var a=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]');a.find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),a.find('a[data-value="'+t+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),d.find(".um-member-directory-sorting-a").find("> a").html(a.find('a[data-value="'+t+'"]').html())}if(d.find(".um-member-directory-view-type").length){var i=um_get_data_for_directory(d,"view_type");void 0===i&&(i=d.find('.um-member-directory-view-type-a[data-default="1"]').data("type")),d.data("view_type",i),d.find(".um-member-directory-view-type .um-member-directory-view-type-a").hide(),d.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="'+i+'"]').show()}d.find(".um-datepicker-filter").each(function(){var e=jQuery(this),r=e.pickadate("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);void 0!==i?r.set("select",1e3*i):r.clear()}),d.find(".um-slider").each(function(){var e=jQuery(this),r=e.data("field_name"),t=um_get_data_for_directory(d,"filter_"+r+"_from"),a=um_get_data_for_directory(d,"filter_"+r+"_to");void 0===t&&(t=e.data("min")),t=parseInt(t),void 0===a&&(a=e.data("max")),a=parseInt(a),e.slider("values",[t,a]),um_set_range_label(e)}),d.find(".um-timepicker-filter").each(function(){var e=jQuery(this),r=e.pickatime("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);if(void 0!==i){var m=i.split(":");r.set("select",60*m[0])}else r.clear()});var m=!1;if(!(m=wp.hooks.applyFilters("um_member_directory_ignore_after_search",m,d))&&1===d.data("must-search")){var s=um_get_search(d);if(!um_get_filters_data(d).length&&!s)return d.data("searched",0),void um_members_hide_preloader(d);d.data("searched",1)}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,d,e)||(um_ajax_get_members(d),um_change_tag(d))})})});
1
+ var um_members_directory_busy=[],um_member_directories=[],um_member_directory_last_data=[];function um_parse_current_url(){var t={},a=window.location.search.substring(1).split("&");return jQuery.each(a,function(e){var r=a[e].split("=");t[r[0]]=r[1]}),t}function um_get_data_for_directory(e,r){var t=um_members_get_hash(e),a={},i=um_parse_current_url();if(jQuery.each(i,function(e){-1!==e.indexOf("_"+t)&&""!==i[e]&&(a[e.replace("_"+t,"")]=i[e])}),r){if(void 0!==a[r])try{a[r]=decodeURIComponent(a[r])}catch(e){console.error(e)}return a[r]}return a}function um_set_url_from_data(e,r,t){var a=um_members_get_hash(e),i=um_get_data_for_directory(e),m={};Array.isArray(t)?(jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")):jQuery.isNumeric(t)||(t=t.split("||"),jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")),""!==t&&(m[r+"_"+a]=t),jQuery.each(i,function(e){r===e?""!==t&&(m[e+"_"+a]=t):m[e+"_"+a]=i[e]}),jQuery.each(um_member_directories,function(e){var r=um_member_directories[e];if(r!==a){var t=um_get_data_for_directory(jQuery('.um-directory[data-hash="'+r+'"]'));jQuery.each(t,function(e){m[e+"_"+r]=t[e]})}});var d=[];jQuery.each(m,function(e){d.push(e+"="+m[e])});var s="?"+(d=wp.hooks.applyFilters("um_member_directory_url_attrs",d)).join("&");"?"===s&&(s=""),window.history.pushState("string","UM Member Directory",window.location.origin+window.location.pathname+s)}function um_members_get_hash(e){return e.data("hash")}function um_is_directory_busy(e){var r=um_members_get_hash(e);return void 0!==um_members_directory_busy[r]&&um_members_directory_busy[r]}function um_members_show_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!0,e.find(".um-members-overlay").show()}function um_members_hide_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!1,e.find(".um-members-overlay").hide()}function um_set_range_label(e,r){var t="",a=e.siblings(".um-slider-range").data("placeholder-s"),i=e.siblings(".um-slider-range").data("placeholder-p");t=r?r.values[0]===r.values[1]?a.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):e.slider("values",0)===e.slider("values",1)?a.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),e.siblings(".um-slider-range").html(t),e.siblings(".um_range_min").val(e.slider("values",0)),e.siblings(".um_range_max").val(e.slider("values",1))}function um_get_search(e){return e.find(".um-search-line").length?e.find(".um-search-line").val():""}function um_get_sort(e){return e.data("sorting")}function um_get_current_page(e){var r=e.data("page");return r&&void 0!==r||(r=1),r}function um_time_convert(e,r){var t=Math.floor(e/60),a=e%60;return 60<=a&&(a=0,24<=(t+=1)&&(t=0)),a<10&&(a="0"+a),t+":"+a}function um_ajax_get_members(u,e){var t=um_members_get_hash(u);if(wp.hooks.applyFilters("um_member_directory_get_members_allow",!0,t,u)){var r=um_get_current_page(u),a=um_get_search(u),i=um_get_sort(u),m=-(new Date).getTimezoneOffset()/60,_={directory_id:t,page:r,search:a,sorting:i,gmt_offset:m,post_refferer:u.data("base-post"),nonce:um_scripts.nonce};u.find(".um-search-filter").length&&u.find(".um-search-filter").each(function(){var e=jQuery(this);if(e.find(".um-slider").length){var r=e.find(".um-slider").data("field_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-datepicker-filter").length){r=e.find(".um-datepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-timepicker-filter").length){r=e.find(".um-timepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");if(void 0!==t)(i=1*(t=t.split(":"))[0])<10&&(i="0"+i),(d=1*t[1])<10&&(d="0"+d),t=i+":"+d+":00";if(void 0!==a){var i,m=a.split(":"),d=1*m[1];(i=1*m[0])<10&&(i="0"+i),d<10&&(d="0"+d),a=i+":"+d+":59"}void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find("select").length){r=e.find("select").attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(_[r]=s.split("||"))}else if(e.hasClass("um-text-filter-type")&&e.find('input[type="text"]').length){var s;r=e.find('input[type="text"]').attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(_[r]=s)}else _=wp.hooks.applyFilters("um_member_directory_custom_filter_handler",_,e,u)}),_=wp.hooks.applyFilters("um_member_directory_filter_request",_),wp.ajax.send("um_get_members",{data:_,success:function(e){um_member_directory_last_data[t]=e,um_build_template(u,e);var r=wp.template("um-members-pagination");u.find(".um-members-pagination-box").html(r(e)),u.data("total_pages",e.pagination.total_pages),e.pagination.total_pages?(u.find(".um-member-directory-sorting-options").prop("disabled",!1),u.find(".um-member-directory-view-type").removeClass("um-disabled")):(u.find(".um-member-directory-sorting-options").prop("disabled",!0),u.find(".um-member-directory-view-type").addClass("um-disabled")),wp.hooks.doAction("um_member_directory_loaded",u,e),um_init_new_dropdown(),um_members_hide_preloader(u)},error:function(e){console.log(e),um_members_hide_preloader(u)}})}else setTimeout(um_ajax_get_members,600,u,e)}function um_build_template(e,r){var t=e.data("view_type"),a=wp.template("um-member-"+t+"-"+um_members_get_hash(e));e.find(".um-members-grid, .um-members-list").remove(),e.find(".um-members-wrapper").prepend(a(r.users));var i=wp.template("um-members-header");e.find(".um-members-intro").remove();var m=wp.hooks.applyFilters("um_member_directory_generate_header",!1,e);(void 0!==r.is_search&&r.is_search||m)&&e.find(".um-members-wrapper").prepend(i(r)),e.addClass("um-loaded"),e.find(".um-members.um-members-grid").length&&UM_Member_Grid(e.find(".um-members.um-members-grid")),jQuery(document).trigger("um_build_template",[e,r]),jQuery(window).trigger("resize"),init_tipsy()}function UM_Member_Grid(r){r.find(".um-member").length&&r.imagesLoaded(function(){var e=wp.hooks.applyFilters("um_member_directory_grid_masonry_attrs",{itemSelector:".um-member",columnWidth:".um-member",gutter:".um-gutter-sizer"},r);r.masonry(e).on("layoutComplete",function(e,r){jQuery(document).trigger("um_grid_initialized",[e,r])})})}function um_get_filters_data(u){var _=[];return u.find(".um-search-filter").each(function(){var t,a,d,i=jQuery(this);if(i.find("input.um-datepicker-filter").length)d="datepicker",i.find("input.um-datepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-datepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("input.um-timepicker-filter").length)d="timepicker",i.find("input.um-timepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-timepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("select").length){d="select",t=i.find("select").attr("name"),a=i.find("select").data("placeholder"),m=void 0===(m=um_get_data_for_directory(u,"filter_"+t))?[]:m.split("||"),jQuery.each(m,function(e){var r=i.find('select option[value="'+m[e]+'"]').data("value_label");_.push({name:t,label:a,value_label:r,value:m[e],type:d})})}else if(i.hasClass("um-text-filter-type")&&i.find('input[type="text"]').length){var m;d="text",t=i.find('input[type="text"]').attr("name"),a=i.find('input[type="text"]').attr("placeholder"),void 0===(m=um_get_data_for_directory(u,"filter_"+t))&&(m=""),""!=m&&_.push({name:t,label:a,value_label:m,value:m,type:d})}else if(i.find("div.ui-slider").length){d="slider",t=i.find("div.ui-slider").data("field_name");var e,r=um_get_data_for_directory(u,"filter_"+t+"_from"),s=um_get_data_for_directory(u,"filter_"+t+"_to");if(void 0===r&&void 0===s)return;e=r===s?i.find("div.um-slider-range").data("placeholder-s").replace("{value}",r).replace("{field_label}",i.find("div.um-slider-range").data("label")):i.find("div.um-slider-range").data("placeholder-p").replace("{min_range}",r).replace("{max_range}",s).replace("{field_label}",i.find("div.um-slider-range").data("label")),a=i.find("div.um-slider-range").data("label"),_.push({name:t,label:a,value_label:e,value:[r,s],type:d})}else _=wp.hooks.applyFilters("um_member_directory_get_filter_data",_,u,i)}),_}function um_change_tag(e){var r=um_get_filters_data(e);e.find(".um-members-filter-tag").remove();var t=e.find(".um-filtered-line");if(t.length){var a=wp.template("um-members-filtered-line");t.prepend(a({filters:r})),0===e.find(".um-members-filter-remove").length?(e.find(".um-clear-filters").hide(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(e.find(".um-clear-filters").show(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"))}}function um_run_search(e){if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=um_get_data_for_directory(e,"search"),t=um_sanitize_value(e.find(".um-search-line").val());if(t===r||""===t&&void 0===r)um_members_hide_preloader(e);else{e.data("general_search",t),um_set_url_from_data(e,"search",t),e.data("page",1),um_set_url_from_data(e,"page","");var a=!1;if(!(a=wp.hooks.applyFilters("um_member_directory_ignore_after_search",a,e)))if(1===e.data("must-search")&&(t=um_get_search(e),0===e.find(".um-members-filter-remove").length&&!t))return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e);e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}}jQuery(document.body).ready(function(){jQuery(".um-directory .um-search-filter select").each(function(){1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var e=jQuery(this);e.select2("destroy").select2({dropdownParent:e.parent()})}),jQuery(document.body).on("mouseover",".um-directory .um-member-directory-view-type",function(){if(!jQuery(this).hasClass("um-disabled")){var e=jQuery(this).find(".um-member-directory-view-type-a:visible");e.hide(),e.next().length?e.next().show().tipsy("show"):jQuery(this).find(".um-member-directory-view-type-a:first").show().tipsy("show")}}).on("mouseout",".um-directory .um-member-directory-view-type",function(){jQuery(this).hasClass("um-disabled")||(jQuery(this).find(".um-member-directory-view-type-a").hide().tipsy("hide"),jQuery(this).find('.um-member-directory-view-type-a[data-type="'+jQuery(this).parents(".um-directory").data("view_type")+'"]').show())}),jQuery(document.body).on("click",".um-directory .um-member-directory-view-type-a",function(){var e=jQuery(this).parents(".um-directory");if(um_is_directory_busy(e))return!1;var r=jQuery(this),t=r.parents(".um-member-directory-view-type");if(!t.hasClass("um-disabled")){um_members_show_preloader(e);var a=t.find(".um-member-directory-view-type-a:visible");a.hide(),a.next().length?a.next().show().tipsy("show"):t.find(".um-member-directory-view-type-a:first").show().tipsy("show");var i=um_member_directory_last_data[um_members_get_hash(e)];if(null!==i){var m=r.data("type");um_set_url_from_data(e,"view_type",m),e.data("view_type",m),um_build_template(e,i),um_init_new_dropdown()}um_members_hide_preloader(e)}}),jQuery(document.body).on("click",".um-directory .um-do-search",function(){um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("keypress",".um-directory .um-search-line",function(e){13===e.which&&um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("click",'.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a',function(){if(1!==jQuery(this).data("selected")){var e=jQuery(this).data("directory-hash"),r=jQuery('.um-directory[data-hash="'+e+'"]');if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=jQuery(this).html(),a=jQuery(this).data("value");r.data("sorting",a),um_set_url_from_data(r,"sort",a),um_ajax_get_members(r),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"] a[data-value="'+a+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),r.find(".um-member-directory-sorting-a").find("> a").html(t)}}}),jQuery(document.body).on("click",".um-directory .pagi:not(.current)",function(){if(!jQuery(this).hasClass("disabled")){var e,r=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(r))um_members_show_preloader(r),1===(e="first"===jQuery(this).data("page")?1:"prev"===jQuery(this).data("page")?1*r.data("page")-1:"next"===jQuery(this).data("page")?1*r.data("page")+1:"last"===jQuery(this).data("page")?parseInt(r.data("total_pages")):parseInt(jQuery(this).data("page")))?(r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass("disabled"),r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled")):(e===parseInt(r.data("total_pages"))?r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass("disabled"):r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled"),r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass("disabled")),r.find(".pagi").removeClass("current"),r.find('.pagi[data-page="'+e+'"]').addClass("current"),r.data("page",e),um_set_url_from_data(r,"page",1===e?"":e),um_ajax_get_members(r)}}),jQuery(document.body).on("change",".um-directory .um-members-pagi-dropdown",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=jQuery(this).val();e.find(".pagi").removeClass("current"),e.find('.pagi[data-page="'+r+'"]').addClass("current"),e.data("page",r),um_set_url_from_data(e,"page",1===r?"":r),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-more").hide(),r.find(".um-member-meta-main").slideDown(),r.find(".um-member-less").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-less").hide(),r.find(".um-member-meta-main").slideUp(),r.find(".um-member-more").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-more").hide(),r.find(".um-member-meta").slideDown(function(){UM_Member_Grid(t)}),r.find(".um-member-less").fadeIn(),setTimeout(function(){UM_Member_Grid(t)},100),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-less").hide(),r.find(".um-member-meta").slideUp(function(){r.find(".um-member-more").fadeIn(),UM_Member_Grid(t)}),!1}),jQuery(".um-member-directory-filters-a").on("click",function(){var e=jQuery(this),r=e.parents(".um-directory").find(".um-search");r.is(":visible")?r.slideUp(250,function(){e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}):r.slideDown({duration:250,start:function(){jQuery(this).css({display:"grid"}),e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}})}),jQuery(document.body).on("change",".um-directory .um-search-filter select",function(){var e=um_sanitize_value(jQuery(this).val());if(""!==e){var r=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=jQuery(this).prop("name"),a=um_get_data_for_directory(r,"filter_"+t);a=void 0===a?[]:a.split("||"),-1===jQuery.inArray(e,a)&&(a.push(e),um_set_url_from_data(r,"filter_"+t,a=a.join("||")),r.data("page",1),um_set_url_from_data(r,"page","")),jQuery(this).find('option[value="'+e+'"]').prop("disabled",!0).hide(),1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var i=jQuery(this);i.select2("destroy").select2({dropdownParent:i.parent()}),i.val("").trigger("change"),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}),jQuery(document.body).on("blur",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){var r=um_sanitize_value(jQuery(this).val()),t=jQuery(this).prop("name"),a=um_get_data_for_directory(e,"filter_"+t);void 0===a&&(a=""),r!==a&&(um_members_show_preloader(e),um_set_url_from_data(e,"filter_"+t,r),e.data("page",1),um_set_url_from_data(e,"page",""),um_ajax_get_members(e),um_change_tag(e),e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),jQuery(document.body).on("keypress",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(e){if(13===e.which){var r=jQuery(this).parents(".um-directory");if(um_is_directory_busy(r))return;var t=um_sanitize_value(jQuery(this).val()),a=jQuery(this).prop("name"),i=um_get_data_for_directory(r,"filter_"+a);if(void 0===i&&(i=""),t===i)return;um_members_show_preloader(r),um_set_url_from_data(r,"filter_"+a,t),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}),jQuery(document.body).on("click",".um-directory .um-members-filter-remove",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)&&e){um_members_show_preloader(e);var r=jQuery(this).data("value"),t=jQuery(this).data("name"),a=jQuery(this).data("type");if("text"===a)um_set_url_from_data(e,"filter_"+t,""),jQuery('.um-search-filter input[name="'+t+'"]').val("");else if("select"===a){var i=um_get_data_for_directory(e,"filter_"+t);i=void 0===i?[]:i.split("||"),-1!==jQuery.inArray(r.toString(),i)&&(i=jQuery.grep(i,function(e){return e!==r.toString()})),i.length||(i=""),um_set_url_from_data(e,"filter_"+t,i);var m=jQuery('.um-search-filter select[name="'+t+'"]');m.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<m.find("option:not(:disabled)").length&&m.prop("disabled",!1),m.select2("destroy").select2({dropdownParent:m.parent()}),0<e.find('.um-search-filter select[data-um-parent="'+t+'"]').length&&m.trigger("change")}else if("slider"===a){um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to","");var d=jQuery(".um-search-filter #"+t+"_min").siblings(".um-slider"),s=d.slider("option");d.slider("values",[s.min,s.max]),jQuery(".um-search-filter #"+t+"_min").val(""),jQuery(".um-search-filter #"+t+"_max").val(""),um_set_range_label(d)}else"datepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):"timepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):wp.hooks.doAction("um_member_directory_filter_remove",a,e,t,r);e.data("page",1),um_set_url_from_data(e,"page",""),jQuery(this).tipsy("hide"),jQuery(this).parents(".um-members-filter-tag").remove(),0===e.find(".um-members-filter-remove").length?e.find(".um-clear-filters").hide():e.find(".um-clear-filters").show();var u=!1;if(!(u=wp.hooks.applyFilters("um_member_directory_ignore_after_search",u,e)))if(1===e.data("must-search")){var _=um_get_search(e);if(0===e.find(".um-members-filter-remove").length&&!_)return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e)}e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-clear-filters-a",function(){var s=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(s)){um_members_show_preloader(s),s.find(".um-members-filter-remove").each(function(){var r=jQuery(this).data("value"),e=jQuery(this).data("name"),t=jQuery(this).data("type");if("text"===t)um_set_url_from_data(s,"filter_"+e,""),jQuery('.um-search-filter input[name="'+e+'"]').val("");else if("select"===t){var a=um_get_data_for_directory(s,"filter_"+e);a=void 0===a?[]:a.split("||"),-1!==jQuery.inArray(r.toString(),a)&&(a=jQuery.grep(a,function(e){return e!==r.toString()})),a.length||(a=""),um_set_url_from_data(s,"filter_"+e,a);var i=jQuery('.um-search-filter select[name="'+e+'"]');i.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<i.find("option:not(:disabled)").length&&i.prop("disabled",!1),i.select2("destroy").select2({dropdownParent:i.parent()}),0<s.find('.um-search-filter select[data-um-parent="'+e+'"]').length&&i.trigger("change")}else if("slider"===t){um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to","");var m=jQuery(".um-search-filter #"+e+"_min").siblings(".um-slider"),d=m.slider("option");m.slider("values",[d.min,d.max]),jQuery(".um-search-filter #"+e+"_min").val(""),jQuery(".um-search-filter #"+e+"_max").val(""),um_set_range_label(m)}else"datepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):"timepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):wp.hooks.doAction("um_member_directory_clear_filters",t,s,e,r)}),s.data("page",1),um_set_url_from_data(s,"page",""),s.find(".um-members-filter-tag").remove(),0===s.find(".um-members-filter-remove").length?(s.find(".um-clear-filters").hide(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(s.find(".um-clear-filters").show(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"));var e=!1;if(!(e=wp.hooks.applyFilters("um_member_directory_ignore_after_search",e,s)))if(1===s.data("must-search"))if(!um_get_search(s))return s.data("searched",0),s.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),s.find(".um-member-directory-sorting-options").prop("disabled",!0),s.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",s),void um_members_hide_preloader(s);s.find(".um-member-directory-sorting-options").prop("disabled",!1),s.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(s)}}),wp.hooks.doAction("um_member_directory_on_first_pages_loading"),jQuery(".um-directory").each(function(){var e=jQuery(this),r=um_members_get_hash(e);um_member_directories.push(r),e.find(".um-search").length&&(e.find(".um-search").is(":visible")||e.find(".um-search").css({display:"grid"}).slideUp(1)),e.find(".um-slider").each(function(){var e=jQuery(this),t=e.parents(".um-directory"),a=e.data("field_name"),r=um_get_data_for_directory(t,"filter_"+a+"_from"),i=um_get_data_for_directory(t,"filter_"+a+"_to");void 0===r&&(r=parseInt(e.data("min"))),void 0===i&&(i=parseInt(e.data("max")));var m=[r,i];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:m,create:function(e,r){},step:1,slide:function(e,r){um_set_range_label(jQuery(this),r)},stop:function(e,r){um_is_directory_busy(t)||(um_members_show_preloader(t),um_set_url_from_data(t,"filter_"+a+"_from",r.values[0]),um_set_url_from_data(t,"filter_"+a+"_to",r.values[1]),t.data("page",1),um_set_url_from_data(t,"page",""),um_ajax_get_members(t),um_change_tag(t),t.data("searched",1),t.find(".um-member-directory-sorting-options").prop("disabled",!1),t.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),um_set_range_label(e)}),e.find(".um-datepicker-filter").each(function(){var s=jQuery(this),u=new Date(1e3*s.data("date_min")),_=new Date(1e3*s.data("date_max")),e=s.pickadate({selectYears:!0,min:u,max:_,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){s.blur()},onClose:function(){s.blur()},onSet:function(e){if(e.select){var r=s.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=s.data("filter_name"),a=s.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");void 0===i&&(i=u/1e3),void 0===m&&(m=_/1e3);var d=e.select/1e3;s.val();"from"===a?i=d:"to"===a&&(m=d),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickadate("picker"),r=s.data("filter_name"),t=s.data("range"),a=um_get_data_for_directory(s.parents(".um-directory"),"filter_"+r+"_"+t);void 0!==a&&e.set("select",1e3*a)}),e.find(".um-timepicker-filter").each(function(){var u=jQuery(this),_=u.attr("id"),o=u.data("filter_name"),n=u.attr("data-min"),l=u.attr("data-max"),e=n.split(":"),r=l.split(":"),t=u.pickatime({format:u.data("format"),interval:parseInt(u.data("intervals")),min:[e[0],e[1]],max:[r[0],r[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){u.blur()},onClose:function(){u.blur()},onSet:function(e){if(e.select){var r=u.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=u.data("filter_name"),a=u.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");if(void 0===i&&(i=n),void 0===m&&(m=l),void 0!==e.select){var d=um_time_convert(e.select,a);"from"===a?i=d:"to"===a&&(m=d)}else"from"===a?i=n:"to"===a&&(m=l);var s=jQuery("#"+_).val();"from"===u.data("range")?jQuery("#"+o+"_to").pickatime("picker").set("min",s):jQuery("#"+o+"_from").pickatime("picker").set("max",s),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickatime("picker"),a=u.data("filter_name"),i=u.data("range"),m=um_get_data_for_directory(u.parents(".um-directory"),"filter_"+a+"_"+i);if(void 0!==m){var d=m.split(":");t.set("select",60*d[0]+1*d[1])}}),wp.hooks.doAction("um_member_directory_on_init",e,r);var t=!1;if(!(t=wp.hooks.applyFilters("um_member_directory_ignore_after_search",t,e))&&1===e.data("must-search")){var a=um_get_search(e);if(!um_get_filters_data(e).length&&!a)return}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,e,r)||(um_members_show_preloader(e),um_ajax_get_members(e,{first_load:!0}),um_change_tag(e))}),window.addEventListener("popstate",function(e){jQuery(".um-directory").each(function(){var d=jQuery(this),e=um_members_get_hash(d);(um_member_directories.push(e),um_members_show_preloader(d),d.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),d.find(".um-member-directory-search-line").length)&&(void 0===(s=um_get_data_for_directory(d,"search"))&&(s=""),d.data("general_search",s),d.find(".um-search-line").val(s));var r=um_get_data_for_directory(d,"page");if(void 0===r?r=1:r>d.data("total_pages")&&(r=d.data("total_pages")),d.data("page",r).attr("data-page",r),d.find(".um-member-directory-sorting").length){var t=um_get_data_for_directory(d,"sort");void 0===t&&(t=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find('a[data-default="1"]').data("value")),d.data("sorting",t);var a=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]');a.find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),a.find('a[data-value="'+t+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),d.find(".um-member-directory-sorting-a").find("> a").html(a.find('a[data-value="'+t+'"]').html())}if(d.find(".um-member-directory-view-type").length){var i=um_get_data_for_directory(d,"view_type");void 0===i&&(i=d.find('.um-member-directory-view-type-a[data-default="1"]').data("type")),d.data("view_type",i),d.find(".um-member-directory-view-type .um-member-directory-view-type-a").hide(),d.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="'+i+'"]').show()}d.find(".um-datepicker-filter").each(function(){var e=jQuery(this),r=e.pickadate("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);void 0!==i?r.set("select",1e3*i):r.clear()}),d.find(".um-slider").each(function(){var e=jQuery(this),r=e.data("field_name"),t=um_get_data_for_directory(d,"filter_"+r+"_from"),a=um_get_data_for_directory(d,"filter_"+r+"_to");void 0===t&&(t=e.data("min")),t=parseInt(t),void 0===a&&(a=e.data("max")),a=parseInt(a),e.slider("values",[t,a]),um_set_range_label(e)}),d.find(".um-timepicker-filter").each(function(){var e=jQuery(this),r=e.pickatime("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);if(void 0!==i){var m=i.split(":");r.set("select",60*m[0])}else r.clear()});var m=!1;if(!(m=wp.hooks.applyFilters("um_member_directory_ignore_after_search",m,d))&&1===d.data("must-search")){var s=um_get_search(d);if(!um_get_filters_data(d).length&&!s)return d.data("searched",0),void um_members_hide_preloader(d);d.data("searched",1)}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,d,e)||(um_ajax_get_members(d),um_change_tag(d))})})});
assets/js/um-scripts.js CHANGED
@@ -1,687 +1,699 @@
1
- function um_init_datetimepicker() {
2
- jQuery('.um-datepicker:not(.picker__input)').each(function(){
3
- var elem = jQuery(this);
4
-
5
- var disable = false;
6
- if ( typeof elem.attr('data-disabled_weekdays') != 'undefined' && elem.attr('data-disabled_weekdays') !== '' ) {
7
- disable = JSON.parse( elem.attr('data-disabled_weekdays') );
8
- }
9
-
10
- var years_n = null;
11
- if ( typeof elem.attr('data-years') != 'undefined' ) {
12
- years_n = elem.attr('data-years');
13
- }
14
-
15
- var minRange = elem.attr('data-date_min');
16
- var maxRange = elem.attr('data-date_max');
17
-
18
- var minSplit = [], maxSplit = [];
19
- if ( typeof minRange != 'undefined' ) {
20
- minSplit = minRange.split(",");
21
- }
22
- if ( typeof maxRange != 'undefined' ) {
23
- maxSplit = maxRange.split(",");
24
- }
25
-
26
- var min = minSplit.length ? new Date(minSplit) : null;
27
- var max = minSplit.length ? new Date(maxSplit) : null;
28
-
29
- // fix min date for safari
30
- if ( min && min.toString() == 'Invalid Date' && minSplit.length == 3 ) {
31
- var minDateString = minSplit[1] + '/' + minSplit[2] + '/' + minSplit[0];
32
- min = new Date(Date.parse(minDateString));
33
- }
34
-
35
- // fix max date for safari
36
- if ( max && max.toString() == 'Invalid Date' && maxSplit.length == 3 ) {
37
- var maxDateString = maxSplit[1] + '/' + maxSplit[2] + '/' + maxSplit[0];
38
- max = new Date(Date.parse(maxDateString));
39
- }
40
-
41
- var data = {
42
- disable: disable,
43
- format: elem.attr( 'data-format' ),
44
- formatSubmit: 'yyyy/mm/dd',
45
- hiddenName: true,
46
- onOpen: function() { elem.blur(); },
47
- onClose: function() { elem.blur(); }
48
- };
49
-
50
- if ( years_n !== null ) {
51
- data.selectYears = years_n;
52
- }
53
-
54
- if ( min !== null ) {
55
- data.min = min;
56
- }
57
-
58
- if ( max !== null ) {
59
- data.max = max;
60
- }
61
-
62
- elem.pickadate( data );
63
- });
64
-
65
- jQuery('.um-timepicker:not(.picker__input)').each(function(){
66
- var elem = jQuery(this);
67
-
68
- elem.pickatime({
69
- format: elem.attr('data-format'),
70
- interval: parseInt( elem.attr('data-intervals') ),
71
- formatSubmit: 'HH:i',
72
- hiddenName: true,
73
- onOpen: function() { elem.blur(); },
74
- onClose: function() { elem.blur(); }
75
- });
76
- });
77
- }
78
-
79
-
80
-
81
- function init_tipsy() {
82
- if ( typeof( jQuery.fn.tipsy ) === 'function' ) {
83
- jQuery('.um-tip-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live', offset: 3 });
84
- jQuery('.um-tip-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live', offset: 3 });
85
- jQuery('.um-tip-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live', offset: 3 });
86
- jQuery('.um-tip-s').tipsy({gravity: 's', opacity: 1, live: 'a.live', offset: 3 });
87
- }
88
- }
89
-
90
- jQuery(document).ready(function() {
91
-
92
- jQuery( document.body ).on('click', '.um-dropdown a.real_url', function() {
93
- window.location = jQuery(this).attr('href');
94
- });
95
-
96
- jQuery( document.body ).on( 'click', '.um-trigger-menu-on-click', function() {
97
- var menu = jQuery(this).find('.um-dropdown');
98
- UM.dropdown.show( menu );
99
- return false;
100
- });
101
-
102
- jQuery( document.body ).on('click', '.um-dropdown-hide', function() {
103
- UM.dropdown.hideAll();
104
- return false;
105
- });
106
-
107
- jQuery( document.body ).on('click', 'a.um-manual-trigger', function() {
108
- var child = jQuery(this).attr('data-child');
109
- var parent = jQuery(this).attr('data-parent');
110
- jQuery(this).parents( parent ).find( child ).trigger('click');
111
- UM.dropdown.hideAll();
112
- return false;
113
- });
114
-
115
- jQuery('.um-s1,.um-s2').css({'display':'block'});
116
-
117
- /**
118
- * Unselect empty option if something is selected
119
- *
120
- * @since 2.1.16
121
- * @param {object} e
122
- * @returns {undefined}
123
- */
124
- function unselectEmptyOption( e ) {
125
- var $element = jQuery( e.currentTarget );
126
- var $selected = $element.find(':selected');
127
-
128
- if ( $selected.length > 1 ) {
129
- $selected.each( function ( i, option ) {
130
- if ( option.value === '' ) {
131
- option.selected = false;
132
- $element.trigger( 'change' );
133
- }
134
- });
135
- }
136
- }
137
-
138
- if ( typeof( jQuery.fn.select2 ) === 'function' ) {
139
- jQuery(".um-s1").each( function( e ) {
140
- var obj = jQuery(this);
141
-
142
- obj.select2({
143
- allowClear: true,
144
- dropdownParent: obj.parent()
145
- }).on( 'change', unselectEmptyOption );
146
- } );
147
-
148
- jQuery(".um-s2").each( function( e ) {
149
- var obj = jQuery(this);
150
-
151
- obj.select2({
152
- allowClear: false,
153
- minimumResultsForSearch: 10,
154
- dropdownParent: obj.parent()
155
- }).on( 'change', unselectEmptyOption );
156
- } );
157
-
158
- jQuery(".um-s3").each( function( e ) {
159
- var obj = jQuery(this);
160
-
161
- obj.select2({
162
- allowClear: false,
163
- minimumResultsForSearch: -1,
164
- dropdownParent: obj.parent()
165
- }).on( 'change', unselectEmptyOption );
166
- } );
167
- }
168
-
169
- init_tipsy();
170
-
171
- if ( typeof( jQuery.fn.um_raty ) === 'function' ) {
172
- jQuery('.um-rating').um_raty({
173
- half: false,
174
- starType: 'i',
175
- number: function() {
176
- return jQuery(this).attr('data-number');
177
- },
178
- score: function() {
179
- return jQuery(this).attr('data-score');
180
- },
181
- scoreName: function() {
182
- return jQuery(this).attr('data-key');
183
- },
184
- hints: false,
185
- click: function( score, evt ) {
186
- um_live_field = this.id;
187
- um_live_value = score;
188
- um_apply_conditions( jQuery(this), false );
189
- }
190
- });
191
-
192
- jQuery('.um-rating-readonly').um_raty({
193
- half: false,
194
- starType: 'i',
195
- number: function() {
196
- return jQuery(this).attr('data-number');
197
- },
198
- score: function() {
199
- return jQuery(this).attr('data-score');
200
- },
201
- scoreName: function() {
202
- return jQuery(this).attr('data-key');
203
- },
204
- hints: false,
205
- readOnly: true
206
- });
207
- }
208
-
209
- jQuery(document).on('change', '.um-field-area input[type="radio"]', function() {
210
- var field = jQuery(this).parents('.um-field-area');
211
- var this_field = jQuery(this).parents('label');
212
- field.find('.um-field-radio').removeClass('active');
213
- field.find('.um-field-radio').find('i').removeAttr('class').addClass('um-icon-android-radio-button-off');
214
- this_field.addClass('active');
215
- this_field.find('i').removeAttr('class').addClass('um-icon-android-radio-button-on');
216
- });
217
-
218
- jQuery(document).on('change', '.um-field-area input[type="checkbox"]', function() {
219
- var this_field = jQuery(this).parents('label');
220
- if ( this_field.hasClass('active') ) {
221
- this_field.removeClass('active');
222
- this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline-blank');
223
- } else {
224
- this_field.addClass('active');
225
- this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline');
226
- }
227
- });
228
-
229
-
230
- um_init_datetimepicker();
231
-
232
- jQuery(document).on('click', '.um .um-single-image-preview a.cancel', function( e ) {
233
- e.preventDefault();
234
- var parent = jQuery(this).parents('.um-field');
235
-
236
- var filename = parent.find( 'input[type="hidden"]#' + parent.data('key') + '-' + jQuery(this).parents('form').find('input[type="hidden"][name="form_id"]').val() ).val();
237
-
238
- var src = jQuery(this).parents('.um-field').find('.um-single-image-preview img').attr('src');
239
- var mode = parent.data('mode');
240
-
241
- var args = {
242
- data: {
243
- mode: mode,
244
- filename: filename,
245
- src: src,
246
- nonce: um_scripts.nonce
247
- },
248
- success: function() {
249
- parent.find('.um-single-image-preview img').attr( 'src', '' );
250
- parent.find('.um-single-image-preview').hide();
251
- parent.find('.um-btn-auto-width').html( parent.data('upload-label') );
252
- parent.find('input[type=hidden]').val( 'empty_file' );
253
- }
254
- };
255
-
256
- if ( mode !== 'register' ) {
257
- args.data.user_id = jQuery(this).parents('form' ).find( '#user_id' ).val();
258
- }
259
-
260
- wp.ajax.send( 'um_remove_file', args );
261
-
262
- return false;
263
- });
264
-
265
- jQuery(document).on('click', '.um .um-single-file-preview a.cancel', function( e ) {
266
- e.preventDefault();
267
- var parent = jQuery(this).parents('.um-field');
268
- var filename = parent.find( 'input[type="hidden"]#' + parent.data('key') + '-' + jQuery(this).parents('form').find('input[type="hidden"][name="form_id"]').val() ).val();
269
- var src = jQuery(this).parents('.um-field').find('.um-single-fileinfo a').attr('href');
270
- var mode = parent.data('mode');
271
-
272
- var args = {
273
- data: {
274
- mode: mode,
275
- filename: filename,
276
- src: src,
277
- nonce: um_scripts.nonce
278
- },
279
- success: function() {
280
- parent.find('.um-single-file-preview').hide();
281
- parent.find('.um-btn-auto-width').html( parent.data('upload-label') );
282
- parent.find('input[type=hidden]').val( 'empty_file' );
283
- }
284
- };
285
-
286
- if ( mode !== 'register' ) {
287
- args.data.user_id = jQuery(this).parents('form' ).find( '#user_id' ).val();
288
- }
289
-
290
- wp.ajax.send( 'um_remove_file', args );
291
-
292
- return false;
293
- });
294
-
295
- jQuery(document).on('click', '.um-field-group-head:not(.disabled)', function() {
296
- var field = jQuery(this).parents('.um-field-group');
297
- var limit = field.data('max_entries');
298
-
299
- if ( field.find('.um-field-group-body').is(':hidden')){
300
- field.find('.um-field-group-body').show();
301
- } else {
302
- field.find('.um-field-group-body:first').clone().appendTo( field );
303
- }
304
-
305
- var increase_id = 0;
306
- field.find('.um-field-group-body').each(function(){
307
- increase_id++;
308
- jQuery(this).find('input').each(function(){
309
- var input = jQuery(this);
310
- input.attr('id', input.data('key') + '-' + increase_id );
311
- input.attr('name', input.data('key') + '-' + increase_id );
312
- input.parent().parent().find('label').attr('for', input.data('key') + '-' + increase_id );
313
- });
314
- });
315
-
316
- if ( limit > 0 && field.find('.um-field-group-body').length == limit ) {
317
-
318
- jQuery(this).addClass('disabled');
319
-
320
- }
321
- });
322
-
323
- jQuery(document).on('click', '.um-field-group-cancel', function( e ) {
324
- e.preventDefault();
325
- var field = jQuery(this).parents('.um-field-group');
326
-
327
- var limit = field.data('max_entries');
328
-
329
- if ( field.find('.um-field-group-body').length > 1 ) {
330
- jQuery(this).parents('.um-field-group-body').remove();
331
- } else {
332
- jQuery(this).parents('.um-field-group-body').hide();
333
- }
334
-
335
- if ( limit > 0 && field.find('.um-field-group-body').length < limit ) {
336
- field.find('.um-field-group-head').removeClass('disabled');
337
- }
338
-
339
- return false;
340
- });
341
-
342
-
343
- jQuery( document.body ).on( 'click', '.um-ajax-paginate', function( e ) {
344
- e.preventDefault();
345
-
346
- var obj = jQuery(this);
347
- var parent = obj.parent();
348
- parent.addClass( 'loading' );
349
-
350
- var pages = obj.data('pages')*1;
351
- var next_page = obj.data('page')*1 + 1;
352
-
353
- var hook = obj.data('hook');
354
-
355
- if ( 'um_load_posts' === hook ) {
356
-
357
- jQuery.ajax({
358
- url: wp.ajax.settings.url,
359
- type: 'post',
360
- data: {
361
- action: 'um_ajax_paginate_posts',
362
- author: jQuery(this).data('author'),
363
- page: next_page,
364
- nonce: um_scripts.nonce
365
- },
366
- complete: function() {
367
- parent.removeClass( 'loading' );
368
- },
369
- success: function( data ) {
370
- parent.before( data );
371
- if ( next_page === pages ) {
372
- parent.remove();
373
- } else {
374
- obj.data( 'page', next_page );
375
- }
376
- }
377
- });
378
- } else if ( 'um_load_comments' === hook ) {
379
-
380
- jQuery.ajax({
381
- url: wp.ajax.settings.url,
382
- type: 'post',
383
- data: {
384
- action: 'um_ajax_paginate_comments',
385
- user_id: jQuery(this).data('user_id'),
386
- page: next_page,
387
- nonce: um_scripts.nonce
388
- },
389
- complete: function() {
390
- parent.removeClass( 'loading' );
391
- },
392
- success: function( data ) {
393
- parent.before( data );
394
- if ( next_page === pages ) {
395
- parent.remove();
396
- } else {
397
- obj.data( 'page', next_page );
398
- }
399
- }
400
- });
401
- } else {
402
- var args = jQuery(this).data('args');
403
- var container = jQuery(this).parents('.um').find('.um-ajax-items');
404
-
405
- jQuery.ajax({
406
- url: wp.ajax.settings.url,
407
- type: 'post',
408
- data: {
409
- action: 'um_ajax_paginate',
410
- hook: hook,
411
- args: args,
412
- nonce: um_scripts.nonce
413
- },
414
- complete: function() {
415
- parent.removeClass( 'loading' );
416
- },
417
- success: function(data){
418
- parent.remove();
419
- container.append( data );
420
- }
421
- });
422
- }
423
- });
424
-
425
-
426
- jQuery(document).on('click', '.um-ajax-action', function( e ) {
427
- e.preventDefault();
428
- var hook = jQuery(this).data('hook');
429
- var user_id = jQuery(this).data('user_id');
430
- var arguments = jQuery(this).data('arguments');
431
-
432
- if ( jQuery(this).data('js-remove') ){
433
- jQuery(this).parents('.'+jQuery(this).data('js-remove')).fadeOut('fast');
434
- }
435
-
436
- jQuery.ajax({
437
- url: wp.ajax.settings.url,
438
- type: 'post',
439
- data: {
440
- action: 'um_muted_action',
441
- hook: hook,
442
- user_id: user_id,
443
- arguments: arguments,
444
- nonce: um_scripts.nonce
445
- },
446
- success: function(data){
447
-
448
- }
449
- });
450
- return false;
451
- });
452
-
453
- jQuery( document.body ).on('click', '#um-search-button', function() {
454
- var action = jQuery(this).parents('.um-search-form').data('members_page');
455
-
456
- var search_keys = [];
457
- jQuery(this).parents('.um-search-form').find('input[name="um-search-keys[]"]').each( function() {
458
- search_keys.push( jQuery(this).val() );
459
- });
460
-
461
- var search = jQuery(this).parents('.um-search-form').find('.um-search-field').val();
462
-
463
- var url;
464
- if ( search === '' ) {
465
- url = action;
466
- } else {
467
- var query = '?';
468
- for ( var i = 0; i < search_keys.length; i++ ) {
469
- query += search_keys[i] + '=' + search;
470
- if ( i !== search_keys.length - 1 ) {
471
- query += '&';
472
- }
473
- }
474
-
475
- url = action + query;
476
- }
477
- window.location = url;
478
- });
479
-
480
- //make search on Enter click
481
- jQuery( document.body ).on( 'keypress', '.um-search-field', function(e) {
482
- if ( e.which === 13 ) {
483
- var action = jQuery(this).parents('.um-search-form').data('members_page');
484
-
485
- var search_keys = [];
486
- jQuery(this).parents('.um-search-form').find('input[name="um-search-keys[]"]').each( function() {
487
- search_keys.push( jQuery(this).val() );
488
- });
489
-
490
- var search = jQuery(this).val();
491
-
492
- var url;
493
- if ( search === '' ) {
494
- url = action;
495
- } else {
496
- var query = '?';
497
- for ( var i = 0; i < search_keys.length; i++ ) {
498
- query += search_keys[i] + '=' + search;
499
- if ( i !== search_keys.length - 1 ) {
500
- query += '&';
501
- }
502
- }
503
-
504
- url = action + query;
505
- }
506
- window.location = url;
507
- }
508
- });
509
-
510
- jQuery('.um-form input[class="um-button"][type="submit"]').prop('disabled', false);
511
-
512
- jQuery(document).one('click', '.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)', function() {
513
- jQuery(this).attr('disabled','disabled');
514
- jQuery(this).parents('form').trigger('submit');
515
- });
516
-
517
-
518
- var um_select_options_cache = {};
519
-
520
- /**
521
- * Find all select fields with parent select fields
522
- */
523
- jQuery('select[data-um-parent]').each( function() {
524
-
525
- var me = jQuery(this);
526
- var parent_option = me.data('um-parent');
527
- var um_ajax_source = me.data('um-ajax-source');
528
-
529
- me.attr('data-um-init-field', true );
530
-
531
- jQuery(document).on('change','select[name="' + parent_option + '"]',function() {
532
- var parent = jQuery(this);
533
- var form_id = parent.closest( 'form' ).find( 'input[type="hidden"][name="form_id"]' ).val();
534
-
535
- var arr_key;
536
- if ( me.attr( 'data-member-directory' ) === 'yes' ) {
537
- var directory = parent.parents('.um-directory');
538
- arr_key = um_get_data_for_directory( directory, 'filter_' + parent_option );
539
- if ( typeof arr_key != 'undefined' ) {
540
- arr_key = arr_key.split('||');
541
- } else {
542
- arr_key = '';
543
- }
544
- } else {
545
- arr_key = parent.val();
546
- }
547
-
548
- if ( typeof arr_key != 'undefined' && arr_key !== '' && typeof um_select_options_cache[ arr_key ] !== 'object' ) {
549
-
550
- if ( typeof( me.um_wait ) === 'undefined' || me.um_wait === false ) {
551
- me.um_wait = true;
552
- } else {
553
- return;
554
- }
555
-
556
- jQuery.ajax({
557
- url: wp.ajax.settings.url,
558
- type: 'post',
559
- data: {
560
- action: 'um_select_options',
561
- parent_option_name: parent_option,
562
- parent_option: arr_key,
563
- child_callback: um_ajax_source,
564
- child_name: me.attr('name'),
565
- members_directory: me.attr('data-member-directory'),
566
- form_id: form_id,
567
- nonce: um_scripts.nonce
568
- },
569
- success: function( data ) {
570
- if ( data.status === 'success' && arr_key !== '' ) {
571
- um_select_options_cache[ arr_key ] = data;
572
- um_field_populate_child_options( me, data, arr_key );
573
- }
574
-
575
- if ( typeof data.debug !== 'undefined' ) {
576
- console.log( data );
577
- }
578
-
579
- me.um_wait = false;
580
- },
581
- error: function( e ) {
582
- console.log( e );
583
- me.um_wait = false;
584
- }
585
- });
586
-
587
- }
588
-
589
- if ( typeof arr_key != 'undefined' && arr_key !== '' && typeof um_select_options_cache[ arr_key ] == 'object' ) {
590
- setTimeout( um_field_populate_child_options, 10, me, um_select_options_cache[ arr_key ], arr_key );
591
- }
592
-
593
- if ( typeof arr_key != 'undefined' || arr_key === '' ) {
594
- me.find('option[value!=""]').remove();
595
- me.val('').trigger('change');
596
- }
597
-
598
- });
599
-
600
- jQuery('select[name="' + parent_option + '"]').trigger('change');
601
-
602
- });
603
-
604
-
605
- /**
606
- * Populates child options and cache ajax response
607
- *
608
- * @param me
609
- * @param data
610
- * @param arr_key
611
- */
612
- function um_field_populate_child_options( me, data, arr_key ) {
613
- var directory = me.parents('.um-directory');
614
- var child_name = me.attr('name');
615
- me.find('option[value!=""]').remove();
616
-
617
- if ( ! me.hasClass('um-child-option-disabled') ) {
618
- me.prop('disabled', false);
619
- }
620
-
621
- var arr_items = [],
622
- search_get = '';
623
-
624
- if ( data.post.members_directory === 'yes' ) {
625
- arr_items.push({id: '', text: '', selected: 1});
626
- }
627
- jQuery.each( data.items, function(k,v){
628
- arr_items.push({id: k, text: v, selected: (v === search_get)});
629
- });
630
-
631
- me.select2('destroy');
632
- me.select2({
633
- data: arr_items,
634
- allowClear: true,
635
- minimumResultsForSearch: 10
636
- });
637
-
638
- if ( data.post.members_directory === 'yes' ) {
639
- me.find('option').each( function() {
640
- if ( jQuery(this).html() !== '' ) {
641
- jQuery(this).data( 'value_label', jQuery(this).html() ).attr( 'data-value_label', jQuery(this).html() );
642
- }
643
- });
644
-
645
- var current_filter_val = um_get_data_for_directory( directory, 'filter_' + child_name );
646
- if ( typeof current_filter_val !== 'undefined' ) {
647
- current_filter_val = current_filter_val.split('||');
648
-
649
- var temp_filter_val = [];
650
- jQuery.each( current_filter_val, function(i) {
651
- if ( me.find('option[value="' + current_filter_val[ i ] + '"]').length ) {
652
- temp_filter_val.push( current_filter_val[ i ] );
653
- }
654
- me.find('option[value="' + current_filter_val[ i ] + '"]').prop('disabled', true).hide();
655
- if ( me.find('option:not(:disabled)').length === 1 ) {
656
- me.prop('disabled', true);
657
- }
658
-
659
- me.select2('destroy').select2();
660
- me.val('').trigger( 'change' );
661
- });
662
-
663
- temp_filter_val = temp_filter_val.join('||');
664
- if ( current_filter_val !== temp_filter_val ) {
665
- um_set_url_from_data( directory, 'filter_' + child_name, temp_filter_val );
666
- um_ajax_get_members( directory );
667
- }
668
- }
669
-
670
- um_change_tag( directory );
671
- }
672
-
673
- if ( data.post.members_directory !== 'yes' ) {
674
- if ( typeof data.field.default !== 'undefined' && ! me.data('um-original-value') ) {
675
- me.val( data.field.default ).trigger('change');
676
- } else if ( me.data('um-original-value') !== '' ) {
677
- me.val( me.data('um-original-value') ).trigger('change');
678
- }
679
-
680
- if ( data.field.editable == 0 ) {
681
- me.addClass('um-child-option-disabled');
682
- me.attr('disabled','disabled');
683
- }
684
- }
685
- }
686
-
687
- });
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function um_sanitize_value( value, el ) {
2
+ var element = document.createElement( 'div' );
3
+ element.innerText = value;
4
+ var sanitized_value = element.innerHTML;
5
+ if ( el ) {
6
+ jQuery( el ).val( sanitized_value );
7
+ }
8
+
9
+ return sanitized_value;
10
+ }
11
+
12
+
13
+ function um_init_datetimepicker() {
14
+ jQuery('.um-datepicker:not(.picker__input)').each(function(){
15
+ var elem = jQuery(this);
16
+
17
+ var disable = false;
18
+ if ( typeof elem.attr('data-disabled_weekdays') != 'undefined' && elem.attr('data-disabled_weekdays') !== '' ) {
19
+ disable = JSON.parse( elem.attr('data-disabled_weekdays') );
20
+ }
21
+
22
+ var years_n = null;
23
+ if ( typeof elem.attr('data-years') != 'undefined' ) {
24
+ years_n = elem.attr('data-years');
25
+ }
26
+
27
+ var minRange = elem.attr('data-date_min');
28
+ var maxRange = elem.attr('data-date_max');
29
+
30
+ var minSplit = [], maxSplit = [];
31
+ if ( typeof minRange != 'undefined' ) {
32
+ minSplit = minRange.split(",");
33
+ }
34
+ if ( typeof maxRange != 'undefined' ) {
35
+ maxSplit = maxRange.split(",");
36
+ }
37
+
38
+ var min = minSplit.length ? new Date(minSplit) : null;
39
+ var max = minSplit.length ? new Date(maxSplit) : null;
40
+
41
+ // fix min date for safari
42
+ if ( min && min.toString() == 'Invalid Date' && minSplit.length == 3 ) {
43
+ var minDateString = minSplit[1] + '/' + minSplit[2] + '/' + minSplit[0];
44
+ min = new Date(Date.parse(minDateString));
45
+ }
46
+
47
+ // fix max date for safari
48
+ if ( max && max.toString() == 'Invalid Date' && maxSplit.length == 3 ) {
49
+ var maxDateString = maxSplit[1] + '/' + maxSplit[2] + '/' + maxSplit[0];
50
+ max = new Date(Date.parse(maxDateString));
51
+ }
52
+
53
+ var data = {
54
+ disable: disable,
55
+ format: elem.attr( 'data-format' ),
56
+ formatSubmit: 'yyyy/mm/dd',
57
+ hiddenName: true,
58
+ onOpen: function() { elem.blur(); },
59
+ onClose: function() { elem.blur(); }
60
+ };
61
+
62
+ if ( years_n !== null ) {
63
+ data.selectYears = years_n;
64
+ }
65
+
66
+ if ( min !== null ) {
67
+ data.min = min;
68
+ }
69
+
70
+ if ( max !== null ) {
71
+ data.max = max;
72
+ }
73
+
74
+ elem.pickadate( data );
75
+ });
76
+
77
+ jQuery('.um-timepicker:not(.picker__input)').each(function(){
78
+ var elem = jQuery(this);
79
+
80
+ elem.pickatime({
81
+ format: elem.attr('data-format'),
82
+ interval: parseInt( elem.attr('data-intervals') ),
83
+ formatSubmit: 'HH:i',
84
+ hiddenName: true,
85
+ onOpen: function() { elem.blur(); },
86
+ onClose: function() { elem.blur(); }
87
+ });
88
+ });
89
+ }
90
+
91
+
92
+
93
+ function init_tipsy() {
94
+ if ( typeof( jQuery.fn.tipsy ) === 'function' ) {
95
+ jQuery('.um-tip-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live', offset: 3 });
96
+ jQuery('.um-tip-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live', offset: 3 });
97
+ jQuery('.um-tip-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live', offset: 3 });
98
+ jQuery('.um-tip-s').tipsy({gravity: 's', opacity: 1, live: 'a.live', offset: 3 });
99
+ }
100
+ }
101
+
102
+ jQuery(document).ready(function() {
103
+
104
+ jQuery( document.body ).on('click', '.um-dropdown a.real_url', function() {
105
+ window.location = jQuery(this).attr('href');
106
+ });
107
+
108
+ jQuery( document.body ).on( 'click', '.um-trigger-menu-on-click', function() {
109
+ var menu = jQuery(this).find('.um-dropdown');
110
+ UM.dropdown.show( menu );
111
+ return false;
112
+ });
113
+
114
+ jQuery( document.body ).on('click', '.um-dropdown-hide', function() {
115
+ UM.dropdown.hideAll();
116
+ return false;
117
+ });
118
+
119
+ jQuery( document.body ).on('click', 'a.um-manual-trigger', function() {
120
+ var child = jQuery(this).attr('data-child');
121
+ var parent = jQuery(this).attr('data-parent');
122
+ jQuery(this).parents( parent ).find( child ).trigger('click');
123
+ UM.dropdown.hideAll();
124
+ return false;
125
+ });
126
+
127
+ jQuery('.um-s1,.um-s2').css({'display':'block'});
128
+
129
+ /**
130
+ * Unselect empty option if something is selected
131
+ *
132
+ * @since 2.1.16
133
+ * @param {object} e
134
+ * @returns {undefined}
135
+ */
136
+ function unselectEmptyOption( e ) {
137
+ var $element = jQuery( e.currentTarget );
138
+ var $selected = $element.find(':selected');
139
+
140
+ if ( $selected.length > 1 ) {
141
+ $selected.each( function ( i, option ) {
142
+ if ( option.value === '' ) {
143
+ option.selected = false;
144
+ $element.trigger( 'change' );
145
+ }
146
+ });
147
+ }
148
+ }
149
+
150
+ if ( typeof( jQuery.fn.select2 ) === 'function' ) {
151
+ jQuery(".um-s1").each( function( e ) {
152
+ var obj = jQuery(this);
153
+
154
+ obj.select2({
155
+ allowClear: true,
156
+ dropdownParent: obj.parent()
157
+ }).on( 'change', unselectEmptyOption );
158
+ } );
159
+
160
+ jQuery(".um-s2").each( function( e ) {
161
+ var obj = jQuery(this);
162
+
163
+ obj.select2({
164
+ allowClear: false,
165
+ minimumResultsForSearch: 10,
166
+ dropdownParent: obj.parent()
167
+ }).on( 'change', unselectEmptyOption );
168
+ } );
169
+
170
+ jQuery(".um-s3").each( function( e ) {
171
+ var obj = jQuery(this);
172
+
173
+ obj.select2({
174
+ allowClear: false,
175
+ minimumResultsForSearch: -1,
176
+ dropdownParent: obj.parent()
177
+ }).on( 'change', unselectEmptyOption );
178
+ } );
179
+ }
180
+
181
+ init_tipsy();
182
+
183
+ if ( typeof( jQuery.fn.um_raty ) === 'function' ) {
184
+ jQuery('.um-rating').um_raty({
185
+ half: false,
186
+ starType: 'i',
187
+ number: function() {
188
+ return jQuery(this).attr('data-number');
189
+ },
190
+ score: function() {
191
+ return jQuery(this).attr('data-score');
192
+ },
193
+ scoreName: function() {
194
+ return jQuery(this).attr('data-key');
195
+ },
196
+ hints: false,
197
+ click: function( score, evt ) {
198
+ um_live_field = this.id;
199
+ um_live_value = score;
200
+ um_apply_conditions( jQuery(this), false );
201
+ }
202
+ });
203
+
204
+ jQuery('.um-rating-readonly').um_raty({
205
+ half: false,
206
+ starType: 'i',
207
+ number: function() {
208
+ return jQuery(this).attr('data-number');
209
+ },
210
+ score: function() {
211
+ return jQuery(this).attr('data-score');
212
+ },
213
+ scoreName: function() {
214
+ return jQuery(this).attr('data-key');
215
+ },
216
+ hints: false,
217
+ readOnly: true
218
+ });
219
+ }
220
+
221
+ jQuery(document).on('change', '.um-field-area input[type="radio"]', function() {
222
+ var field = jQuery(this).parents('.um-field-area');
223
+ var this_field = jQuery(this).parents('label');
224
+ field.find('.um-field-radio').removeClass('active');
225
+ field.find('.um-field-radio').find('i').removeAttr('class').addClass('um-icon-android-radio-button-off');
226
+ this_field.addClass('active');
227
+ this_field.find('i').removeAttr('class').addClass('um-icon-android-radio-button-on');
228
+ });
229
+
230
+ jQuery(document).on('change', '.um-field-area input[type="checkbox"]', function() {
231
+ var this_field = jQuery(this).parents('label');
232
+ if ( this_field.hasClass('active') ) {
233
+ this_field.removeClass('active');
234
+ this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline-blank');
235
+ } else {
236
+ this_field.addClass('active');
237
+ this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline');
238
+ }
239
+ });
240
+
241
+
242
+ um_init_datetimepicker();
243
+
244
+ jQuery(document).on('click', '.um .um-single-image-preview a.cancel', function( e ) {
245
+ e.preventDefault();
246
+ var parent = jQuery(this).parents('.um-field');
247
+
248
+ var filename = parent.find( 'input[type="hidden"]#' + parent.data('key') + '-' + jQuery(this).parents('form').find('input[type="hidden"][name="form_id"]').val() ).val();
249
+
250
+ var src = jQuery(this).parents('.um-field').find('.um-single-image-preview img').attr('src');
251
+ var mode = parent.data('mode');
252
+
253
+ var args = {
254
+ data: {
255
+ mode: mode,
256
+ filename: filename,
257
+ src: src,
258
+ nonce: um_scripts.nonce
259
+ },
260
+ success: function() {
261
+ parent.find('.um-single-image-preview img').attr( 'src', '' );
262
+ parent.find('.um-single-image-preview').hide();
263
+ parent.find('.um-btn-auto-width').html( parent.data('upload-label') );
264
+ parent.find('input[type="hidden"]').val( 'empty_file' );
265
+ }
266
+ };
267
+
268
+ if ( mode !== 'register' ) {
269
+ args.data.user_id = jQuery(this).parents('form' ).find( '#user_id' ).val();
270
+ }
271
+
272
+ wp.ajax.send( 'um_remove_file', args );
273
+
274
+ return false;
275
+ });
276
+
277
+ jQuery(document).on('click', '.um .um-single-file-preview a.cancel', function( e ) {
278
+ e.preventDefault();
279
+ var parent = jQuery(this).parents('.um-field');
280
+ var filename = parent.find( 'input[type="hidden"]#' + parent.data('key') + '-' + jQuery(this).parents('form').find('input[type="hidden"][name="form_id"]').val() ).val();
281
+ var src = jQuery(this).parents('.um-field').find('.um-single-fileinfo a').attr('href');
282
+ var mode = parent.data('mode');
283
+
284
+ var args = {
285
+ data: {
286
+ mode: mode,
287
+ filename: filename,
288
+ src: src,
289
+ nonce: um_scripts.nonce
290
+ },
291
+ success: function() {
292
+ parent.find('.um-single-file-preview').hide();
293
+ parent.find('.um-btn-auto-width').html( parent.data('upload-label') );
294
+ parent.find('input[type=hidden]').val( 'empty_file' );
295
+ }
296
+ };
297
+
298
+ if ( mode !== 'register' ) {
299
+ args.data.user_id = jQuery(this).parents('form' ).find( '#user_id' ).val();
300
+ }
301
+
302
+ wp.ajax.send( 'um_remove_file', args );
303
+
304
+ return false;
305
+ });
306
+
307
+ jQuery(document).on('click', '.um-field-group-head:not(.disabled)', function() {
308
+ var field = jQuery(this).parents('.um-field-group');
309
+ var limit = field.data('max_entries');
310
+
311
+ if ( field.find('.um-field-group-body').is(':hidden')){
312
+ field.find('.um-field-group-body').show();
313
+ } else {
314
+ field.find('.um-field-group-body:first').clone().appendTo( field );
315
+ }
316
+
317
+ var increase_id = 0;
318
+ field.find('.um-field-group-body').each(function(){
319
+ increase_id++;
320
+ jQuery(this).find('input').each(function(){
321
+ var input = jQuery(this);
322
+ input.attr('id', input.data('key') + '-' + increase_id );
323
+ input.attr('name', input.data('key') + '-' + increase_id );
324
+ input.parent().parent().find('label').attr('for', input.data('key') + '-' + increase_id );
325
+ });
326
+ });
327
+
328
+ if ( limit > 0 && field.find('.um-field-group-body').length == limit ) {
329
+
330
+ jQuery(this).addClass('disabled');
331
+
332
+ }
333
+ });
334
+
335
+ jQuery(document).on('click', '.um-field-group-cancel', function( e ) {
336
+ e.preventDefault();
337
+ var field = jQuery(this).parents('.um-field-group');
338
+
339
+ var limit = field.data('max_entries');
340
+
341
+ if ( field.find('.um-field-group-body').length > 1 ) {
342
+ jQuery(this).parents('.um-field-group-body').remove();
343
+ } else {
344
+ jQuery(this).parents('.um-field-group-body').hide();
345
+ }
346
+
347
+ if ( limit > 0 && field.find('.um-field-group-body').length < limit ) {
348
+ field.find('.um-field-group-head').removeClass('disabled');
349
+ }
350
+
351
+ return false;
352
+ });
353
+
354
+
355
+ jQuery( document.body ).on( 'click', '.um-ajax-paginate', function( e ) {
356
+ e.preventDefault();
357
+
358
+ var obj = jQuery(this);
359
+ var parent = obj.parent();
360
+ parent.addClass( 'loading' );
361
+
362
+ var pages = obj.data('pages')*1;
363
+ var next_page = obj.data('page')*1 + 1;
364
+
365
+ var hook = obj.data('hook');
366
+
367
+ if ( 'um_load_posts' === hook ) {
368
+
369
+ jQuery.ajax({
370
+ url: wp.ajax.settings.url,
371
+ type: 'post',
372
+ data: {
373
+ action: 'um_ajax_paginate_posts',
374
+ author: jQuery(this).data('author'),
375
+ page: next_page,
376
+ nonce: um_scripts.nonce
377
+ },
378
+ complete: function() {
379
+ parent.removeClass( 'loading' );
380
+ },
381
+ success: function( data ) {
382
+ parent.before( data );
383
+ if ( next_page === pages ) {
384
+ parent.remove();
385
+ } else {
386
+ obj.data( 'page', next_page );
387
+ }
388
+ }
389
+ });
390
+ } else if ( 'um_load_comments' === hook ) {
391
+
392
+ jQuery.ajax({
393
+ url: wp.ajax.settings.url,
394
+ type: 'post',
395
+ data: {
396
+ action: 'um_ajax_paginate_comments',
397
+ user_id: jQuery(this).data('user_id'),
398
+ page: next_page,
399
+ nonce: um_scripts.nonce
400
+ },
401
+ complete: function() {
402
+ parent.removeClass( 'loading' );
403
+ },
404
+ success: function( data ) {
405
+ parent.before( data );
406
+ if ( next_page === pages ) {
407
+ parent.remove();
408
+ } else {
409
+ obj.data( 'page', next_page );
410
+ }
411
+ }
412
+ });
413
+ } else {
414
+ var args = jQuery(this).data('args');
415
+ var container = jQuery(this).parents('.um').find('.um-ajax-items');
416
+
417
+ jQuery.ajax({
418
+ url: wp.ajax.settings.url,
419
+ type: 'post',
420
+ data: {
421
+ action: 'um_ajax_paginate',
422
+ hook: hook,
423
+ args: args,
424
+ nonce: um_scripts.nonce
425
+ },
426
+ complete: function() {
427
+ parent.removeClass( 'loading' );
428
+ },
429
+ success: function(data){
430
+ parent.remove();
431
+ container.append( data );
432
+ }
433
+ });
434
+ }
435
+ });
436
+
437
+
438
+ jQuery(document).on('click', '.um-ajax-action', function( e ) {
439
+ e.preventDefault();
440
+ var hook = jQuery(this).data('hook');
441
+ var user_id = jQuery(this).data('user_id');
442
+ var arguments = jQuery(this).data('arguments');
443
+
444
+ if ( jQuery(this).data('js-remove') ){
445
+ jQuery(this).parents('.'+jQuery(this).data('js-remove')).fadeOut('fast');
446
+ }
447
+
448
+ jQuery.ajax({
449
+ url: wp.ajax.settings.url,
450
+ type: 'post',
451
+ data: {
452
+ action: 'um_muted_action',
453
+ hook: hook,
454
+ user_id: user_id,
455
+ arguments: arguments,
456
+ nonce: um_scripts.nonce
457
+ },
458
+ success: function(data){
459
+
460
+ }
461
+ });
462
+ return false;
463
+ });
464
+
465
+ jQuery( document.body ).on('click', '#um-search-button', function() {
466
+ var action = jQuery(this).parents('.um-search-form').data('members_page');
467
+
468
+ var search_keys = [];
469
+ jQuery(this).parents('.um-search-form').find('input[name="um-search-keys[]"]').each( function() {
470
+ search_keys.push( jQuery(this).val() );
471
+ });
472
+
473
+ var search = jQuery(this).parents('.um-search-form').find('.um-search-field').val();
474
+
475
+ var url;
476
+ if ( search === '' ) {
477
+ url = action;
478
+ } else {
479
+ var query = '?';
480
+ for ( var i = 0; i < search_keys.length; i++ ) {
481
+ query += search_keys[i] + '=' + search;
482
+ if ( i !== search_keys.length - 1 ) {
483
+ query += '&';
484
+ }
485
+ }
486
+
487
+ url = action + query;
488
+ }
489
+ window.location = url;
490
+ });
491
+
492
+ //make search on Enter click
493
+ jQuery( document.body ).on( 'keypress', '.um-search-field', function(e) {
494
+ if ( e.which === 13 ) {
495
+ var action = jQuery(this).parents('.um-search-form').data('members_page');
496
+
497
+ var search_keys = [];
498
+ jQuery(this).parents('.um-search-form').find('input[name="um-search-keys[]"]').each( function() {
499
+ search_keys.push( jQuery(this).val() );
500
+ });
501
+
502
+ var search = jQuery(this).val();
503
+
504
+ var url;
505
+ if ( search === '' ) {
506
+ url = action;
507
+ } else {
508
+ var query = '?';
509
+ for ( var i = 0; i < search_keys.length; i++ ) {
510
+ query += search_keys[i] + '=' + search;
511
+ if ( i !== search_keys.length - 1 ) {
512
+ query += '&';
513
+ }
514
+ }
515
+
516
+ url = action + query;
517
+ }
518
+ window.location = url;
519
+ }
520
+ });
521
+
522
+ jQuery('.um-form input[class="um-button"][type="submit"]').prop('disabled', false);
523
+
524
+ jQuery(document).one('click', '.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)', function() {
525
+ jQuery(this).attr('disabled','disabled');
526
+ jQuery(this).parents('form').trigger('submit');
527
+ });
528
+
529
+
530
+ var um_select_options_cache = {};
531
+
532
+ /**
533
+ * Find all select fields with parent select fields
534
+ */
535
+ jQuery('select[data-um-parent]').each( function() {
536
+
537
+ var me = jQuery(this);
538
+ var parent_option = me.data('um-parent');
539
+ var um_ajax_source = me.data('um-ajax-source');
540
+
541
+ me.attr('data-um-init-field', true );
542
+
543
+ jQuery(document).on('change','select[name="' + parent_option + '"]',function() {
544
+ var parent = jQuery(this);
545
+ var form_id = parent.closest( 'form' ).find( 'input[type="hidden"][name="form_id"]' ).val();
546
+
547
+ var arr_key;
548
+ if ( me.attr( 'data-member-directory' ) === 'yes' ) {
549
+ var directory = parent.parents('.um-directory');
550
+ arr_key = um_get_data_for_directory( directory, 'filter_' + parent_option );
551
+ if ( typeof arr_key != 'undefined' ) {
552
+ arr_key = arr_key.split('||');
553
+ } else {
554
+ arr_key = '';
555
+ }
556
+ } else {
557
+ arr_key = parent.val();
558
+ }
559
+
560
+ if ( typeof arr_key != 'undefined' && arr_key !== '' && typeof um_select_options_cache[ arr_key ] !== 'object' ) {
561
+
562
+ if ( typeof( me.um_wait ) === 'undefined' || me.um_wait === false ) {
563
+ me.um_wait = true;
564
+ } else {
565
+ return;
566
+ }
567
+
568
+ jQuery.ajax({
569
+ url: wp.ajax.settings.url,
570
+ type: 'post',
571
+ data: {
572
+ action: 'um_select_options',
573
+ parent_option_name: parent_option,
574
+ parent_option: arr_key,
575
+ child_callback: um_ajax_source,
576
+ child_name: me.attr('name'),
577
+ members_directory: me.attr('data-member-directory'),
578
+ form_id: form_id,
579
+ nonce: um_scripts.nonce
580
+ },
581
+ success: function( data ) {
582
+ if ( data.status === 'success' && arr_key !== '' ) {
583
+ um_select_options_cache[ arr_key ] = data;
584
+ um_field_populate_child_options( me, data, arr_key );
585
+ }
586
+
587
+ if ( typeof data.debug !== 'undefined' ) {
588
+ console.log( data );
589
+ }
590
+
591
+ me.um_wait = false;
592
+ },
593
+ error: function( e ) {
594
+ console.log( e );
595
+ me.um_wait = false;
596
+ }
597
+ });
598
+
599
+ }
600
+
601
+ if ( typeof arr_key != 'undefined' && arr_key !== '' && typeof um_select_options_cache[ arr_key ] == 'object' ) {
602
+ setTimeout( um_field_populate_child_options, 10, me, um_select_options_cache[ arr_key ], arr_key );
603
+ }
604
+
605
+ if ( typeof arr_key != 'undefined' || arr_key === '' ) {
606
+ me.find('option[value!=""]').remove();
607
+ me.val('').trigger('change');
608
+ }
609
+
610
+ });
611
+
612
+ jQuery('select[name="' + parent_option + '"]').trigger('change');
613
+
614
+ });
615
+
616
+
617
+ /**
618
+ * Populates child options and cache ajax response
619
+ *
620
+ * @param me
621
+ * @param data
622
+ * @param arr_key
623
+ */
624
+ function um_field_populate_child_options( me, data, arr_key ) {
625
+ var directory = me.parents('.um-directory');
626
+ var child_name = me.attr('name');
627
+ me.find('option[value!=""]').remove();
628
+
629
+ if ( ! me.hasClass('um-child-option-disabled') ) {
630
+ me.prop('disabled', false);
631
+ }
632
+
633
+ var arr_items = [],
634
+ search_get = '';
635
+
636
+ if ( data.post.members_directory === 'yes' ) {
637
+ arr_items.push({id: '', text: '', selected: 1});
638
+ }
639
+ jQuery.each( data.items, function(k,v){
640
+ arr_items.push({id: k, text: v, selected: (v === search_get)});
641
+ });
642
+
643
+ me.select2('destroy');
644
+ me.select2({
645
+ data: arr_items,
646
+ allowClear: true,
647
+ minimumResultsForSearch: 10
648
+ });
649
+
650
+ if ( data.post.members_directory === 'yes' ) {
651
+ me.find('option').each( function() {
652
+ if ( jQuery(this).html() !== '' ) {
653
+ jQuery(this).data( 'value_label', jQuery(this).html() ).attr( 'data-value_label', jQuery(this).html() );
654
+ }
655
+ });
656
+
657
+ var current_filter_val = um_get_data_for_directory( directory, 'filter_' + child_name );
658
+ if ( typeof current_filter_val !== 'undefined' ) {
659
+ current_filter_val = current_filter_val.split('||');
660
+
661
+ var temp_filter_val = [];
662
+ jQuery.each( current_filter_val, function(i) {
663
+ if ( me.find('option[value="' + current_filter_val[ i ] + '"]').length ) {
664
+ temp_filter_val.push( current_filter_val[ i ] );
665
+ }
666
+ me.find('option[value="' + current_filter_val[ i ] + '"]').prop('disabled', true).hide();
667
+ if ( me.find('option:not(:disabled)').length === 1 ) {
668
+ me.prop('disabled', true);
669
+ }
670
+
671
+ me.select2('destroy').select2();
672
+ me.val('').trigger( 'change' );
673
+ });
674
+
675
+ temp_filter_val = temp_filter_val.join('||');
676
+ if ( current_filter_val !== temp_filter_val ) {
677
+ um_set_url_from_data( directory, 'filter_' + child_name, temp_filter_val );
678
+ um_ajax_get_members( directory );
679
+ }
680
+ }
681
+
682
+ um_change_tag( directory );
683
+ }
684
+
685
+ if ( data.post.members_directory !== 'yes' ) {
686
+ if ( typeof data.field.default !== 'undefined' && ! me.data('um-original-value') ) {
687
+ me.val( data.field.default ).trigger('change');
688
+ } else if ( me.data('um-original-value') !== '' ) {
689
+ me.val( me.data('um-original-value') ).trigger('change');
690
+ }
691
+
692
+ if ( data.field.editable == 0 ) {
693
+ me.addClass('um-child-option-disabled');
694
+ me.attr('disabled','disabled');
695
+ }
696
+ }
697
+ }
698
+
699
+ });
assets/js/um-scripts.min.js CHANGED
@@ -1 +1 @@
1
- function um_init_datetimepicker(){jQuery(".um-datepicker:not(.picker__input)").each(function(){var e=jQuery(this),t=!1;void 0!==e.attr("data-disabled_weekdays")&&""!==e.attr("data-disabled_weekdays")&&(t=JSON.parse(e.attr("data-disabled_weekdays")));var a=null;void 0!==e.attr("data-years")&&(a=e.attr("data-years"));var i=e.attr("data-date_min"),r=e.attr("data-date_max"),n=[],u=[];void 0!==i&&(n=i.split(",")),void 0!==r&&(u=r.split(","));var o=n.length?new Date(n):null,d=n.length?new Date(u):null;if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}if(d&&"Invalid Date"==d.toString()&&3==u.length){var l=u[1]+"/"+u[2]+"/"+u[0];d=new Date(Date.parse(l))}var c={disable:t,format:e.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}};null!==a&&(c.selectYears=a),null!==o&&(c.min=o),null!==d&&(c.max=d),e.pickadate(c)}),jQuery(".um-timepicker:not(.picker__input)").each(function(){var e=jQuery(this);e.pickatime({format:e.attr("data-format"),interval:parseInt(e.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}})})}function init_tipsy(){"function"==typeof jQuery.fn.tipsy&&(jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}))}jQuery(document).ready(function(){function a(e){var a=jQuery(e.currentTarget),t=a.find(":selected");1<t.length&&t.each(function(e,t){""===t.value&&(t.selected=!1,a.trigger("change"))})}jQuery(document.body).on("click",".um-dropdown a.real_url",function(){window.location=jQuery(this).attr("href")}),jQuery(document.body).on("click",".um-trigger-menu-on-click",function(){var e=jQuery(this).find(".um-dropdown");return UM.dropdown.show(e),!1}),jQuery(document.body).on("click",".um-dropdown-hide",function(){return UM.dropdown.hideAll(),!1}),jQuery(document.body).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");return jQuery(this).parents(t).find(e).trigger("click"),UM.dropdown.hideAll(),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),"function"==typeof jQuery.fn.select2&&(jQuery(".um-s1").each(function(e){var t=jQuery(this);t.select2({allowClear:!0,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s2").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:10,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s3").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:-1,dropdownParent:t.parent()}).on("change",a)})),init_tipsy(),"function"==typeof jQuery.fn.um_raty&&(jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){um_live_field=this.id,um_live_value=e,um_apply_conditions(jQuery(this),!1)}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0})),jQuery(document).on("change",'.um-field-area input[type="radio"]',function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",'.um-field-area input[type="checkbox"]',function(){var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),um_init_datetimepicker(),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e);var a=0;e.find(".um-field-group-body").each(function(){a++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+a),e.attr("name",e.data("key")+"-"+a),e.parent().parent().find("label").attr("for",e.data("key")+"-"+a)})}),0<t&&e.find(".um-field-group-body").length==t&&jQuery(this).addClass("disabled")}),jQuery(document).on("click",".um-field-group-cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field-group"),a=t.data("max_entries");return 1<t.find(".um-field-group-body").length?jQuery(this).parents(".um-field-group-body").remove():jQuery(this).parents(".um-field-group-body").hide(),0<a&&t.find(".um-field-group-body").length<a&&t.find(".um-field-group-head").removeClass("disabled"),!1}),jQuery(document.body).on("click",".um-ajax-paginate",function(e){e.preventDefault();var t=jQuery(this),a=t.parent();a.addClass("loading");var i=1*t.data("pages"),r=1*t.data("page")+1,n=t.data("hook");if("um_load_posts"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_posts",author:jQuery(this).data("author"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else if("um_load_comments"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_comments",user_id:jQuery(this).data("user_id"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else{var u=jQuery(this).data("args"),o=jQuery(this).parents(".um").find(".um-ajax-items");jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate",hook:n,args:u,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.remove(),o.append(e)}})}}),jQuery(document).on("click",".um-ajax-action",function(e){e.preventDefault();var t=jQuery(this).data("hook"),a=jQuery(this).data("user_id"),arguments=jQuery(this).data("arguments");return jQuery(this).data("js-remove")&&jQuery(this).parents("."+jQuery(this).data("js-remove")).fadeOut("fast"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_muted_action",hook:t,user_id:a,arguments:arguments,nonce:um_scripts.nonce},success:function(e){}}),!1}),jQuery(document.body).on("click","#um-search-button",function(){var e=jQuery(this).parents(".um-search-form").data("members_page"),t=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){t.push(jQuery(this).val())});var a,i=jQuery(this).parents(".um-search-form").find(".um-search-field").val();if(""===i)a=e;else{for(var r="?",n=0;n<t.length;n++)r+=t[n]+"="+i,n!==t.length-1&&(r+="&");a=e+r}window.location=a}),jQuery(document.body).on("keypress",".um-search-field",function(e){if(13===e.which){var t=jQuery(this).parents(".um-search-form").data("members_page"),a=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){a.push(jQuery(this).val())});var i,r=jQuery(this).val();if(""===r)i=t;else{for(var n="?",u=0;u<a.length;u++)n+=a[u]+"="+r,u!==a.length-1&&(n+="&");i=t+n}window.location=i}}),jQuery('.um-form input[class="um-button"][type="submit"]').prop("disabled",!1),jQuery(document).one("click",'.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)',function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parents("form").trigger("submit")});var o={};function d(t,e,a){var i=t.parents(".um-directory"),r=t.attr("name");t.find('option[value!=""]').remove(),t.hasClass("um-child-option-disabled")||t.prop("disabled",!1);var n=[];if("yes"===e.post.members_directory&&n.push({id:"",text:"",selected:1}),jQuery.each(e.items,function(e,t){n.push({id:e,text:t,selected:""===t})}),t.select2("destroy"),t.select2({data:n,allowClear:!0,minimumResultsForSearch:10}),"yes"===e.post.members_directory){t.find("option").each(function(){""!==jQuery(this).html()&&jQuery(this).data("value_label",jQuery(this).html()).attr("data-value_label",jQuery(this).html())});var u=um_get_data_for_directory(i,"filter_"+r);if(void 0!==u){u=u.split("||");var o=[];jQuery.each(u,function(e){t.find('option[value="'+u[e]+'"]').length&&o.push(u[e]),t.find('option[value="'+u[e]+'"]').prop("disabled",!0).hide(),1===t.find("option:not(:disabled)").length&&t.prop("disabled",!0),t.select2("destroy").select2(),t.val("").trigger("change")}),o=o.join("||"),u!==o&&(um_set_url_from_data(i,"filter_"+r,o),um_ajax_get_members(i))}um_change_tag(i)}"yes"!==e.post.members_directory&&(void 0===e.field.default||t.data("um-original-value")?""!==t.data("um-original-value")&&t.val(t.data("um-original-value")).trigger("change"):t.val(e.field.default).trigger("change"),0==e.field.editable&&(t.addClass("um-child-option-disabled"),t.attr("disabled","disabled")))}jQuery("select[data-um-parent]").each(function(){var r=jQuery(this),n=r.data("um-parent"),u=r.data("um-ajax-source");r.attr("data-um-init-field",!0),jQuery(document).on("change",'select[name="'+n+'"]',function(){var t,e=jQuery(this),a=e.closest("form").find('input[type="hidden"][name="form_id"]').val();if("yes"===r.attr("data-member-directory")){var i=e.parents(".um-directory");t=void 0!==(t=um_get_data_for_directory(i,"filter_"+n))?t.split("||"):""}else t=e.val();if(void 0!==t&&""!==t&&"object"!=typeof o[t]){if(void 0!==r.um_wait&&!1!==r.um_wait)return;r.um_wait=!0,jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_select_options",parent_option_name:n,parent_option:t,child_callback:u,child_name:r.attr("name"),members_directory:r.attr("data-member-directory"),form_id:a,nonce:um_scripts.nonce},success:function(e){"success"===e.status&&""!==t&&(o[t]=e,d(r,e,t)),void 0!==e.debug&&console.log(e),r.um_wait=!1},error:function(e){console.log(e),r.um_wait=!1}})}void 0!==t&&""!==t&&"object"==typeof o[t]&&setTimeout(d,10,r,o[t],t),void 0===t&&""!==t||(r.find('option[value!=""]').remove(),r.val("").trigger("change"))}),jQuery('select[name="'+n+'"]').trigger("change")})});
1
+ function um_sanitize_value(e,t){var a=document.createElement("div");a.innerText=e;var i=a.innerHTML;return t&&jQuery(t).val(i),i}function um_init_datetimepicker(){jQuery(".um-datepicker:not(.picker__input)").each(function(){var e=jQuery(this),t=!1;void 0!==e.attr("data-disabled_weekdays")&&""!==e.attr("data-disabled_weekdays")&&(t=JSON.parse(e.attr("data-disabled_weekdays")));var a=null;void 0!==e.attr("data-years")&&(a=e.attr("data-years"));var i=e.attr("data-date_min"),r=e.attr("data-date_max"),n=[],u=[];void 0!==i&&(n=i.split(",")),void 0!==r&&(u=r.split(","));var o=n.length?new Date(n):null,d=n.length?new Date(u):null;if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}if(d&&"Invalid Date"==d.toString()&&3==u.length){var l=u[1]+"/"+u[2]+"/"+u[0];d=new Date(Date.parse(l))}var c={disable:t,format:e.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}};null!==a&&(c.selectYears=a),null!==o&&(c.min=o),null!==d&&(c.max=d),e.pickadate(c)}),jQuery(".um-timepicker:not(.picker__input)").each(function(){var e=jQuery(this);e.pickatime({format:e.attr("data-format"),interval:parseInt(e.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}})})}function init_tipsy(){"function"==typeof jQuery.fn.tipsy&&(jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}))}jQuery(document).ready(function(){function a(e){var a=jQuery(e.currentTarget),t=a.find(":selected");1<t.length&&t.each(function(e,t){""===t.value&&(t.selected=!1,a.trigger("change"))})}jQuery(document.body).on("click",".um-dropdown a.real_url",function(){window.location=jQuery(this).attr("href")}),jQuery(document.body).on("click",".um-trigger-menu-on-click",function(){var e=jQuery(this).find(".um-dropdown");return UM.dropdown.show(e),!1}),jQuery(document.body).on("click",".um-dropdown-hide",function(){return UM.dropdown.hideAll(),!1}),jQuery(document.body).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");return jQuery(this).parents(t).find(e).trigger("click"),UM.dropdown.hideAll(),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),"function"==typeof jQuery.fn.select2&&(jQuery(".um-s1").each(function(e){var t=jQuery(this);t.select2({allowClear:!0,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s2").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:10,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s3").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:-1,dropdownParent:t.parent()}).on("change",a)})),init_tipsy(),"function"==typeof jQuery.fn.um_raty&&(jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){um_live_field=this.id,um_live_value=e,um_apply_conditions(jQuery(this),!1)}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0})),jQuery(document).on("change",'.um-field-area input[type="radio"]',function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",'.um-field-area input[type="checkbox"]',function(){var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),um_init_datetimepicker(),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find('input[type="hidden"]').val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e);var a=0;e.find(".um-field-group-body").each(function(){a++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+a),e.attr("name",e.data("key")+"-"+a),e.parent().parent().find("label").attr("for",e.data("key")+"-"+a)})}),0<t&&e.find(".um-field-group-body").length==t&&jQuery(this).addClass("disabled")}),jQuery(document).on("click",".um-field-group-cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field-group"),a=t.data("max_entries");return 1<t.find(".um-field-group-body").length?jQuery(this).parents(".um-field-group-body").remove():jQuery(this).parents(".um-field-group-body").hide(),0<a&&t.find(".um-field-group-body").length<a&&t.find(".um-field-group-head").removeClass("disabled"),!1}),jQuery(document.body).on("click",".um-ajax-paginate",function(e){e.preventDefault();var t=jQuery(this),a=t.parent();a.addClass("loading");var i=1*t.data("pages"),r=1*t.data("page")+1,n=t.data("hook");if("um_load_posts"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_posts",author:jQuery(this).data("author"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else if("um_load_comments"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_comments",user_id:jQuery(this).data("user_id"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else{var u=jQuery(this).data("args"),o=jQuery(this).parents(".um").find(".um-ajax-items");jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate",hook:n,args:u,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.remove(),o.append(e)}})}}),jQuery(document).on("click",".um-ajax-action",function(e){e.preventDefault();var t=jQuery(this).data("hook"),a=jQuery(this).data("user_id"),arguments=jQuery(this).data("arguments");return jQuery(this).data("js-remove")&&jQuery(this).parents("."+jQuery(this).data("js-remove")).fadeOut("fast"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_muted_action",hook:t,user_id:a,arguments:arguments,nonce:um_scripts.nonce},success:function(e){}}),!1}),jQuery(document.body).on("click","#um-search-button",function(){var e=jQuery(this).parents(".um-search-form").data("members_page"),t=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){t.push(jQuery(this).val())});var a,i=jQuery(this).parents(".um-search-form").find(".um-search-field").val();if(""===i)a=e;else{for(var r="?",n=0;n<t.length;n++)r+=t[n]+"="+i,n!==t.length-1&&(r+="&");a=e+r}window.location=a}),jQuery(document.body).on("keypress",".um-search-field",function(e){if(13===e.which){var t=jQuery(this).parents(".um-search-form").data("members_page"),a=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){a.push(jQuery(this).val())});var i,r=jQuery(this).val();if(""===r)i=t;else{for(var n="?",u=0;u<a.length;u++)n+=a[u]+"="+r,u!==a.length-1&&(n+="&");i=t+n}window.location=i}}),jQuery('.um-form input[class="um-button"][type="submit"]').prop("disabled",!1),jQuery(document).one("click",'.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)',function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parents("form").trigger("submit")});var o={};function d(t,e,a){var i=t.parents(".um-directory"),r=t.attr("name");t.find('option[value!=""]').remove(),t.hasClass("um-child-option-disabled")||t.prop("disabled",!1);var n=[];if("yes"===e.post.members_directory&&n.push({id:"",text:"",selected:1}),jQuery.each(e.items,function(e,t){n.push({id:e,text:t,selected:""===t})}),t.select2("destroy"),t.select2({data:n,allowClear:!0,minimumResultsForSearch:10}),"yes"===e.post.members_directory){t.find("option").each(function(){""!==jQuery(this).html()&&jQuery(this).data("value_label",jQuery(this).html()).attr("data-value_label",jQuery(this).html())});var u=um_get_data_for_directory(i,"filter_"+r);if(void 0!==u){u=u.split("||");var o=[];jQuery.each(u,function(e){t.find('option[value="'+u[e]+'"]').length&&o.push(u[e]),t.find('option[value="'+u[e]+'"]').prop("disabled",!0).hide(),1===t.find("option:not(:disabled)").length&&t.prop("disabled",!0),t.select2("destroy").select2(),t.val("").trigger("change")}),o=o.join("||"),u!==o&&(um_set_url_from_data(i,"filter_"+r,o),um_ajax_get_members(i))}um_change_tag(i)}"yes"!==e.post.members_directory&&(void 0===e.field.default||t.data("um-original-value")?""!==t.data("um-original-value")&&t.val(t.data("um-original-value")).trigger("change"):t.val(e.field.default).trigger("change"),0==e.field.editable&&(t.addClass("um-child-option-disabled"),t.attr("disabled","disabled")))}jQuery("select[data-um-parent]").each(function(){var r=jQuery(this),n=r.data("um-parent"),u=r.data("um-ajax-source");r.attr("data-um-init-field",!0),jQuery(document).on("change",'select[name="'+n+'"]',function(){var t,e=jQuery(this),a=e.closest("form").find('input[type="hidden"][name="form_id"]').val();if("yes"===r.attr("data-member-directory")){var i=e.parents(".um-directory");t=void 0!==(t=um_get_data_for_directory(i,"filter_"+n))?t.split("||"):""}else t=e.val();if(void 0!==t&&""!==t&&"object"!=typeof o[t]){if(void 0!==r.um_wait&&!1!==r.um_wait)return;r.um_wait=!0,jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_select_options",parent_option_name:n,parent_option:t,child_callback:u,child_name:r.attr("name"),members_directory:r.attr("data-member-directory"),form_id:a,nonce:um_scripts.nonce},success:function(e){"success"===e.status&&""!==t&&(o[t]=e,d(r,e,t)),void 0!==e.debug&&console.log(e),r.um_wait=!1},error:function(e){console.log(e),r.um_wait=!1}})}void 0!==t&&""!==t&&"object"==typeof o[t]&&setTimeout(d,10,r,o[t],t),void 0===t&&""!==t||(r.find('option[value!=""]').remove(),r.val("").trigger("change"))}),jQuery('select[name="'+n+'"]').trigger("change")})});
includes/admin/assets/css/um-admin-forms.css CHANGED
@@ -1,400 +1,404 @@
1
- .um-form-table.um-third-column .um-forms-line th {
2
- width: 33%;
3
- }
4
-
5
- .um-form-table.um-half-column .um-forms-line th {
6
- width: 50%;
7
- }
8
-
9
- .um-form-table.um-two-thirds-column .um-forms-line th {
10
- width: 83%;
11
- }
12
-
13
- .um-form-table.um-top-label .um-forms-line td {
14
- padding: 0 0 15px 0;
15
- }
16
-
17
- .um-form-table.um-top-label .um-forms-line td label {
18
- margin: 0 0 5px 0;
19
- display: inline-block;
20
- }
21
-
22
- .um-form-table.um-top-label .um-forms-line[data-field_type="icon"] td label {
23
- width: 100%;
24
- display: block;
25
- margin: 0 0 5px 0;
26
- }
27
-
28
- .um_admin_fonticon_wrapper {
29
- display: flex;
30
- flex-direction: row;
31
- flex-wrap: nowrap;
32
- justify-content: flex-start;
33
- align-items: center;
34
- }
35
-
36
- .um-admin-icon-value {
37
- line-height: 1;
38
- }
39
-
40
- .um_admin_fonticon_wrapper .um-admin-icon-value i {
41
- top: 0;
42
- }
43
-
44
- input[type=text].um-forms-field.um-long-field,
45
- select.um-forms-field.um-long-field,
46
- textarea.um-forms-field.um-long-field {
47
- width:100% !important;
48
- }
49
-
50
- input[type=text].um-forms-field.um-medium-field,
51
- select.um-forms-field.um-medium-field,
52
- textarea.um-forms-field.um-medium-field {
53
- width:50% !important;
54
- }
55
-
56
- input[type=text].um-forms-field.um-small-field,
57
- select.um-forms-field.um-small-field,
58
- textarea.um-forms-field.um-small-field {
59
- width:25% !important;
60
- }
61
-
62
-
63
-
64
- .um-multi-text-list,
65
- .um-multi-selects-list,
66
- .um-md-default-filters-list {
67
- float: left;
68
- width:100%;
69
- margin: 0 0 10px 0;
70
- }
71
-
72
- .um-hidden-multi-text,
73
- .um-hidden-multi-selects,
74
- .um-hidden-md-default-filters {
75
- display: none !important;
76
- }
77
-
78
- .um-multi-text-option-line,
79
- .um-multi-selects-option-line,
80
- .um-md-default-filters-option-line {
81
- float:left;
82
- width:100%;
83
- margin: 0;
84
- padding: 0;
85
- clear:both;
86
- }
87
-
88
- .um-md-default-filters-option-line {
89
- border-bottom: 1px solid #eee;
90
- padding: 0 0 5px 0;
91
- margin: 5px 0 0 0;
92
- }
93
-
94
- .um-md-default-filters-option-line .um.um-field-wrapper2 {
95
- margin: 5px 0 0 0;
96
- }
97
-
98
- .um-multi-selects-option-line.um-admin-drag-fld {
99
- background: none;
100
- border: none;
101
- display: flex;
102
- flex-direction: row;
103
- justify-content: flex-start;
104
- align-items: center;
105
- flex-wrap: nowrap;
106
- }
107
-
108
- .um-multi-selects-option-line.um-admin-drag-fld .um-field-icon {
109
- float: left;
110
- width: 20px;
111
- text-align: left;
112
- line-height: 30px;
113
- }
114
-
115
- .um-multi-selects-option-line .um-field-wrapper {
116
- float:left;
117
- width: calc( 100% - 60px );
118
- line-height: 30px;
119
- box-sizing: border-box;
120
- }
121
-
122
- .um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields {
123
- margin: 5px 0 0 0;
124
- }
125
-
126
- .um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label {
127
- float:left;
128
- width: 100%;
129
- line-height: 30px;
130
- box-sizing: border-box;
131
- margin: 0 !important;
132
- padding: 0 !important;
133
- font-weight: bold;
134
- display: flex;
135
- flex-direction: row;
136
- flex-wrap: nowrap;
137
- justify-content: space-between;
138
- align-items: baseline;
139
- }
140
-
141
- .um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label input[type="text"] {
142
- width: auto;
143
- display: inline;
144
- font-weight: normal;
145
- max-width: 70%;
146
- flex: 0.9;
147
- }
148
-
149
- .um-multi-selects-option-line.um-admin-drag-fld .um-field-wrapper {
150
- width: calc( 100% - 90px );
151
- }
152
-
153
- .um-multi-text-option-line .um-field-wrapper {
154
- float:left;
155
- width: calc( 100% - 90px );
156
- line-height: 30px;
157
- box-sizing: border-box;
158
- }
159
-
160
- .um-md-default-filters-option-line .um-field-wrapper {
161
- float:left;
162
- width: calc( 100% - 60px );
163
- line-height: 30px;
164
- box-sizing: border-box;
165
- }
166
-
167
- .um-md-default-filters-option-line .um-field-wrapper2 {
168
- float:left;
169
- width: calc( 100% - 60px );
170
- line-height: 30px;
171
- box-sizing: border-box;
172
- }
173
-
174
- .um-md-default-filters-option-line .um-field-wrapper2 .ui-slider-range.ui-widget-header {
175
- background: #44b0ec;
176
- border: 1px solid #44b0ec !important;
177
- margin-top: -1px;
178
- }
179
-
180
- .um-md-default-filters-option-line .um-field-wrapper2 select {
181
- width: 100%;
182
- float: left;
183
- }
184
-
185
- .um-md-default-filters-option-line .um-field-wrapper2 input {
186
- width: 100%;
187
- float: left;
188
- }
189
-
190
- .um-md-default-filters-option-line .um-field-wrapper2 input.um-timepicker-filter,
191
- .um-md-default-filters-option-line .um-field-wrapper2 input.um-datepicker-filter {
192
- width: calc( 50% - 7px ) !important;
193
- float: left;
194
- }
195
-
196
- .um-md-default-filters-option-line .um-field-wrapper2 .um-slider {
197
- margin: 5px 9px 0 9px;
198
- width: calc( 100% - 18px );
199
- box-sizing: border-box;
200
- display: block;
201
- }
202
-
203
- .um-md-default-filters-option-line .um-field-wrapper2 input.um-timepicker-filter:first-child,
204
- .um-md-default-filters-option-line .um-field-wrapper2 input.um-datepicker-filter:first-child {
205
- margin-right: 11px;
206
- }
207
-
208
- .um-multi-text-option-line .um-field-wrapper input,
209
- .um-multi-selects-option-line .um-field-wrapper select {
210
- float:left;
211
- width: 100%;
212
- margin:0;
213
- }
214
-
215
-
216
- .um-multi-text-option-line .um-field-control,
217
- .um-multi-selects-option-line .um-field-control,
218
- .um-md-default-filters-option-line .um-field-control {
219
- float:left;
220
- width: 60px;
221
- line-height: 30px;
222
- padding: 0 10px;
223
- box-sizing: border-box;
224
- }
225
-
226
- .um-form-table .description {
227
- font-style: italic;
228
- }
229
-
230
-
231
- .um-form-fields-section {
232
- float:left;
233
- clear: none;
234
- margin:0;
235
- padding: 0 10px 0 0;
236
- box-sizing: border-box;
237
- -moz-box-sizing: border-box;
238
- -webkit-box-sizing: border-box;
239
- }
240
-
241
- .um-form-fields-section label {
242
- float:left;
243
- width:100%;
244
- margin:0;
245
- padding:0;
246
- }
247
-
248
- .um-form-fields-section label input {
249
- float:left;
250
- margin-top:0;
251
- }
252
-
253
- .um-form-fields-section label span {
254
- float:left;
255
- width:calc( 100% - 20px );
256
- }
257
-
258
- .um-multi-text-option-line,
259
- .um-multi-selects-option-line {
260
- margin: 0 0 5px 0;
261
- }
262
-
263
- @media screen and (max-width: 782px) {
264
- .um-form-fields-section {
265
- width:100% !important;
266
- }
267
- .um-admin-metabox .um-form-fields-section label {
268
- line-height: 22px !important;
269
- margin: 0 0 12px 0 !important;
270
- }
271
- .um-form-fields-section label span {
272
- width:calc( 100% - 30px );
273
- }
274
-
275
- .um-multi-text-option-line,
276
- .um-multi-selects-option-line {
277
- margin: 0 0 6px 0;
278
- }
279
-
280
- .um-forms-line label {
281
- float:left;
282
- width:100%;
283
- }
284
-
285
-
286
- .um-form-table.um-third-column .um-forms-line th,
287
- .um-form-table.um-half-column .um-forms-line th,
288
- .um-form-table.um-two-thirds-column .um-forms-line th {
289
- float:left;
290
- width: 100%;
291
- }
292
-
293
- .um-form-table.um-third-column .um-forms-line td,
294
- .um-form-table.um-half-column .um-forms-line td,
295
- .um-form-table.um-two-thirds-column .um-forms-line td {
296
- float:left;
297
- width: 100%;
298
- }
299
-
300
- .um-form-table.um-third-column .um-forms-line th label,
301
- .um-form-table.um-half-column .um-forms-line th label,
302
- .um-form-table.um-two-thirds-column .um-forms-line th label {
303
- float:left;
304
- width: 100%;
305
- }
306
- }
307
-
308
-
309
- /*Multi text filed */
310
- .um-forms-line .um-text-delete {
311
- color: #a00;
312
- float:left;
313
- }
314
-
315
- .um-forms-line .um-text-delete:hover {
316
- color: red;
317
- }
318
-
319
- .um-forms-line .um-multi-text-add-option {
320
- margin-bottom: 14px;
321
- }
322
-
323
-
324
- /* Media uploader */
325
- .um-forms-line .icon_preview {
326
- display: none;
327
- max-width: 200px;
328
- max-height: 200px;
329
- padding: 5px;
330
- cursor: pointer;
331
- border: 1px solid #e3e3e3;
332
- background: #f7f7f7;
333
- border-radius: 3px;
334
- height: auto;
335
- width: auto !important;
336
- }
337
-
338
-
339
- .um-forms-line[data-conditional] {
340
- display: none;
341
- }
342
-
343
-
344
-
345
- /* Same page update field */
346
- .um-forms-line td .um-same-page-update-wrapper {
347
- display: none;
348
- margin: 7px 0 0 0;
349
- }
350
-
351
- .um-forms-line td .um-same-page-update-wrapper input.um-admin-form-same-page-update {
352
- margin: 7px 0 0 0;
353
- }
354
-
355
- .um-forms-line td .um-same-page-update-wrapper .upgrade_log {
356
- margin: 7px 0 0 0;
357
- width:100%;
358
- height:150px;
359
- overflow: auto;
360
- border: 1px solid #a1a1a1;
361
- }
362
-
363
- .um-forms-line[data-field_type="same_page_update"] {
364
- vertical-align: baseline;
365
- }
366
-
367
- .um-forms-line[data-field_type="same_page_update"] th,
368
- .um-forms-line[data-field_type="same_page_update"] td {
369
- vertical-align: baseline;
370
- }
371
-
372
- .um-sortable-items-field .um-sortable-item {
373
- cursor: move !important;
374
- padding: 5px;
375
- box-sizing: border-box;
376
- -moz-box-sizing: border-box;
377
- -webkit-box-sizing: border-box;
378
- border: 1px solid #7e8993;
379
- border-radius: 4px;
380
- -moz-border-radius: 4px;
381
- background: #f1f1f1;
382
- height: 42px;
383
- line-height: 28px;
384
- display: flex;
385
- flex-direction: row;
386
- justify-content: flex-start;
387
- align-items: center;
388
- flex-wrap: nowrap;
389
- }
390
-
391
- .um-sortable-items-field .um-sortable-item.um-hidden-item {
392
- display: none;
393
- }
394
-
395
- .um-sortable-items-field .um-sortable-item .um-field-icon {
396
- font-size: 18px;
397
- width: 20px;
398
- text-align: left;
399
- margin: 0 10px 0 0;
400
- }
 
 
 
 
1
+ .um-form-table.um-third-column .um-forms-line th {
2
+ width: 33%;
3
+ }
4
+
5
+ .um-form-table.um-half-column .um-forms-line th {
6
+ width: 50%;
7
+ }
8
+
9
+ .um-form-table.um-two-thirds-column .um-forms-line th {
10
+ width: 83%;
11
+ }
12
+
13
+ .um-form-table.um-top-label .um-forms-line td {
14
+ padding: 0 0 15px 0;
15
+ }
16
+
17
+ .um-form-table.um-top-label .um-forms-line td label {
18
+ margin: 0 0 5px 0;
19
+ display: inline-block;
20
+ }
21
+
22
+ .um-form-table.um-top-label .um-forms-line[data-field_type="icon"] td label {
23
+ width: 100%;
24
+ display: block;
25
+ margin: 0 0 5px 0;
26
+ }
27
+
28
+ .um_admin_fonticon_wrapper {
29
+ display: flex;
30
+ flex-direction: row;
31
+ flex-wrap: nowrap;
32
+ justify-content: flex-start;
33
+ align-items: center;
34
+ }
35
+
36
+ .um-admin-icon-value {
37
+ line-height: 1;
38
+ }
39
+
40
+ .um_admin_fonticon_wrapper .um-admin-icon-value i {
41
+ top: 0;
42
+ }
43
+
44
+ input[type=text].um-forms-field.um-long-field,
45
+ select.um-forms-field.um-long-field,
46
+ textarea.um-forms-field.um-long-field {
47
+ width:100% !important;
48
+ }
49
+
50
+ input[type=text].um-forms-field.um-medium-field,
51
+ select.um-forms-field.um-medium-field,
52
+ textarea.um-forms-field.um-medium-field {
53
+ width:50% !important;
54
+ }
55
+
56
+ input[type=text].um-forms-field.um-small-field,
57
+ select.um-forms-field.um-small-field,
58
+ textarea.um-forms-field.um-small-field {
59
+ width:25% !important;
60
+ }
61
+
62
+
63
+
64
+ .um-multi-text-list,
65
+ .um-multi-selects-list,
66
+ .um-md-default-filters-list {
67
+ float: left;
68
+ width:100%;
69
+ margin: 0 0 10px 0;
70
+ }
71
+
72
+ .um-hidden-multi-text,
73
+ .um-hidden-multi-selects,
74
+ .um-hidden-md-default-filters {
75
+ display: none !important;
76
+ }
77
+
78
+ .um-multi-text-option-line,
79
+ .um-multi-selects-option-line,
80
+ .um-md-default-filters-option-line {
81
+ float:left;
82
+ width:100%;
83
+ margin: 0;
84
+ padding: 0;
85
+ clear:both;
86
+ }
87
+
88
+ .um-md-default-filters-option-line {
89
+ border-bottom: 1px solid #eee;
90
+ padding: 0 0 5px 0;
91
+ margin: 5px 0 0 0;
92
+ }
93
+
94
+ .um-md-default-filters-option-line .um.um-field-wrapper2 {
95
+ margin: 5px 0 0 0;
96
+ }
97
+
98
+ .um-multi-selects-option-line.um-admin-drag-fld {
99
+ background: none;
100
+ border: none;
101
+ display: flex;
102
+ flex-direction: row;
103
+ justify-content: flex-start;
104
+ align-items: center;
105
+ flex-wrap: nowrap;
106
+ }
107
+
108
+ .um-multi-selects-option-line.um-admin-drag-fld .um-field-icon {
109
+ float: left;
110
+ width: 20px;
111
+ text-align: left;
112
+ line-height: 30px;
113
+ }
114
+
115
+ .um-multi-selects-option-line .um-field-wrapper {
116
+ float:left;
117
+ width: calc( 100% - 60px );
118
+ line-height: 30px;
119
+ box-sizing: border-box;
120
+ }
121
+
122
+ .um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields {
123
+ margin: 5px 0 0 0;
124
+ }
125
+
126
+ .um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label {
127
+ float:left;
128
+ width: 100%;
129
+ line-height: 30px;
130
+ box-sizing: border-box;
131
+ margin: 0 !important;
132
+ padding: 0 !important;
133
+ font-weight: bold;
134
+ display: flex;
135
+ flex-direction: row;
136
+ flex-wrap: nowrap;
137
+ justify-content: space-between;
138
+ align-items: baseline;
139
+ }
140
+
141
+ .um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label input[type="text"] {
142
+ width: auto;
143
+ display: inline;
144
+ font-weight: normal;
145
+ max-width: 70%;
146
+ flex: 0.9;
147
+ }
148
+
149
+ .um-multi-selects-option-line.um-admin-drag-fld .um-field-wrapper {
150
+ width: calc( 100% - 90px );
151
+ }
152
+
153
+ .um-multi-text-option-line .um-field-wrapper {
154
+ float:left;
155
+ width: calc( 100% - 90px );
156
+ line-height: 30px;
157
+ box-sizing: border-box;
158
+ }
159
+
160
+ .um-md-default-filters-option-line .um-field-wrapper {
161
+ float:left;
162
+ width: calc( 100% - 60px );
163
+ line-height: 30px;
164
+ box-sizing: border-box;
165
+ }
166
+
167
+ .um-md-default-filters-option-line .um-field-wrapper2 {
168
+ float:left;
169
+ width: calc( 100% - 60px );
170
+ line-height: 30px;
171
+ box-sizing: border-box;
172
+ }
173
+
174
+ .um-md-default-filters-option-line .um-field-wrapper2 .ui-slider-range.ui-widget-header {
175
+ background: #44b0ec;
176
+ border: 1px solid #44b0ec !important;
177
+ margin-top: -1px;
178
+ }
179
+
180
+ .um-md-default-filters-option-line .um-field-wrapper2 select {
181
+ width: 100%;
182
+ float: left;
183
+ }
184
+
185
+ .um-md-default-filters-option-line .um-field-wrapper2 input {
186
+ width: 100%;
187
+ float: left;
188
+ }
189
+
190
+ .um-md-default-filters-option-line .um-field-wrapper2 input.um-timepicker-filter,
191
+ .um-md-default-filters-option-line .um-field-wrapper2 input.um-datepicker-filter {
192
+ width: calc( 50% - 7px ) !important;
193
+ float: left;
194
+ }
195
+
196
+ .um-md-default-filters-option-line .um-field-wrapper2 .um-slider {
197
+ margin: 5px 9px 0 9px;
198
+ width: calc( 100% - 18px );
199
+ box-sizing: border-box;
200
+ display: block;
201
+ }
202
+
203
+ .um-md-default-filters-option-line .um-field-wrapper2 input.um-timepicker-filter:first-child,
204
+ .um-md-default-filters-option-line .um-field-wrapper2 input.um-datepicker-filter:first-child {
205
+ margin-right: 11px;
206
+ }
207
+
208
+ .um-multi-text-option-line .um-field-wrapper input,
209
+ .um-multi-selects-option-line .um-field-wrapper select {
210
+ float:left;
211
+ width: 100%;
212
+ margin:0;
213
+ }
214
+
215
+
216
+ .um-multi-text-option-line .um-field-control,
217
+ .um-multi-selects-option-line .um-field-control,
218
+ .um-md-default-filters-option-line .um-field-control {
219
+ float:left;
220
+ width: 60px;
221
+ line-height: 30px;
222
+ padding: 0 10px;
223
+ box-sizing: border-box;
224
+ }
225
+
226
+ .um-form-table .description {
227
+ font-style: italic;
228
+ }
229
+
230
+ .um-form-field .description {
231
+ clear: both;
232
+ }
233
+
234
+
235
+ .um-form-fields-section {
236
+ float:left;
237
+ clear: none;
238
+ margin:0;
239
+ padding: 0 10px 0 0;
240
+ box-sizing: border-box;
241
+ -moz-box-sizing: border-box;
242
+ -webkit-box-sizing: border-box;
243
+ }
244
+
245
+ .um-form-fields-section label {
246
+ float:left;
247
+ width:100%;
248
+ margin:0;
249
+ padding:0;
250
+ }
251
+
252
+ .um-form-fields-section label input {
253
+ float:left;
254
+ margin-top:0;
255
+ }
256
+
257
+ .um-form-fields-section label span {
258
+ float:left;
259
+ width:calc( 100% - 20px );
260
+ }
261
+
262
+ .um-multi-text-option-line,
263
+ .um-multi-selects-option-line {
264
+ margin: 0 0 5px 0;
265
+ }
266
+
267
+ @media screen and (max-width: 782px) {
268
+ .um-form-fields-section {
269
+ width:100% !important;
270
+ }
271
+ .um-admin-metabox .um-form-fields-section label {
272
+ line-height: 22px !important;
273
+ margin: 0 0 12px 0 !important;
274
+ }
275
+ .um-form-fields-section label span {
276
+ width:calc( 100% - 30px );
277
+ }
278
+
279
+ .um-multi-text-option-line,
280
+ .um-multi-selects-option-line {
281
+ margin: 0 0 6px 0;
282
+ }
283
+
284
+ .um-forms-line label {
285
+ float:left;
286
+ width:100%;
287
+ }
288
+
289
+
290
+ .um-form-table.um-third-column .um-forms-line th,
291
+ .um-form-table.um-half-column .um-forms-line th,
292
+ .um-form-table.um-two-thirds-column .um-forms-line th {
293
+ float:left;
294
+ width: 100%;
295
+ }
296
+
297
+ .um-form-table.um-third-column .um-forms-line td,
298
+ .um-form-table.um-half-column .um-forms-line td,
299
+ .um-form-table.um-two-thirds-column .um-forms-line td {
300
+ float:left;
301
+ width: 100%;
302
+ }
303
+
304
+ .um-form-table.um-third-column .um-forms-line th label,
305
+ .um-form-table.um-half-column .um-forms-line th label,
306
+ .um-form-table.um-two-thirds-column .um-forms-line th label {
307
+ float:left;
308
+ width: 100%;
309
+ }
310
+ }
311
+
312
+
313
+ /*Multi text filed */
314
+ .um-forms-line .um-text-delete {
315
+ color: #a00;
316
+ float:left;
317
+ }
318
+
319
+ .um-forms-line .um-text-delete:hover {
320
+ color: red;
321
+ }
322
+
323
+ .um-forms-line .um-multi-text-add-option {
324
+ margin-bottom: 14px;
325
+ }
326
+
327
+
328
+ /* Media uploader */
329
+ .um-forms-line .icon_preview {
330
+ display: none;
331
+ max-width: 200px;
332
+ max-height: 200px;
333
+ padding: 5px;
334
+ cursor: pointer;
335
+ border: 1px solid #e3e3e3;
336
+ background: #f7f7f7;
337
+ border-radius: 3px;
338
+ height: auto;
339
+ width: auto !important;
340
+ }
341
+
342
+
343
+ .um-forms-line[data-conditional] {
344
+ display: none;
345
+ }
346
+
347
+
348
+
349
+ /* Same page update field */
350
+ .um-forms-line td .um-same-page-update-wrapper {
351
+ display: none;
352
+ margin: 7px 0 0 0;
353
+ }
354
+
355
+ .um-forms-line td .um-same-page-update-wrapper input.um-admin-form-same-page-update {
356
+ margin: 7px 0 0 0;
357
+ }
358
+
359
+ .um-forms-line td .um-same-page-update-wrapper .upgrade_log {
360
+ margin: 7px 0 0 0;
361
+ width:100%;
362
+ height:150px;
363
+ overflow: auto;
364
+ border: 1px solid #a1a1a1;
365
+ }
366
+
367
+ .um-forms-line[data-field_type="same_page_update"] {
368
+ vertical-align: baseline;
369
+ }
370
+
371
+ .um-forms-line[data-field_type="same_page_update"] th,
372
+ .um-forms-line[data-field_type="same_page_update"] td {
373
+ vertical-align: baseline;
374
+ }
375
+
376
+ .um-sortable-items-field .um-sortable-item {
377
+ cursor: move !important;
378
+ padding: 5px;
379
+ box-sizing: border-box;
380
+ -moz-box-sizing: border-box;
381
+ -webkit-box-sizing: border-box;
382
+ border: 1px solid #7e8993;
383
+ border-radius: 4px;
384
+ -moz-border-radius: 4px;
385
+ background: #f1f1f1;
386
+ height: 42px;
387
+ line-height: 28px;
388
+ display: flex;
389
+ flex-direction: row;
390
+ justify-content: flex-start;
391
+ align-items: center;
392
+ flex-wrap: nowrap;
393
+ }
394
+
395
+ .um-sortable-items-field .um-sortable-item.um-hidden-item {
396
+ display: none;
397
+ }
398
+
399
+ .um-sortable-items-field .um-sortable-item .um-field-icon {
400
+ font-size: 18px;
401
+ width: 20px;
402
+ text-align: left;
403
+ margin: 0 10px 0 0;
404
+ }
includes/admin/assets/js/um-admin-blocks.js CHANGED
@@ -1,235 +1,235 @@
1
- 'use strict';
2
-
3
- var um_components = wp.components,
4
- umSelectControl = um_components.SelectControl,
5
- umTextareaControl = um_components.TextareaControl;
6
-
7
-
8
- function um_admin_blocks_custom_fields( um_condition_fields, props ) {
9
- return wp.hooks.applyFilters( 'um_admin_blocks_custom_fields', [], um_condition_fields, props );
10
- }
11
-
12
- var um_block_restriction = wp.compose.createHigherOrderComponent( function( BlockEdit ) {
13
- var um_condition_fields = {
14
- um_who_access: 'um_block_settings_hide',
15
- um_roles_access: 'um_block_settings_hide',
16
- um_message_type: 'um_block_settings_hide',
17
- um_message_content: 'um_block_settings_hide'
18
- };
19
-
20
- um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_default', um_condition_fields );
21
-
22
- return function( props ) {
23
-
24
- if ( props.attributes.um_is_restrict !== true ) {
25
- um_condition_fields['um_who_access'] = 'um_block_settings_hide';
26
- um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
27
- um_condition_fields['um_message_type'] = 'um_block_settings_hide';
28
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
29
- } else {
30
- um_condition_fields['um_who_access'] = '';
31
-
32
- if ( parseInt( props.attributes.um_who_access ) === 0 || typeof props.attributes.um_who_access === 'undefined' ) {
33
- um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
34
- um_condition_fields['um_message_type'] = 'um_block_settings_hide';
35
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
36
- } else if ( parseInt( props.attributes.um_who_access ) === 1 ) {
37
- um_condition_fields['um_roles_access'] = '';
38
- um_condition_fields['um_message_type'] = '';
39
-
40
- if ( parseInt( props.attributes.um_message_type ) === 2 ) {
41
- um_condition_fields['um_message_content'] = '';
42
- } else {
43
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
44
- }
45
- } else {
46
- um_condition_fields['um_message_type'] = '';
47
-
48
- if ( parseInt( props.attributes.um_message_type ) === 2 ) {
49
- um_condition_fields['um_message_content'] = '';
50
- } else {
51
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
52
- }
53
- }
54
- }
55
-
56
- um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields', um_condition_fields, props );
57
-
58
- return wp.element.createElement(
59
- wp.element.Fragment,
60
- {},
61
- wp.element.createElement( BlockEdit, props ),
62
- wp.element.createElement(
63
- wp.blockEditor.InspectorControls,
64
- {},
65
- wp.element.createElement(
66
- wp.components.PanelBody,
67
- {
68
- title: wp.i18n.__( 'UM access Controls', 'ultimate-member' ),
69
- className: 'um_block_settings'
70
- },
71
- wp.element.createElement(
72
- wp.components.ToggleControl,
73
- {
74
- label: wp.i18n.__( 'Restrict access?', 'ultimate-member' ),
75
- checked: props.attributes.um_is_restrict,
76
- onChange: function onChange( value ) {
77
- props.setAttributes({ um_is_restrict: value });
78
- if ( value === false ) {
79
- um_condition_fields['um_who_access'] = 'um_block_settings_hide';
80
- um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
81
- um_condition_fields['um_message_type'] = 'um_block_settings_hide';
82
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
83
- } else {
84
- um_condition_fields['um_who_access'] = '';
85
- }
86
-
87
- um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_on_change', um_condition_fields, 'um_is_restrict', value );
88
- }
89
- }
90
- ),
91
- wp.element.createElement(
92
- umSelectControl,
93
- {
94
- type: 'number',
95
- className: um_condition_fields['um_who_access'],
96
- label: wp.i18n.__( 'Who can access this content?', 'ultimate-member' ),
97
- value: props.attributes.um_who_access,
98
- options: [
99
- {
100
- label: wp.i18n.__( 'Everyone', 'ultimate-member' ),
101
- value: 0
102
- },
103
- {
104
- label: wp.i18n.__( 'Logged in users', 'ultimate-member' ),
105
- value: 1
106
- },
107
- {
108
- label: wp.i18n.__( 'Logged out users', 'ultimate-member' ),
109
- value: 2
110
- }
111
- ],
112
- onChange: function onChange( value ) {
113
- props.setAttributes({ um_who_access: value });
114
- if ( parseInt( value ) === 0 ) {
115
- um_condition_fields['um_message_type'] = 'um_block_settings_hide';
116
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
117
- um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
118
- } else if ( parseInt( value ) === 1 ) {
119
- um_condition_fields['um_message_type'] = '';
120
- um_condition_fields['um_roles_access'] = '';
121
- } else {
122
- um_condition_fields['um_message_type'] = '';
123
- um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
124
- }
125
-
126
- um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_on_change', um_condition_fields, 'um_who_access', value );
127
- }
128
- }
129
- ),
130
- wp.element.createElement(
131
- umSelectControl,
132
- {
133
- multiple: true,
134
- className: um_condition_fields['um_roles_access'],
135
- label: wp.i18n.__( 'What roles can access this content?', 'ultimate-member' ),
136
- value: props.attributes.um_roles_access,
137
- options: um_restrict_roles,
138
- onChange: function onChange( value ) {
139
- props.setAttributes({ um_roles_access: value });
140
- }
141
- }
142
- ),
143
- wp.element.createElement(
144
- umSelectControl,
145
- {
146
- type: 'number',
147
- className: um_condition_fields['um_message_type'],
148
- label: wp.i18n.__( 'Restriction Action', 'ultimate-member' ),
149
- value: props.attributes.um_message_type,
150
- options: [
151
- {
152
- label: wp.i18n.__( 'Hide block', 'ultimate-member' ),
153
- value: 0
154
- },
155
- {
156
- label: wp.i18n.__( 'Show global default message', 'ultimate-member' ),
157
- value: 1
158
- },
159
- {
160
- label: wp.i18n.__( 'Show custom message', 'ultimate-member' ),
161
- value: 2
162
- }
163
- ],
164
- onChange: function onChange( value ) {
165
- props.setAttributes({ um_message_type: value });
166
- if ( parseInt( value ) === 2 ) {
167
- um_condition_fields['um_message_content'] = '';
168
- } else {
169
- um_condition_fields['um_message_content'] = 'um_block_settings_hide';
170
- }
171
- }
172
- }
173
- ),
174
- wp.element.createElement(
175
- umTextareaControl,
176
- {
177
- type: 'number',
178
- className: um_condition_fields['um_message_content'],
179
- label: wp.i18n.__( 'Restriction Message Content', 'ultimate-member' ),
180
- value: props.attributes.um_message_content,
181
- onChange: function onChange( value ) {
182
- props.setAttributes({ um_message_content: value });
183
- }
184
- }
185
- ),
186
- um_admin_blocks_custom_fields( um_condition_fields, props )
187
- )
188
- )
189
- );
190
- };
191
- }, 'um_block_restriction' );
192
-
193
- wp.hooks.addFilter( 'editor.BlockEdit', 'um-block/um_block_restriction', um_block_restriction );
194
-
195
-
196
- /**
197
- * Save Attributes
198
- *
199
- * @type {{um_is_restrict: {type: string}, um_who_access: {type: string}, um_message_type: {type: string}, um_message_content: {type: string}}}
200
- */
201
- var um_block_restrict_settings = {
202
- um_is_restrict: {
203
- type: "boolean"
204
- },
205
- um_who_access: {
206
- type: "select"
207
- },
208
- um_roles_access: {
209
- type: "select"
210
- },
211
- um_message_type: {
212
- type: "select"
213
- },
214
- um_message_content: {
215
- type: "string"
216
- }
217
- };
218
-
219
- um_block_restrict_settings = wp.hooks.applyFilters( 'um_admin_blocks_restrict_settings', um_block_restrict_settings );
220
-
221
-
222
- /**
223
- *
224
- * @param settings
225
- * @returns {*}
226
- */
227
- function um_add_block_attributes( settings ) {
228
- var _lodash = lodash,
229
- assign = _lodash.assign;
230
-
231
- settings.attributes = assign( settings.attributes, um_block_restrict_settings );
232
- return settings;
233
- }
234
-
235
- wp.hooks.addFilter( 'blocks.registerBlockType', 'um-block/um_add_block_attributes', um_add_block_attributes );
1
+ 'use strict';
2
+
3
+ var um_components = wp.components,
4
+ umSelectControl = um_components.SelectControl,
5
+ umTextareaControl = um_components.TextareaControl;
6
+
7
+
8
+ function um_admin_blocks_custom_fields( um_condition_fields, props ) {
9
+ return wp.hooks.applyFilters( 'um_admin_blocks_custom_fields', [], um_condition_fields, props );
10
+ }
11
+
12
+ var um_block_restriction = wp.compose.createHigherOrderComponent( function( BlockEdit ) {
13
+ var um_condition_fields = {
14
+ um_who_access: 'um_block_settings_hide',
15
+ um_roles_access: 'um_block_settings_hide',
16
+ um_message_type: 'um_block_settings_hide',
17
+ um_message_content: 'um_block_settings_hide'
18
+ };
19
+
20
+ um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_default', um_condition_fields );
21
+
22
+ return function( props ) {
23
+
24
+ if ( props.attributes.um_is_restrict !== true ) {
25
+ um_condition_fields['um_who_access'] = 'um_block_settings_hide';
26
+ um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
27
+ um_condition_fields['um_message_type'] = 'um_block_settings_hide';
28
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
29
+ } else {
30
+ um_condition_fields['um_who_access'] = '';
31
+
32
+ if ( parseInt( props.attributes.um_who_access ) === 0 || typeof props.attributes.um_who_access === 'undefined' ) {
33
+ um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
34
+ um_condition_fields['um_message_type'] = 'um_block_settings_hide';
35
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
36
+ } else if ( parseInt( props.attributes.um_who_access ) === 1 ) {
37
+ um_condition_fields['um_roles_access'] = '';
38
+ um_condition_fields['um_message_type'] = '';
39
+
40
+ if ( parseInt( props.attributes.um_message_type ) === 2 ) {
41
+ um_condition_fields['um_message_content'] = '';
42
+ } else {
43
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
44
+ }
45
+ } else {
46
+ um_condition_fields['um_message_type'] = '';
47
+
48
+ if ( parseInt( props.attributes.um_message_type ) === 2 ) {
49
+ um_condition_fields['um_message_content'] = '';
50
+ } else {
51
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
52
+ }
53
+ }
54
+ }
55
+
56
+ um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields', um_condition_fields, props );
57
+
58
+ return wp.element.createElement(
59
+ wp.element.Fragment,
60
+ {},
61
+ wp.element.createElement( BlockEdit, props ),
62
+ wp.element.createElement(
63
+ wp.blockEditor.InspectorControls,
64
+ {},
65
+ wp.element.createElement(
66
+ wp.components.PanelBody,
67
+ {
68
+ title: wp.i18n.__( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
69
+ className: 'um_block_settings'
70
+ },
71
+ wp.element.createElement(
72
+ wp.components.ToggleControl,
73
+ {
74
+ label: wp.i18n.__( 'Restrict access?', 'ultimate-member' ),
75
+ checked: props.attributes.um_is_restrict,
76
+ onChange: function onChange( value ) {
77
+ props.setAttributes({ um_is_restrict: value });
78
+ if ( value === false ) {
79
+ um_condition_fields['um_who_access'] = 'um_block_settings_hide';
80
+ um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
81
+ um_condition_fields['um_message_type'] = 'um_block_settings_hide';
82
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
83
+ } else {
84
+ um_condition_fields['um_who_access'] = '';
85
+ }
86
+
87
+ um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_on_change', um_condition_fields, 'um_is_restrict', value );
88
+ }
89
+ }
90
+ ),
91
+ wp.element.createElement(
92
+ umSelectControl,
93
+ {
94
+ type: 'number',
95
+ className: um_condition_fields['um_who_access'],
96
+ label: wp.i18n.__( 'Who can access this block?', 'ultimate-member' ),
97
+ value: props.attributes.um_who_access,
98
+ options: [
99
+ {
100
+ label: wp.i18n.__( 'Everyone', 'ultimate-member' ),
101
+ value: 0
102
+ },
103
+ {
104
+ label: wp.i18n.__( 'Logged in users', 'ultimate-member' ),
105
+ value: 1
106
+ },
107
+ {
108
+ label: wp.i18n.__( 'Logged out users', 'ultimate-member' ),
109
+ value: 2
110
+ }
111
+ ],
112
+ onChange: function onChange( value ) {
113
+ props.setAttributes({ um_who_access: value });
114
+ if ( parseInt( value ) === 0 ) {
115
+ um_condition_fields['um_message_type'] = 'um_block_settings_hide';
116
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
117
+ um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
118
+ } else if ( parseInt( value ) === 1 ) {
119
+ um_condition_fields['um_message_type'] = '';
120
+ um_condition_fields['um_roles_access'] = '';
121
+ } else {
122
+ um_condition_fields['um_message_type'] = '';
123
+ um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
124
+ }
125
+
126
+ um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_on_change', um_condition_fields, 'um_who_access', value );
127
+ }
128
+ }
129
+ ),
130
+ wp.element.createElement(
131
+ umSelectControl,
132
+ {
133
+ multiple: true,
134
+ className: um_condition_fields['um_roles_access'],
135
+ label: wp.i18n.__( 'What roles can access this block?', 'ultimate-member' ),
136
+ value: props.attributes.um_roles_access,
137
+ options: um_restrict_roles,
138
+ onChange: function onChange( value ) {
139
+ props.setAttributes({ um_roles_access: value });
140
+ }
141
+ }
142
+ ),
143
+ wp.element.createElement(
144
+ umSelectControl,
145
+ {
146
+ type: 'number',
147
+ className: um_condition_fields['um_message_type'],
148
+ label: wp.i18n.__( 'Restriction action', 'ultimate-member' ),
149
+ value: props.attributes.um_message_type,
150
+ options: [
151
+ {
152
+ label: wp.i18n.__( 'Hide block', 'ultimate-member' ),
153
+ value: 0
154
+ },
155
+ {
156
+ label: wp.i18n.__( 'Show global default message', 'ultimate-member' ),
157
+ value: 1
158
+ },
159
+ {
160
+ label: wp.i18n.__( 'Show custom message', 'ultimate-member' ),
161
+ value: 2
162
+ }
163
+ ],
164
+ onChange: function onChange( value ) {
165
+ props.setAttributes({ um_message_type: value });
166
+ if ( parseInt( value ) === 2 ) {
167
+ um_condition_fields['um_message_content'] = '';
168
+ } else {
169
+ um_condition_fields['um_message_content'] = 'um_block_settings_hide';
170
+ }
171
+ }
172
+ }
173
+ ),
174
+ wp.element.createElement(
175
+ umTextareaControl,
176
+ {
177
+ type: 'number',
178
+ className: um_condition_fields['um_message_content'],
179
+ label: wp.i18n.__( 'Custom restricted access message', 'ultimate-member' ),
180
+ value: props.attributes.um_message_content,
181
+ onChange: function onChange( value ) {
182
+ props.setAttributes({ um_message_content: value });
183
+ }
184
+ }
185
+ ),
186
+ um_admin_blocks_custom_fields( um_condition_fields, props )
187
+ )
188
+ )
189
+ );
190
+ };
191
+ }, 'um_block_restriction' );
192
+
193
+ wp.hooks.addFilter( 'editor.BlockEdit', 'um-block/um_block_restriction', um_block_restriction );
194
+
195
+
196
+ /**
197
+ * Save Attributes
198
+ *
199
+ * @type {{um_is_restrict: {type: string}, um_who_access: {type: string}, um_message_type: {type: string}, um_message_content: {type: string}}}
200
+ */
201
+ var um_block_restrict_settings = {
202
+ um_is_restrict: {
203
+ type: "boolean"
204
+ },
205
+ um_who_access: {
206
+ type: "select"
207
+ },
208
+ um_roles_access: {
209
+ type: "select"
210
+ },
211
+ um_message_type: {
212
+ type: "select"
213
+ },
214
+ um_message_content: {
215
+ type: "string"
216
+ }
217
+ };
218
+
219
+ um_block_restrict_settings = wp.hooks.applyFilters( 'um_admin_blocks_restrict_settings', um_block_restrict_settings );
220
+
221
+
222
+ /**
223
+ *
224
+ * @param settings
225
+ * @returns {*}
226
+ */
227
+ function um_add_block_attributes( settings ) {
228
+ var _lodash = lodash,
229
+ assign = _lodash.assign;
230
+
231
+ settings.attributes = assign( settings.attributes, um_block_restrict_settings );
232
+ return settings;
233
+ }
234
+
235
+ wp.hooks.addFilter( 'blocks.registerBlockType', 'um-block/um_add_block_attributes', um_add_block_attributes );
includes/admin/class-admin.php CHANGED
@@ -1,1956 +1,1970 @@
1
- <?php
2
- namespace um\admin;
3
-
4
- // Exit if accessed directly.
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- if ( ! class_exists( 'um\admin\Admin' ) ) {
10
-
11
-
12
- /**
13
- * Class Admin
14
- * @package um\admin
15
- */
16
- class Admin extends Admin_Functions {
17
-
18
-
19
- /**
20
- * @var string
21
- */
22
- public $templates_path;
23
-
24
-
25
- /**
26
- * @var array
27
- */
28
- public $role_meta;
29
-
30
-
31
- /**
32
- * @var array
33
- */
34
- public $restriction_term_meta;
35
-
36
-
37
- /**
38
- * @var array
39
- */
40
- public $member_directory_meta;
41
-
42
-
43
- /**
44
- * @var array
45
- */
46
- public $form_meta;
47
-
48
-
49
- /**
50
- * @var array
51
- */
52
- public $builder_input;
53
-
54
-
55
- /**
56
- * @var array
57
- */
58
- public $restriction_post_meta;
59
-
60
-
61
- /**
62
- * Admin constructor.
63
- */
64
- public function __construct() {
65
- parent::__construct();
66
-
67
- $this->templates_path = um_path . 'includes/admin/templates/';
68
-
69
- $this->role_meta = apply_filters(
70
- 'um_role_meta_map',
71
- array(
72
- '_um_priority' => array(
73
- 'sanitize' => 'int',
74
- ),
75
- '_um_can_access_wpadmin' => array(
76
- 'sanitize' => 'bool',
77
- ),
78
- '_um_can_not_see_adminbar' => array(
79
- 'sanitize' => 'bool',
80
- ),
81
- '_um_can_edit_everyone' => array(
82
- 'sanitize' => 'bool',
83
- ),
84
- '_um_can_edit_roles' => array(
85
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
86
- ),
87
- '_um_can_delete_everyone' => array(
88
- 'sanitize' => 'bool',
89
- ),
90
- '_um_can_delete_roles' => array(
91
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
92
- ),
93
- '_um_can_edit_profile' => array(
94
- 'sanitize' => 'bool',
95
- ),
96
- '_um_can_delete_profile' => array(
97
- 'sanitize' => 'bool',
98
- ),
99
- '_um_can_view_all' => array(
100
- 'sanitize' => 'bool',
101
- ),
102
- '_um_can_view_roles' => array(
103
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
104
- ),
105
- '_um_can_make_private_profile' => array(
106
- 'sanitize' => 'bool',
107
- ),
108
- '_um_can_access_private_profile' => array(
109
- 'sanitize' => 'bool',
110
- ),
111
- '_um_profile_noindex' => array(
112
- 'sanitize' => array( $this, 'sanitize_profile_noindex' ),
113
- ),
114
- '_um_default_homepage' => array(
115
- 'sanitize' => 'bool',
116
- ),
117
- '_um_redirect_homepage' => array(
118
- 'sanitize' => 'url',
119
- ),
120
- '_um_status' => array(
121
- 'sanitize' => 'sanitize_array_key',
122
- 'default' => 'approved',
123
- 'array' => array( 'approved', 'checkmail', 'pending' ),
124
- ),
125
- '_um_auto_approve_act' => array(
126
- 'sanitize' => 'sanitize_array_key',
127
- 'default' => 'redirect_profile',
128
- 'array' => array( 'redirect_profile', 'redirect_url' ),
129
- ),
130
- '_um_auto_approve_url' => array(
131
- 'sanitize' => 'url',
132
- ),
133
- '_um_login_email_activate' => array(
134
- 'sanitize' => 'bool',
135
- ),
136
- '_um_checkmail_action' => array(
137
- 'sanitize' => 'sanitize_array_key',
138
- 'default' => 'show_message',
139
- 'array' => array( 'show_message', 'redirect_url' ),
140
- ),
141
- '_um_checkmail_message' => array(
142
- 'sanitize' => 'textarea',
143
- ),
144
- '_um_checkmail_url' => array(
145
- 'sanitize' => 'url',
146
- ),
147
- '_um_url_email_activate' => array(
148
- 'sanitize' => 'url',
149
- ),
150
- '_um_pending_action' => array(
151
- 'sanitize' => 'sanitize_array_key',
152
- 'default' => 'show_message',
153
- 'array' => array( 'show_message', 'redirect_url' ),
154
- ),
155
- '_um_pending_message' => array(
156
- 'sanitize' => 'textarea',
157
- ),
158
- '_um_pending_url' => array(
159
- 'sanitize' => 'url',
160
- ),
161
- '_um_after_login' => array(
162
- 'sanitize' => 'sanitize_array_key',
163
- 'default' => 'redirect_profile',
164
- 'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
165
- ),
166
- '_um_login_redirect_url' => array(
167
- 'sanitize' => 'url',
168
- ),
169
- '_um_after_logout' => array(
170
- 'sanitize' => 'sanitize_array_key',
171
- 'default' => 'redirect_home',
172
- 'array' => array( 'redirect_home', 'redirect_url' ),
173
- ),
174
- '_um_logout_redirect_url' => array(
175
- 'sanitize' => 'url',
176
- ),
177
- '_um_after_delete' => array(
178
- 'sanitize' => 'sanitize_array_key',
179
- 'default' => 'redirect_home',
180
- 'array' => array( 'redirect_home', 'redirect_url' ),
181
- ),
182
- '_um_delete_redirect_url' => array(
183
- 'sanitize' => 'url',
184
- ),
185
- 'wp_capabilities' => array(
186
- 'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
187
- ),
188
- )
189
- );
190
-
191
- $this->restriction_post_meta = apply_filters(
192
- 'um_restriction_post_meta_map',
193
- array(
194
- '_um_custom_access_settings' => array(
195
- 'sanitize' => 'bool',
196
- ),
197
- '_um_accessible' => array(
198
- 'sanitize' => 'int',
199
- ),
200
- '_um_access_roles' => array(
201
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
202
- ),
203
- '_um_noaccess_action' => array(
204
- 'sanitize' => 'int',
205
- ),
206
- '_um_restrict_by_custom_message' => array(
207
- 'sanitize' => 'int',
208
- ),
209
- '_um_restrict_custom_message' => array(
210
- 'sanitize' => 'textarea',
211
- ),
212
- '_um_access_redirect' => array(
213
- 'sanitize' => 'int',
214
- ),
215
- '_um_access_redirect_url' => array(
216
- 'sanitize' => 'url',
217
- ),
218
- '_um_access_hide_from_queries' => array(
219
- 'sanitize' => 'bool',
220
- ),
221
- )
222
- );
223
-
224
- $this->restriction_term_meta = apply_filters(
225
- 'um_restriction_term_meta_map',
226
- array(
227
- '_um_custom_access_settings' => array(
228
- 'sanitize' => 'bool',
229
- ),
230
- '_um_accessible' => array(
231
- 'sanitize' => 'int',
232
- ),
233
- '_um_access_roles' => array(
234
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
235
- ),
236
- '_um_noaccess_action' => array(
237
- 'sanitize' => 'int',
238
- ),
239
- '_um_restrict_by_custom_message' => array(
240
- 'sanitize' => 'int',
241
- ),
242
- '_um_restrict_custom_message' => array(
243
- 'sanitize' => 'textarea',
244
- ),
245
- '_um_access_redirect' => array(
246
- 'sanitize' => 'int',
247
- ),
248
- '_um_access_redirect_url' => array(
249
- 'sanitize' => 'url',
250
- ),
251
- '_um_access_hide_from_queries' => array(
252
- 'sanitize' => 'bool',
253
- ),
254
- )
255
- );
256
-
257
- $this->member_directory_meta = apply_filters(
258
- 'um_member_directory_meta_map',
259
- array(
260
- '_um_directory_template' => array(
261
- 'sanitize' => 'text',
262
- ),
263
- '_um_mode' => array(
264
- 'sanitize' => 'key',
265
- ),
266
- '_um_view_types' => array(
267
- 'sanitize' => array( $this, 'sanitize_md_view_types' ),
268
- ),
269
- '_um_default_view' => array(
270
- 'sanitize' => 'key',
271
- ),
272
- '_um_roles' => array(
273
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
274
- ),
275
- '_um_has_profile_photo' => array(
276
- 'sanitize' => 'bool',
277
- ),
278
- '_um_show_these_users' => array(
279
- 'sanitize' => 'textarea',
280
- ),
281
- '_um_exclude_these_users' => array(
282
- 'sanitize' => 'textarea',
283
- ),
284
- '_um_must_search' => array(
285
- 'sanitize' => 'bool',
286
- ),
287
- '_um_max_users' => array(
288
- 'sanitize' => 'absint',
289
- ),
290
- '_um_profiles_per_page' => array(
291
- 'sanitize' => 'absint',
292
- ),
293
- '_um_profiles_per_page_mobile' => array(
294
- 'sanitize' => 'absint',
295
- ),
296
- '_um_directory_header' => array(
297
- 'sanitize' => 'text',
298
- ),
299
- '_um_directory_header_single' => array(
300
- 'sanitize' => 'text',
301
- ),
302
- '_um_directory_no_users' => array(
303
- 'sanitize' => 'text',
304
- ),
305
- '_um_profile_photo' => array(
306
- 'sanitize' => 'bool',
307
- ),
308
- '_um_cover_photos' => array(
309
- 'sanitize' => 'bool',
310
- ),
311
- '_um_show_name' => array(
312
- 'sanitize' => 'bool',
313
- ),
314
- '_um_show_tagline' => array(
315
- 'sanitize' => 'bool',
316
- ),
317
- '_um_tagline_fields' => array(
318
- 'sanitize' => array( $this, 'sanitize_user_field' ),
319
- ),
320
- '_um_show_userinfo' => array(
321
- 'sanitize' => 'bool',
322
- ),
323
- '_um_reveal_fields' => array(
324
- 'sanitize' => array( $this, 'sanitize_user_field' ),
325
- ),
326
- '_um_show_social' => array(
327
- 'sanitize' => 'bool',
328
- ),
329
- '_um_userinfo_animate' => array(
330
- 'sanitize' => 'bool',
331
- ),
332
- '_um_search' => array(
333
- 'sanitize' => 'bool',
334
- ),
335
- '_um_roles_can_search' => array(
336
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
337
- ),
338
- '_um_filters' => array(
339
- 'sanitize' => 'bool',
340
- ),
341
- '_um_roles_can_filter' => array(
342
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
343
- ),
344
- '_um_search_fields' => array(
345
- 'sanitize' => array( $this, 'sanitize_filter_fields' ),
346
- ),
347
- '_um_filters_expanded' => array(
348
- 'sanitize' => 'bool',
349
- ),
350
- '_um_filters_is_collapsible' => array(
351
- 'sanitize' => 'bool',
352
- ),
353
- '_um_search_filters' => array(
354
- 'sanitize' => array( $this, 'sanitize_filter_fields' ),
355
- ),
356
- '_um_sortby' => array(
357
- 'sanitize' => 'text',
358
- ),
359
- '_um_sortby_custom' => array(
360
- 'sanitize' => 'text',
361
- ),
362
- '_um_sortby_custom_label' => array(
363
- 'sanitize' => 'text',
364
- ),
365
- '_um_enable_sorting' => array(
366
- 'sanitize' => 'bool',
367
- ),
368
- '_um_sorting_fields' => array(
369
- 'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
370
- ),
371
- )
372
- );
373
-
374
- $this->form_meta = apply_filters(
375
- 'um_form_meta_map',
376
- array(
377
- '_um_mode' => array(
378
- 'sanitize' => 'key',
379
- ),
380
- '_um_register_use_gdpr' => array(
381
- 'sanitize' => 'bool',
382
- ),
383
- '_um_register_use_gdpr_content_id' => array(
384
- 'sanitize' => 'absint',
385
- ),
386
- '_um_register_use_gdpr_toggle_show' => array(
387
- 'sanitize' => 'text',
388
- ),
389
- '_um_register_use_gdpr_toggle_hide' => array(
390
- 'sanitize' => 'text',
391
- ),
392
- '_um_register_use_gdpr_agreement' => array(
393
- 'sanitize' => 'text',
394
- ),
395
- '_um_register_use_gdpr_error_text' => array(
396
- 'sanitize' => 'text',
397
- ),
398
- '_um_register_use_custom_settings' => array(
399
- 'sanitize' => 'bool',
400
- ),
401
- '_um_register_role' => array(
402
- 'sanitize' => 'key',
403
- ),
404
- '_um_register_template' => array(
405
- 'sanitize' => 'text',
406
- ),
407
- '_um_register_max_width' => array(
408
- 'sanitize' => 'absint',
409
- ),
410
- '_um_register_icons' => array(
411
- 'sanitize' => 'key',
412
- ),
413
- '_um_register_primary_btn_word' => array(
414
- 'sanitize' => 'text',
415
- ),
416
- '_um_register_secondary_btn' => array(
417
- 'sanitize' => 'bool',
418
- ),
419
- '_um_register_secondary_btn_word' => array(
420
- 'sanitize' => 'text',
421
- ),
422
- '_um_login_after_login' => array(
423
- 'sanitize' => 'key',
424
- ),
425
- '_um_login_redirect_url' => array(
426
- 'sanitize' => 'url',
427
- ),
428
- '_um_login_use_custom_settings' => array(
429
- 'sanitize' => 'bool',
430
- ),
431
- '_um_login_template' => array(
432
- 'sanitize' => 'text',
433
- ),
434
- '_um_login_max_width' => array(
435
- 'sanitize' => 'absint',
436
- ),
437
- '_um_login_icons' => array(
438
- 'sanitize' => 'key',
439
- ),
440
- '_um_login_primary_btn_word' => array(
441
- 'sanitize' => 'text',
442
- ),
443
- '_um_login_secondary_btn' => array(
444
- 'sanitize' => 'bool',
445
- ),
446
- '_um_login_secondary_btn_word' => array(
447
- 'sanitize' => 'text',
448
- ),
449
- '_um_login_forgot_pass_link' => array(
450
- 'sanitize' => 'bool',
451
- ),
452
- '_um_login_show_rememberme' => array(
453
- 'sanitize' => 'bool',
454
- ),
455
- '_um_profile_metafields' => array(
456
- 'sanitize' => array( $this, 'sanitize_user_field' ),
457
- ),
458
- '_um_profile_use_custom_settings' => array(
459
- 'sanitize' => 'bool',
460
- ),
461
- '_um_profile_role' => array(
462
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
463
- ),
464
- '_um_profile_template' => array(
465
- 'sanitize' => 'text',
466
- ),
467
- '_um_profile_max_width' => array(
468
- 'sanitize' => 'absint',
469
- ),
470
- '_um_profile_area_max_width' => array(
471
- 'sanitize' => 'absint',
472
- ),
473
- '_um_profile_icons' => array(
474
- 'sanitize' => 'key',
475
- ),
476
- '_um_profile_primary_btn_word' => array(
477
- 'sanitize' => 'text',
478
- ),
479
- '_um_profile_secondary_btn' => array(
480
- 'sanitize' => 'bool',
481
- ),
482
- '_um_profile_secondary_btn_word' => array(
483
- 'sanitize' => 'text',
484
- ),
485
- '_um_profile_cover_enabled' => array(
486
- 'sanitize' => 'bool',
487
- ),
488
- '_um_profile_coversize' => array(
489
- 'sanitize' => 'absint',
490
- ),
491
- '_um_profile_cover_ratio' => array(
492
- 'sanitize' => 'text',
493
- ),
494
- '_um_profile_disable_photo_upload' => array(
495
- 'sanitize' => 'bool',
496
- ),
497
- '_um_profile_photosize' => array(
498
- 'sanitize' => array( $this, 'sanitize_photosize' ),
499
- ),
500
- '_um_profile_photo_required' => array(
501
- 'sanitize' => 'bool',
502
- ),
503
- '_um_profile_show_name' => array(
504
- 'sanitize' => 'bool',
505
- ),
506
- '_um_profile_show_social_links' => array(
507
- 'sanitize' => 'bool',
508
- ),
509
- '_um_profile_show_bio' => array(
510
- 'sanitize' => 'bool',
511
- ),
512
-
513
- )
514
- );
515
-
516
- $this->builder_input = apply_filters(
517
- 'um_builder_input_map',
518
- array(
519
- '_in_row' => array(
520
- 'sanitize' => 'key',
521
- ),
522
- '_in_sub_row' => array(
523
- 'sanitize' => 'absint',
524
- ),
525
- '_in_column' => array(
526
- 'sanitize' => 'absint',
527
- ),
528
- '_in_group' => array(
529
- 'sanitize' => 'absint',
530
- ),
531
- '_visibility' => array(
532
- 'sanitize' => 'key',
533
- ),
534
- '_conditional_action' => array(
535
- 'sanitize' => 'key',
536
- ),
537
- '_conditional_action1' => array(
538
- 'sanitize' => 'key',
539
- ),
540
- '_conditional_action2' => array(
541
- 'sanitize' => 'key',
542
- ),
543
- '_conditional_action3' => array(
544
- 'sanitize' => 'key',
545
- ),
546
- '_conditional_action4' => array(
547
- 'sanitize' => 'key',
548
- ),
549
- '_conditional_field' => array(
550
- 'sanitize' => 'text',
551
- ),
552
- '_conditional_field1' => array(
553
- 'sanitize' => 'text',
554
- ),
555
- '_conditional_field2' => array(
556
- 'sanitize' => 'text',
557
- ),
558
- '_conditional_field3' => array(
559
- 'sanitize' => 'text',
560
- ),
561
- '_conditional_field4' => array(
562
- 'sanitize' => 'text',
563
- ),
564
- '_conditional_operator' => array(
565
- 'sanitize' => 'text',
566
- ),
567
- '_conditional_operator1' => array(
568
- 'sanitize' => 'text',
569
- ),
570
- '_conditional_operator2' => array(
571
- 'sanitize' => 'text',
572
- ),
573
- '_conditional_operator3' => array(
574
- 'sanitize' => 'text',
575
- ),
576
- '_conditional_operator4' => array(
577
- 'sanitize' => 'text',
578
- ),
579
- '_conditional_value' => array(
580
- 'sanitize' => 'text',
581
- ),
582
- '_conditional_value1' => array(
583
- 'sanitize' => 'text',
584
- ),
585
- '_conditional_value2' => array(
586
- 'sanitize' => 'text',
587
- ),
588
- '_conditional_value3' => array(
589
- 'sanitize' => 'text',
590
- ),
591
- '_conditional_value4' => array(
592
- 'sanitize' => 'text',
593
- ),
594
- '_validate' => array(
595
- 'sanitize' => 'key',
596
- ),
597
- '_custom_validate' => array(
598
- 'sanitize' => 'text',
599
- ),
600
- '_icon' => array(
601
- 'sanitize' => 'key',
602
- ),
603
- '_css_class' => array(
604
- 'sanitize' => 'text',
605
- ),
606
- '_width' => array(
607
- 'sanitize' => 'absint',
608
- ),
609
- '_divider_text' => array(
610
- 'sanitize' => 'text',
611
- ),
612
- '_padding' => array(
613
- 'sanitize' => 'text',
614
- ),
615
- '_margin' => array(
616
- 'sanitize' => 'text',
617
- ),
618
- '_border' => array(
619
- 'sanitize' => 'text',
620
- ),
621
- '_borderstyle' => array(
622
- 'sanitize' => 'key',
623
- ),
624
- '_borderradius' => array(
625
- 'sanitize' => 'text',
626
- ),
627
- '_bordercolor' => array(
628
- 'sanitize' => 'text',
629
- ),
630
- '_heading' => array(
631
- 'sanitize' => 'bool',
632
- ),
633
- '_heading_text' => array(
634
- 'sanitize' => 'text',
635
- ),
636
- '_background' => array(
637
- 'sanitize' => 'text',
638
- ),
639
- '_heading_background_color' => array(
640
- 'sanitize' => 'text',
641
- ),
642
- '_heading_text_color' => array(
643
- 'sanitize' => 'text',
644
- ),
645
- '_text_color' => array(
646
- 'sanitize' => 'text',
647
- ),
648
- '_icon_color' => array(
649
- 'sanitize' => 'text',
650
- ),
651
- '_color' => array(
652
- 'sanitize' => 'text',
653
- ),
654
- '_url_text' => array(
655
- 'sanitize' => 'text',
656
- ),
657
- '_url_target' => array(
658
- 'sanitize' => 'key',
659
- ),
660
- '_url_rel' => array(
661
- 'sanitize' => 'key',
662
- ),
663
- '_force_good_pass' => array(
664
- 'sanitize' => 'bool',
665
- ),
666
- '_force_confirm_pass' => array(
667
- 'sanitize' => 'bool',
668
- ),
669
- '_style' => array(
670
- 'sanitize' => 'key',
671
- ),
672
- '_intervals' => array(
673
- 'sanitize' => 'absint',
674
- ),
675
- '_format' => array(
676
- 'sanitize' => 'text',
677
- ),
678
- '_format_custom' => array(
679
- 'sanitize' => 'text',
680
- ),
681
- '_pretty_format' => array(
682
- 'sanitize' => 'bool',
683
- ),
684
- '_disabled_weekdays' => array(
685
- 'sanitize' => 'absint',
686
- ),
687
- '_years' => array(
688
- 'sanitize' => 'absint',
689
- ),
690
- '_years_x' => array(
691
- 'sanitize' => 'key',
692
- ),
693
- '_range_start' => array(
694
- 'sanitize' => 'text',
695
- ),
696
- '_range_end' => array(
697
- 'sanitize' => 'text',
698
- ),
699
- '_range' => array(
700
- 'sanitize' => 'key',
701
- ),
702
- '_content' => array(
703
- 'sanitize' => 'textarea',
704
- ),
705
- '_crop' => array(
706
- 'sanitize' => 'int',
707
- ),
708
- '_allowed_types' => array(
709
- 'sanitize' => 'key',
710
- ),
711
- '_upload_text' => array(
712
- 'sanitize' => 'text',
713
- ),
714
- '_upload_help_text' => array(
715
- 'sanitize' => 'text',
716
- ),
717
- '_button_text' => array(
718
- 'sanitize' => 'text',
719
- ),
720
- '_max_size' => array(
721
- 'sanitize' => 'absint',
722
- ),
723
- '_height' => array(
724
- 'sanitize' => 'text',
725
- ),
726
- '_spacing' => array(
727
- 'sanitize' => 'text',
728
- ),
729
- '_is_multi' => array(
730
- 'sanitize' => 'bool',
731
- ),
732
- '_max_selections' => array(
733
- 'sanitize' => 'absint',
734
- ),
735
- '_min_selections' => array(
736
- 'sanitize' => 'absint',
737
- ),
738
- '_max_entries' => array(
739
- 'sanitize' => 'absint',
740
- ),
741
- '_max_words' => array(
742
- 'sanitize' => 'absint',
743
- ),
744
- '_min' => array(
745
- 'sanitize' => 'absint',
746
- ),
747
- '_max' => array(
748
- 'sanitize' => 'absint',
749
- ),
750
- '_min_chars' => array(
751
- 'sanitize' => 'absint',
752
- ),
753
- '_max_chars' => array(
754
- 'sanitize' => 'absint',
755
- ),
756
- '_html' => array(
757
- 'sanitize' => 'bool',
758
- ),
759
- '_options' => array(
760
- 'sanitize' => 'textarea',
761
- ),
762
- '_title' => array(
763
- 'sanitize' => 'text',
764
- ),
765
- '_id' => array(
766
- 'sanitize' => 'text',
767
- ),
768
- '_metakey' => array(
769
- 'sanitize' => 'text',
770
- ),
771
- '_help' => array(
772
- 'sanitize' => 'text',
773
- ),
774
- '_default' => array(
775
- 'sanitize' => 'text',
776
- ),
777
- '_label' => array(
778
- 'sanitize' => 'text',
779
- ),
780
- '_label_confirm_pass' => array(
781
- 'sanitize' => 'text',
782
- ),
783
- '_placeholder' => array(
784
- 'sanitize' => 'text',
785
- ),
786
- '_public' => array(
787
- 'sanitize' => 'text',
788
- ),
789
- '_roles' => array(
790
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
791
- ),
792
- '_required' => array(
793
- 'sanitize' => 'bool',
794
- ),
795
- '_editable' => array(
796
- 'sanitize' => 'bool',
797
- ),
798
- '_number' => array(
799
- 'sanitize' => 'absint',
800
- ),
801
- '_custom_dropdown_options_source' => array(
802
- 'sanitize' => 'text',
803
- ),
804
- '_parent_dropdown_relationship' => array(
805
- 'sanitize' => 'text',
806
- ),
807
- )
808
- );
809
-
810
- add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
811
-
812
- $prefix = is_network_admin() ? 'network_admin_' : '';
813
- add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
814
-
815
- add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
816
- add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
817
- add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
818
- add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
819
- add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
820
- add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
821
- add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
822
- add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
823
-
824
- add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
825
-
826
- add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
827
-
828
- add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
829
- add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
830
- add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
831
- }
832
-
833
-
834
- /**
835
- * @param array|string $value
836
- *
837
- * @return array|string
838
- */
839
- public function sanitize_md_sorting_fields( $value ) {
840
- $filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
841
- $filter_fields = array_keys( $filter_fields );
842
-
843
- if ( '' !== $value ) {
844
- $value = array_filter(
845
- $value,
846
- function( $v, $k ) use ( $filter_fields ) {
847
- if ( 'other_data' === $k ) {
848
- return true;
849
- } else {
850
- return in_array( sanitize_text_field( $v ), $filter_fields, true );
851
- }
852
- },
853
- ARRAY_FILTER_USE_BOTH
854
- );
855
-
856
- $value = array_map(
857
- function( $item ) {
858
- if ( is_array( $item ) ) {
859
- if ( isset( $item['meta_key'] ) ) {
860
- $item['meta_key'] = sanitize_text_field( $item['meta_key'] );
861
- }
862
- if ( isset( $item['label'] ) ) {
863
- $item['label'] = sanitize_text_field( $item['label'] );
864
- }
865
-
866
- return $item;
867
- } else {
868
- return sanitize_text_field( $item );
869
- }
870
- },
871
- $value
872
- );
873
- }
874
-
875
- return $value;
876
- }
877
-
878
-
879
- /**
880
- * @param array|string $value
881
- *
882
- * @return array|string
883
- */
884
- public function sanitize_filter_fields( $value ) {
885
- $filter_fields = array_keys( UM()->member_directory()->filter_fields );
886
-
887
- if ( '' !== $value ) {
888
- $value = array_filter(
889
- $value,
890
- function( $v, $k ) use ( $filter_fields ) {
891
- return in_array( sanitize_text_field( $v ), $filter_fields, true );
892
- },
893
- ARRAY_FILTER_USE_BOTH
894
- );
895
-
896
- $value = array_map( 'sanitize_text_field', $value );
897
- }
898
-
899
- return $value;
900
- }
901
-
902
-
903
- /**
904
- * @param array|string $value
905
- *
906
- * @return array|string
907
- */
908
- public function sanitize_user_field( $value ) {
909
- $user_fields = array_keys( UM()->builtin()->all_user_fields() );
910
-
911
- if ( '' !== $value ) {
912
- $value = array_filter(
913
- $value,
914
- function( $v, $k ) use ( $user_fields ) {
915
- return in_array( sanitize_text_field( $v ), $user_fields, true );
916
- },
917
- ARRAY_FILTER_USE_BOTH
918
- );
919
-
920
- $value = array_map( 'sanitize_text_field', $value );
921
- }
922
-
923
- return $value;
924
- }
925
-
926
-
927
- /**
928
- * @param array|string $value
929
- *
930
- * @return array|string
931
- */
932
- public function sanitize_md_view_types( $value ) {
933
- $view_types = array_map(
934
- function ( $item ) {
935
- return $item['title'];
936
- },
937
- UM()->member_directory()->view_types
938
- );
939
- $view_types = array_keys( $view_types );
940
-
941
- if ( '' !== $value ) {
942
- $value = array_filter(
943
- $value,
944
- function( $v, $k ) use ( $view_types ) {
945
- return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
946
- },
947
- ARRAY_FILTER_USE_BOTH
948
- );
949
-
950
- $value = array_map( 'sanitize_key', $value );
951
- }
952
-
953
- return $value;
954
- }
955
-
956
-
957
- /**
958
- * @param array|string $value
959
- *
960
- * @return array|string
961
- */
962
- public function sanitize_photosize( $value ) {
963
- $sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
964
- $sizes = array_keys( $sizes );
965
-
966
- if ( '' !== $value ) {
967
- $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
968
- }
969
-
970
- return $value;
971
- }
972
-
973
-
974
- /**
975
- * @param array|string $value
976
- *
977
- * @return array|string
978
- */
979
- public function sanitize_cover_photosize( $value ) {
980
- $sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
981
- $sizes = array_keys( $sizes );
982
-
983
- if ( '' !== $value ) {
984
- $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
985
- }
986
-
987
- return $value;
988
- }
989
-
990
-
991
- /**
992
- * @param array|string $value
993
- *
994
- * @return array|string
995
- */
996
- public function sanitize_restriction_existed_role( $value ) {
997
- $all_roles = array_keys( UM()->roles()->get_roles() );
998
-
999
- if ( '' !== $value ) {
1000
- $value = array_filter(
1001
- $value,
1002
- function( $v, $k ) use ( $all_roles ) {
1003
- return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
1004
- },
1005
- ARRAY_FILTER_USE_BOTH
1006
- );
1007
-
1008
- $value = array_map( 'sanitize_key', $value );
1009
- }
1010
-
1011
- return $value;
1012
- }
1013
-
1014
-
1015
- /**
1016
- * @param array|string $value
1017
- *
1018
- * @return array|string
1019
- */
1020
- public function sanitize_existed_role( $value ) {
1021
- $all_roles = array_keys( UM()->roles()->get_roles() );
1022
-
1023
- if ( '' !== $value ) {
1024
- $value = array_filter(
1025
- $value,
1026
- function( $v, $k ) use ( $all_roles ) {
1027
- return in_array( sanitize_key( $v ), $all_roles, true );
1028
- },
1029
- ARRAY_FILTER_USE_BOTH
1030
- );
1031
-
1032
- $value = array_map( 'sanitize_key', $value );
1033
- }
1034
-
1035
- return $value;
1036
- }
1037
-
1038
-
1039
- /**
1040
- * @param array|string $value
1041
- *
1042
- * @return array|string
1043
- */
1044
- public function sanitize_tabs_privacy( $value ) {
1045
- $all_privacy = array_keys( UM()->profile()->tabs_privacy() );
1046
-
1047
- if ( '' !== $value ) {
1048
- $value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
1049
- }
1050
-
1051
- return $value;
1052
- }
1053
-
1054
-
1055
- /**
1056
- * @param $value
1057
- *
1058
- * @return bool|string
1059
- */
1060
- public function sanitize_profile_noindex( $value ) {
1061
- $value = '' !== $value ? (bool) $value : $value;
1062
- return $value;
1063
- }
1064
-
1065
-
1066
- /**
1067
- * @param $value
1068
- *
1069
- * @return array
1070
- */
1071
- public function sanitize_wp_capabilities( $value ) {
1072
- $value = array_map( 'boolval', array_filter( $value ) );
1073
- return $value;
1074
- }
1075
-
1076
-
1077
- /**
1078
- * Sanitize role meta fields when wp-admin form has been submitted
1079
- *
1080
- * @param array $data
1081
- *
1082
- * @return array
1083
- */
1084
- public function sanitize_role_meta( $data ) {
1085
- $sanitized = array();
1086
- foreach ( $data as $k => $v ) {
1087
- if ( ! array_key_exists( $k, $this->role_meta ) ) {
1088
- // @todo remove since 2.2.x and leave only continue
1089
- $sanitized[ $k ] = $v;
1090
- continue;
1091
- }
1092
-
1093
- if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
1094
- // @todo remove since 2.2.x and leave only continue
1095
- $sanitized[ $k ] = $v;
1096
- continue;
1097
- }
1098
-
1099
- if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1100
- add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
1101
- }
1102
-
1103
- switch ( $this->role_meta[ $k ]['sanitize'] ) {
1104
- default:
1105
- $sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
1106
- break;
1107
- case 'int':
1108
- $sanitized[ $k ] = (int) $v;
1109
- break;
1110
- case 'bool':
1111
- $sanitized[ $k ] = (bool) $v;
1112
- break;
1113
- case 'url':
1114
- $sanitized[ $k ] = esc_url_raw( $v );
1115
- break;
1116
- case 'textarea':
1117
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1118
- break;
1119
- case 'sanitize_array_key':
1120
- if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
1121
- continue 2;
1122
- }
1123
-
1124
- $sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
1125
- break;
1126
- }
1127
- }
1128
-
1129
- $data = $sanitized;
1130
-
1131
- $data = apply_filters( 'um_save_role_meta_sanitize', $data );
1132
-
1133
- return $data;
1134
- }
1135
-
1136
-
1137
- /**
1138
- * Sanitize post restriction meta fields when wp-admin form has been submitted
1139
- *
1140
- * @param array $data
1141
- *
1142
- * @return array
1143
- */
1144
- public function sanitize_post_restriction_meta( $data ) {
1145
- $sanitized = array();
1146
- foreach ( $data as $k => $v ) {
1147
- if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
1148
- // @todo remove since 2.2.x and leave only continue
1149
- $sanitized[ $k ] = $v;
1150
- continue;
1151
- }
1152
-
1153
- if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
1154
- // @todo remove since 2.2.x and leave only continue
1155
- $sanitized[ $k ] = $v;
1156
- continue;
1157
- }
1158
-
1159
- if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1160
- add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
1161
- }
1162
-
1163
- switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
1164
- default:
1165
- $sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
1166
- break;
1167
- case 'int':
1168
- $sanitized[ $k ] = (int) $v;
1169
- break;
1170
- case 'bool':
1171
- $sanitized[ $k ] = (bool) $v;
1172
- break;
1173
- case 'url':
1174
- $sanitized[ $k ] = esc_url_raw( $v );
1175
- break;
1176
- case 'textarea':
1177
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1178
- break;
1179
- }
1180
- }
1181
-
1182
- $data = $sanitized;
1183
-
1184
- $data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
1185
-
1186
- return $data;
1187
- }
1188
-
1189
-
1190
- /**
1191
- * Sanitize term restriction meta fields when wp-admin form has been submitted
1192
- *
1193
- * @param array $data
1194
- *
1195
- * @return array
1196
- */
1197
- public function sanitize_term_restriction_meta( $data ) {
1198
- $sanitized = array();
1199
- foreach ( $data as $k => $v ) {
1200
- if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
1201
- // @todo remove since 2.2.x and leave only continue
1202
- $sanitized[ $k ] = $v;
1203
- continue;
1204
- }
1205
-
1206
- if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
1207
- // @todo remove since 2.2.x and leave only continue
1208
- $sanitized[ $k ] = $v;
1209
- continue;
1210
- }
1211
-
1212
- if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1213
- add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
1214
- }
1215
-
1216
- switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
1217
- default:
1218
- $sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
1219
- break;
1220
- case 'int':
1221
- $sanitized[ $k ] = (int) $v;
1222
- break;
1223
- case 'bool':
1224
- $sanitized[ $k ] = (bool) $v;
1225
- break;
1226
- case 'url':
1227
- $sanitized[ $k ] = esc_url_raw( $v );
1228
- break;
1229
- case 'textarea':
1230
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1231
- break;
1232
- }
1233
- }
1234
-
1235
- $data = $sanitized;
1236
-
1237
- $data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
1238
-
1239
- return $data;
1240
- }
1241
-
1242
-
1243
- /**
1244
- * Sanitize member directory meta when wp-admin form has been submitted
1245
- *
1246
- * @todo checking all sanitize types
1247
- *
1248
- * @param array $data
1249
- *
1250
- * @return array
1251
- */
1252
- public function sanitize_member_directory_meta( $data ) {
1253
- $sanitized = array();
1254
- foreach ( $data as $k => $v ) {
1255
- if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
1256
- // @todo remove since 2.2.x and leave only continue
1257
- $sanitized[ $k ] = $v;
1258
- continue;
1259
- }
1260
-
1261
- if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
1262
- // @todo remove since 2.2.x and leave only continue
1263
- $sanitized[ $k ] = $v;
1264
- continue;
1265
- }
1266
-
1267
- if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1268
- add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
1269
- }
1270
-
1271
- switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
1272
- default:
1273
- $sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
1274
- break;
1275
- case 'int':
1276
- $sanitized[ $k ] = (int) $v;
1277
- break;
1278
- case 'bool':
1279
- $sanitized[ $k ] = (bool) $v;
1280
- break;
1281
- case 'url':
1282
- if ( is_array( $v ) ) {
1283
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1284
- } else {
1285
- $sanitized[ $k ] = esc_url_raw( $v );
1286
- }
1287
- break;
1288
- case 'text':
1289
- $sanitized[ $k ] = sanitize_text_field( $v );
1290
- break;
1291
- case 'textarea':
1292
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1293
- break;
1294
- case 'key':
1295
- if ( is_array( $v ) ) {
1296
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1297
- } else {
1298
- $sanitized[ $k ] = sanitize_key( $v );
1299
- }
1300
- break;
1301
- case 'absint':
1302
- if ( is_array( $v ) ) {
1303
- $sanitized[ $k ] = array_map( 'absint', $v );
1304
- } else {
1305
- $sanitized[ $k ] = absint( $v );
1306
- }
1307
- break;
1308
- }
1309
- }
1310
-
1311
- $data = $sanitized;
1312
-
1313
- $data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
1314
-
1315
- return $data;
1316
- }
1317
-
1318
-
1319
- /**
1320
- * Sanitize builder field meta when wp-admin form has been submitted
1321
- *
1322
- * @todo checking all sanitize types
1323
- *
1324
- * @param array $data
1325
- *
1326
- * @return array
1327
- */
1328
- public function sanitize_builder_field_meta( $data ) {
1329
- $sanitized = array();
1330
- foreach ( $data as $k => $v ) {
1331
- if ( ! array_key_exists( $k, $this->builder_input ) ) {
1332
- // @todo remove since 2.2.x and leave only continue
1333
- $sanitized[ $k ] = $v;
1334
- continue;
1335
- }
1336
-
1337
- if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
1338
- // @todo remove since 2.2.x and leave only continue
1339
- $sanitized[ $k ] = $v;
1340
- continue;
1341
- }
1342
-
1343
- if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
1344
- add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
1345
- }
1346
-
1347
- switch ( $this->builder_input[ $k ]['sanitize'] ) {
1348
- default:
1349
- $sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
1350
- break;
1351
- case 'int':
1352
- $sanitized[ $k ] = (int) $v;
1353
- break;
1354
- case 'bool':
1355
- $sanitized[ $k ] = (bool) $v;
1356
- break;
1357
- case 'url':
1358
- if ( is_array( $v ) ) {
1359
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1360
- } else {
1361
- $sanitized[ $k ] = esc_url_raw( $v );
1362
- }
1363
- break;
1364
- case 'text':
1365
- $sanitized[ $k ] = sanitize_text_field( $v );
1366
- break;
1367
- case 'textarea':
1368
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1369
- break;
1370
- case 'key':
1371
- if ( is_array( $v ) ) {
1372
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1373
- } else {
1374
- $sanitized[ $k ] = sanitize_key( $v );
1375
- }
1376
- break;
1377
- case 'absint':
1378
- if ( is_array( $v ) ) {
1379
- $sanitized[ $k ] = array_map( 'absint', $v );
1380
- } else {
1381
- $sanitized[ $k ] = absint( $v );
1382
- }
1383
- break;
1384
- }
1385
- }
1386
-
1387
- $data = $sanitized;
1388
-
1389
- $data = apply_filters( 'um_save_builder_input_sanitize', $data );
1390
-
1391
- return $data;
1392
- }
1393
-
1394
-
1395
- /**
1396
- * Sanitize form meta when wp-admin form has been submitted
1397
- *
1398
- * @todo checking all sanitize types
1399
- *
1400
- * @param array $data
1401
- *
1402
- * @return array
1403
- */
1404
- public function sanitize_form_meta( $data ) {
1405
- $sanitized = array();
1406
- foreach ( $data as $k => $v ) {
1407
- if ( ! array_key_exists( $k, $this->form_meta ) ) {
1408
- // @todo remove since 2.2.x and leave only continue
1409
- $sanitized[ $k ] = $v;
1410
- continue;
1411
- }
1412
-
1413
- if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
1414
- // @todo remove since 2.2.x and leave only continue
1415
- $sanitized[ $k ] = $v;
1416
- continue;
1417
- }
1418
-
1419
- if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1420
- add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
1421
- }
1422
-
1423
- switch ( $this->form_meta[ $k ]['sanitize'] ) {
1424
- default:
1425
- $sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
1426
- break;
1427
- case 'int':
1428
- $sanitized[ $k ] = (int) $v;
1429
- break;
1430
- case 'bool':
1431
- $sanitized[ $k ] = (bool) $v;
1432
- break;
1433
- case 'url':
1434
- if ( is_array( $v ) ) {
1435
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1436
- } else {
1437
- $sanitized[ $k ] = esc_url_raw( $v );
1438
- }
1439
- break;
1440
- case 'text':
1441
- $sanitized[ $k ] = sanitize_text_field( $v );
1442
- break;
1443
- case 'textarea':
1444
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1445
- break;
1446
- case 'key':
1447
- if ( is_array( $v ) ) {
1448
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1449
- } else {
1450
- $sanitized[ $k ] = sanitize_key( $v );
1451
- }
1452
- break;
1453
- case 'absint':
1454
- if ( is_array( $v ) ) {
1455
- $sanitized[ $k ] = array_map( 'absint', $v );
1456
- } else {
1457
- $sanitized[ $k ] = absint( $v );
1458
- }
1459
- break;
1460
- }
1461
- }
1462
-
1463
- $data = $sanitized;
1464
-
1465
- $data = apply_filters( 'um_save_form_meta_sanitize', $data );
1466
-
1467
- return $data;
1468
- }
1469
-
1470
-
1471
- /**
1472
- * Sanitize options when wp-admin form has been submitted
1473
- *
1474
- * @todo checking all sanitize types
1475
- *
1476
- * @param array $data
1477
- *
1478
- * @return array
1479
- */
1480
- public function sanitize_options( $data ) {
1481
- $sanitized = array();
1482
- foreach ( $data as $k => $v ) {
1483
- if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
1484
- // @todo remove since 2.2.x and leave only continue
1485
- $sanitized[ $k ] = $v;
1486
- continue;
1487
- }
1488
-
1489
- if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
1490
- // @todo remove since 2.2.x and leave only continue
1491
- $sanitized[ $k ] = $v;
1492
- continue;
1493
- }
1494
-
1495
- if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
1496
- add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
1497
- }
1498
-
1499
- switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
1500
- default:
1501
- $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
1502
- break;
1503
- case 'int':
1504
- $sanitized[ $k ] = (int) $v;
1505
- break;
1506
- case 'absint':
1507
- if ( is_array( $v ) ) {
1508
- $sanitized[ $k ] = array_map( 'absint', $v );
1509
- } else {
1510
- $sanitized[ $k ] = absint( $v );
1511
- }
1512
- break;
1513
- case 'key':
1514
- if ( is_array( $v ) ) {
1515
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1516
- } else {
1517
- $sanitized[ $k ] = sanitize_key( $v );
1518
- }
1519
- break;
1520
- case 'bool':
1521
- $sanitized[ $k ] = (bool) $v;
1522
- break;
1523
- case 'url':
1524
- if ( is_array( $v ) ) {
1525
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1526
- } else {
1527
- $sanitized[ $k ] = esc_url_raw( $v );
1528
- }
1529
- break;
1530
- case 'wp_kses':
1531
- $sanitized[ $k ] = wp_kses_post( $v );
1532
- break;
1533
- case 'textarea':
1534
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1535
- break;
1536
- case 'text':
1537
- $sanitized[ $k ] = sanitize_text_field( $v );
1538
- break;
1539
- }
1540
- }
1541
-
1542
- $data = $sanitized;
1543
-
1544
- $data = apply_filters( 'um_save_settings_sanitize', $data );
1545
-
1546
- return $data;
1547
- }
1548
-
1549
-
1550
- /**
1551
- * Adds class to our admin pages
1552
- *
1553
- * @param $classes
1554
- *
1555
- * @return string
1556
- */
1557
- public function admin_body_class( $classes ) {
1558
- if ( $this->is_um_screen() ) {
1559
- return "$classes um-admin";
1560
- }
1561
- return $classes;
1562
- }
1563
-
1564
-
1565
- /**
1566
- *
1567
- */
1568
- public function manual_upgrades_request() {
1569
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1570
- die();
1571
- }
1572
-
1573
- $last_request = get_option( 'um_last_manual_upgrades_request', false );
1574
-
1575
- if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
1576
-
1577
- if ( is_multisite() ) {
1578
- $blogs_ids = get_sites();
1579
- foreach( $blogs_ids as $b ) {
1580
- switch_to_blog( $b->blog_id );
1581
- wp_clean_update_cache();
1582
-
1583
- UM()->plugin_updater()->um_checklicenses();
1584
-
1585
- update_option( 'um_last_manual_upgrades_request', time() );
1586
- restore_current_blog();
1587
- }
1588
- } else {
1589
- wp_clean_update_cache();
1590
-
1591
- UM()->plugin_updater()->um_checklicenses();
1592
-
1593
- update_option( 'um_last_manual_upgrades_request', time() );
1594
- }
1595
-
1596
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
1597
- } else {
1598
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
1599
- }
1600
- exit( wp_redirect( $url ) );
1601
- }
1602
-
1603
-
1604
- /**
1605
- * Core pages installation
1606
- */
1607
- function install_core_pages() {
1608
- if ( ! is_admin() ) {
1609
- die();
1610
- }
1611
-
1612
- UM()->setup()->install_default_pages();
1613
-
1614
- //check empty pages in settings
1615
- $empty_pages = array();
1616
-
1617
- $pages = UM()->config()->permalinks;
1618
- if ( $pages && is_array( $pages ) ) {
1619
- foreach ( $pages as $slug => $page_id ) {
1620
- $page = get_post( $page_id );
1621
-
1622
- if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
1623
- $empty_pages[] = $slug;
1624
- }
1625
- }
1626
- }
1627
-
1628
- //if there aren't empty pages - then hide pages notice
1629
- if ( empty( $empty_pages ) ) {
1630
- $hidden_notices = get_option( 'um_hidden_admin_notices', array() );
1631
- $hidden_notices[] = 'wrong_pages';
1632
-
1633
- update_option( 'um_hidden_admin_notices', $hidden_notices );
1634
- }
1635
-
1636
- $url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
1637
- exit( wp_redirect( $url ) );
1638
- }
1639
-
1640
-
1641
- /**
1642
- * Clear all users cache
1643
- *
1644
- * @param $action
1645
- */
1646
- function user_cache( $action ) {
1647
- global $wpdb;
1648
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1649
- die();
1650
- }
1651
-
1652
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
1653
-
1654
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
1655
- exit( wp_redirect( $url ) );
1656
- }
1657
-
1658
-
1659
- /**
1660
- * Purge temp uploads dir
1661
- * @param $action
1662
- */
1663
- function purge_temp( $action ) {
1664
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1665
- die();
1666
- }
1667
-
1668
- UM()->files()->remove_dir( UM()->files()->upload_temp );
1669
-
1670
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
1671
- exit( wp_redirect( $url ) );
1672
- }
1673
-
1674
-
1675
- /**
1676
- * Duplicate form
1677
- *
1678
- * @param $action
1679
- */
1680
- function duplicate_form( $action ) {
1681
- if ( ! is_admin() || ! current_user_can('manage_options') ) {
1682
- die();
1683
- }
1684
- if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
1685
- die();
1686
- }
1687
-
1688
- $post_id = absint( $_REQUEST['post_id'] );
1689
-
1690
- $n = array(
1691
- 'post_type' => 'um_form',
1692
- 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
1693
- 'post_status' => 'publish',
1694
- 'post_author' => get_current_user_id(),
1695
- );
1696
-
1697
- $n_id = wp_insert_post( $n );
1698
-
1699
- $n_fields = get_post_custom( $post_id );
1700
- foreach ( $n_fields as $key => $value ) {
1701
-
1702
- if ( $key == '_um_custom_fields' ) {
1703
- $the_value = unserialize( $value[0] );
1704
- } else {
1705
- $the_value = $value[0];
1706
- }
1707
-
1708
- update_post_meta( $n_id, $key, $the_value );
1709
-
1710
- }
1711
-
1712
- delete_post_meta( $n_id, '_um_core' );
1713
-
1714
- $url = admin_url( 'edit.php?post_type=um_form' );
1715
- $url = add_query_arg( 'update', 'form_duplicated', $url );
1716
-
1717
- exit( wp_redirect( $url ) );
1718
-
1719
- }
1720
-
1721
-
1722
- /**
1723
- * Action to hide notices in admin
1724
- *
1725
- * @param $action
1726
- */
1727
- function um_hide_notice( $action ) {
1728
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1729
- die();
1730
- }
1731
-
1732
- update_option( $action, 1 );
1733
- exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
1734
- }
1735
-
1736
-
1737
- /**
1738
- * Various user actions
1739
- *
1740
- * @param $action
1741
- */
1742
- function user_action( $action ) {
1743
- if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
1744
- die();
1745
- }
1746
- if ( ! isset( $_REQUEST['sub'] ) ) {
1747
- die();
1748
- }
1749
- if ( ! isset( $_REQUEST['user_id'] ) ) {
1750
- die();
1751
- }
1752
-
1753
- um_fetch_user( absint( $_REQUEST['user_id'] ) );
1754
-
1755
- $subaction = sanitize_key( $_REQUEST['sub'] );
1756
-
1757
- /**
1758
- * UM hook
1759
- *
1760
- * @type action
1761
- * @title um_admin_user_action_hook
1762
- * @description Action on bulk user subaction
1763
- * @input_vars
1764
- * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
1765
- * @change_log
1766
- * ["Since: 2.0"]
1767
- * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
1768
- * @example
1769
- * <?php
1770
- * add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
1771
- * function my_admin_user_action( $subaction ) {
1772
- * // your code here
1773
- * }
1774
- * ?>
1775
- */
1776
- do_action( 'um_admin_user_action_hook', $subaction );
1777
- /**
1778
- * UM hook
1779
- *
1780
- * @type action
1781
- * @title um_admin_user_action_{$subaction}_hook
1782
- * @description Action on bulk user subaction
1783
- * @change_log
1784
- * ["Since: 2.0"]
1785
- * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
1786
- * @example
1787
- * <?php
1788
- * add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
1789
- * function my_admin_user_action() {
1790
- * // your code here
1791
- * }
1792
- * ?>
1793
- */
1794
- do_action( "um_admin_user_action_{$subaction}_hook" );
1795
-
1796
- um_reset_user();
1797
-
1798
- wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
1799
- exit;
1800
-
1801
- }
1802
-
1803
-
1804
- /**
1805
- * Add any custom links to plugin page
1806
- *
1807
- * @param array $links
1808
- *
1809
- * @return array
1810
- */
1811
- function plugin_links( $links ) {
1812
- $more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
1813
- $more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
1814
-
1815
- $links = $more_links + $links;
1816
- return $links;
1817
- }
1818
-
1819
-
1820
- /**
1821
- * Init admin action/filters + request handlers
1822
- */
1823
- function admin_init() {
1824
- if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
1825
- $action = sanitize_key( $_REQUEST['um_adm_action'] );
1826
-
1827
- /**
1828
- * UM hook
1829
- *
1830
- * @type action
1831
- * @title um_admin_do_action__
1832
- * @description Make some action on custom admin action
1833
- * @input_vars
1834
- * [{"var":"$action","type":"string","desc":"Admin Action"}]
1835
- * @change_log
1836
- * ["Since: 2.0"]
1837
- * @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
1838
- * @example
1839
- * <?php
1840
- * add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
1841
- * function my_admin_do_action( $action ) {
1842
- * // your code here
1843
- * }
1844
- * ?>
1845
- */
1846
- do_action( 'um_admin_do_action__', $action );
1847
- /**
1848
- * UM hook
1849
- *
1850
- * @type action
1851
- * @title um_admin_do_action__{$action}
1852
- * @description Make some action on custom admin $action
1853
- * @input_vars
1854
- * [{"var":"$action","type":"string","desc":"Admin Action"}]
1855
- * @change_log
1856
- * ["Since: 2.0"]
1857
- * @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
1858
- * @example
1859
- * <?php
1860
- * add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
1861
- * function my_admin_do_action( $action ) {
1862
- * // your code here
1863
- * }
1864
- * ?>
1865
- */
1866
- do_action( "um_admin_do_action__{$action}", $action );
1867
- }
1868
- }
1869
-
1870
-
1871
- /**
1872
- * Updated post messages
1873
- *
1874
- * @param array $messages
1875
- *
1876
- * @return array
1877
- */
1878
- function post_updated_messages( $messages ) {
1879
- global $post_ID;
1880
-
1881
- $post_type = get_post_type( $post_ID );
1882
-
1883
- if ( $post_type == 'um_form' ) {
1884
- $messages['um_form'] = array(
1885
- 0 => '',
1886
- 1 => __( 'Form updated.', 'ultimate-member' ),
1887
- 2 => __( 'Custom field updated.', 'ultimate-member' ),
1888
- 3 => __( 'Custom field deleted.', 'ultimate-member' ),
1889
- 4 => __( 'Form updated.', 'ultimate-member' ),
1890
- 5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
1891
- 6 => __( 'Form created.', 'ultimate-member' ),
1892
- 7 => __( 'Form saved.', 'ultimate-member' ),
1893
- 8 => __( 'Form submitted.', 'ultimate-member' ),
1894
- 9 => __( 'Form scheduled.', 'ultimate-member' ),
1895
- 10 => __( 'Form draft updated.', 'ultimate-member' ),
1896
- );
1897
- }
1898
-
1899
- return $messages;
1900
- }
1901
-
1902
-
1903
- /**
1904
- * Gettext filters
1905
- *
1906
- * @param $translation
1907
- * @param $text
1908
- * @param $domain
1909
- *
1910
- * @return string
1911
- */
1912
- function gettext( $translation, $text, $domain ) {
1913
- global $post;
1914
- if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
1915
- $translations = get_translations_for_domain( $domain );
1916
- if ( $text == 'Publish' ) {
1917
- return $translations->translate( 'Create' );
1918
- } elseif ( $text == 'Move to Trash' ) {
1919
- return $translations->translate( 'Delete' );
1920
- }
1921
- }
1922
-
1923
- return $translation;
1924
- }
1925
-
1926
-
1927
- /**
1928
- * Fix parent file for correct highlighting
1929
- *
1930
- * @param $parent_file
1931
- *
1932
- * @return string
1933
- */
1934
- function parent_file( $parent_file ) {
1935
- global $current_screen;
1936
- $screen_id = $current_screen->id;
1937
- if ( strstr( $screen_id, 'um_' ) ) {
1938
- $parent_file = 'ultimatemember';
1939
- }
1940
- return $parent_file;
1941
- }
1942
-
1943
-
1944
- /**
1945
- * @since 2.0
1946
- *
1947
- * @return core\Admin_Notices()
1948
- */
1949
- function notices() {
1950
- if ( empty( UM()->classes['admin_notices'] ) ) {
1951
- UM()->classes['admin_notices'] = new core\Admin_Notices();
1952
- }
1953
- return UM()->classes['admin_notices'];
1954
- }
1955
- }
1956
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace um\admin;
3
+
4
+ // Exit if accessed directly.
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ if ( ! class_exists( 'um\admin\Admin' ) ) {
10
+
11
+
12
+ /**
13
+ * Class Admin
14
+ * @package um\admin
15
+ */
16
+ class Admin extends Admin_Functions {
17
+
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ public $templates_path;
23
+
24
+
25
+ /**
26
+ * @var array
27
+ */
28
+ public $role_meta;
29
+
30
+
31
+ /**
32
+ * @var array
33
+ */
34
+ public $restriction_term_meta;
35
+
36
+
37
+ /**
38
+ * @var array
39
+ */
40
+ public $member_directory_meta;
41
+
42
+
43
+ /**
44
+ * @var array
45
+ */
46
+ public $form_meta;
47
+
48
+
49
+ /**
50
+ * @var array
51
+ */
52
+ public $builder_input;
53
+
54
+
55
+ /**
56
+ * @var array
57
+ */
58
+ public $restriction_post_meta;
59
+
60
+
61
+ /**
62
+ * Admin constructor.
63
+ */
64
+ public function __construct() {
65
+ parent::__construct();
66
+
67
+ $this->templates_path = um_path . 'includes/admin/templates/';
68
+
69
+ add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
70
+
71
+ $prefix = is_network_admin() ? 'network_admin_' : '';
72
+ add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
73
+
74
+ add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
75
+ add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
76
+ add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
77
+ add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
78
+ add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
79
+ add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
80
+ add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
81
+ add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
82
+
83
+ add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
84
+
85
+ add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
86
+
87
+ add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
88
+ add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
89
+ add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
90
+ }
91
+
92
+
93
+ function init_variables() {
94
+ $this->role_meta = apply_filters(
95
+ 'um_role_meta_map',
96
+ array(
97
+ '_um_priority' => array(
98
+ 'sanitize' => 'int',
99
+ ),
100
+ '_um_can_access_wpadmin' => array(
101
+ 'sanitize' => 'bool',
102
+ ),
103
+ '_um_can_not_see_adminbar' => array(
104
+ 'sanitize' => 'bool',
105
+ ),
106
+ '_um_can_edit_everyone' => array(
107
+ 'sanitize' => 'bool',
108
+ ),
109
+ '_um_can_edit_roles' => array(
110
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
111
+ ),
112
+ '_um_can_delete_everyone' => array(
113
+ 'sanitize' => 'bool',
114
+ ),
115
+ '_um_can_delete_roles' => array(
116
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
117
+ ),
118
+ '_um_can_edit_profile' => array(
119
+ 'sanitize' => 'bool',
120
+ ),
121
+ '_um_can_delete_profile' => array(
122
+ 'sanitize' => 'bool',
123
+ ),
124
+ '_um_can_view_all' => array(
125
+ 'sanitize' => 'bool',
126
+ ),
127
+ '_um_can_view_roles' => array(
128
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
129
+ ),
130
+ '_um_can_make_private_profile' => array(
131
+ 'sanitize' => 'bool',
132
+ ),
133
+ '_um_can_access_private_profile' => array(
134
+ 'sanitize' => 'bool',
135
+ ),
136
+ '_um_profile_noindex' => array(
137
+ 'sanitize' => array( $this, 'sanitize_profile_noindex' ),
138
+ ),
139
+ '_um_default_homepage' => array(
140
+ 'sanitize' => 'bool',
141
+ ),
142
+ '_um_redirect_homepage' => array(
143
+ 'sanitize' => 'url',
144
+ ),
145
+ '_um_status' => array(
146
+ 'sanitize' => 'sanitize_array_key',
147
+ 'default' => 'approved',
148
+ 'array' => array( 'approved', 'checkmail', 'pending' ),
149
+ ),
150
+ '_um_auto_approve_act' => array(
151
+ 'sanitize' => 'sanitize_array_key',
152
+ 'default' => 'redirect_profile',
153
+ 'array' => array( 'redirect_profile', 'redirect_url' ),
154
+ ),
155
+ '_um_auto_approve_url' => array(
156
+ 'sanitize' => 'url',
157
+ ),
158
+ '_um_login_email_activate' => array(
159
+ 'sanitize' => 'bool',
160
+ ),
161
+ '_um_checkmail_action' => array(
162
+ 'sanitize' => 'sanitize_array_key',
163
+ 'default' => 'show_message',
164
+ 'array' => array( 'show_message', 'redirect_url' ),
165
+ ),
166
+ '_um_checkmail_message' => array(
167
+ 'sanitize' => 'textarea',
168
+ ),
169
+ '_um_checkmail_url' => array(
170
+ 'sanitize' => 'url',
171
+ ),
172
+ '_um_url_email_activate' => array(
173
+ 'sanitize' => 'url',
174
+ ),
175
+ '_um_pending_action' => array(
176
+ 'sanitize' => 'sanitize_array_key',
177
+ 'default' => 'show_message',
178
+ 'array' => array( 'show_message', 'redirect_url' ),
179
+ ),
180
+ '_um_pending_message' => array(
181
+ 'sanitize' => 'textarea',
182
+ ),
183
+ '_um_pending_url' => array(
184
+ 'sanitize' => 'url',
185
+ ),
186
+ '_um_after_login' => array(
187
+ 'sanitize' => 'sanitize_array_key',
188
+ 'default' => 'redirect_profile',
189
+ 'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
190
+ ),
191
+ '_um_login_redirect_url' => array(
192
+ 'sanitize' => 'url',
193
+ ),
194
+ '_um_after_logout' => array(
195
+ 'sanitize' => 'sanitize_array_key',
196
+ 'default' => 'redirect_home',
197
+ 'array' => array( 'redirect_home', 'redirect_url' ),
198
+ ),
199
+ '_um_logout_redirect_url' => array(
200
+ 'sanitize' => 'url',
201
+ ),
202
+ '_um_after_delete' => array(
203
+ 'sanitize' => 'sanitize_array_key',
204
+ 'default' => 'redirect_home',
205
+ 'array' => array( 'redirect_home', 'redirect_url' ),
206
+ ),
207
+ '_um_delete_redirect_url' => array(
208
+ 'sanitize' => 'url',
209
+ ),
210
+ 'wp_capabilities' => array(
211
+ 'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
212
+ ),
213
+ )
214
+ );
215
+
216
+ $this->restriction_post_meta = apply_filters(
217
+ 'um_restriction_post_meta_map',
218
+ array(
219
+ '_um_custom_access_settings' => array(
220
+ 'sanitize' => 'bool',
221
+ ),
222
+ '_um_accessible' => array(
223
+ 'sanitize' => 'int',
224
+ ),
225
+ '_um_access_roles' => array(
226
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
227
+ ),
228
+ '_um_noaccess_action' => array(
229
+ 'sanitize' => 'int',
230
+ ),
231
+ '_um_restrict_by_custom_message' => array(
232
+ 'sanitize' => 'int',
233
+ ),
234
+ '_um_restrict_custom_message' => array(
235
+ 'sanitize' => 'wp_kses',
236
+ ),
237
+ '_um_access_redirect' => array(
238
+ 'sanitize' => 'int',
239
+ ),
240
+ '_um_access_redirect_url' => array(
241
+ 'sanitize' => 'url',
242
+ ),
243
+ '_um_access_hide_from_queries' => array(
244
+ 'sanitize' => 'bool',
245
+ ),
246
+ )
247
+ );
248
+
249
+ $this->restriction_term_meta = apply_filters(
250
+ 'um_restriction_term_meta_map',
251
+ array(
252
+ '_um_custom_access_settings' => array(
253
+ 'sanitize' => 'bool',
254
+ ),
255
+ '_um_accessible' => array(
256
+ 'sanitize' => 'int',
257
+ ),
258
+ '_um_access_roles' => array(
259
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
260
+ ),
261
+ '_um_noaccess_action' => array(
262
+ 'sanitize' => 'int',
263
+ ),
264
+ '_um_restrict_by_custom_message' => array(
265
+ 'sanitize' => 'int',
266
+ ),
267
+ '_um_restrict_custom_message' => array(
268
+ 'sanitize' => 'wp_kses',
269
+ ),
270
+ '_um_access_redirect' => array(
271
+ 'sanitize' => 'int',
272
+ ),
273
+ '_um_access_redirect_url' => array(
274
+ 'sanitize' => 'url',
275
+ ),
276
+ '_um_access_hide_from_queries' => array(
277
+ 'sanitize' => 'bool',
278
+ ),
279
+ )
280
+ );
281
+
282
+ $this->member_directory_meta = apply_filters(
283
+ 'um_member_directory_meta_map',
284
+ array(
285
+ '_um_directory_template' => array(
286
+ 'sanitize' => 'text',
287
+ ),
288
+ '_um_mode' => array(
289
+ 'sanitize' => 'key',
290
+ ),
291
+ '_um_view_types' => array(
292
+ 'sanitize' => array( $this, 'sanitize_md_view_types' ),
293
+ ),
294
+ '_um_default_view' => array(
295
+ 'sanitize' => 'key',
296
+ ),
297
+ '_um_roles' => array(
298
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
299
+ ),
300
+ '_um_has_profile_photo' => array(
301
+ 'sanitize' => 'bool',
302
+ ),
303
+ '_um_show_these_users' => array(
304
+ 'sanitize' => 'textarea',
305
+ ),
306
+ '_um_exclude_these_users' => array(
307
+ 'sanitize' => 'textarea',
308
+ ),
309
+ '_um_must_search' => array(
310
+ 'sanitize' => 'bool',
311
+ ),
312
+ '_um_max_users' => array(
313
+ 'sanitize' => 'absint',
314
+ ),
315
+ '_um_profiles_per_page' => array(
316
+ 'sanitize' => 'absint',
317
+ ),
318
+ '_um_profiles_per_page_mobile' => array(
319
+ 'sanitize' => 'absint',
320
+ ),
321
+ '_um_directory_header' => array(
322
+ 'sanitize' => 'text',
323
+ ),
324
+ '_um_directory_header_single' => array(
325
+ 'sanitize' => 'text',
326
+ ),
327
+ '_um_directory_no_users' => array(
328
+ 'sanitize' => 'text',
329
+ ),
330
+ '_um_profile_photo' => array(
331
+ 'sanitize' => 'bool',
332
+ ),
333
+ '_um_cover_photos' => array(
334
+ 'sanitize' => 'bool',
335
+ ),
336
+ '_um_show_name' => array(
337
+ 'sanitize' => 'bool',
338
+ ),
339
+ '_um_show_tagline' => array(
340
+ 'sanitize' => 'bool',
341
+ ),
342
+ '_um_tagline_fields' => array(
343
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
344
+ ),
345
+ '_um_show_userinfo' => array(
346
+ 'sanitize' => 'bool',
347
+ ),
348
+ '_um_reveal_fields' => array(
349
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
350
+ ),
351
+ '_um_show_social' => array(
352
+ 'sanitize' => 'bool',
353
+ ),
354
+ '_um_userinfo_animate' => array(
355
+ 'sanitize' => 'bool',
356
+ ),
357
+ '_um_search' => array(
358
+ 'sanitize' => 'bool',
359
+ ),
360
+ '_um_roles_can_search' => array(
361
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
362
+ ),
363
+ '_um_filters' => array(
364
+ 'sanitize' => 'bool',
365
+ ),
366
+ '_um_roles_can_filter' => array(
367
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
368
+ ),
369
+ '_um_search_fields' => array(
370
+ 'sanitize' => array( $this, 'sanitize_filter_fields' ),
371
+ ),
372
+ '_um_filters_expanded' => array(
373
+ 'sanitize' => 'bool',
374
+ ),
375
+ '_um_filters_is_collapsible' => array(
376
+ 'sanitize' => 'bool',
377
+ ),
378
+ '_um_search_filters' => array(
379
+ 'sanitize' => array( $this, 'sanitize_filter_fields' ),
380
+ ),
381
+ '_um_sortby' => array(
382
+ 'sanitize' => 'text',
383
+ ),
384
+ '_um_sortby_custom' => array(
385
+ 'sanitize' => 'text',
386
+ ),
387
+ '_um_sortby_custom_label' => array(
388
+ 'sanitize' => 'text',
389
+ ),
390
+ '_um_enable_sorting' => array(
391
+ 'sanitize' => 'bool',
392
+ ),
393
+ '_um_sorting_fields' => array(
394
+ 'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
395
+ ),
396
+ )
397
+ );
398
+
399
+ $this->form_meta = apply_filters(
400
+ 'um_form_meta_map',
401
+ array(
402
+ '_um_mode' => array(
403
+ 'sanitize' => 'key',
404
+ ),
405
+ '_um_register_use_gdpr' => array(
406
+ 'sanitize' => 'bool',
407
+ ),
408
+ '_um_register_use_gdpr_content_id' => array(
409
+ 'sanitize' => 'absint',
410
+ ),
411
+ '_um_register_use_gdpr_toggle_show' => array(
412
+ 'sanitize' => 'text',
413
+ ),
414
+ '_um_register_use_gdpr_toggle_hide' => array(
415
+ 'sanitize' => 'text',
416
+ ),
417
+ '_um_register_use_gdpr_agreement' => array(
418
+ 'sanitize' => 'text',
419
+ ),
420
+ '_um_register_use_gdpr_error_text' => array(
421
+ 'sanitize' => 'text',
422
+ ),
423
+ '_um_register_use_custom_settings' => array(
424
+ 'sanitize' => 'bool',
425
+ ),
426
+ '_um_register_role' => array(
427
+ 'sanitize' => 'key',
428
+ ),
429
+ '_um_register_template' => array(
430
+ 'sanitize' => 'text',
431
+ ),
432
+ '_um_register_max_width' => array(
433
+ 'sanitize' => 'text',
434
+ ),
435
+ '_um_register_icons' => array(
436
+ 'sanitize' => 'key',
437
+ ),
438
+ '_um_register_primary_btn_word' => array(
439
+ 'sanitize' => 'text',
440
+ ),
441
+ '_um_register_secondary_btn' => array(
442
+ 'sanitize' => 'bool',
443
+ ),
444
+ '_um_register_secondary_btn_word' => array(
445
+ 'sanitize' => 'text',
446
+ ),
447
+ '_um_login_after_login' => array(
448
+ 'sanitize' => 'key',
449
+ ),
450
+ '_um_login_redirect_url' => array(
451
+ 'sanitize' => 'url',
452
+ ),
453
+ '_um_login_use_custom_settings' => array(
454
+ 'sanitize' => 'bool',
455
+ ),
456
+ '_um_login_template' => array(
457
+ 'sanitize' => 'text',
458
+ ),
459
+ '_um_login_max_width' => array(
460
+ 'sanitize' => 'text',
461
+ ),
462
+ '_um_login_icons' => array(
463
+ 'sanitize' => 'key',
464
+ ),
465
+ '_um_login_primary_btn_word' => array(
466
+ 'sanitize' => 'text',
467
+ ),
468
+ '_um_login_secondary_btn' => array(
469
+ 'sanitize' => 'bool',
470
+ ),
471
+ '_um_login_secondary_btn_word' => array(
472
+ 'sanitize' => 'text',
473
+ ),
474
+ '_um_login_forgot_pass_link' => array(
475
+ 'sanitize' => 'bool',
476
+ ),
477
+ '_um_login_show_rememberme' => array(
478
+ 'sanitize' => 'bool',
479
+ ),
480
+ '_um_profile_metafields' => array(
481
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
482
+ ),
483
+ '_um_profile_use_custom_settings' => array(
484
+ 'sanitize' => 'bool',
485
+ ),
486
+ '_um_profile_role' => array(
487
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
488
+ ),
489
+ '_um_profile_template' => array(
490
+ 'sanitize' => 'text',
491
+ ),
492
+ '_um_profile_max_width' => array(
493
+ 'sanitize' => 'text',
494
+ ),
495
+ '_um_profile_area_max_width' => array(
496
+ 'sanitize' => 'text',
497
+ ),
498
+ '_um_profile_icons' => array(
499
+ 'sanitize' => 'key',
500
+ ),
501
+ '_um_profile_primary_btn_word' => array(
502
+ 'sanitize' => 'text',
503
+ ),
504
+ '_um_profile_secondary_btn' => array(
505
+ 'sanitize' => 'bool',
506
+ ),
507
+ '_um_profile_secondary_btn_word' => array(
508
+ 'sanitize' => 'text',
509
+ ),
510
+ '_um_profile_cover_enabled' => array(
511
+ 'sanitize' => 'bool',
512
+ ),
513
+ '_um_profile_coversize' => array(
514
+ 'sanitize' => 'absint',
515
+ ),
516
+ '_um_profile_cover_ratio' => array(
517
+ 'sanitize' => 'text',
518
+ ),
519
+ '_um_profile_disable_photo_upload' => array(
520
+ 'sanitize' => 'bool',
521
+ ),
522
+ '_um_profile_photosize' => array(
523
+ 'sanitize' => array( $this, 'sanitize_photosize' ),
524
+ ),
525
+ '_um_profile_photo_required' => array(
526
+ 'sanitize' => 'bool',
527
+ ),
528
+ '_um_profile_show_name' => array(
529
+ 'sanitize' => 'bool',
530
+ ),
531
+ '_um_profile_show_social_links' => array(
532
+ 'sanitize' => 'bool',
533
+ ),
534
+ '_um_profile_show_bio' => array(
535
+ 'sanitize' => 'bool',
536
+ ),
537
+
538
+ )
539
+ );
540
+
541
+ $this->builder_input = apply_filters(
542
+ 'um_builder_input_map',
543
+ array(
544
+ '_in_row' => array(
545
+ 'sanitize' => 'key',
546
+ ),
547
+ '_in_sub_row' => array(
548
+ 'sanitize' => 'absint',
549
+ ),
550
+ '_in_column' => array(
551
+ 'sanitize' => 'absint',
552
+ ),
553
+ '_in_group' => array(
554
+ 'sanitize' => 'absint',
555
+ ),
556
+ '_visibility' => array(
557
+ 'sanitize' => 'key',
558
+ ),
559
+ '_conditional_action' => array(
560
+ 'sanitize' => 'key',
561
+ ),
562
+ '_conditional_action1' => array(
563
+ 'sanitize' => 'key',
564
+ ),
565
+ '_conditional_action2' => array(
566
+ 'sanitize' => 'key',
567
+ ),
568
+ '_conditional_action3' => array(
569
+ 'sanitize' => 'key',
570
+ ),
571
+ '_conditional_action4' => array(
572
+ 'sanitize' => 'key',
573
+ ),
574
+ '_conditional_field' => array(
575
+ 'sanitize' => 'text',
576
+ ),
577
+ '_conditional_field1' => array(
578
+ 'sanitize' => 'text',
579
+ ),
580
+ '_conditional_field2' => array(
581
+ 'sanitize' => 'text',
582
+ ),
583
+ '_conditional_field3' => array(
584
+ 'sanitize' => 'text',
585
+ ),
586
+ '_conditional_field4' => array(
587
+ 'sanitize' => 'text',
588
+ ),
589
+ '_conditional_operator' => array(
590
+ 'sanitize' => 'text',
591
+ ),
592
+ '_conditional_operator1' => array(
593
+ 'sanitize' => 'text',
594
+ ),
595
+ '_conditional_operator2' => array(
596
+ 'sanitize' => 'text',
597
+ ),
598
+ '_conditional_operator3' => array(
599
+ 'sanitize' => 'text',
600
+ ),
601
+ '_conditional_operator4' => array(
602
+ 'sanitize' => 'text',
603
+ ),
604
+ '_conditional_value' => array(
605
+ 'sanitize' => 'text',
606
+ ),
607
+ '_conditional_value1' => array(
608
+ 'sanitize' => 'text',
609
+ ),
610
+ '_conditional_value2' => array(
611
+ 'sanitize' => 'text',
612
+ ),
613
+ '_conditional_value3' => array(
614
+ 'sanitize' => 'text',
615
+ ),
616
+ '_conditional_value4' => array(
617
+ 'sanitize' => 'text',
618
+ ),
619
+ '_validate' => array(
620
+ 'sanitize' => 'key',
621
+ ),
622
+ '_custom_validate' => array(
623
+ 'sanitize' => 'text',
624
+ ),
625
+ '_icon' => array(
626
+ 'sanitize' => 'key',
627
+ ),
628
+ '_css_class' => array(
629
+ 'sanitize' => 'text',
630
+ ),
631
+ '_width' => array(
632
+ 'sanitize' => 'absint',
633
+ ),
634
+ '_divider_text' => array(
635
+ 'sanitize' => 'text',
636
+ ),
637
+ '_padding' => array(
638
+ 'sanitize' => 'text',
639
+ ),
640
+ '_margin' => array(
641
+ 'sanitize' => 'text',
642
+ ),
643
+ '_border' => array(
644
+ 'sanitize' => 'text',
645
+ ),
646
+ '_borderstyle' => array(
647
+ 'sanitize' => 'key',
648
+ ),
649
+ '_borderradius' => array(
650
+ 'sanitize' => 'text',
651
+ ),
652
+ '_bordercolor' => array(
653
+ 'sanitize' => 'text',
654
+ ),
655
+ '_heading' => array(
656
+ 'sanitize' => 'bool',
657
+ ),
658
+ '_heading_text' => array(
659
+ 'sanitize' => 'text',
660
+ ),
661
+ '_background' => array(
662
+ 'sanitize' => 'text',
663
+ ),
664
+ '_heading_background_color' => array(
665
+ 'sanitize' => 'text',
666
+ ),
667
+ '_heading_text_color' => array(
668
+ 'sanitize' => 'text',
669
+ ),
670
+ '_text_color' => array(
671
+ 'sanitize' => 'text',
672
+ ),
673
+ '_icon_color' => array(
674
+ 'sanitize' => 'text',
675
+ ),
676
+ '_color' => array(
677
+ 'sanitize' => 'text',
678
+ ),
679
+ '_url_text' => array(
680
+ 'sanitize' => 'text',
681
+ ),
682
+ '_url_target' => array(
683
+ 'sanitize' => 'key',
684
+ ),
685
+ '_url_rel' => array(
686
+ 'sanitize' => 'key',
687
+ ),
688
+ '_force_good_pass' => array(
689
+ 'sanitize' => 'bool',
690
+ ),
691
+ '_force_confirm_pass' => array(
692
+ 'sanitize' => 'bool',
693
+ ),
694
+ '_style' => array(
695
+ 'sanitize' => 'key',
696
+ ),
697
+ '_intervals' => array(
698
+ 'sanitize' => 'absint',
699
+ ),
700
+ '_format' => array(
701
+ 'sanitize' => 'text',
702
+ ),
703
+ '_format_custom' => array(
704
+ 'sanitize' => 'text',
705
+ ),
706
+ '_pretty_format' => array(
707
+ 'sanitize' => 'bool',
708
+ ),
709
+ '_disabled_weekdays' => array(
710
+ 'sanitize' => 'absint',
711
+ ),
712
+ '_years' => array(
713
+ 'sanitize' => 'absint',
714
+ ),
715
+ '_years_x' => array(
716
+ 'sanitize' => 'key',
717
+ ),
718
+ '_range_start' => array(
719
+ 'sanitize' => 'text',
720
+ ),
721
+ '_range_end' => array(
722
+ 'sanitize' => 'text',
723
+ ),
724
+ '_range' => array(
725
+ 'sanitize' => 'key',
726
+ ),
727
+ '_content' => array(
728
+ 'sanitize' => 'textarea',
729
+ ),
730
+ '_crop' => array(
731
+ 'sanitize' => 'int',
732
+ ),
733
+ '_allowed_types' => array(
734
+ 'sanitize' => 'key',
735
+ ),
736
+ '_upload_text' => array(
737
+ 'sanitize' => 'text',
738
+ ),
739
+ '_upload_help_text' => array(
740
+ 'sanitize' => 'text',
741
+ ),
742
+ '_button_text' => array(
743
+ 'sanitize' => 'text',
744
+ ),
745
+ '_max_size' => array(
746
+ 'sanitize' => 'absint',
747
+ ),
748
+ '_height' => array(
749
+ 'sanitize' => 'text',
750
+ ),
751
+ '_spacing' => array(
752
+ 'sanitize' => 'text',
753
+ ),
754
+ '_is_multi' => array(
755
+ 'sanitize' => 'bool',
756
+ ),
757
+ '_max_selections' => array(
758
+ 'sanitize' => 'absint',
759
+ ),
760
+ '_min_selections' => array(
761
+ 'sanitize' => 'absint',
762
+ ),
763
+ '_max_entries' => array(
764
+ 'sanitize' => 'absint',
765
+ ),
766
+ '_max_words' => array(
767
+ 'sanitize' => 'absint',
768
+ ),
769
+ '_min' => array(
770
+ 'sanitize' => 'absint',
771
+ ),
772
+ '_max' => array(
773
+ 'sanitize' => 'absint',
774
+ ),
775
+ '_min_chars' => array(
776
+ 'sanitize' => 'absint',
777
+ ),
778
+ '_max_chars' => array(
779
+ 'sanitize' => 'absint',
780
+ ),
781
+ '_html' => array(
782
+ 'sanitize' => 'bool',
783
+ ),
784
+ '_options' => array(
785
+ 'sanitize' => 'textarea',
786
+ ),
787
+ '_title' => array(
788
+ 'sanitize' => 'text',
789
+ ),
790
+ '_id' => array(
791
+ 'sanitize' => 'text',
792
+ ),
793
+ '_metakey' => array(
794
+ 'sanitize' => 'text',
795
+ ),
796
+ '_help' => array(
797
+ 'sanitize' => 'text',
798
+ ),
799
+ '_default' => array(
800
+ 'sanitize' => 'text',
801
+ ),
802
+ '_label' => array(
803
+ 'sanitize' => 'text',
804
+ ),
805
+ '_label_confirm_pass' => array(
806
+ 'sanitize' => 'text',
807
+ ),
808
+ '_placeholder' => array(
809
+ 'sanitize' => 'text',
810
+ ),
811
+ '_public' => array(
812
+ 'sanitize' => 'text',
813
+ ),
814
+ '_roles' => array(
815
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
816
+ ),
817
+ '_required' => array(
818
+ 'sanitize' => 'bool',
819
+ ),
820
+ '_editable' => array(
821
+ 'sanitize' => 'bool',
822
+ ),
823
+ '_number' => array(
824
+ 'sanitize' => 'absint',
825
+ ),
826
+ '_custom_dropdown_options_source' => array(
827
+ 'sanitize' => 'text',
828
+ ),
829
+ '_parent_dropdown_relationship' => array(
830
+ 'sanitize' => 'text',
831
+ ),
832
+ )
833
+ );
834
+ }
835
+
836
+
837
+ /**
838
+ * @param array|string $value
839
+ *
840
+ * @return array|string
841
+ */
842
+ public function sanitize_md_sorting_fields( $value ) {
843
+ $filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
844
+ $filter_fields = array_keys( $filter_fields );
845
+
846
+ if ( '' !== $value ) {
847
+ $value = array_filter(
848
+ $value,
849
+ function( $v, $k ) use ( $filter_fields ) {
850
+ if ( 'other_data' === $k ) {
851
+ return true;
852
+ } else {
853
+ return in_array( sanitize_text_field( $v ), $filter_fields, true );
854
+ }
855
+ },
856
+ ARRAY_FILTER_USE_BOTH
857
+ );
858
+
859
+ $value = array_map(
860
+ function( $item ) {
861
+ if ( is_array( $item ) ) {
862
+ if ( isset( $item['meta_key'] ) ) {
863
+ $item['meta_key'] = sanitize_text_field( $item['meta_key'] );
864
+ }
865
+ if ( isset( $item['label'] ) ) {
866
+ $item['label'] = sanitize_text_field( $item['label'] );
867
+ }
868
+
869
+ return $item;
870
+ } else {
871
+ return sanitize_text_field( $item );
872
+ }
873
+ },
874
+ $value
875
+ );
876
+ }
877
+
878
+ return $value;
879
+ }
880
+
881
+
882
+ /**
883
+ * @param array|string $value
884
+ *
885
+ * @return array|string
886
+ */
887
+ public function sanitize_filter_fields( $value ) {
888
+ $filter_fields = array_keys( UM()->member_directory()->filter_fields );
889
+
890
+ if ( '' !== $value ) {
891
+ $value = array_filter(
892
+ $value,
893
+ function( $v, $k ) use ( $filter_fields ) {
894
+ return in_array( sanitize_text_field( $v ), $filter_fields, true );
895
+ },
896
+ ARRAY_FILTER_USE_BOTH
897
+ );
898
+
899
+ $value = array_map( 'sanitize_text_field', $value );
900
+ }
901
+
902
+ return $value;
903
+ }
904
+
905
+
906
+ /**
907
+ * @param array|string $value
908
+ *
909
+ * @return array|string
910
+ */
911
+ public function sanitize_user_field( $value ) {
912
+ $user_fields = array_keys( UM()->builtin()->all_user_fields() );
913
+
914
+ if ( '' !== $value ) {
915
+ $value = array_filter(
916
+ $value,
917
+ function( $v, $k ) use ( $user_fields ) {
918
+ return in_array( sanitize_text_field( $v ), $user_fields, true );
919
+ },
920
+ ARRAY_FILTER_USE_BOTH
921
+ );
922
+
923
+ $value = array_map( 'sanitize_text_field', $value );
924
+ }
925
+
926
+ return $value;
927
+ }
928
+
929
+
930
+ /**
931
+ * @param array|string $value
932
+ *
933
+ * @return array|string
934
+ */
935
+ public function sanitize_md_view_types( $value ) {
936
+ $view_types = array_map(
937
+ function ( $item ) {
938
+ return $item['title'];
939
+ },
940
+ UM()->member_directory()->view_types
941
+ );
942
+ $view_types = array_keys( $view_types );
943
+
944
+ if ( '' !== $value ) {
945
+ $value = array_filter(
946
+ $value,
947
+ function( $v, $k ) use ( $view_types ) {
948
+ return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
949
+ },
950
+ ARRAY_FILTER_USE_BOTH
951
+ );
952
+
953
+ $value = array_map( 'sanitize_key', $value );
954
+ }
955
+
956
+ return $value;
957
+ }
958
+
959
+
960
+ /**
961
+ * @param array|string $value
962
+ *
963
+ * @return array|string
964
+ */
965
+ public function sanitize_photosize( $value ) {
966
+ $sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
967
+ $sizes = array_keys( $sizes );
968
+
969
+ if ( '' !== $value ) {
970
+ $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
971
+ }
972
+
973
+ return $value;
974
+ }
975
+
976
+
977
+ /**
978
+ * @param array|string $value
979
+ *
980
+ * @return array|string
981
+ */
982
+ public function sanitize_cover_photosize( $value ) {
983
+ $sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
984
+ $sizes = array_keys( $sizes );
985
+
986
+ if ( '' !== $value ) {
987
+ $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
988
+ }
989
+
990
+ return $value;
991
+ }
992
+
993
+
994
+ /**
995
+ * @param array|string $value
996
+ *
997
+ * @return array|string
998
+ */
999
+ public function sanitize_restriction_existed_role( $value ) {
1000
+ $all_roles = array_keys( UM()->roles()->get_roles() );
1001
+
1002
+ if ( '' !== $value ) {
1003
+ $value = array_filter(
1004
+ $value,
1005
+ function( $v, $k ) use ( $all_roles ) {
1006
+ return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
1007
+ },
1008
+ ARRAY_FILTER_USE_BOTH
1009
+ );
1010
+
1011
+ $value = array_map( 'sanitize_key', $value );
1012
+ }
1013
+
1014
+ return $value;
1015
+ }
1016
+
1017
+
1018
+ /**
1019
+ * @param array|string $value
1020
+ *
1021
+ * @return array|string
1022
+ */
1023
+ public function sanitize_existed_role( $value ) {
1024
+ $all_roles = array_keys( UM()->roles()->get_roles() );
1025
+
1026
+ if ( '' !== $value ) {
1027
+ $value = array_filter(
1028
+ $value,
1029
+ function( $v, $k ) use ( $all_roles ) {
1030
+ return in_array( sanitize_key( $v ), $all_roles, true );
1031
+ },
1032
+ ARRAY_FILTER_USE_BOTH
1033
+ );
1034
+
1035
+ $value = array_map( 'sanitize_key', $value );
1036
+ }
1037
+
1038
+ return $value;
1039
+ }
1040
+
1041
+
1042
+ /**
1043
+ * @param array|string $value
1044
+ *
1045
+ * @return array|string
1046
+ */
1047
+ public function sanitize_tabs_privacy( $value ) {
1048
+ $all_privacy = array_keys( UM()->profile()->tabs_privacy() );
1049
+
1050
+ if ( '' !== $value ) {
1051
+ $value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
1052
+ }
1053
+
1054
+ return $value;
1055
+ }
1056
+
1057
+
1058
+ /**
1059
+ * @param $value
1060
+ *
1061
+ * @return bool|string
1062
+ */
1063
+ public function sanitize_profile_noindex( $value ) {
1064
+ $value = '' !== $value ? (bool) $value : $value;
1065
+ return $value;
1066
+ }
1067
+
1068
+
1069
+ /**
1070
+ * @param $value
1071
+ *
1072
+ * @return array
1073
+ */
1074
+ public function sanitize_wp_capabilities( $value ) {
1075
+ $value = array_map( 'boolval', array_filter( $value ) );
1076
+ return $value;
1077
+ }
1078
+
1079
+
1080
+ /**
1081
+ * Sanitize role meta fields when wp-admin form has been submitted
1082
+ *
1083
+ * @param array $data
1084
+ *
1085
+ * @return array
1086
+ */
1087
+ public function sanitize_role_meta( $data ) {
1088
+ $sanitized = array();
1089
+ foreach ( $data as $k => $v ) {
1090
+ if ( ! array_key_exists( $k, $this->role_meta ) ) {
1091
+ // @todo remove since 2.2.x and leave only continue
1092
+ $sanitized[ $k ] = $v;
1093
+ continue;
1094
+ }
1095
+
1096
+ if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
1097
+ // @todo remove since 2.2.x and leave only continue
1098
+ $sanitized[ $k ] = $v;
1099
+ continue;
1100
+ }
1101
+
1102
+ if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1103
+ add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
1104
+ }
1105
+
1106
+ switch ( $this->role_meta[ $k ]['sanitize'] ) {
1107
+ default:
1108
+ $sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
1109
+ break;
1110
+ case 'int':
1111
+ $sanitized[ $k ] = (int) $v;
1112
+ break;
1113
+ case 'bool':
1114
+ $sanitized[ $k ] = (bool) $v;
1115
+ break;
1116
+ case 'url':
1117
+ $sanitized[ $k ] = esc_url_raw( $v );
1118
+ break;
1119
+ case 'textarea':
1120
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1121
+ break;
1122
+ case 'sanitize_array_key':
1123
+ if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
1124
+ continue 2;
1125
+ }
1126
+
1127
+ $sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
1128
+ break;
1129
+ }
1130
+ }
1131
+
1132
+ $data = $sanitized;
1133
+
1134
+ $data = apply_filters( 'um_save_role_meta_sanitize', $data );
1135
+
1136
+ return $data;
1137
+ }
1138
+
1139
+
1140
+ /**
1141
+ * Sanitize post restriction meta fields when wp-admin form has been submitted
1142
+ *
1143
+ * @param array $data
1144
+ *
1145
+ * @return array
1146
+ */
1147
+ public function sanitize_post_restriction_meta( $data ) {
1148
+ $sanitized = array();
1149
+ foreach ( $data as $k => $v ) {
1150
+ if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
1151
+ // @todo remove since 2.2.x and leave only continue
1152
+ $sanitized[ $k ] = $v;
1153
+ continue;
1154
+ }
1155
+
1156
+ if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
1157
+ // @todo remove since 2.2.x and leave only continue
1158
+ $sanitized[ $k ] = $v;
1159
+ continue;
1160
+ }
1161
+
1162
+ if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1163
+ add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
1164
+ }
1165
+
1166
+ switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
1167
+ default:
1168
+ $sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
1169
+ break;
1170
+ case 'int':
1171
+ $sanitized[ $k ] = (int) $v;
1172
+ break;
1173
+ case 'bool':
1174
+ $sanitized[ $k ] = (bool) $v;
1175
+ break;
1176
+ case 'url':
1177
+ $sanitized[ $k ] = esc_url_raw( $v );
1178
+ break;
1179
+ case 'textarea':
1180
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1181
+ break;
1182
+ case 'wp_kses':
1183
+ $sanitized[ $k ] = wp_kses_post( $v );
1184
+ break;
1185
+ }
1186
+ }
1187
+
1188
+ $data = $sanitized;
1189
+
1190
+ $data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
1191
+
1192
+ return $data;
1193
+ }
1194
+
1195
+
1196
+ /**
1197
+ * Sanitize term restriction meta fields when wp-admin form has been submitted
1198
+ *
1199
+ * @param array $data
1200
+ *
1201
+ * @return array
1202
+ */
1203
+ public function sanitize_term_restriction_meta( $data ) {
1204
+ $sanitized = array();
1205
+ foreach ( $data as $k => $v ) {
1206
+ if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
1207
+ // @todo remove since 2.2.x and leave only continue
1208
+ $sanitized[ $k ] = $v;
1209
+ continue;
1210
+ }
1211
+
1212
+ if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
1213
+ // @todo remove since 2.2.x and leave only continue
1214
+ $sanitized[ $k ] = $v;
1215
+ continue;
1216
+ }
1217
+
1218
+ if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1219
+ add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
1220
+ }
1221
+
1222
+ switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
1223
+ default:
1224
+ $sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
1225
+ break;
1226
+ case 'int':
1227
+ $sanitized[ $k ] = (int) $v;
1228
+ break;
1229
+ case 'bool':
1230
+ $sanitized[ $k ] = (bool) $v;
1231
+ break;
1232
+ case 'url':
1233
+ $sanitized[ $k ] = esc_url_raw( $v );
1234
+ break;
1235
+ case 'textarea':
1236
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1237
+ break;
1238
+ case 'wp_kses':
1239
+ $sanitized[ $k ] = wp_kses_post( $v );
1240
+ break;
1241
+ }
1242
+ }
1243
+
1244
+ $data = $sanitized;
1245
+
1246
+ $data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
1247
+
1248
+ return $data;
1249
+ }
1250
+
1251
+
1252
+ /**
1253
+ * Sanitize member directory meta when wp-admin form has been submitted
1254
+ *
1255
+ * @todo checking all sanitize types
1256
+ *
1257
+ * @param array $data
1258
+ *
1259
+ * @return array
1260
+ */
1261
+ public function sanitize_member_directory_meta( $data ) {
1262
+ $sanitized = array();
1263
+ foreach ( $data as $k => $v ) {
1264
+ if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
1265
+ // @todo remove since 2.2.x and leave only continue
1266
+ $sanitized[ $k ] = $v;
1267
+ continue;
1268
+ }
1269
+
1270
+ if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
1271
+ // @todo remove since 2.2.x and leave only continue
1272
+ $sanitized[ $k ] = $v;
1273
+ continue;
1274
+ }
1275
+
1276
+ if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1277
+ add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
1278
+ }
1279
+
1280
+ switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
1281
+ default:
1282
+ $sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
1283
+ break;
1284
+ case 'int':
1285
+ $sanitized[ $k ] = (int) $v;
1286
+ break;
1287
+ case 'bool':
1288
+ $sanitized[ $k ] = (bool) $v;
1289
+ break;
1290
+ case 'url':
1291
+ if ( is_array( $v ) ) {
1292
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1293
+ } else {
1294
+ $sanitized[ $k ] = esc_url_raw( $v );
1295
+ }
1296
+ break;
1297
+ case 'text':
1298
+ $sanitized[ $k ] = sanitize_text_field( $v );
1299
+ break;
1300
+ case 'textarea':
1301
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1302
+ break;
1303
+ case 'key':
1304
+ if ( is_array( $v ) ) {
1305
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1306
+ } else {
1307
+ $sanitized[ $k ] = sanitize_key( $v );
1308
+ }
1309
+ break;
1310
+ case 'absint':
1311
+ if ( is_array( $v ) ) {
1312
+ $sanitized[ $k ] = array_map( 'absint', $v );
1313
+ } else {
1314
+ $sanitized[ $k ] = absint( $v );
1315
+ }
1316
+ break;
1317
+ }
1318
+ }
1319
+
1320
+ $data = $sanitized;
1321
+
1322
+ $data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
1323
+
1324
+ return $data;
1325
+ }
1326
+
1327
+
1328
+ /**
1329
+ * Sanitize builder field meta when wp-admin form has been submitted
1330
+ *
1331
+ * @todo checking all sanitize types
1332
+ *
1333
+ * @param array $data
1334
+ *
1335
+ * @return array
1336
+ */
1337
+ public function sanitize_builder_field_meta( $data ) {
1338
+ $sanitized = array();
1339
+ foreach ( $data as $k => $v ) {
1340
+ if ( ! array_key_exists( $k, $this->builder_input ) ) {
1341
+ // @todo remove since 2.2.x and leave only continue
1342
+ $sanitized[ $k ] = $v;
1343
+ continue;
1344
+ }
1345
+
1346
+ if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
1347
+ // @todo remove since 2.2.x and leave only continue
1348
+ $sanitized[ $k ] = $v;
1349
+ continue;
1350
+ }
1351
+
1352
+ if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
1353
+ add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
1354
+ }
1355
+
1356
+ switch ( $this->builder_input[ $k ]['sanitize'] ) {
1357
+ default:
1358
+ $sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
1359
+ break;
1360
+ case 'int':
1361
+ $sanitized[ $k ] = (int) $v;
1362
+ break;
1363
+ case 'bool':
1364
+ $sanitized[ $k ] = (bool) $v;
1365
+ break;
1366
+ case 'url':
1367
+ if ( is_array( $v ) ) {
1368
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1369
+ } else {
1370
+ $sanitized[ $k ] = esc_url_raw( $v );
1371
+ }
1372
+ break;
1373
+ case 'text':
1374
+ $sanitized[ $k ] = sanitize_text_field( $v );
1375
+ break;
1376
+ case 'textarea':
1377
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1378
+ break;
1379
+ case 'wp_kses':
1380
+ $sanitized[ $k ] = wp_kses_post( $v );
1381
+ break;
1382
+ case 'key':
1383
+ if ( is_array( $v ) ) {
1384
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1385
+ } else {
1386
+ $sanitized[ $k ] = sanitize_key( $v );
1387
+ }
1388
+ break;
1389
+ case 'absint':
1390
+ if ( is_array( $v ) ) {
1391
+ $sanitized[ $k ] = array_map( 'absint', $v );
1392
+ } else {
1393
+ $sanitized[ $k ] = absint( $v );
1394
+ }
1395
+ break;
1396
+ }
1397
+ }
1398
+
1399
+ $data = $sanitized;
1400
+
1401
+ $data = apply_filters( 'um_save_builder_input_sanitize', $data );
1402
+
1403
+ return $data;
1404
+ }
1405
+
1406
+
1407
+ /**
1408
+ * Sanitize form meta when wp-admin form has been submitted
1409
+ *
1410
+ * @todo checking all sanitize types
1411
+ *
1412
+ * @param array $data
1413
+ *
1414
+ * @return array
1415
+ */
1416
+ public function sanitize_form_meta( $data ) {
1417
+ $sanitized = array();
1418
+ foreach ( $data as $k => $v ) {
1419
+ if ( ! array_key_exists( $k, $this->form_meta ) ) {
1420
+ // @todo remove since 2.2.x and leave only continue
1421
+ $sanitized[ $k ] = $v;
1422
+ continue;
1423
+ }
1424
+
1425
+ if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
1426
+ // @todo remove since 2.2.x and leave only continue
1427
+ $sanitized[ $k ] = $v;
1428
+ continue;
1429
+ }
1430
+
1431
+ if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1432
+ add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
1433
+ }
1434
+
1435
+ switch ( $this->form_meta[ $k ]['sanitize'] ) {
1436
+ default:
1437
+ $sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
1438
+ break;
1439
+ case 'int':
1440
+ $sanitized[ $k ] = (int) $v;
1441
+ break;
1442
+ case 'bool':
1443
+ $sanitized[ $k ] = (bool) $v;
1444
+ break;
1445
+ case 'url':
1446
+ if ( is_array( $v ) ) {
1447
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1448
+ } else {
1449
+ $sanitized[ $k ] = esc_url_raw( $v );
1450
+ }
1451
+ break;
1452
+ case 'text':
1453
+ $sanitized[ $k ] = sanitize_text_field( $v );
1454
+ break;
1455
+ case 'textarea':
1456
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1457
+ break;
1458
+ case 'key':
1459
+ if ( is_array( $v ) ) {
1460
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1461
+ } else {
1462
+ $sanitized[ $k ] = sanitize_key( $v );
1463
+ }
1464
+ break;
1465
+ case 'absint':
1466
+ if ( is_array( $v ) ) {
1467
+ $sanitized[ $k ] = array_map( 'absint', $v );
1468
+ } else {
1469
+ $sanitized[ $k ] = absint( $v );
1470
+ }
1471
+ break;
1472
+ }
1473
+ }
1474
+
1475
+ $data = $sanitized;
1476
+
1477
+ $data = apply_filters( 'um_save_form_meta_sanitize', $data );
1478
+
1479
+ return $data;
1480
+ }
1481
+
1482
+
1483
+ /**
1484
+ * Sanitize options when wp-admin form has been submitted
1485
+ *
1486
+ * @todo checking all sanitize types
1487
+ *
1488
+ * @param array $data
1489
+ *
1490
+ * @return array
1491
+ */
1492
+ public function sanitize_options( $data ) {
1493
+ $sanitized = array();
1494
+ foreach ( $data as $k => $v ) {
1495
+ if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
1496
+ // @todo remove since 2.2.x and leave only continue
1497
+ $sanitized[ $k ] = $v;
1498
+ continue;
1499
+ }
1500
+
1501
+ if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
1502
+ // @todo remove since 2.2.x and leave only continue
1503
+ $sanitized[ $k ] = $v;
1504
+ continue;
1505
+ }
1506
+
1507
+ if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
1508
+ add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
1509
+ }
1510
+
1511
+ switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
1512
+ default:
1513
+ $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
1514
+ break;
1515
+ case 'int':
1516
+ $sanitized[ $k ] = (int) $v;
1517
+ break;
1518
+ case 'absint':
1519
+ if ( is_array( $v ) ) {
1520
+ $sanitized[ $k ] = array_map( 'absint', $v );
1521
+ } else {
1522
+ $sanitized[ $k ] = absint( $v );
1523
+ }
1524
+ break;
1525
+ case 'key':
1526
+ if ( is_array( $v ) ) {
1527
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1528
+ } else {
1529
+ $sanitized[ $k ] = sanitize_key( $v );
1530
+ }
1531
+ break;
1532
+ case 'bool':
1533
+ $sanitized[ $k ] = (bool) $v;
1534
+ break;
1535
+ case 'url':
1536
+ if ( is_array( $v ) ) {
1537
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1538
+ } else {
1539
+ $sanitized[ $k ] = esc_url_raw( $v );
1540
+ }
1541
+ break;
1542
+ case 'wp_kses':
1543
+ $sanitized[ $k ] = wp_kses_post( $v );
1544
+ break;
1545
+ case 'textarea':
1546
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1547
+ break;
1548
+ case 'text':
1549
+ $sanitized[ $k ] = sanitize_text_field( $v );
1550
+ break;
1551
+ }
1552
+ }
1553
+
1554
+ $data = $sanitized;
1555
+
1556
+ $data = apply_filters( 'um_save_settings_sanitize', $data );
1557
+
1558
+ return $data;
1559
+ }
1560
+
1561
+
1562
+ /**
1563
+ * Adds class to our admin pages
1564
+ *
1565
+ * @param $classes
1566
+ *
1567
+ * @return string
1568
+ */
1569
+ public function admin_body_class( $classes ) {
1570
+ if ( $this->is_um_screen() ) {
1571
+ return "$classes um-admin";
1572
+ }
1573
+ return $classes;
1574
+ }
1575
+
1576
+
1577
+ /**
1578
+ *
1579
+ */
1580
+ public function manual_upgrades_request() {
1581
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1582
+ die();
1583
+ }
1584
+
1585
+ $last_request = get_option( 'um_last_manual_upgrades_request', false );
1586
+
1587
+ if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
1588
+
1589
+ if ( is_multisite() ) {
1590
+ $blogs_ids = get_sites();
1591
+ foreach( $blogs_ids as $b ) {
1592
+ switch_to_blog( $b->blog_id );
1593
+ wp_clean_update_cache();
1594
+
1595
+ UM()->plugin_updater()->um_checklicenses();
1596
+
1597
+ update_option( 'um_last_manual_upgrades_request', time() );
1598
+ restore_current_blog();
1599
+ }
1600
+ } else {
1601
+ wp_clean_update_cache();
1602
+
1603
+ UM()->plugin_updater()->um_checklicenses();
1604
+
1605
+ update_option( 'um_last_manual_upgrades_request', time() );
1606
+ }
1607
+
1608
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
1609
+ } else {
1610
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
1611
+ }
1612
+ exit( wp_redirect( $url ) );
1613
+ }
1614
+
1615
+
1616
+ /**
1617
+ * Core pages installation
1618
+ */
1619
+ function install_core_pages() {
1620
+ if ( ! is_admin() ) {
1621
+ die();
1622
+ }
1623
+
1624
+ UM()->setup()->install_default_pages();
1625
+
1626
+ //check empty pages in settings
1627
+ $empty_pages = array();
1628
+
1629
+ $pages = UM()->config()->permalinks;
1630
+ if ( $pages && is_array( $pages ) ) {
1631
+ foreach ( $pages as $slug => $page_id ) {
1632
+ $page = get_post( $page_id );
1633
+
1634
+ if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
1635
+ $empty_pages[] = $slug;
1636
+ }
1637
+ }
1638
+ }
1639
+
1640
+ //if there aren't empty pages - then hide pages notice
1641
+ if ( empty( $empty_pages ) ) {
1642
+ $hidden_notices = get_option( 'um_hidden_admin_notices', array() );
1643
+ $hidden_notices[] = 'wrong_pages';
1644
+
1645
+ update_option( 'um_hidden_admin_notices', $hidden_notices );
1646
+ }
1647
+
1648
+ $url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
1649
+ exit( wp_redirect( $url ) );
1650
+ }
1651
+
1652
+
1653
+ /**
1654
+ * Clear all users cache
1655
+ *
1656
+ * @param $action
1657
+ */
1658
+ function user_cache( $action ) {
1659
+ global $wpdb;
1660
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1661
+ die();
1662
+ }
1663
+
1664
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
1665
+
1666
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
1667
+ exit( wp_redirect( $url ) );
1668
+ }
1669
+
1670
+
1671
+ /**
1672
+ * Purge temp uploads dir
1673
+ * @param $action
1674
+ */
1675
+ function purge_temp( $action ) {
1676
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1677
+ die();
1678
+ }
1679
+
1680
+ UM()->files()->remove_dir( UM()->files()->upload_temp );
1681
+
1682
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
1683
+ exit( wp_redirect( $url ) );
1684
+ }
1685
+
1686
+
1687
+ /**
1688
+ * Duplicate form
1689
+ *
1690
+ * @param $action
1691
+ */
1692
+ function duplicate_form( $action ) {
1693
+ if ( ! is_admin() || ! current_user_can('manage_options') ) {
1694
+ die();
1695
+ }
1696
+ if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
1697
+ die();
1698
+ }
1699
+
1700
+ $post_id = absint( $_REQUEST['post_id'] );
1701
+
1702
+ $n = array(
1703
+ 'post_type' => 'um_form',
1704
+ 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
1705
+ 'post_status' => 'publish',
1706
+ 'post_author' => get_current_user_id(),
1707
+ );
1708
+
1709
+ $n_id = wp_insert_post( $n );
1710
+
1711
+ $n_fields = get_post_custom( $post_id );
1712
+ foreach ( $n_fields as $key => $value ) {
1713
+
1714
+ if ( $key == '_um_custom_fields' ) {
1715
+ $the_value = unserialize( $value[0] );
1716
+ } else {
1717
+ $the_value = $value[0];
1718
+ }
1719
+
1720
+ update_post_meta( $n_id, $key, $the_value );
1721
+
1722
+ }
1723
+
1724
+ delete_post_meta( $n_id, '_um_core' );
1725
+
1726
+ $url = admin_url( 'edit.php?post_type=um_form' );
1727
+ $url = add_query_arg( 'update', 'form_duplicated', $url );
1728
+
1729
+ exit( wp_redirect( $url ) );
1730
+
1731
+ }
1732
+
1733
+
1734
+ /**
1735
+ * Action to hide notices in admin
1736
+ *
1737
+ * @param $action
1738
+ */
1739
+ function um_hide_notice( $action ) {
1740
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1741
+ die();
1742
+ }
1743
+
1744
+ update_option( $action, 1 );
1745
+ exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
1746
+ }
1747
+
1748
+
1749
+ /**
1750
+ * Various user actions
1751
+ *
1752
+ * @param $action
1753
+ */
1754
+ function user_action( $action ) {
1755
+ if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
1756
+ die();
1757
+ }
1758
+ if ( ! isset( $_REQUEST['sub'] ) ) {
1759
+ die();
1760
+ }
1761
+ if ( ! isset( $_REQUEST['user_id'] ) ) {
1762
+ die();
1763
+ }
1764
+
1765
+ um_fetch_user( absint( $_REQUEST['user_id'] ) );
1766
+
1767
+ $subaction = sanitize_key( $_REQUEST['sub'] );
1768
+
1769
+ /**
1770
+ * UM hook
1771
+ *
1772
+ * @type action
1773
+ * @title um_admin_user_action_hook
1774
+ * @description Action on bulk user subaction
1775
+ * @input_vars
1776
+ * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
1777
+ * @change_log
1778
+ * ["Since: 2.0"]
1779
+ * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
1780
+ * @example
1781
+ * <?php
1782
+ * add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
1783
+ * function my_admin_user_action( $subaction ) {
1784
+ * // your code here
1785
+ * }
1786
+ * ?>
1787
+ */
1788
+ do_action( 'um_admin_user_action_hook', $subaction );
1789
+ /**
1790
+ * UM hook
1791
+ *
1792
+ * @type action
1793
+ * @title um_admin_user_action_{$subaction}_hook
1794
+ * @description Action on bulk user subaction
1795
+ * @change_log
1796
+ * ["Since: 2.0"]
1797
+ * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
1798
+ * @example
1799
+ * <?php
1800
+ * add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
1801
+ * function my_admin_user_action() {
1802
+ * // your code here
1803
+ * }
1804
+ * ?>
1805
+ */
1806
+ do_action( "um_admin_user_action_{$subaction}_hook" );
1807
+
1808
+ um_reset_user();
1809
+
1810
+ wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
1811
+ exit;
1812
+
1813
+ }
1814
+
1815
+
1816
+ /**
1817
+ * Add any custom links to plugin page
1818
+ *
1819
+ * @param array $links
1820
+ *
1821
+ * @return array
1822
+ */
1823
+ function plugin_links( $links ) {
1824
+ $more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
1825
+ $more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
1826
+
1827
+ $links = $more_links + $links;
1828
+ return $links;
1829
+ }
1830
+
1831
+
1832
+ /**
1833
+ * Init admin action/filters + request handlers
1834
+ */
1835
+ function admin_init() {
1836
+ $this->init_variables();
1837
+
1838
+ if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
1839
+ $action = sanitize_key( $_REQUEST['um_adm_action'] );
1840
+
1841
+ /**
1842
+ * UM hook
1843
+ *
1844
+ * @type action
1845
+ * @title um_admin_do_action__
1846
+ * @description Make some action on custom admin action
1847
+ * @input_vars
1848
+ * [{"var":"$action","type":"string","desc":"Admin Action"}]
1849
+ * @change_log
1850
+ * ["Since: 2.0"]
1851
+ * @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
1852
+ * @example
1853
+ * <?php
1854
+ * add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
1855
+ * function my_admin_do_action( $action ) {
1856
+ * // your code here
1857
+ * }
1858
+ * ?>
1859
+ */
1860
+ do_action( 'um_admin_do_action__', $action );
1861
+ /**
1862
+ * UM hook
1863
+ *
1864
+ * @type action
1865
+ * @title um_admin_do_action__{$action}
1866
+ * @description Make some action on custom admin $action
1867
+ * @input_vars
1868
+ * [{"var":"$action","type":"string","desc":"Admin Action"}]
1869
+ * @change_log
1870
+ * ["Since: 2.0"]
1871
+ * @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
1872
+ * @example
1873
+ * <?php
1874
+ * add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
1875
+ * function my_admin_do_action( $action ) {
1876
+ * // your code here
1877
+ * }
1878
+ * ?>
1879
+ */
1880
+ do_action( "um_admin_do_action__{$action}", $action );
1881
+ }
1882
+ }
1883
+
1884
+
1885
+ /**
1886
+ * Updated post messages
1887
+ *
1888
+ * @param array $messages
1889
+ *
1890
+ * @return array
1891
+ */
1892
+ function post_updated_messages( $messages ) {
1893
+ global $post_ID;
1894
+
1895
+ $post_type = get_post_type( $post_ID );
1896
+
1897
+ if ( $post_type == 'um_form' ) {
1898
+ $messages['um_form'] = array(
1899
+ 0 => '',
1900
+ 1 => __( 'Form updated.', 'ultimate-member' ),
1901
+ 2 => __( 'Custom field updated.', 'ultimate-member' ),
1902
+ 3 => __( 'Custom field deleted.', 'ultimate-member' ),
1903
+ 4 => __( 'Form updated.', 'ultimate-member' ),
1904
+ 5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
1905
+ 6 => __( 'Form created.', 'ultimate-member' ),
1906
+ 7 => __( 'Form saved.', 'ultimate-member' ),
1907
+ 8 => __( 'Form submitted.', 'ultimate-member' ),
1908
+ 9 => __( 'Form scheduled.', 'ultimate-member' ),
1909
+ 10 => __( 'Form draft updated.', 'ultimate-member' ),
1910
+ );
1911
+ }
1912
+
1913
+ return $messages;
1914
+ }
1915
+
1916
+
1917
+ /**
1918
+ * Gettext filters
1919
+ *
1920
+ * @param $translation
1921
+ * @param $text
1922
+ * @param $domain
1923
+ *
1924
+ * @return string
1925
+ */
1926
+ function gettext( $translation, $text, $domain ) {
1927
+ global $post;
1928
+ if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
1929
+ $translations = get_translations_for_domain( $domain );
1930
+ if ( $text == 'Publish' ) {
1931
+ return $translations->translate( 'Create' );
1932
+ } elseif ( $text == 'Move to Trash' ) {
1933
+ return $translations->translate( 'Delete' );
1934
+ }
1935
+ }
1936
+
1937
+ return $translation;
1938
+ }
1939
+
1940
+
1941
+ /**
1942
+ * Fix parent file for correct highlighting
1943
+ *
1944
+ * @param $parent_file
1945
+ *
1946
+ * @return string
1947
+ */
1948
+ function parent_file( $parent_file ) {
1949
+ global $current_screen;
1950
+ $screen_id = $current_screen->id;
1951
+ if ( strstr( $screen_id, 'um_' ) ) {
1952
+ $parent_file = 'ultimatemember';
1953
+ }
1954
+ return $parent_file;
1955
+ }
1956
+
1957
+
1958
+ /**
1959
+ * @since 2.0
1960
+ *
1961
+ * @return core\Admin_Notices()
1962
+ */
1963
+ function notices() {
1964
+ if ( empty( UM()->classes['admin_notices'] ) ) {
1965
+ UM()->classes['admin_notices'] = new core\Admin_Notices();
1966
+ }
1967
+ return UM()->classes['admin_notices'];
1968
+ }
1969
+ }
1970
+ }
includes/admin/core/class-admin-builder.php CHANGED
@@ -1,1228 +1,1228 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_Builder
13
- * @package um\admin\core
14
- */
15
- class Admin_Builder {
16
-
17
-
18
- /**
19
- * @var
20
- */
21
- var $form_id;
22
-
23
-
24
- /**
25
- * Admin_Builder constructor.
26
- */
27
- function __construct() {
28
- add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
29
- add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
30
- add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
31
- add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
32
- add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
33
- add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
34
- }
35
-
36
-
37
- /**
38
- * Apply a filter to handle errors for field updating in backend
39
- *
40
- * @param $errors
41
- * @param $array
42
- *
43
- * @return mixed
44
- */
45
- function um_admin_field_update_error_handling( $errors, $array ) {
46
- /**
47
- * @var $field_type
48
- */
49
- extract( $array );
50
-
51
- $field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
52
-
53
- if ( isset( $field_attr['validate'] ) ) {
54
-
55
- $validate = $field_attr['validate'];
56
- foreach ( $validate as $post_input => $arr ) {
57
-
58
- $skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
59
- if ( $skip ) {
60
- continue;
61
- }
62
-
63
- $mode = $arr['mode'];
64
-
65
- switch ( $mode ) {
66
-
67
- case 'numeric':
68
- if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
69
- $errors[ $post_input ] = $validate[ $post_input ]['error'];
70
- }
71
- break;
72
-
73
- case 'unique':
74
- if ( ! isset( $array['post']['edit_mode'] ) ) {
75
- if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
76
- $errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
77
- }
78
- }
79
- break;
80
-
81
- case 'required':
82
- if ( $array['post'][ $post_input ] == '' ) {
83
- $errors[ $post_input ] = $validate[ $post_input ]['error'];
84
- }
85
- break;
86
-
87
- case 'range-start':
88
- if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
89
- $errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
90
- }
91
- break;
92
-
93
- case 'range-end':
94
- if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
95
- $errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
96
- }
97
- break;
98
-
99
- }
100
-
101
- }
102
-
103
- }
104
-
105
- return $errors;
106
-
107
- }
108
-
109
-
110
- /**
111
- * Some fields may require extra fields before saving
112
- *
113
- * @param $array
114
- *
115
- * @return mixed
116
- */
117
- function um_admin_pre_save_fields_hook( $array ) {
118
- /**
119
- * @var $form_id
120
- * @var $field_type
121
- */
122
- extract( $array );
123
-
124
- $fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
125
-
126
- $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
127
- $count = 1;
128
- if ( ! empty( $fields ) ) {
129
- $count = count( $fields ) + 1;
130
- }
131
-
132
- // set unique meta key
133
- if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
134
- $array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
135
- }
136
-
137
- // set position
138
- if ( ! isset( $array['post']['_position'] ) ) {
139
- $array['post']['_position'] = $count;
140
- }
141
-
142
- return $array;
143
- }
144
-
145
-
146
- /**
147
- * Modify field args just before it is saved into form
148
- *
149
- * @param $array
150
- *
151
- * @return mixed
152
- */
153
- function um_admin_pre_save_field_to_form( $array ){
154
- unset( $array['conditions'] );
155
- if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
156
- $array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
157
- $array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
158
- }
159
-
160
- if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
161
- $array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
162
- $array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
163
- }
164
-
165
- if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
166
- $array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
167
- $array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
168
- }
169
-
170
- if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
171
- $array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
172
- $array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
173
- }
174
-
175
- if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
176
- $array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
177
- $array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
178
- }
179
-
180
- return $array;
181
- }
182
-
183
-
184
- /**
185
- * Put status handler in modal
186
- */
187
- function add_message_handlers() {
188
- ?>
189
- <div class="um-admin-error-block"></div>
190
- <div class="um-admin-success-block"></div>
191
- <?php
192
- }
193
-
194
-
195
- /**
196
- * Footer of modal
197
- *
198
- * @param $form_id
199
- * @param $field_args
200
- * @param $in_edit
201
- * @param $edit_array
202
- */
203
- function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
204
- $metabox = UM()->metabox();
205
-
206
- if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
207
- return;
208
- } ?>
209
-
210
- <div class="um-admin-btn-toggle">
211
-
212
- <?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
213
- <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
214
- <?php } else { ?>
215
- <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
216
- <?php } ?>
217
-
218
- <div class="um-admin-btn-content">
219
- <div class="um-admin-cur-condition-template">
220
-
221
- <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
222
- <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
223
- <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
224
- <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
225
-
226
- <p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
227
-
228
- <div class="um-admin-clear"></div>
229
- </div>
230
- <p class="um-admin-conditions-notice">
231
- <small>
232
- <?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
233
- <br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
234
- <br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
235
- </small>
236
- </p>
237
- <p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
238
- <p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
239
-
240
- <div class="um-admin-clear"></div>
241
-
242
- <?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
243
-
244
- foreach ( $edit_array['conditions'] as $k => $arr ) {
245
-
246
- if ( $k == 0 ) $k = ''; ?>
247
-
248
- <div class="um-admin-cur-condition">
249
-
250
- <?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
251
- <?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
252
- <?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
253
- <?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
254
-
255
- <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
256
-
257
- <div class="um-admin-clear"></div>
258
- </div>
259
-
260
- <?php
261
- }
262
-
263
- } else { ?>
264
-
265
- <div class="um-admin-cur-condition">
266
-
267
- <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
268
- <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
269
- <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
270
- <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
271
-
272
- <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
273
-
274
- <div class="um-admin-clear"></div>
275
- </div>
276
-
277
- <?php } ?>
278
- </div>
279
- </div>
280
-
281
- <?php
282
- }
283
-
284
-
285
- /**
286
- * Update the builder area
287
- */
288
- function update_builder() {
289
- UM()->admin()->check_ajax_nonce();
290
-
291
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
292
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
293
- }
294
-
295
- ob_start();
296
-
297
- $this->form_id = absint( $_POST['form_id'] );
298
-
299
- $this->show_builder();
300
-
301
- $output = ob_get_clean();
302
-
303
- if ( is_array( $output ) ) {
304
- print_r( $output );
305
- } else {
306
- echo $output;
307
- }
308
- die;
309
- }
310
-
311
-
312
- /**
313
- * Sort array function
314
- *
315
- * @param array $arr
316
- * @param string $col
317
- * @param int $dir
318
- *
319
- * @return array
320
- */
321
- function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
322
- $sort_col = array();
323
-
324
- foreach ( $arr as $key => $row ) {
325
- if ( ! empty( $row[ $col ] ) ) {
326
- $sort_col[ $key ] = $row[ $col ];
327
- }
328
- }
329
-
330
- if ( ! empty( $sort_col ) ) {
331
- array_multisort( $sort_col, $dir, $arr );
332
- }
333
-
334
- return $arr;
335
- }
336
-
337
-
338
- /**
339
- * Get fields in row
340
- *
341
- * @param $row_id
342
- *
343
- * @return string
344
- */
345
- function get_fields_by_row( $row_id ) {
346
-
347
- if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
348
- $this->global_fields = array();
349
- }
350
-
351
- foreach ( $this->global_fields as $key => $array ) {
352
- if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
353
- $results[ $key ] = $array;
354
- unset( $this->global_fields[ $key ] );
355
- }
356
- }
357
-
358
- return ( isset ( $results ) ) ? $results : '';
359
- }
360
-
361
-
362
- /**
363
- * Get fields by sub row
364
- *
365
- * @param $row_fields
366
- * @param $subrow_id
367
- *
368
- * @return string
369
- */
370
- function get_fields_in_subrow( $row_fields, $subrow_id ) {
371
- if ( ! is_array( $row_fields ) ) {
372
- return '';
373
- }
374
-
375
- foreach( $row_fields as $key => $array ) {
376
- if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
377
- $results[ $key ] = $array;
378
- unset( $this->global_fields[ $key ] );
379
- }
380
- }
381
-
382
- return ( isset ( $results ) ) ? $results : '';
383
- }
384
-
385
-
386
- /**
387
- * Display the builder
388
- */
389
- function show_builder() {
390
-
391
- $fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
392
-
393
- if ( !isset( $fields ) || empty( $fields ) ) { ?>
394
-
395
- <div class="um-admin-drag-row">
396
-
397
- <!-- Master Row Actions -->
398
- <div class="um-admin-drag-row-icons">
399
- <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
400
- <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
401
- <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
402
- </div>
403
- <div class="um-admin-clear"></div>
404
-
405
- <div class="um-admin-drag-rowsubs">
406
- <div class="um-admin-drag-rowsub">
407
-
408
- <!-- Column Layout -->
409
- <div class="um-admin-drag-ctrls columns">
410
- <a href="javascript:void(0);" class="active" data-cols="1"></a>
411
- <a href="javascript:void(0);" data-cols="2"></a>
412
- <a href="javascript:void(0);" data-cols="3"></a>
413
- </div>
414
-
415
- <!-- Sub Row Actions -->
416
- <div class="um-admin-drag-rowsub-icons">
417
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
418
- </div><div class="um-admin-clear"></div>
419
-
420
- <!-- Columns -->
421
- <div class="um-admin-drag-col">
422
-
423
- </div>
424
-
425
- <div class="um-admin-drag-col-dynamic"></div>
426
-
427
- <div class="um-admin-clear"></div>
428
-
429
- </div>
430
- </div>
431
-
432
- </div>
433
-
434
- <?php
435
-
436
- } else {
437
-
438
- if ( empty( $fields ) || ! is_array( $fields ) ) {
439
- $this->global_fields = array();
440
- } else {
441
- $this->global_fields = $fields;
442
- }
443
-
444
- foreach ( $this->global_fields as $key => $array ) {
445
- if ( $array['type'] == 'row' ) {
446
- $rows[ $key ] = $array;
447
- unset( $this->global_fields[ $key ] ); // not needed now
448
- }
449
-
450
- }
451
-
452
- if ( ! isset( $rows ) ) {
453
- $rows = array(
454
- '_um_row_1' => array(
455
- 'type' => 'row',
456
- 'id' => '_um_row_1',
457
- 'sub_rows' => 1,
458
- 'cols' => 1
459
- ),
460
- );
461
- }
462
-
463
- foreach ( $rows as $row_id => $array ) { ?>
464
-
465
- <div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
466
-
467
- <!-- Master Row Actions -->
468
- <div class="um-admin-drag-row-icons">
469
- <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
470
- <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
471
- <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
472
- <?php if ( $row_id != '_um_row_1' ) {?>
473
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
474
- <?php } ?>
475
- </div><div class="um-admin-clear"></div>
476
-
477
- <div class="um-admin-drag-rowsubs">
478
-
479
- <?php $row_fields = $this->get_fields_by_row( $row_id );
480
-
481
- $sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
482
- for ( $c = 0; $c < $sub_rows; $c++ ) {
483
-
484
- $subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
485
-
486
- ?>
487
-
488
- <div class="um-admin-drag-rowsub">
489
-
490
- <!-- Column Layout -->
491
- <div class="um-admin-drag-ctrls columns">
492
-
493
- <?php
494
-
495
- if ( !isset( $array['cols'] ) ){
496
- $col_num = 1;
497
- } else {
498
-
499
- $col_split = explode(':', $array['cols'] );
500
- $col_num = $col_split[$c];
501
-
502
- }
503
-
504
- for ( $i = 1; $i <= 3; $i++ ) {
505
- echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
506
- if ( $col_num == $i ) echo 'class="active"';
507
- echo '></a>';
508
- }
509
-
510
- ?>
511
-
512
- </div>
513
-
514
- <!-- Sub Row Actions -->
515
- <div class="um-admin-drag-rowsub-icons">
516
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
517
- <?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
518
- </div>
519
- <div class="um-admin-clear"></div>
520
-
521
- <!-- Columns -->
522
- <div class="um-admin-drag-col">
523
-
524
- <?php
525
-
526
- if ( is_array( $subrow_fields ) ) {
527
-
528
- $subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
529
-
530
- foreach( $subrow_fields as $key => $keyarray ) {
531
- /**
532
- * @var $type
533
- * @var $title
534
- */
535
- extract( $keyarray );
536
-
537
- ?>
538
-
539
- <div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
540
-
541
- <div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
542
- <?php if ( $type == 'group' ) { ?>
543
- <i class="um-icon-plus"></i>
544
- <?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
545
- <i class="<?php echo $keyarray['icon']; ?>"></i>
546
- <?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
547
- <?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
548
- <div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
549
- <div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
550
-
551
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
552
-
553
- <a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
554
-
555
- <?php if ( $type == 'group' ) { ?>
556
-
557
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
558
- <?php } else { ?>
559
-
560
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
561
-
562
- <?php } ?>
563
-
564
- </div><div class="um-admin-clear"></div>
565
-
566
- <?php if ( $type == 'group' ) { ?>
567
- <div class="um-admin-drag-group">
568
-
569
- </div>
570
- <?php } ?>
571
-
572
- </div>
573
-
574
- <?php
575
-
576
- } // end foreach
577
-
578
- } // end if
579
-
580
- ?>
581
-
582
- </div>
583
-
584
- <div class="um-admin-drag-col-dynamic"></div>
585
-
586
- <div class="um-admin-clear"></div>
587
-
588
- </div>
589
-
590
- <?php } ?>
591
-
592
- </div>
593
-
594
- </div>
595
-
596
- <?php
597
-
598
- } // rows loop
599
-
600
- } // if fields exist
601
-
602
- }
603
-
604
-
605
- /**
606
- *
607
- */
608
- function update_field() {
609
- UM()->admin()->check_ajax_nonce();
610
-
611
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
612
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
613
- }
614
-
615
- $output['error'] = null;
616
-
617
- $array = array(
618
- 'field_type' => sanitize_key( $_POST['_type'] ),
619
- 'form_id' => absint( $_POST['post_id'] ),
620
- 'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
621
- 'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
622
- );
623
-
624
- /**
625
- * UM hook
626
- *
627
- * @type filter
628
- * @title um_admin_pre_save_fields_hook
629
- * @description Filter field data before save
630
- * @input_vars
631
- * [{"var":"$array","type":"array","desc":"Save Field data"}]
632
- * @change_log
633
- * ["Since: 2.0"]
634
- * @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
635
- * @example
636
- * <?php
637
- * add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
638
- * function my_admin_pre_save_fields( $array ) {
639
- * // your code here
640
- * return $array;
641
- * }
642
- * ?>
643
- */
644
- $array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
645
-
646
- /**
647
- * UM hook
648
- *
649
- * @type filter
650
- * @title um_admin_field_update_error_handling
651
- * @description Change error string on save field
652
- * @input_vars
653
- * [{"var":"$error","type":"string","desc":"Error String"},
654
- * {"var":"$array","type":"array","desc":"Save Field data"}]
655
- * @change_log
656
- * ["Since: 2.0"]
657
- * @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
658
- * @example
659
- * <?php
660
- * add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
661
- * function my_admin_field_update_error( $error, $array ) {
662
- * // your code here
663
- * return $error;
664
- * }
665
- * ?>
666
- */
667
- $output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
668
-
669
- /**
670
- * @var $_metakey
671
- * @var $post_id
672
- */
673
- extract( $array['post'] );
674
-
675
- if ( empty( $output['error'] ) ) {
676
-
677
- $save = array();
678
- $save[ $_metakey ] = null;
679
- foreach ( $array['post'] as $key => $val ) {
680
-
681
- if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute
682
- $new_key = ltrim ( $key, '_' );
683
-
684
- if ( $new_key == 'options' ) {
685
- //$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
686
- $save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
687
- } else {
688
- $save[ $_metakey ][ $new_key ] = $val;
689
- }
690
-
691
- } elseif ( strstr( $key, 'um_editor' ) ) {
692
-
693
- if ( 'block' === $array['post']['_type'] ) {
694
- $save[ $_metakey ]['content'] = wp_kses_post( $val );
695
- } else {
696
- $save[ $_metakey ]['content'] = sanitize_textarea_field( $val );
697
- }
698
- }
699
-
700
- }
701
-
702
- $field_ID = $_metakey;
703
- $field_args = $save[ $_metakey ];
704
-
705
- /**
706
- * UM hook
707
- *
708
- * @type filter
709
- * @title um_admin_pre_save_field_to_form
710
- * @description Change field options before save to form
711
- * @input_vars
712
- * [{"var":"$field_args","type":"array","desc":"Field Options"}]
713
- * @change_log
714
- * ["Since: 2.0"]
715
- * @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
716
- * @example
717
- * <?php
718
- * add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
719
- * function my_admin_pre_save_field_to_form( $field_args ) {
720
- * // your code here
721
- * return $field_args;
722
- * }
723
- * ?>
724
- */
725
- $field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
726
-
727
- UM()->fields()->update_field( $field_ID, $field_args, $post_id );
728
-
729
- /**
730
- * UM hook
731
- *
732
- * @type filter
733
- * @title um_admin_pre_save_field_to_db
734
- * @description Change field options before save to DB
735
- * @input_vars
736
- * [{"var":"$field_args","type":"array","desc":"Field Options"}]
737
- * @change_log
738
- * ["Since: 2.0"]
739
- * @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
740
- * @example
741
- * <?php
742
- * add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
743
- * function my_admin_pre_save_field_to_form( $field_args ) {
744
- * // your code here
745
- * return $field_args;
746
- * }
747
- * ?>
748
- */
749
- $field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
750
-
751
- if ( ! isset( $array['args']['form_only'] ) ) {
752
- if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
753
- UM()->fields()->globally_update_field( $field_ID, $field_args );
754
- }
755
- }
756
-
757
- }
758
-
759
- $output = json_encode( $output );
760
- if ( is_array( $output ) ) {
761
- print_r( $output );
762
- } else {
763
- echo $output;
764
- }
765
- die;
766
- }
767
-
768
-
769
- /**
770
- *
771
- */
772
- function dynamic_modal_content() {
773
- UM()->admin()->check_ajax_nonce();
774
-
775
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
776
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
777
- }
778
-
779
- $metabox = UM()->metabox();
780
-
781
- /**
782
- * @var $act_id
783
- * @var $arg1
784
- * @var $arg2
785
- * @var $arg3
786
- */
787
- extract( $_POST );
788
-
789
- if ( isset( $arg1 ) ) {
790
- $arg1 = sanitize_text_field( $arg1 );
791
- }
792
-
793
- if ( isset( $arg2 ) ) {
794
- $arg2 = sanitize_text_field( $arg2 );
795
- }
796
-
797
- if ( isset( $arg3 ) ) {
798
- $arg3 = sanitize_text_field( $arg3 );
799
- }
800
-
801
- switch ( sanitize_key( $act_id ) ) {
802
-
803
- default:
804
-
805
- ob_start();
806
-
807
- /**
808
- * UM hook
809
- *
810
- * @type action
811
- * @title um_admin_ajax_modal_content__hook
812
- * @description Integration hook on ajax popup admin builder modal content
813
- * @input_vars
814
- * [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
815
- * @change_log
816
- * ["Since: 2.0"]
817
- * @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
818
- * @example
819
- * <?php
820
- * add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
821
- * function um_admin_ajax_modal_content__hook( $act_id ) {
822
- * // your code here
823
- * }
824
- * ?>
825
- */
826
- do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
827
- /**
828
- * UM hook
829
- *
830
- * @type action
831
- * @title um_admin_ajax_modal_content__hook_{$act_id}
832
- * @description Integration hook on ajax popup admin builder modal content
833
- * @change_log
834
- * ["Since: 2.0"]
835
- * @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
836
- * @example
837
- * <?php
838
- * add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
839
- * function my_admin_ajax_modal_content() {
840
- * // your code here
841
- * }
842
- * ?>
843
- */
844
- do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
845
-
846
- $output = ob_get_clean();
847
- break;
848
-
849
- case 'um_admin_fonticon_selector':
850
-
851
- ob_start(); ?>
852
-
853
- <div class="um-admin-metabox">
854
- <p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
855
- </div>
856
-
857
- <div class="um-admin-icons">
858
- <?php foreach( UM()->fonticons()->all as $icon ) { ?>
859
- <span data-code="<?php echo esc_attr( $icon ); ?>" title="<?php echo esc_attr( $icon ); ?>" class="um-admin-tipsy-n"><i class="<?php echo $icon; ?>"></i></span>
860
- <?php } ?>
861
- </div><div class="um-admin-clear"></div>
862
-
863
- <?php $output = ob_get_clean();
864
- break;
865
-
866
- case 'um_admin_show_fields':
867
-
868
- ob_start();
869
- $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
870
- $form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
871
- //$form_fields = array_keys( $form_fields );
872
- ?>
873
-
874
- <h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
875
- <div class="um-admin-btns">
876
-
877
- <?php if ( UM()->builtin()->core_fields ) {
878
- foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
879
-
880
- if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
881
- continue;
882
- } ?>
883
-
884
- <a href="javascript:void(0);" class="button" data-modal="UM_add_field" data-modal-size="normal" data-dynamic-content="um_admin_new_field_popup" data-arg1="<?php echo esc_attr( $field_type ); ?>" data-arg2="<?php echo esc_attr( $arg2 ) ?>"><?php echo esc_html( $array['name'] ); ?></a>
885
-
886
- <?php }
887
- } ?>
888
-
889
- </div>
890
-
891
- <h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
892
- <div class="um-admin-btns">
893
-
894
- <?php if ( UM()->builtin()->predefined_fields ) {
895
- foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
896
- if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
897
-
898
- <a href="javascript:void(0);" class="button" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_predefined" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?></a>
899
-
900
- <?php }
901
- }
902
- } else {
903
- echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
904
- } ?>
905
-
906
- </div>
907
-
908
- <h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
909
- <div class="um-admin-btns">
910
-
911
- <?php
912
- if ( UM()->builtin()->custom_fields ) {
913
- foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
914
- if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
915
- continue;
916
- } ?>
917
-
918
- <a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>" title="<?php echo __( 'Meta Key', 'ultimate-member' ) . ' - ' . esc_attr( $field_key ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
919
-
920
- <?php }
921
- } else {
922
- echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
923
- } ?>
924
-
925
- </div>
926
-
927
- <?php $output = ob_get_clean();
928
- break;
929
-
930
- case 'um_admin_edit_field_popup':
931
-
932
- ob_start();
933
-
934
- $args = UM()->builtin()->get_core_field_attrs( $arg1 );
935
-
936
- $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
937
-
938
- $metabox->set_field_type = $arg1;
939
- $metabox->in_edit = true;
940
- $metabox->edit_array = $form_fields[ $arg3 ];
941
-
942
- if ( !isset( $metabox->edit_array['metakey'] ) ){
943
- $metabox->edit_array['metakey'] = $metabox->edit_array['id'];
944
- }
945
-
946
- if ( !isset( $metabox->edit_array['position'] ) ){
947
- $metabox->edit_array['position'] = $metabox->edit_array['id'];
948
- }
949
-
950
- extract( $args );
951
-
952
- if ( ! isset( $col1 ) ) {
953
-
954
- echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
955
-
956
- } else {
957
-
958
- ?>
959
-
960
- <?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
961
- <input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
962
- <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
963
- <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
964
- <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
965
- <?php } ?>
966
-
967
- <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
968
-
969
- <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
970
-
971
- <input type="hidden" name="edit_mode" id="edit_mode" value="true" />
972
-
973
- <input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
974
-
975
- <input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
976
-
977
- <?php if ( isset( $args['mce_content'] ) ) { ?>
978
- <div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
979
- <?php } ?>
980
-
981
- <?php $this->modal_header(); ?>
982
-
983
- <div class="um-admin-half">
984
-
985
- <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
986
-
987
- </div>
988
-
989
- <div class="um-admin-half um-admin-right">
990
-
991
- <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
992
-
993
- </div><div class="um-admin-clear"></div>
994
-
995
- <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
996
-
997
- <div class="um-admin-clear"></div>
998
-
999
- <?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
1000
-
1001
- <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
1002
-
1003
- <?php
1004
-
1005
- }
1006
-
1007
- $output = ob_get_clean();
1008
- break;
1009
-
1010
- case 'um_admin_new_field_popup':
1011
-
1012
- ob_start();
1013
-
1014
- $args = UM()->builtin()->get_core_field_attrs( $arg1 );
1015
-
1016
- $metabox->set_field_type = $arg1;
1017
-
1018
- /**
1019
- * @var $in_row
1020
- * @var $in_sub_row
1021
- * @var $in_column
1022
- * @var $in_group
1023
- */
1024
- extract( $args );
1025
-
1026
- if ( ! isset( $col1 ) ) {
1027
-
1028
- echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
1029
-
1030
- } else {
1031
-
1032
- if ( $in_column ) { ?>
1033
- <input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
1034
- <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
1035
- <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
1036
- <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
1037
- <?php } ?>
1038
-
1039
- <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
1040
-
1041
- <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
1042
-
1043
- <?php $this->modal_header(); ?>
1044
-
1045
- <div class="um-admin-half">
1046
-
1047
- <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
1048
-
1049
- </div>
1050
-
1051
- <div class="um-admin-half um-admin-right">
1052
-
1053
- <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
1054
-
1055
- </div><div class="um-admin-clear"></div>
1056
-
1057
- <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
1058
-
1059
- <div class="um-admin-clear"></div>
1060
-
1061
- <?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
1062
-
1063
- <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
1064
-
1065
- <?php
1066
-
1067
- }
1068
-
1069
- $output = ob_get_clean();
1070
- break;
1071
-
1072
- case 'um_admin_preview_form':
1073
-
1074
- UM()->user()->preview = true;
1075
-
1076
- $mode = UM()->query()->get_attr('mode', $arg1 );
1077
-
1078
- if ( $mode == 'profile' ) {
1079
- UM()->fields()->editing = true;
1080
- }
1081
-
1082
- $output = '<div class="um-admin-preview-overlay"></div>';
1083
-
1084
- if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
1085
- $output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
1086
- } else {
1087
- $output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
1088
- }
1089
-
1090
- break;
1091
-
1092
- case 'um_admin_review_registration':
1093
- //$user_id = $arg1;
1094
-
1095
- if ( ! current_user_can( 'administrator' ) ) {
1096
- if ( ! um_can_view_profile( $arg1 ) ) {
1097
- $output = '';
1098
- break;
1099
- }
1100
- }
1101
-
1102
- um_fetch_user( $arg1 );
1103
-
1104
- UM()->user()->preview = true;
1105
-
1106
- $output = um_user_submitted_registration_formatted( true );
1107
-
1108
- um_reset_user();
1109
-
1110
- break;
1111
-
1112
- }
1113
-
1114
- if ( is_array( $output ) ) {
1115
- print_r( $output );
1116
- } else {
1117
- echo $output;
1118
- }
1119
- die;
1120
- }
1121
-
1122
-
1123
- /**
1124
- *
1125
- */
1126
- function modal_header() {
1127
- /**
1128
- * UM hook
1129
- *
1130
- * @type action
1131
- * @title um_admin_field_modal_header
1132
- * @description Modal Window Header
1133
- * @change_log
1134
- * ["Since: 2.0"]
1135
- * @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
1136
- * @example
1137
- * <?php
1138
- * add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
1139
- * function my_admin_field_modal_header() {
1140
- * // your code here
1141
- * }
1142
- * ?>
1143
- */
1144
- do_action( 'um_admin_field_modal_header' );
1145
- }
1146
-
1147
-
1148
- /**
1149
- * Modal Footer loading
1150
- *
1151
- * @param $arg2
1152
- * @param $args
1153
- * @param $metabox
1154
- */
1155
- function modal_footer( $arg2, $args, $metabox ) {
1156
- /**
1157
- * UM hook
1158
- *
1159
- * @type action
1160
- * @title um_admin_field_modal_footer
1161
- * @description Modal Window Footer
1162
- * @input_vars
1163
- * [{"var":"$arg2","type":"string","desc":"Ajax Action"},
1164
- * {"var":"$args","type":"array","desc":"Modal window arguments"},
1165
- * {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
1166
- * {"var":"$edit_array","type":"array","desc":"Edit Array"}]
1167
- * @change_log
1168
- * ["Since: 2.0"]
1169
- * @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
1170
- * @example
1171
- * <?php
1172
- * add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
1173
- * function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
1174
- * // your code here
1175
- * }
1176
- * ?>
1177
- */
1178
- do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
1179
- }
1180
-
1181
-
1182
- /**
1183
- * Skip field validation for:
1184
- * - '_options' if Choices Callback specified
1185
- *
1186
- * @param boolean $skip
1187
- * @param string $post_input
1188
- * @param array $array
1189
- * @return boolean
1190
- */
1191
- public function skip_field_validation( $skip, $post_input, $array ) {
1192
- if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
1193
- $skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
1194
- }
1195
-
1196
- return $skip;
1197
- }
1198
-
1199
-
1200
- /**
1201
- * Retrieves dropdown/multi-select options from a callback function
1202
- */
1203
- function populate_dropdown_options() {
1204
- UM()->admin()->check_ajax_nonce();
1205
-
1206
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
1207
- wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
1208
- }
1209
-
1210
- $arr_options = array();
1211
-
1212
- $um_callback_func = sanitize_key( $_POST['um_option_callback'] );
1213
- if ( empty( $um_callback_func ) ) {
1214
- $arr_options['status'] = 'empty';
1215
- $arr_options['function_name'] = $um_callback_func;
1216
- $arr_options['function_exists'] = function_exists( $um_callback_func );
1217
- }
1218
-
1219
- $arr_options['data'] = array();
1220
- if ( function_exists( $um_callback_func ) ) {
1221
- $arr_options['data'] = call_user_func( $um_callback_func );
1222
- }
1223
-
1224
- wp_send_json( $arr_options );
1225
- }
1226
-
1227
- }
1228
- }
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_Builder
13
+ * @package um\admin\core
14
+ */
15
+ class Admin_Builder {
16
+
17
+
18
+ /**
19
+ * @var
20
+ */
21
+ var $form_id;
22
+
23
+
24
+ /**
25
+ * Admin_Builder constructor.
26
+ */
27
+ function __construct() {
28
+ add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
29
+ add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
30
+ add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
31
+ add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
32
+ add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
33
+ add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
34
+ }
35
+
36
+
37
+ /**
38
+ * Apply a filter to handle errors for field updating in backend
39
+ *
40
+ * @param $errors
41
+ * @param $array
42
+ *
43
+ * @return mixed
44
+ */
45
+ function um_admin_field_update_error_handling( $errors, $array ) {
46
+ /**
47
+ * @var $field_type
48
+ */
49
+ extract( $array );
50
+
51
+ $field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
52
+
53
+ if ( isset( $field_attr['validate'] ) ) {
54
+
55
+ $validate = $field_attr['validate'];
56
+ foreach ( $validate as $post_input => $arr ) {
57
+
58
+ $skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
59
+ if ( $skip ) {
60
+ continue;
61
+ }
62
+
63
+ $mode = $arr['mode'];
64
+
65
+ switch ( $mode ) {
66
+
67
+ case 'numeric':
68
+ if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
69
+ $errors[ $post_input ] = $validate[ $post_input ]['error'];
70
+ }
71
+ break;
72
+
73
+ case 'unique':
74
+ if ( ! isset( $array['post']['edit_mode'] ) ) {
75
+ if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
76
+ $errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
77
+ }
78
+ }
79
+ break;
80
+
81
+ case 'required':
82
+ if ( $array['post'][ $post_input ] == '' ) {
83
+ $errors[ $post_input ] = $validate[ $post_input ]['error'];
84
+ }
85
+ break;
86
+
87
+ case 'range-start':
88
+ if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
89
+ $errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
90
+ }
91
+ break;
92
+
93
+ case 'range-end':
94
+ if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
95
+ $errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
96
+ }
97
+ break;
98
+
99
+ }
100
+
101
+ }
102
+
103
+ }
104
+
105
+ return $errors;
106
+
107
+ }
108
+
109
+
110
+ /**
111
+ * Some fields may require extra fields before saving
112
+ *
113
+ * @param $array
114
+ *
115
+ * @return mixed
116
+ */
117
+ function um_admin_pre_save_fields_hook( $array ) {
118
+ /**
119
+ * @var $form_id
120
+ * @var $field_type
121
+ */
122
+ extract( $array );
123
+
124
+ $fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
125
+
126
+ $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
127
+ $count = 1;
128
+ if ( ! empty( $fields ) ) {
129
+ $count = count( $fields ) + 1;
130
+ }
131
+
132
+ // set unique meta key
133
+ if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
134
+ $array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
135
+ }
136
+
137
+ // set position
138
+ if ( ! isset( $array['post']['_position'] ) ) {
139
+ $array['post']['_position'] = $count;
140
+ }
141
+
142
+ return $array;
143
+ }
144
+
145
+
146
+ /**
147
+ * Modify field args just before it is saved into form
148
+ *
149
+ * @param $array
150
+ *
151
+ * @return mixed
152
+ */
153
+ function um_admin_pre_save_field_to_form( $array ){
154
+ unset( $array['conditions'] );
155
+ if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
156
+ $array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
157
+ $array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
158
+ }
159
+
160
+ if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
161
+ $array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
162
+ $array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
163
+ }
164
+
165
+ if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
166
+ $array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
167
+ $array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
168
+ }
169
+
170
+ if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
171
+ $array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
172
+ $array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
173
+ }
174
+
175
+ if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
176
+ $array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
177
+ $array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
178
+ }
179
+
180
+ return $array;
181
+ }
182
+
183
+
184
+ /**
185
+ * Put status handler in modal
186
+ */
187
+ function add_message_handlers() {
188
+ ?>
189
+ <div class="um-admin-error-block"></div>
190
+ <div class="um-admin-success-block"></div>
191
+ <?php
192
+ }
193
+
194
+
195
+ /**
196
+ * Footer of modal
197
+ *
198
+ * @param $form_id
199
+ * @param $field_args
200
+ * @param $in_edit
201
+ * @param $edit_array
202
+ */
203
+ function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
204
+ $metabox = UM()->metabox();
205
+
206
+ if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
207
+ return;
208
+ } ?>
209
+
210
+ <div class="um-admin-btn-toggle">
211
+
212
+ <?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
213
+ <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
214
+ <?php } else { ?>
215
+ <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
216
+ <?php } ?>
217
+
218
+ <div class="um-admin-btn-content">
219
+ <div class="um-admin-cur-condition-template">
220
+
221
+ <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
222
+ <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
223
+ <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
224
+ <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
225
+
226
+ <p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
227
+
228
+ <div class="um-admin-clear"></div>
229
+ </div>
230
+ <p class="um-admin-conditions-notice">
231
+ <small>
232
+ <?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
233
+ <br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
234
+ <br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
235
+ </small>
236
+ </p>
237
+ <p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
238
+ <p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
239
+
240
+ <div class="um-admin-clear"></div>
241
+
242
+ <?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
243
+
244
+ foreach ( $edit_array['conditions'] as $k => $arr ) {
245
+
246
+ if ( $k == 0 ) $k = ''; ?>
247
+
248
+ <div class="um-admin-cur-condition">
249
+
250
+ <?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
251
+ <?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
252
+ <?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
253
+ <?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
254
+
255
+ <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
256
+
257
+ <div class="um-admin-clear"></div>
258
+ </div>
259
+
260
+ <?php
261
+ }
262
+
263
+ } else { ?>
264
+
265
+ <div class="um-admin-cur-condition">
266
+
267
+ <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
268
+ <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
269
+ <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
270
+ <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
271
+
272
+ <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
273
+
274
+ <div class="um-admin-clear"></div>
275
+ </div>
276
+
277
+ <?php } ?>
278
+ </div>
279
+ </div>
280
+
281
+ <?php
282
+ }
283
+
284
+
285
+ /**
286
+ * Update the builder area
287
+ */
288
+ function update_builder() {
289
+ UM()->admin()->check_ajax_nonce();
290
+
291
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
292
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
293
+ }
294
+
295
+ ob_start();
296
+
297
+ $this->form_id = absint( $_POST['form_id'] );
298
+
299
+ $this->show_builder();
300
+
301
+ $output = ob_get_clean();
302
+
303
+ if ( is_array( $output ) ) {
304
+ print_r( $output );
305
+ } else {
306
+ echo $output;
307
+ }
308
+ die;
309
+ }
310
+
311
+
312
+ /**
313
+ * Sort array function
314
+ *
315
+ * @param array $arr
316
+ * @param string $col
317
+ * @param int $dir
318
+ *
319
+ * @return array
320
+ */
321
+ function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
322
+ $sort_col = array();
323
+
324
+ foreach ( $arr as $key => $row ) {
325
+ if ( ! empty( $row[ $col ] ) ) {
326
+ $sort_col[ $key ] = $row[ $col ];
327
+ }
328
+ }
329
+
330
+ if ( ! empty( $sort_col ) ) {
331
+ array_multisort( $sort_col, $dir, $arr );
332
+ }
333
+
334
+ return $arr;
335
+ }
336
+
337
+
338
+ /**
339
+ * Get fields in row
340
+ *
341
+ * @param $row_id
342
+ *
343
+ * @return string
344
+ */
345
+ function get_fields_by_row( $row_id ) {
346
+
347
+ if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
348
+ $this->global_fields = array();
349
+ }
350
+
351
+ foreach ( $this->global_fields as $key => $array ) {
352
+ if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
353
+ $results[ $key ] = $array;
354
+ unset( $this->global_fields[ $key ] );
355
+ }
356
+ }
357
+
358
+ return ( isset ( $results ) ) ? $results : '';
359
+ }
360
+
361
+
362
+ /**
363
+ * Get fields by sub row
364
+ *
365
+ * @param $row_fields
366
+ * @param $subrow_id
367
+ *
368
+ * @return string
369
+ */
370
+ function get_fields_in_subrow( $row_fields, $subrow_id ) {
371
+ if ( ! is_array( $row_fields ) ) {
372
+ return '';
373
+ }
374
+
375
+ foreach( $row_fields as $key => $array ) {
376
+ if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
377
+ $results[ $key ] = $array;
378
+ unset( $this->global_fields[ $key ] );
379
+ }
380
+ }
381
+
382
+ return ( isset ( $results ) ) ? $results : '';
383
+ }
384
+
385
+
386
+ /**
387
+ * Display the builder
388
+ */
389
+ function show_builder() {
390
+
391
+ $fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
392
+
393
+ if ( !isset( $fields ) || empty( $fields ) ) { ?>
394
+
395
+ <div class="um-admin-drag-row">
396
+
397
+ <!-- Master Row Actions -->
398
+ <div class="um-admin-drag-row-icons">
399
+ <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
400
+ <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
401
+ <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
402
+ </div>
403
+ <div class="um-admin-clear"></div>
404
+
405
+ <div class="um-admin-drag-rowsubs">
406
+ <div class="um-admin-drag-rowsub">
407
+
408
+ <!-- Column Layout -->
409
+ <div class="um-admin-drag-ctrls columns">
410
+ <a href="javascript:void(0);" class="active" data-cols="1"></a>
411
+ <a href="javascript:void(0);" data-cols="2"></a>
412
+ <a href="javascript:void(0);" data-cols="3"></a>
413
+ </div>
414
+
415
+ <!-- Sub Row Actions -->
416
+ <div class="um-admin-drag-rowsub-icons">
417
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
418
+ </div><div class="um-admin-clear"></div>
419
+
420
+ <!-- Columns -->
421
+ <div class="um-admin-drag-col">
422
+
423
+ </div>
424
+
425
+ <div class="um-admin-drag-col-dynamic"></div>
426
+
427
+ <div class="um-admin-clear"></div>
428
+
429
+ </div>
430
+ </div>
431
+
432
+ </div>
433
+
434
+ <?php
435
+
436
+ } else {
437
+
438
+ if ( empty( $fields ) || ! is_array( $fields ) ) {
439
+ $this->global_fields = array();
440
+ } else {
441
+ $this->global_fields = $fields;
442
+ }
443
+
444
+ foreach ( $this->global_fields as $key => $array ) {
445
+ if ( $array['type'] == 'row' ) {
446
+ $rows[ $key ] = $array;
447
+ unset( $this->global_fields[ $key ] ); // not needed now
448
+ }
449
+
450
+ }
451
+
452
+ if ( ! isset( $rows ) ) {
453
+ $rows = array(
454
+ '_um_row_1' => array(
455
+ 'type' => 'row',
456
+ 'id' => '_um_row_1',
457
+ 'sub_rows' => 1,
458
+ 'cols' => 1
459
+ ),
460
+ );
461
+ }
462
+
463
+ foreach ( $rows as $row_id => $array ) { ?>
464
+
465
+ <div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
466
+
467
+ <!-- Master Row Actions -->
468
+ <div class="um-admin-drag-row-icons">
469
+ <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
470
+ <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
471
+ <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
472
+ <?php if ( $row_id != '_um_row_1' ) {?>
473
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
474
+ <?php } ?>
475
+ </div><div class="um-admin-clear"></div>
476
+
477
+ <div class="um-admin-drag-rowsubs">
478
+
479
+ <?php $row_fields = $this->get_fields_by_row( $row_id );
480
+
481
+ $sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
482
+ for ( $c = 0; $c < $sub_rows; $c++ ) {
483
+
484
+ $subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
485
+
486
+ ?>
487
+
488
+ <div class="um-admin-drag-rowsub">
489
+
490
+ <!-- Column Layout -->
491
+ <div class="um-admin-drag-ctrls columns">
492
+
493
+ <?php
494
+
495
+ if ( ! isset( $array['cols'] ) ) {
496
+ $col_num = 1;
497
+ } elseif ( is_numeric( $array['cols'] ) ) {
498
+ $col_num = (int) $array['cols'];
499
+ } else {
500
+ $col_split = explode( ':', $array['cols'] );
501
+ $col_num = $col_split[ $c ];
502
+ }
503
+
504
+ for ( $i = 1; $i <= 3; $i++ ) {
505
+ echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
506
+ if ( $col_num == $i ) echo 'class="active"';
507
+ echo '></a>';
508
+ }
509
+
510
+ ?>
511
+
512
+ </div>
513
+
514
+ <!-- Sub Row Actions -->
515
+ <div class="um-admin-drag-rowsub-icons">
516
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
517
+ <?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
518
+ </div>
519
+ <div class="um-admin-clear"></div>
520
+
521
+ <!-- Columns -->
522
+ <div class="um-admin-drag-col">
523
+
524
+ <?php
525
+
526
+ if ( is_array( $subrow_fields ) ) {
527
+
528
+ $subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
529
+
530
+ foreach( $subrow_fields as $key => $keyarray ) {
531
+ /**
532
+ * @var $type
533
+ * @var $title
534
+ */
535
+ extract( $keyarray );
536
+
537
+ ?>
538
+
539
+ <div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
540
+
541
+ <div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
542
+ <?php if ( $type == 'group' ) { ?>
543
+ <i class="um-icon-plus"></i>
544
+ <?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
545
+ <i class="<?php echo $keyarray['icon']; ?>"></i>
546
+ <?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
547
+ <?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
548
+ <div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
549
+ <div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
550
+
551
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
552
+
553
+ <a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
554
+
555
+ <?php if ( $type == 'group' ) { ?>
556
+
557
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
558
+ <?php } else { ?>
559
+
560
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
561
+
562
+ <?php } ?>
563
+
564
+ </div><div class="um-admin-clear"></div>
565
+
566
+ <?php if ( $type == 'group' ) { ?>
567
+ <div class="um-admin-drag-group">
568
+
569
+ </div>
570
+ <?php } ?>
571
+
572
+ </div>
573
+
574
+ <?php
575
+
576
+ } // end foreach
577
+
578
+ } // end if
579
+
580
+ ?>
581
+
582
+ </div>
583
+
584
+ <div class="um-admin-drag-col-dynamic"></div>
585
+
586
+ <div class="um-admin-clear"></div>
587
+
588
+ </div>
589
+
590
+ <?php } ?>
591
+
592
+ </div>
593
+
594
+ </div>
595
+
596
+ <?php
597
+
598
+ } // rows loop
599
+
600
+ } // if fields exist
601
+
602
+ }
603
+
604
+
605
+ /**
606
+ *
607
+ */
608
+ function update_field() {
609
+ UM()->admin()->check_ajax_nonce();
610
+
611
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
612
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
613
+ }
614
+
615
+ $output['error'] = null;
616
+
617
+ $array = array(
618
+ 'field_type' => sanitize_key( $_POST['_type'] ),
619
+ 'form_id' => absint( $_POST['post_id'] ),
620
+ 'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
621
+ 'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
622
+ );
623
+
624
+ /**
625
+ * UM hook
626
+ *
627
+ * @type filter
628
+ * @title um_admin_pre_save_fields_hook
629
+ * @description Filter field data before save
630
+ * @input_vars
631
+ * [{"var":"$array","type":"array","desc":"Save Field data"}]
632
+ * @change_log
633
+ * ["Since: 2.0"]
634
+ * @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
635
+ * @example
636
+ * <?php
637
+ * add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
638
+ * function my_admin_pre_save_fields( $array ) {
639
+ * // your code here
640
+ * return $array;
641
+ * }
642
+ * ?>
643
+ */
644
+ $array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
645
+
646
+ /**
647
+ * UM hook
648
+ *
649
+ * @type filter
650
+ * @title um_admin_field_update_error_handling
651
+ * @description Change error string on save field
652
+ * @input_vars
653
+ * [{"var":"$error","type":"string","desc":"Error String"},
654
+ * {"var":"$array","type":"array","desc":"Save Field data"}]
655
+ * @change_log
656
+ * ["Since: 2.0"]
657
+ * @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
658
+ * @example
659
+ * <?php
660
+ * add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
661
+ * function my_admin_field_update_error( $error, $array ) {
662
+ * // your code here
663
+ * return $error;
664
+ * }
665
+ * ?>
666
+ */
667
+ $output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
668
+
669
+ /**
670
+ * @var $_metakey
671
+ * @var $post_id
672
+ */
673
+ extract( $array['post'] );
674
+
675
+ if ( empty( $output['error'] ) ) {
676
+
677
+ $save = array();
678
+ $save[ $_metakey ] = null;
679
+ foreach ( $array['post'] as $key => $val ) {
680
+
681
+ if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute
682
+ $new_key = ltrim ( $key, '_' );
683
+
684
+ if ( $new_key == 'options' ) {
685
+ //$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
686
+ $save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
687
+ } else {
688
+ $save[ $_metakey ][ $new_key ] = $val;
689
+ }
690
+
691
+ } elseif ( strstr( $key, 'um_editor' ) ) {
692
+
693
+ if ( 'block' === $array['post']['_type'] ) {
694
+ $save[ $_metakey ]['content'] = wp_kses_post( $val );
695
+ } else {
696
+ $save[ $_metakey ]['content'] = sanitize_textarea_field( $val );
697
+ }
698
+ }
699
+
700
+ }
701
+
702
+ $field_ID = $_metakey;
703
+ $field_args = $save[ $_metakey ];
704
+
705
+ /**
706
+ * UM hook
707
+ *
708
+ * @type filter
709
+ * @title um_admin_pre_save_field_to_form
710
+ * @description Change field options before save to form
711
+ * @input_vars
712
+ * [{"var":"$field_args","type":"array","desc":"Field Options"}]
713
+ * @change_log
714
+ * ["Since: 2.0"]
715
+ * @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
716
+ * @example
717
+ * <?php
718
+ * add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
719
+ * function my_admin_pre_save_field_to_form( $field_args ) {
720
+ * // your code here
721
+ * return $field_args;
722
+ * }
723
+ * ?>
724
+ */
725
+ $field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
726
+
727
+ UM()->fields()->update_field( $field_ID, $field_args, $post_id );
728
+
729
+ /**
730
+ * UM hook
731
+ *
732
+ * @type filter
733
+ * @title um_admin_pre_save_field_to_db
734
+ * @description Change field options before save to DB
735
+ * @input_vars
736
+ * [{"var":"$field_args","type":"array","desc":"Field Options"}]
737
+ * @change_log
738
+ * ["Since: 2.0"]
739
+ * @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
740
+ * @example
741
+ * <?php
742
+ * add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
743
+ * function my_admin_pre_save_field_to_form( $field_args ) {
744
+ * // your code here
745
+ * return $field_args;
746
+ * }
747
+ * ?>
748
+ */
749
+ $field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
750
+
751
+ if ( ! isset( $array['args']['form_only'] ) ) {
752
+ if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
753
+ UM()->fields()->globally_update_field( $field_ID, $field_args );
754
+ }
755
+ }
756
+
757
+ }
758
+
759
+ $output = json_encode( $output );
760
+ if ( is_array( $output ) ) {
761
+ print_r( $output );
762
+ } else {
763
+ echo $output;
764
+ }
765
+ die;
766
+ }
767
+
768
+
769
+ /**
770
+ *
771
+ */
772
+ function dynamic_modal_content() {
773
+ UM()->admin()->check_ajax_nonce();
774
+
775
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
776
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
777
+ }
778
+
779
+ $metabox = UM()->metabox();
780
+
781
+ /**
782
+ * @var $act_id
783
+ * @var $arg1
784
+ * @var $arg2
785
+ * @var $arg3
786
+ */
787
+ extract( $_POST );
788
+
789
+ if ( isset( $arg1 ) ) {
790
+ $arg1 = sanitize_text_field( $arg1 );
791
+ }
792
+
793
+ if ( isset( $arg2 ) ) {
794
+ $arg2 = sanitize_text_field( $arg2 );
795
+ }
796
+
797
+ if ( isset( $arg3 ) ) {
798
+ $arg3 = sanitize_text_field( $arg3 );
799
+ }
800
+
801
+ switch ( sanitize_key( $act_id ) ) {
802
+
803
+ default:
804
+
805
+ ob_start();
806
+
807
+ /**
808
+ * UM hook
809
+ *
810
+ * @type action
811
+ * @title um_admin_ajax_modal_content__hook
812
+ * @description Integration hook on ajax popup admin builder modal content
813
+ * @input_vars
814
+ * [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
815
+ * @change_log
816
+ * ["Since: 2.0"]
817
+ * @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
818
+ * @example
819
+ * <?php
820
+ * add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
821
+ * function um_admin_ajax_modal_content__hook( $act_id ) {
822
+ * // your code here
823
+ * }
824
+ * ?>
825
+ */
826
+ do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
827
+ /**
828
+ * UM hook
829
+ *
830
+ * @type action
831
+ * @title um_admin_ajax_modal_content__hook_{$act_id}
832
+ * @description Integration hook on ajax popup admin builder modal content
833
+ * @change_log
834
+ * ["Since: 2.0"]
835
+ * @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
836
+ * @example
837
+ * <?php
838
+ * add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
839
+ * function my_admin_ajax_modal_content() {
840
+ * // your code here
841
+ * }
842
+ * ?>
843
+ */
844
+ do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
845
+
846
+ $output = ob_get_clean();
847
+ break;
848
+
849
+ case 'um_admin_fonticon_selector':
850
+
851
+ ob_start(); ?>
852
+
853
+ <div class="um-admin-metabox">
854
+ <p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
855
+ </div>
856
+
857
+ <div class="um-admin-icons">
858
+ <?php foreach( UM()->fonticons()->all as $icon ) { ?>
859
+ <span data-code="<?php echo esc_attr( $icon ); ?>" title="<?php echo esc_attr( $icon ); ?>" class="um-admin-tipsy-n"><i class="<?php echo $icon; ?>"></i></span>
860
+ <?php } ?>
861
+ </div><div class="um-admin-clear"></div>
862
+
863
+ <?php $output = ob_get_clean();
864
+ break;
865
+
866
+ case 'um_admin_show_fields':
867
+
868
+ ob_start();
869
+ $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
870
+ $form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
871
+ //$form_fields = array_keys( $form_fields );
872
+ ?>
873
+
874
+ <h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
875
+ <div class="um-admin-btns">
876
+
877
+ <?php if ( UM()->builtin()->core_fields ) {
878
+ foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
879
+
880
+ if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
881
+ continue;
882
+ } ?>
883
+
884
+ <a href="javascript:void(0);" class="button" data-modal="UM_add_field" data-modal-size="normal" data-dynamic-content="um_admin_new_field_popup" data-arg1="<?php echo esc_attr( $field_type ); ?>" data-arg2="<?php echo esc_attr( $arg2 ) ?>"><?php echo esc_html( $array['name'] ); ?></a>
885
+
886
+ <?php }
887
+ } ?>
888
+
889
+ </div>
890
+
891
+ <h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
892
+ <div class="um-admin-btns">
893
+
894
+ <?php if ( UM()->builtin()->predefined_fields ) {
895
+ foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
896
+ if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
897
+
898
+ <a href="javascript:void(0);" class="button" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_predefined" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?></a>
899
+
900
+ <?php }
901
+ }
902
+ } else {
903
+ echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
904
+ } ?>
905
+
906
+ </div>
907
+
908
+ <h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
909
+ <div class="um-admin-btns">
910
+
911
+ <?php
912
+ if ( UM()->builtin()->custom_fields ) {
913
+ foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
914
+ if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
915
+ continue;
916
+ } ?>
917
+
918
+ <a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>" title="<?php echo __( 'Meta Key', 'ultimate-member' ) . ' - ' . esc_attr( $field_key ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
919
+
920
+ <?php }
921
+ } else {
922
+ echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
923
+ } ?>
924
+
925
+ </div>
926
+
927
+ <?php $output = ob_get_clean();
928
+ break;
929
+
930
+ case 'um_admin_edit_field_popup':
931
+
932
+ ob_start();
933
+
934
+ $args = UM()->builtin()->get_core_field_attrs( $arg1 );
935
+
936
+ $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
937
+
938
+ $metabox->set_field_type = $arg1;
939
+ $metabox->in_edit = true;
940
+ $metabox->edit_array = $form_fields[ $arg3 ];
941
+
942
+ if ( !isset( $metabox->edit_array['metakey'] ) ){
943
+ $metabox->edit_array['metakey'] = $metabox->edit_array['id'];
944
+ }
945
+
946
+ if ( !isset( $metabox->edit_array['position'] ) ){
947
+ $metabox->edit_array['position'] = $metabox->edit_array['id'];
948
+ }
949
+
950
+ extract( $args );
951
+
952
+ if ( ! isset( $col1 ) ) {
953
+
954
+ echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
955
+
956
+ } else {
957
+
958
+ ?>
959
+
960
+ <?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
961
+ <input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
962
+ <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
963
+ <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
964
+ <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
965
+ <?php } ?>
966
+
967
+ <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
968
+
969
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
970
+
971
+ <input type="hidden" name="edit_mode" id="edit_mode" value="true" />
972
+
973
+ <input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
974
+
975
+ <input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
976
+
977
+ <?php if ( isset( $args['mce_content'] ) ) { ?>
978
+ <div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
979
+ <?php } ?>
980
+
981
+ <?php $this->modal_header(); ?>
982
+
983
+ <div class="um-admin-half">
984
+
985
+ <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
986
+
987
+ </div>
988
+
989
+ <div class="um-admin-half um-admin-right">
990
+
991
+ <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
992
+
993
+ </div><div class="um-admin-clear"></div>
994
+
995
+ <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
996
+
997
+ <div class="um-admin-clear"></div>
998
+
999
+ <?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
1000
+
1001
+ <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
1002
+
1003
+ <?php
1004
+
1005
+ }
1006
+
1007
+ $output = ob_get_clean();
1008
+ break;
1009
+
1010
+ case 'um_admin_new_field_popup':
1011
+
1012
+ ob_start();
1013
+
1014
+ $args = UM()->builtin()->get_core_field_attrs( $arg1 );
1015
+
1016
+ $metabox->set_field_type = $arg1;
1017
+
1018
+ /**
1019
+ * @var $in_row
1020
+ * @var $in_sub_row
1021
+ * @var $in_column
1022
+ * @var $in_group
1023
+ */
1024
+ extract( $args );
1025
+
1026
+ if ( ! isset( $col1 ) ) {
1027
+
1028
+ echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
1029
+
1030
+ } else {
1031
+
1032
+ if ( $in_column ) { ?>
1033
+ <input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
1034
+ <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
1035
+ <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
1036
+ <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
1037
+ <?php } ?>
1038
+
1039
+ <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
1040
+
1041
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
1042
+
1043
+ <?php $this->modal_header(); ?>
1044
+
1045
+ <div class="um-admin-half">
1046
+
1047
+ <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
1048
+
1049
+ </div>
1050
+
1051
+ <div class="um-admin-half um-admin-right">
1052
+
1053
+ <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
1054
+
1055
+ </div><div class="um-admin-clear"></div>
1056
+
1057
+ <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
1058
+
1059
+ <div class="um-admin-clear"></div>
1060
+
1061
+ <?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
1062
+
1063
+ <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
1064
+
1065
+ <?php
1066
+
1067
+ }
1068
+
1069
+ $output = ob_get_clean();
1070
+ break;
1071
+
1072
+ case 'um_admin_preview_form':
1073
+
1074
+ UM()->user()->preview = true;
1075
+
1076
+ $mode = UM()->query()->get_attr('mode', $arg1 );
1077
+
1078
+ if ( $mode == 'profile' ) {
1079
+ UM()->fields()->editing = true;
1080
+ }
1081
+
1082
+ $output = '<div class="um-admin-preview-overlay"></div>';
1083
+
1084
+ if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
1085
+ $output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
1086
+ } else {
1087
+ $output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
1088
+ }
1089
+
1090
+ break;
1091
+
1092
+ case 'um_admin_review_registration':
1093
+ //$user_id = $arg1;
1094
+
1095
+ if ( ! current_user_can( 'administrator' ) ) {
1096
+ if ( ! um_can_view_profile( $arg1 ) ) {
1097
+ $output = '';
1098
+ break;
1099
+ }
1100
+ }
1101
+
1102
+ um_fetch_user( $arg1 );
1103
+
1104
+ UM()->user()->preview = true;
1105
+
1106
+ $output = um_user_submitted_registration_formatted( true );
1107
+
1108
+ um_reset_user();
1109
+
1110
+ break;
1111
+
1112
+ }
1113
+
1114
+ if ( is_array( $output ) ) {
1115
+ print_r( $output );
1116
+ } else {
1117
+ echo $output;
1118
+ }
1119
+ die;
1120
+ }
1121
+
1122
+
1123
+ /**
1124
+ *
1125
+ */
1126
+ function modal_header() {
1127
+ /**
1128
+ * UM hook
1129
+ *
1130
+ * @type action
1131
+ * @title um_admin_field_modal_header
1132
+ * @description Modal Window Header
1133
+ * @change_log
1134
+ * ["Since: 2.0"]
1135
+ * @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
1136
+ * @example
1137
+ * <?php
1138
+ * add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
1139
+ * function my_admin_field_modal_header() {
1140
+ * // your code here
1141
+ * }
1142
+ * ?>
1143
+ */
1144
+ do_action( 'um_admin_field_modal_header' );
1145
+ }
1146
+
1147
+
1148
+ /**
1149
+ * Modal Footer loading
1150
+ *
1151
+ * @param $arg2
1152
+ * @param $args
1153
+ * @param $metabox
1154
+ */
1155
+ function modal_footer( $arg2, $args, $metabox ) {
1156
+ /**
1157
+ * UM hook
1158
+ *
1159
+ * @type action
1160
+ * @title um_admin_field_modal_footer
1161
+ * @description Modal Window Footer
1162
+ * @input_vars
1163
+ * [{"var":"$arg2","type":"string","desc":"Ajax Action"},
1164
+ * {"var":"$args","type":"array","desc":"Modal window arguments"},
1165
+ * {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
1166
+ * {"var":"$edit_array","type":"array","desc":"Edit Array"}]
1167
+ * @change_log
1168
+ * ["Since: 2.0"]
1169
+ * @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
1170
+ * @example
1171
+ * <?php
1172
+ * add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
1173
+ * function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
1174
+ * // your code here
1175
+ * }
1176
+ * ?>
1177
+ */
1178
+ do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
1179
+ }
1180
+
1181
+
1182
+ /**
1183
+ * Skip field validation for:
1184
+ * - '_options' if Choices Callback specified
1185
+ *
1186
+ * @param boolean $skip
1187
+ * @param string $post_input
1188
+ * @param array $array
1189
+ * @return boolean
1190
+ */
1191
+ public function skip_field_validation( $skip, $post_input, $array ) {
1192
+ if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
1193
+ $skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
1194
+ }
1195
+
1196
+ return $skip;
1197
+ }
1198
+
1199
+
1200
+ /**
1201
+ * Retrieves dropdown/multi-select options from a callback function
1202
+ */
1203
+ function populate_dropdown_options() {
1204
+ UM()->admin()->check_ajax_nonce();
1205
+
1206
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
1207
+ wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
1208
+ }
1209
+
1210
+ $arr_options = array();
1211
+
1212
+ $um_callback_func = sanitize_key( $_POST['um_option_callback'] );
1213
+ if ( empty( $um_callback_func ) ) {
1214
+ $arr_options['status'] = 'empty';
1215
+ $arr_options['function_name'] = $um_callback_func;
1216
+ $arr_options['function_exists'] = function_exists( $um_callback_func );
1217
+ }
1218
+
1219
+ $arr_options['data'] = array();
1220
+ if ( function_exists( $um_callback_func ) ) {
1221
+ $arr_options['data'] = call_user_func( $um_callback_func );
1222
+ }
1223
+
1224
+ wp_send_json( $arr_options );
1225
+ }
1226
+
1227
+ }
1228
+ }
includes/admin/core/class-admin-dragdrop.php CHANGED
@@ -1,243 +1,249 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_DragDrop
13
- * @package um\admin\core
14
- */
15
- class Admin_DragDrop {
16
-
17
-
18
- /**
19
- * Admin_DragDrop constructor.
20
- */
21
- function __construct() {
22
- add_action( 'admin_footer', array( &$this, 'load_field_order' ), 9 );
23
- }
24
-
25
-
26
- /**
27
- * Update order of fields
28
- */
29
- public function update_order() {
30
- UM()->admin()->check_ajax_nonce();
31
-
32
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
33
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
34
- }
35
-
36
- /**
37
- * @var $form_id
38
- */
39
- extract( $_POST );
40
-
41
- if ( isset( $form_id ) ) {
42
- $form_id = absint( $form_id );
43
- }
44
-
45
- $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
46
-
47
- $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
48
- $this->exist_rows = array();
49
-
50
- if ( ! empty( $fields ) ) {
51
- foreach ( $fields as $key => $array ) {
52
- if ( 'row' === $array['type'] ) {
53
- $this->row_data[ $key ] = $array;
54
- unset( $fields[ $key ] );
55
- }
56
- }
57
- } else {
58
- $fields = array();
59
- }
60
-
61
- foreach ( $_POST as $key => $value ) {
62
-
63
- $key = sanitize_key( $key );
64
-
65
- // adding rows
66
- if ( 0 === strpos( $key, '_um_row_' ) ) {
67
-
68
- $update_args = null;
69
-
70
- $row_id = str_replace( '_um_row_', '', $key );
71
-
72
- $row_array = array(
73
- 'type' => 'row',
74
- 'id' => sanitize_key( $value ),
75
- 'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ),
76
- 'cols' => absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] ),
77
- 'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ),
78
- );
79
-
80
- $row_args = $row_array;
81
-
82
- if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
83
- foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
84
- if ( 'position' !== $k && 'metakey' !== $k ) {
85
- $update_args[ $k ] = $v;
86
- }
87
- }
88
- if ( isset( $update_args ) ) {
89
- $row_args = array_merge( $update_args, $row_array );
90
- }
91
- $this->exist_rows[] = $key;
92
- }
93
-
94
- $fields[ $key ] = $row_args;
95
-
96
- }
97
-
98
- // change field position
99
- if ( 0 === strpos( $key, 'um_position_' ) ) {
100
- $field_key = str_replace( 'um_position_', '', $key );
101
- if ( isset( $fields[ $field_key ] ) ) {
102
- $fields[ $field_key ]['position'] = absint( $value );
103
- }
104
- }
105
-
106
- // change field master row
107
- if ( 0 === strpos( $key, 'um_row_' ) ) {
108
- $field_key = str_replace( 'um_row_', '', $key );
109
- if ( isset( $fields[ $field_key ] ) ) {
110
- $fields[ $field_key ]['in_row'] = sanitize_key( $value );
111
- }
112
- }
113
-
114
- // change field sub row
115
- if ( 0 === strpos( $key, 'um_subrow_' ) ) {
116
- $field_key = str_replace( 'um_subrow_', '', $key );
117
- if ( isset( $fields[ $field_key ] ) ) {
118
- $fields[ $field_key ]['in_sub_row'] = sanitize_key( $value );
119
- }
120
- }
121
-
122
- // change field column
123
- if ( 0 === strpos( $key, 'um_col_' ) ) {
124
- $field_key = str_replace( 'um_col_', '', $key );
125
- if ( isset( $fields[ $field_key ] ) ) {
126
- $fields[ $field_key ]['in_column'] = absint( $value );
127
- }
128
- }
129
-
130
- // add field to group
131
- if ( 0 === strpos( $key, 'um_group_' ) ) {
132
- $field_key = str_replace( 'um_group_', '', $key );
133
- if ( isset( $fields[ $field_key ] ) ) {
134
- $fields[ $field_key ]['in_group'] = absint( $value );
135
- }
136
- }
137
- }
138
-
139
- foreach ( $this->row_data as $k => $v ) {
140
- if ( ! in_array( $k, $this->exist_rows, true ) ) {
141
- unset( $this->row_data[ $k ] );
142
- }
143
- }
144
-
145
- update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
146
-
147
- update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
148
-
149
- UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
150
-
151
- }
152
-
153
-
154
- /**
155
- * Load form to maintain form order
156
- */
157
- public function load_field_order() {
158
-
159
- $screen = get_current_screen();
160
-
161
- if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
162
- return;
163
- } ?>
164
-
165
- <div class="um-col-demon-settings" data-in_row="" data-in_sub_row="" data-in_column="" data-in_group=""></div>
166
-
167
- <div class="um-col-demon-row" style="display:none;">
168
-
169
- <div class="um-admin-drag-row-icons">
170
- <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
171
- <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( get_the_ID() ); ?>"><i class="um-faicon-pencil"></i></a>
172
- <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
173
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
174
- </div>
175
- <div class="um-admin-clear"></div>
176
-
177
- <div class="um-admin-drag-rowsubs">
178
- <div class="um-admin-drag-rowsub">
179
-
180
- <div class="um-admin-drag-ctrls columns">
181
- <a href="javascript:void(0);" class="active" data-cols="1"></a>
182
- <a href="javascript:void(0);" data-cols="2"></a>
183
- <a href="javascript:void(0);" data-cols="3"></a>
184
- </div>
185
-
186
- <div class="um-admin-drag-rowsub-icons">
187
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
188
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
189
- </div><div class="um-admin-clear"></div>
190
-
191
- <div class="um-admin-drag-col">
192
- </div>
193
-
194
- <div class="um-admin-drag-col-dynamic"></div>
195
-
196
- <div class="um-admin-clear"></div>
197
-
198
- </div>
199
- </div>
200
-
201
- </div>
202
-
203
- <div class="um-col-demon-subrow" style="display:none;">
204
-
205
- <div class="um-admin-drag-ctrls columns">
206
- <a href="javascript:void(0);" class="active" data-cols="1"></a>
207
- <a href="javascript:void(0);" data-cols="2"></a>
208
- <a href="javascript:void(0);" data-cols="3"></a>
209
- </div>
210
-
211
- <div class="um-admin-drag-rowsub-icons">
212
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
213
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
214
- </div><div class="um-admin-clear"></div>
215
-
216
- <div class="um-admin-drag-col">
217
- </div>
218
-
219
- <div class="um-admin-drag-col-dynamic"></div>
220
-
221
- <div class="um-admin-clear"></div>
222
-
223
- </div>
224
-
225
-
226
- <form action="" method="post" class="um_update_order">
227
-
228
- <input type="hidden" name="form_id" id="form_id" value="<?php echo esc_attr( get_the_ID() ); ?>" />
229
- <input type="hidden" name="action" value="um_update_order" />
230
- <input type="hidden" name="nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-admin-nonce' ) ) ?>" />
231
-
232
- <div class="um_update_order_fields">
233
-
234
- </div>
235
-
236
- </form>
237
-
238
- <?php
239
-
240
- }
241
-
242
- }
243
- }
 
 
 
 
 
 
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_DragDrop
13
+ * @package um\admin\core
14
+ */
15
+ class Admin_DragDrop {
16
+
17
+
18
+ /**
19
+ * Admin_DragDrop constructor.
20
+ */
21
+ function __construct() {
22
+ add_action( 'admin_footer', array( &$this, 'load_field_order' ), 9 );
23
+ }
24
+
25
+
26
+ /**
27
+ * Update order of fields
28
+ */
29
+ public function update_order() {
30
+ UM()->admin()->check_ajax_nonce();
31
+
32
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
33
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
34
+ }
35
+
36
+ /**
37
+ * @var $form_id
38
+ */
39
+ extract( $_POST );
40
+
41
+ if ( isset( $form_id ) ) {
42
+ $form_id = absint( $form_id );
43
+ }
44
+
45
+ $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
46
+
47
+ $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
48
+ $this->exist_rows = array();
49
+
50
+ if ( ! empty( $fields ) ) {
51
+ foreach ( $fields as $key => $array ) {
52
+ if ( 'row' === $array['type'] ) {
53
+ $this->row_data[ $key ] = $array;
54
+ unset( $fields[ $key ] );
55
+ }
56
+ }
57
+ } else {
58
+ $fields = array();
59
+ }
60
+
61
+ foreach ( $_POST as $key => $value ) {
62
+
63
+ $key = sanitize_key( $key );
64
+
65
+ // adding rows
66
+ if ( 0 === strpos( $key, '_um_row_' ) ) {
67
+
68
+ $update_args = null;
69
+
70
+ $row_id = str_replace( '_um_row_', '', $key );
71
+
72
+ if ( strstr( $_POST[ '_um_rowcols_' . $row_id . '_cols' ], ':' ) ) {
73
+ $cols = sanitize_text_field( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
74
+ } else {
75
+ $cols = absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
76
+ }
77
+
78
+ $row_array = array(
79
+ 'type' => 'row',
80
+ 'id' => sanitize_key( $value ),
81
+ 'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ),
82
+ 'cols' => $cols,
83
+ 'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ),
84
+ );
85
+
86
+ $row_args = $row_array;
87
+
88
+ if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
89
+ foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
90
+ if ( 'position' !== $k && 'metakey' !== $k ) {
91
+ $update_args[ $k ] = $v;
92
+ }
93
+ }
94
+ if ( isset( $update_args ) ) {
95
+ $row_args = array_merge( $update_args, $row_array );
96
+ }
97
+ $this->exist_rows[] = $key;
98
+ }
99
+
100
+ $fields[ $key ] = $row_args;
101
+
102
+ }
103
+
104
+ // change field position
105
+ if ( 0 === strpos( $key, 'um_position_' ) ) {
106
+ $field_key = str_replace( 'um_position_', '', $key );
107
+ if ( isset( $fields[ $field_key ] ) ) {
108
+ $fields[ $field_key ]['position'] = absint( $value );
109
+ }
110
+ }
111
+
112
+ // change field master row
113
+ if ( 0 === strpos( $key, 'um_row_' ) ) {
114
+ $field_key = str_replace( 'um_row_', '', $key );
115
+ if ( isset( $fields[ $field_key ] ) ) {
116
+ $fields[ $field_key ]['in_row'] = sanitize_key( $value );
117
+ }
118
+ }
119
+
120
+ // change field sub row
121
+ if ( 0 === strpos( $key, 'um_subrow_' ) ) {
122
+ $field_key = str_replace( 'um_subrow_', '', $key );
123
+ if ( isset( $fields[ $field_key ] ) ) {
124
+ $fields[ $field_key ]['in_sub_row'] = sanitize_key( $value );
125
+ }
126
+ }
127
+
128
+ // change field column
129
+ if ( 0 === strpos( $key, 'um_col_' ) ) {
130
+ $field_key = str_replace( 'um_col_', '', $key );
131
+ if ( isset( $fields[ $field_key ] ) ) {
132
+ $fields[ $field_key ]['in_column'] = absint( $value );
133
+ }
134
+ }
135
+
136
+ // add field to group
137
+ if ( 0 === strpos( $key, 'um_group_' ) ) {
138
+ $field_key = str_replace( 'um_group_', '', $key );
139
+ if ( isset( $fields[ $field_key ] ) ) {
140
+ $fields[ $field_key ]['in_group'] = ! empty( $value ) ? absint( $value ) : '';
141
+ }
142
+ }
143
+ }
144
+
145
+ foreach ( $this->row_data as $k => $v ) {
146
+ if ( ! in_array( $k, $this->exist_rows, true ) ) {
147
+ unset( $this->row_data[ $k ] );
148
+ }
149
+ }
150
+
151
+ update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
152
+
153
+ update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
154
+
155
+ UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
156
+
157
+ }
158
+
159
+
160
+ /**
161
+ * Load form to maintain form order
162
+ */
163
+ public function load_field_order() {
164
+
165
+ $screen = get_current_screen();
166
+
167
+ if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
168
+ return;
169
+ } ?>
170
+
171
+ <div class="um-col-demon-settings" data-in_row="" data-in_sub_row="" data-in_column="" data-in_group=""></div>
172
+
173
+ <div class="um-col-demon-row" style="display:none;">
174
+
175
+ <div class="um-admin-drag-row-icons">
176
+ <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
177
+ <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( get_the_ID() ); ?>"><i class="um-faicon-pencil"></i></a>
178
+ <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
179
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
180
+ </div>
181
+ <div class="um-admin-clear"></div>
182
+
183
+ <div class="um-admin-drag-rowsubs">
184
+ <div class="um-admin-drag-rowsub">
185
+
186
+ <div class="um-admin-drag-ctrls columns">
187
+ <a href="javascript:void(0);" class="active" data-cols="1"></a>
188
+ <a href="javascript:void(0);" data-cols="2"></a>
189
+ <a href="javascript:void(0);" data-cols="3"></a>
190
+ </div>
191
+
192
+ <div class="um-admin-drag-rowsub-icons">
193
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
194
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
195
+ </div><div class="um-admin-clear"></div>
196
+
197
+ <div class="um-admin-drag-col">
198
+ </div>
199
+
200
+ <div class="um-admin-drag-col-dynamic"></div>
201
+
202
+ <div class="um-admin-clear"></div>
203
+
204
+ </div>
205
+ </div>
206
+
207
+ </div>
208
+
209
+ <div class="um-col-demon-subrow" style="display:none;">
210
+
211
+ <div class="um-admin-drag-ctrls columns">
212
+ <a href="javascript:void(0);" class="active" data-cols="1"></a>
213
+ <a href="javascript:void(0);" data-cols="2"></a>
214
+ <a href="javascript:void(0);" data-cols="3"></a>
215
+ </div>
216
+
217
+ <div class="um-admin-drag-rowsub-icons">
218
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
219
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
220
+ </div><div class="um-admin-clear"></div>
221
+
222
+ <div class="um-admin-drag-col">
223
+ </div>
224
+
225
+ <div class="um-admin-drag-col-dynamic"></div>
226
+
227
+ <div class="um-admin-clear"></div>
228
+
229
+ </div>
230
+
231
+
232
+ <form action="" method="post" class="um_update_order">
233
+
234
+ <input type="hidden" name="form_id" id="form_id" value="<?php echo esc_attr( get_the_ID() ); ?>" />
235
+ <input type="hidden" name="action" value="um_update_order" />
236
+ <input type="hidden" name="nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-admin-nonce' ) ) ?>" />
237
+
238
+ <div class="um_update_order_fields">
239
+
240
+ </div>
241
+
242
+ </form>
243
+
244
+ <?php
245
+
246
+ }
247
+
248
+ }
249
+ }
includes/admin/core/class-admin-metabox.php CHANGED
@@ -1,2437 +1,2427 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_Metabox
13
- *
14
- * @package um\admin\core
15
- */
16
- class Admin_Metabox {
17
-
18
-
19
- /**
20
- * @var bool
21
- */
22
- private $form_nonce_added = false;
23
-
24
-
25
- /**
26
- * @var bool
27
- */
28
- private $directory_nonce_added = false;
29
-
30
-
31
- /**
32
- * @var bool
33
- */
34
- private $custom_nonce_added = false;
35
-
36
-
37
- var $init_icon = false;
38
-
39
-
40
- /**
41
- * Admin_Metabox constructor.
42
- */
43
- function __construct() {
44
- $this->in_edit = false;
45
- $this->edit_mode_value = null;
46
- $this->edit_array = [];
47
-
48
- add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
49
- add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
50
-
51
- add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
52
- add_action( 'load-post-new.php', array( &$this, 'add_metabox' ), 9 );
53
-
54
- add_action( 'admin_init', array( &$this, 'add_taxonomy_metabox' ), 9 );
55
-
56
- //roles metaboxes
57
- add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
58
-
59
- add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
60
- add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
61
-
62
- add_filter( 'um_member_directory_meta_value_before_save', array( UM()->member_directory(), 'before_save_data' ), 10, 3 );
63
- }
64
-
65
-
66
- /**
67
- * Hide Woocommerce Shop page restrict content metabox
68
- * @param $hide
69
- *
70
- * @return bool
71
- */
72
- function hide_metabox_restrict_content_shop( $hide ) {
73
- if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
74
- absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) {
75
- return true;
76
- }
77
-
78
- return $hide;
79
- }
80
-
81
-
82
- /**
83
- * Filter validation types on loop
84
- *
85
- * @param $break
86
- * @param $key
87
- * @param $form_id
88
- * @param $field_array
89
- *
90
- * @return bool
91
- */
92
- function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
93
-
94
- // show unique username validation only for user_login field
95
- if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
96
- return false;
97
- }
98
-
99
- return $break;
100
- }
101
-
102
-
103
- /**
104
- * Gets the role meta
105
- *
106
- * @param $id
107
- *
108
- * @return mixed
109
- */
110
- function get_custom_post_meta( $id ) {
111
- $all_meta = get_post_custom( $id );
112
- foreach ( $all_meta as $k => $v ) {
113
- if ( strstr( $k, '_um_' ) ) {
114
- $um_meta[ $k ] = $v;
115
- }
116
- }
117
- if ( isset( $um_meta ) ) {
118
- return $um_meta;
119
- }
120
-
121
- return false;
122
- }
123
-
124
-
125
- /**
126
- * Runs on admin head
127
- */
128
- function admin_head(){
129
- global $post;
130
- if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
131
- $this->postmeta = $this->get_custom_post_meta($post->ID);
132
- }
133
- }
134
-
135
-
136
- /**
137
- * Init the metaboxes
138
- */
139
- function add_metabox() {
140
- global $current_screen;
141
-
142
- if ( $current_screen->id == 'um_form' ) {
143
- add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 );
144
- add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 );
145
- }
146
-
147
- if ( $current_screen->id == 'um_directory' ) {
148
- add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 );
149
- add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 );
150
- }
151
-
152
- //restrict content metabox
153
- $post_types = UM()->options()->get( 'restricted_access_post_metabox' );
154
- if ( ! empty( $post_types[ $current_screen->id ] ) ) {
155
-
156
- /**
157
- * UM hook
158
- *
159
- * @type filter
160
- * @title um_restrict_content_hide_metabox
161
- * @description Show/Hide Restrict content metabox
162
- * @input_vars
163
- * [{"var":"$show","type":"bool","desc":"Show Metabox"}]
164
- * @change_log
165
- * ["Since: 2.0"]
166
- * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 );
167
- * @example
168
- * <?php
169
- * add_filter( 'um_restrict_content_hide_metabox', 'my_restrict_content_hide_metabox', 10, 1 );
170
- * function my_restrict_content_hide_metabox( $show ) {
171
- * // your code here
172
- * return $show;
173
- * }
174
- * ?>
175
- */
176
- $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
177
-
178
- if ( ! $hide_metabox ) {
179
- add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
180
- add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
181
- }
182
-
183
- if ( $current_screen->id == 'attachment' ) {
184
- add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
185
- add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
186
- }
187
- }
188
-
189
-
190
- add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 );
191
- }
192
-
193
-
194
- /**
195
- * @param $post_id
196
- * @param $post
197
- */
198
- public function save_metabox_custom( $post_id, $post ) {
199
- // validate nonce
200
- if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
201
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
202
- return;
203
- }
204
-
205
- /**
206
- * UM hook
207
- *
208
- * @type action
209
- * @title um_admin_custom_restrict_content_metaboxes
210
- * @description Save metabox custom with restrict content
211
- * @input_vars
212
- * [{"var":"$post_id","type":"int","desc":"Post ID"},
213
- * {"var":"$post","type":"array","desc":"Post data"}]
214
- * @change_log
215
- * ["Since: 2.0"]
216
- * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 );
217
- * @example
218
- * <?php
219
- * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10, 2 );
220
- * function my_admin_custom_restrict_content( $post_id, $post ) {
221
- * // your code here
222
- * }
223
- * ?>
224
- */
225
- do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post );
226
- }
227
-
228
-
229
- /**
230
- *
231
- */
232
- function add_metabox_restrict_content() {
233
- global $current_screen;
234
-
235
- add_meta_box(
236
- 'um-admin-restrict-content',
237
- __( 'UM Content Restriction', 'ultimate-member' ),
238
- array( &$this, 'restrict_content_cb' ),
239
- $current_screen->id,
240
- 'normal',
241
- 'default'
242
- );
243
-
244
- /**
245
- * UM hook
246
- *
247
- * @type action
248
- * @title um_admin_custom_restrict_content_metaboxes
249
- * @description Add restrict content custom metabox
250
- * @change_log
251
- * ["Since: 2.0"]
252
- * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 );
253
- * @example
254
- * <?php
255
- * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10 );
256
- * function my_admin_custom_restrict_content() {
257
- * // your code here
258
- * }
259
- * ?>
260
- */
261
- do_action( 'um_admin_custom_restrict_content_metaboxes' );
262
- }
263
-
264
-
265
- /**
266
- * Content restriction metabox
267
- *
268
- * @param $object
269
- * @param $box
270
- */
271
- function restrict_content_cb( $object, $box ) {
272
- include_once UM()->admin()->templates_path . 'access/restrict_content.php';
273
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' );
274
- }
275
-
276
-
277
- /**
278
- * Init the metaboxes
279
- */
280
- function add_taxonomy_metabox() {
281
- //restrict content metabox
282
- $all_taxonomies = get_taxonomies( array( 'public' => true ) );
283
- $tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
284
- $exclude_taxonomies = UM()->excluded_taxonomies();
285
-
286
- foreach ( $all_taxonomies as $key => $taxonomy ) {
287
- if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) )
288
- continue;
289
-
290
- add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) );
291
- add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) );
292
- add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
293
- add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
294
- }
295
- }
296
-
297
-
298
- /**
299
- * @param $post_id
300
- * @param $post
301
- */
302
- function save_metabox_restrict_content( $post_id, $post ) {
303
- // validate nonce
304
- if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) ||
305
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
306
- return;
307
- }
308
-
309
- // validate user
310
- $post_type = get_post_type_object( $post->post_type );
311
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
312
- return;
313
- }
314
-
315
- if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
316
- $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
317
-
318
- update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
319
- } else {
320
- delete_post_meta( $post_id, 'um_content_restriction' );
321
- }
322
- }
323
-
324
-
325
- /**
326
- * @param $post_id
327
- *
328
- */
329
- function save_attachment_metabox_restrict_content( $post_id ) {
330
- // validate nonce
331
- if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] )
332
- || ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
333
- return;
334
- }
335
-
336
- $post = get_post( $post_id );
337
-
338
- // validate user
339
- $post_type = get_post_type_object( $post->post_type );
340
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
341
- return;
342
- }
343
-
344
- if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
345
- $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
346
-
347
- update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
348
- } else {
349
- delete_post_meta( $post_id, 'um_content_restriction' );
350
- }
351
- }
352
-
353
-
354
- /**
355
- *
356
- */
357
- function um_category_access_fields_create() {
358
- $data = array();
359
-
360
- /**
361
- * UM hook
362
- *
363
- * @type filter
364
- * @title um_admin_category_access_settings_fields
365
- * @description Settings fields for terms
366
- * @input_vars
367
- * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
368
- * {"var":"$data","type":"array","desc":"Settings Data"},
369
- * {"var":"$screen","type":"string","desc":"Category Screen"}]
370
- * @change_log
371
- * ["Since: 2.0"]
372
- * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
373
- * @example
374
- * <?php
375
- * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
376
- * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
377
- * // your code here
378
- * $access_settings_fields[] = array(
379
- * 'id' => 'my-field-key',
380
- * 'type' => 'my-field-type',
381
- * 'label' => __( 'My field Label', 'ultimate-member' ),
382
- * 'description' => __( 'My Field Description', 'ultimate-member' ),
383
- * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
384
- * );
385
- * return $access_settings_fields;
386
- * }
387
- * ?>
388
- */
389
- $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
390
- array(
391
- 'id' => '_um_custom_access_settings',
392
- 'type' => 'checkbox',
393
- 'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
394
- 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
395
- 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
396
- ),
397
- array(
398
- 'id' => '_um_accessible',
399
- 'type' => 'select',
400
- 'label' => __( 'Who can access this content?', 'ultimate-member' ),
401
- 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
402
- 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
403
- 'options' => array(
404
- '0' => __( 'Everyone', 'ultimate-member' ),
405
- '1' => __( 'Logged out users', 'ultimate-member' ),
406
- '2' => __( 'Logged in users', 'ultimate-member' ),
407
- ),
408
- 'conditional' => array( '_um_custom_access_settings', '=', '1' )
409
- ),
410
- array(
411
- 'id' => '_um_access_roles',
412
- 'type' => 'multi_checkbox',
413
- 'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
414
- 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
415
- 'options' => UM()->roles()->get_roles( false ),
416
- 'columns' => 3,
417
- 'conditional' => array( '_um_accessible', '=', '2' )
418
- ),
419
- array(
420
- 'id' => '_um_noaccess_action',
421
- 'type' => 'select',
422
- 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
423
- 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
424
- 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
425
- 'options' => array(
426
- '0' => __( 'Show access restricted message', 'ultimate-member' ),
427
- '1' => __( 'Redirect user', 'ultimate-member' ),
428
- ),
429
- 'conditional' => array( '_um_accessible', '!=', '0' )
430
- ),
431
- array(
432
- 'id' => '_um_restrict_by_custom_message',
433
- 'type' => 'select',
434
- 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
435
- 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
436
- 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
437
- 'options' => array(
438
- '0' => __( 'Global default message (default)', 'ultimate-member' ),
439
- '1' => __( 'Custom message', 'ultimate-member' ),
440
- ),
441
- 'conditional' => array( '_um_noaccess_action', '=', '0' )
442
- ),
443
- array(
444
- 'id' => '_um_restrict_custom_message',
445
- 'type' => 'wp_editor',
446
- 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
447
- 'description' => __( 'Changed global restrict message', 'ultimate-member' ),
448
- 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
449
- 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
450
- ),
451
- array(
452
- 'id' => '_um_access_redirect',
453
- 'type' => 'select',
454
- 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
455
- 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
456
- 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
457
- 'conditional' => array( '_um_noaccess_action', '=', '1' ),
458
- 'options' => array(
459
- '0' => __( 'Login page', 'ultimate-member' ),
460
- '1' => __( 'Custom URL', 'ultimate-member' ),
461
- ),
462
- ),
463
- array(
464
- 'id' => '_um_access_redirect_url',
465
- 'type' => 'text',
466
- 'label' => __( 'Redirect URL', 'ultimate-member' ),
467
- 'description' => __( 'Changed global restrict message', 'ultimate-member' ),
468
- 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
469
- 'conditional' => array( '_um_access_redirect', '=', '1' )
470
- ),
471
- array(
472
- 'id' => '_um_access_hide_from_queries',
473
- 'type' => 'checkbox',
474
- 'label' => __( 'Hide from queries', 'ultimate-member' ),
475
- 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
476
- 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
477
- 'conditional' => array( '_um_accessible', '!=', '0' )
478
- )
479
- ), $data, 'create' );
480
-
481
- UM()->admin_forms( array(
482
- 'class' => 'um-restrict-content um-third-column',
483
- 'prefix_id' => 'um_content_restriction',
484
- 'without_wrapper' => true,
485
- 'div_line' => true,
486
- 'fields' => $fields
487
- ) )->render_form();
488
-
489
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
490
- }
491
-
492
-
493
- /**
494
- * @param $term
495
- */
496
- function um_category_access_fields_edit( $term ) {
497
- $termID = $term->term_id;
498
-
499
- $data = get_term_meta( $termID, 'um_content_restriction', true );
500
-
501
- $_um_access_roles_value = array();
502
- if ( ! empty( $data['_um_access_roles'] ) ) {
503
- foreach ( $data['_um_access_roles'] as $key => $value ) {
504
- if ( $value ) {
505
- $_um_access_roles_value[] = $key;
506
- }
507
- }
508
- }
509
-
510
- /**
511
- * UM hook
512
- *
513
- * @type filter
514
- * @title um_admin_category_access_settings_fields
515
- * @description Settings fields for terms
516
- * @input_vars
517
- * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
518
- * {"var":"$data","type":"array","desc":"Settings Data"},
519
- * {"var":"$screen","type":"string","desc":"Category Screen"}]
520
- * @change_log
521
- * ["Since: 2.0"]
522
- * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
523
- * @example
524
- * <?php
525
- * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
526
- * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
527
- * // your code here
528
- * $access_settings_fields[] = array(
529
- * 'id' => 'my-field-key',
530
- * 'type' => 'my-field-type',
531
- * 'label' => __( 'My field Label', 'ultimate-member' ),
532
- * 'description' => __( 'My Field Description', 'ultimate-member' ),
533
- * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
534
- * );
535
- * return $access_settings_fields;
536
- * }
537
- * ?>
538
- */
539
- $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
540
- array(
541
- 'id' => '_um_custom_access_settings',
542
- 'type' => 'checkbox',
543
- 'class' => 'form-field',
544
- 'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
545
- 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
546
- 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
547
- ),
548
- array(
549
- 'id' => '_um_accessible',
550
- 'type' => 'select',
551
- 'class' => 'form-field',
552
- 'label' => __( 'Who can access this content?', 'ultimate-member' ),
553
- 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
554
- 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
555
- 'options' => array(
556
- '0' => __( 'Everyone', 'ultimate-member' ),
557
- '1' => __( 'Logged out users', 'ultimate-member' ),
558
- '2' => __( 'Logged in users', 'ultimate-member' ),
559
- ),
560
- 'conditional' => array( '_um_custom_access_settings', '=', '1' )
561
- ),
562
- array(
563
- 'id' => '_um_access_roles',
564
- 'type' => 'multi_checkbox',
565
- 'class' => 'form-field',
566
- 'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
567
- 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
568
- 'value' => $_um_access_roles_value,
569
- 'options' => UM()->roles()->get_roles( false ),
570
- 'columns' => 3,
571
- 'conditional' => array( '_um_accessible', '=', '2' )
572
- ),
573
- array(
574
- 'id' => '_um_noaccess_action',
575
- 'type' => 'select',
576
- 'class' => 'form-field',
577
- 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
578
- 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
579
- 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
580
- 'options' => array(
581
- '0' => __( 'Show access restricted message', 'ultimate-member' ),
582
- '1' => __( 'Redirect user', 'ultimate-member' ),
583
- ),
584
- 'conditional' => array( '_um_accessible', '!=', '0' )
585
- ),
586
- array(
587
- 'id' => '_um_restrict_by_custom_message',
588
- 'type' => 'select',
589
- 'class' => 'form-field',
590
- 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
591
- 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
592
- 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
593
- 'options' => array(
594
- '0' => __( 'Global default message (default)', 'ultimate-member' ),
595
- '1' => __( 'Custom message', 'ultimate-member' ),
596
- ),
597
- 'conditional' => array( '_um_noaccess_action', '=', '0' )
598
- ),
599
- array(
600
- 'id' => '_um_restrict_custom_message',
601
- 'type' => 'wp_editor',
602
- 'class' => 'form-field',
603
- 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
604
- 'description' => __( 'Changed global restrict message', 'ultimate-member' ),
605
- 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
606
- 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
607
- ),
608
- array(
609
- 'id' => '_um_access_redirect',
610
- 'type' => 'select',
611
- 'class' => 'form-field',
612
- 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
613
- 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
614
- 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
615
- 'conditional' => array( '_um_noaccess_action', '=', '1' ),
616
- 'options' => array(
617
- '0' => __( 'Login page', 'ultimate-member' ),
618
- '1' => __( 'Custom URL', 'ultimate-member' ),
619
- ),
620
- ),
621
- array(
622
- 'id' => '_um_access_redirect_url',
623
- 'type' => 'text',
624
- 'class' => 'form-field',
625
- 'label' => __( 'Redirect URL', 'ultimate-member' ),
626
- 'description' => __( 'Changed global restrict message', 'ultimate-member' ),
627
- 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
628
- 'conditional' => array( '_um_access_redirect', '=', '1' )
629
- ),
630
- array(
631
- 'id' => '_um_access_hide_from_queries',
632
- 'type' => 'checkbox',
633
- 'class' => 'form-field',
634
- 'label' => __( 'Hide from queries', 'ultimate-member' ),
635
- 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
636
- 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
637
- 'conditional' => array( '_um_accessible', '!=', '0' )
638
- )
639
- ), $data, 'edit' );
640
-
641
- UM()->admin_forms( array(
642
- 'class' => 'um-restrict-content um-third-column',
643
- 'prefix_id' => 'um_content_restriction',
644
- 'without_wrapper' => true,
645
- 'fields' => $fields
646
- ) )->render_form();
647
-
648
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
649
- }
650
-
651
-
652
- /**
653
- * @param $termID
654
- *
655
- * @return mixed
656
- */
657
- function um_category_access_fields_save( $termID ) {
658
-
659
- // validate nonce
660
- if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) {
661
- return $termID;
662
- }
663
-
664
- // validate user
665
- $term = get_term( $termID );
666
- $taxonomy = get_taxonomy( $term->taxonomy );
667
-
668
- if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) {
669
- return $termID;
670
- }
671
-
672
- if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
673
- $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
674
-
675
- update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
676
- } else {
677
- delete_term_meta( $termID, 'um_content_restriction' );
678
- }
679
-
680
- return $termID;
681
- }
682
-
683
-
684
- /**
685
- * Load a directory metabox
686
- *
687
- * @param $object
688
- * @param $box
689
- */
690
- function load_metabox_directory( $object, $box ) {
691
- $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
692
-
693
- preg_match('#\{.*?\}#s', $box['id'], $matches );
694
-
695
- if ( isset( $matches[0] ) ) {
696
- $path = $matches[0];
697
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
698
- } else {
699
- $path = um_path;
700
- }
701
-
702
- $path = str_replace('{','', $path );
703
- $path = str_replace('}','', $path );
704
-
705
-
706
- include_once $path . 'includes/admin/templates/directory/'. $box['id'] . '.php';
707
- if ( ! $this->directory_nonce_added ) {
708
- $this->directory_nonce_added = true;
709
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' );
710
- }
711
- }
712
-
713
-
714
- /**
715
- * Load a role metabox
716
- *
717
- * @param $object
718
- * @param $box
719
- */
720
- function load_metabox_role( $object, $box ) {
721
- global $post;
722
-
723
- $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
724
-
725
- if ( $box['id'] == 'builder' ) {
726
- UM()->builder()->form_id = get_the_ID();
727
- }
728
-
729
- preg_match('#\{.*?\}#s', $box['id'], $matches);
730
-
731
- if ( isset($matches[0]) ){
732
- $path = $matches[0];
733
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
734
- } else {
735
- $path = um_path;
736
- }
737
-
738
- $path = str_replace('{','', $path );
739
- $path = str_replace('}','', $path );
740
-
741
- include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php';
742
- //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' );
743
- }
744
-
745
-
746
- /**
747
- * Load a form metabox
748
- *
749
- * @param $object
750
- * @param $box
751
- */
752
- function load_metabox_form( $object, $box ) {
753
- global $post;
754
-
755
- $box['id'] = str_replace( 'um-admin-form-','', $box['id'] );
756
-
757
- if ( $box['id'] == 'builder' ) {
758
- UM()->builder()->form_id = get_the_ID();
759
- }
760
-
761
- preg_match('#\{.*?\}#s', $box['id'], $matches);
762
-
763
- if ( isset( $matches[0] ) ) {
764
- $path = $matches[0];
765
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
766
- } else {
767
- $path = um_path;
768
- }
769
-
770
- $path = str_replace('{','', $path );
771
- $path = str_replace('}','', $path );
772
-
773
- include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php';
774
-
775
- if ( ! $this->form_nonce_added ) {
776
- $this->form_nonce_added = true;
777
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' );
778
- }
779
- }
780
-
781
-
782
- /**
783
- * Load admin custom metabox
784
- *
785
- * @param $object
786
- * @param $box
787
- */
788
- function load_metabox_custom( $object, $box ) {
789
- global $post;
790
-
791
- $box['id'] = str_replace('um-admin-custom-','', $box['id']);
792
-
793
- preg_match('#\{.*?\}#s', $box['id'], $matches);
794
-
795
- if ( isset($matches[0]) ){
796
- $path = $matches[0];
797
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
798
- } else {
799
- $path = um_path;
800
- }
801
-
802
- $path = str_replace('{','', $path );
803
- $path = str_replace('}','', $path );
804
-
805
- include_once $path . 'includes/admin/templates/'. $box['id'] . '.php';
806
- if ( ! $this->custom_nonce_added ) {
807
- $this->custom_nonce_added = true;
808
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' );
809
- }
810
- }
811
-
812
-
813
- /**
814
- * Add directory metabox
815
- */
816
- function add_metabox_directory() {
817
- add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
818
- add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
819
- add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
820
- add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
821
- add_meta_box( 'um-admin-form-pagination', __( 'Results &amp; Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
822
- add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' );
823
- add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' );
824
- }
825
-
826
-
827
- /**
828
- * Add role metabox
829
- */
830
- function add_metabox_role() {
831
- $callback = array( &$this, 'load_metabox_role' );
832
-
833
- $roles_metaboxes = array(
834
- array(
835
- 'id' => 'um-admin-form-admin-permissions',
836
- 'title' => __( 'Administrative Permissions', 'ultimate-member' ),
837
- 'callback' => $callback,
838
- 'screen' => 'um_role_meta',
839
- 'context' => 'normal',
840
- 'priority' => 'default'
841
- ),
842
- array(
843
- 'id' => 'um-admin-form-general',
844
- 'title' => __( 'General Permissions', 'ultimate-member' ),
845
- 'callback' => $callback,
846
- 'screen' => 'um_role_meta',
847
- 'context' => 'normal',
848
- 'priority' => 'default'
849
- ),
850
- array(
851
- 'id' => 'um-admin-form-profile',
852
- 'title' => __( 'Profile Access', 'ultimate-member' ),
853
- 'callback' => $callback,
854
- 'screen' => 'um_role_meta',
855
- 'context' => 'normal',
856
- 'priority' => 'default'
857
- )
858
- );
859
-
860
- if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
861
- $roles_metaboxes[] = array(
862
- 'id' => 'um-admin-form-home',
863
- 'title' => __( 'Homepage Options', 'ultimate-member' ),
864
- 'callback' => $callback,
865
- 'screen' => 'um_role_meta',
866
- 'context' => 'normal',
867
- 'priority' => 'default'
868
- );
869
- }
870
-
871
- $roles_metaboxes = array_merge( $roles_metaboxes, array(
872
- array(
873
- 'id' => 'um-admin-form-register',
874
- 'title' => __( 'Registration Options', 'ultimate-member' ),
875
- 'callback' => $callback,
876
- 'screen' => 'um_role_meta',
877
- 'context' => 'normal',
878
- 'priority' => 'default'
879
- ),
880
- array(
881
- 'id' => 'um-admin-form-login',
882
- 'title' => __( 'Login Options', 'ultimate-member' ),
883
- 'callback' => $callback,
884
- 'screen' => 'um_role_meta',
885
- 'context' => 'normal',
886
- 'priority' => 'default'
887
- ),
888
- array(
889
- 'id' => 'um-admin-form-logout',
890
- 'title' => __( 'Logout Options', 'ultimate-member' ),
891
- 'callback' => $callback,
892
- 'screen' => 'um_role_meta',
893
- 'context' => 'normal',
894
- 'priority' => 'default'
895
- ),
896
- array(
897
- 'id' => 'um-admin-form-delete',
898
- 'title' => __( 'Delete Options', 'ultimate-member' ),
899
- 'callback' => $callback,
900
- 'screen' => 'um_role_meta',
901
- 'context' => 'normal',
902
- 'priority' => 'default'
903
- ),
904
- array(
905
- 'id' => 'um-admin-form-publish',
906
- 'title' => __( 'Publish', 'ultimate-member' ),
907
- 'callback' => $callback,
908
- 'screen' => 'um_role_meta',
909
- 'context' => 'side',
910
- 'priority' => 'default'
911
- )
912
- ) );
913
-
914
- /**
915
- * UM hook
916
- *
917
- * @type filter
918
- * @title um_admin_role_metaboxes
919
- * @description Extend metaboxes at Add/Edit User Role
920
- * @input_vars
921
- * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}]
922
- * @change_log
923
- * ["Since: 2.0"]
924
- * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );
925
- * @example
926
- * <?php
927
- * add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );
928
- * function my_admin_role_metaboxes( $roles_metaboxes ) {
929
- * // your code here
930
- * $roles_metaboxes[] = array(
931
- * 'id' => 'um-admin-form-your-custom',
932
- * 'title' => __( 'My Roles Metabox', 'ultimate-member' ),
933
- * 'callback' => 'my-metabox-callback',
934
- * 'screen' => 'um_role_meta',
935
- * 'context' => 'side',
936
- * 'priority' => 'default'
937
- * );
938
- *
939
- * return $roles_metaboxes;
940
- * }
941
- * ?>
942
- */
943
- $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
944
-
945
- $wp_caps_metabox = false;
946
- if ( ! empty( $_GET['id'] ) ) {
947
- $data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' );
948
- if ( ! empty( $data['_um_is_custom'] ) ) {
949
- $wp_caps_metabox = true;
950
- }
951
- }
952
- if ( 'add' == sanitize_key( $_GET['tab'] ) || $wp_caps_metabox ) {
953
- $roles_metaboxes[] = array(
954
- 'id' => 'um-admin-form-wp-capabilities',
955
- 'title' => __( 'WP Capabilities', 'ultimate-member' ),
956
- 'callback' => $callback,
957
- 'screen' => 'um_role_meta',
958
- 'context' => 'normal',
959
- 'priority' => 'default'
960
- );
961
- }
962
-
963
-
964
- foreach ( $roles_metaboxes as $metabox ) {
965
- add_meta_box(
966
- $metabox['id'],
967
- $metabox['title'],
968
- $metabox['callback'],
969
- $metabox['screen'],
970
- $metabox['context'],
971
- $metabox['priority']
972
- );
973
- }
974
- }
975
-
976
-
977
- /**
978
- * Add form metabox
979
- */
980
- function add_metabox_form() {
981
-
982
- add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
983
- add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
984
- add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
985
-
986
- add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
987
-
988
- /**
989
- * UM hook
990
- *
991
- * @type action
992
- * @title um_admin_custom_register_metaboxes
993
- * @description Add custom metaboxes for register form
994
- * @change_log
995
- * ["Since: 2.0"]
996
- * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 );
997
- * @example
998
- * <?php
999
- * add_action( 'um_admin_custom_register_metaboxes', 'my_admin_custom_register_metaboxes', 10 );
1000
- * function my_admin_custom_register_metaboxes() {
1001
- * // your code here
1002
- * }
1003
- * ?>
1004
- */
1005
- do_action( 'um_admin_custom_register_metaboxes' );
1006
-
1007
- add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1008
- add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1009
-
1010
- /**
1011
- * UM hook
1012
- *
1013
- * @type action
1014
- * @title um_admin_custom_profile_metaboxes
1015
- * @description Add custom metaboxes for profile form
1016
- * @change_log
1017
- * ["Since: 2.0"]
1018
- * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 );
1019
- * @example
1020
- * <?php
1021
- * add_action( 'um_admin_custom_profile_metaboxes', 'my_admin_custom_profile_metaboxes', 10 );
1022
- * function my_admin_custom_profile_metaboxes() {
1023
- * // your code here
1024
- * }
1025
- * ?>
1026
- */
1027
- do_action( 'um_admin_custom_profile_metaboxes' );
1028
-
1029
- add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1030
- add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1031
-
1032
- /**
1033
- * UM hook
1034
- *
1035
- * @type action
1036
- * @title um_admin_custom_login_metaboxes
1037
- * @description Add custom metaboxes for login form
1038
- * @change_log
1039
- * ["Since: 2.0"]
1040
- * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 );
1041
- * @example
1042
- * <?php
1043
- * add_action( 'um_admin_custom_login_metaboxes', 'my_admin_custom_login_metaboxes', 10 );
1044
- * function my_admin_custom_login_metaboxes() {
1045
- * // your code here
1046
- * }
1047
- * ?>
1048
- */
1049
- do_action( 'um_admin_custom_login_metaboxes' );
1050
- }
1051
-
1052
-
1053
- /**
1054
- * Save directory metabox
1055
- *
1056
- * @param $post_id
1057
- * @param $post
1058
- */
1059
- function save_metabox_directory( $post_id, $post ) {
1060
- global $wpdb;
1061
-
1062
- // validate nonce
1063
- if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) ||
1064
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
1065
- return;
1066
- }
1067
-
1068
- // validate post type
1069
- if ( $post->post_type != 'um_directory' ) {
1070
- return;
1071
- }
1072
-
1073
- // validate user
1074
- $post_type = get_post_type_object( $post->post_type );
1075
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1076
- return;
1077
- }
1078
-
1079
- $where = array( 'ID' => $post_id );
1080
-
1081
- if ( empty( $_POST['post_title'] ) ) {
1082
- $_POST['post_title'] = sprintf( __( 'Directory #%s', 'ultimate-member' ), $post_id );
1083
- }
1084
-
1085
- $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1086
-
1087
- do_action( 'um_before_member_directory_save', $post_id );
1088
-
1089
- // save
1090
- delete_post_meta( $post_id, '_um_roles' );
1091
- delete_post_meta( $post_id, '_um_tagline_fields' );
1092
- delete_post_meta( $post_id, '_um_reveal_fields' );
1093
- delete_post_meta( $post_id, '_um_search_fields' );
1094
- delete_post_meta( $post_id, '_um_roles_can_search' );
1095
- delete_post_meta( $post_id, '_um_roles_can_filter' );
1096
- delete_post_meta( $post_id, '_um_show_these_users' );
1097
- delete_post_meta( $post_id, '_um_exclude_these_users' );
1098
-
1099
- delete_post_meta( $post_id, '_um_search_filters' );
1100
- delete_post_meta( $post_id, '_um_search_filters_gmt' );
1101
-
1102
- delete_post_meta( $post_id, '_um_sorting_fields' );
1103
-
1104
- //save metadata
1105
- $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
1106
- foreach ( $metadata as $k => $v ) {
1107
-
1108
- if ( $k == '_um_show_these_users' && trim( $v ) ) {
1109
- $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1110
- }
1111
-
1112
- if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
1113
- $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1114
- }
1115
-
1116
- if ( strstr( $k, '_um_' ) ) {
1117
-
1118
- if ( $k === '_um_is_default' ) {
1119
-
1120
- $mode = UM()->query()->get_attr( 'mode', $post_id );
1121
-
1122
- if ( ! empty( $mode ) ) {
1123
-
1124
- $posts = $wpdb->get_col(
1125
- "SELECT post_id
1126
- FROM {$wpdb->postmeta}
1127
- WHERE meta_key = '_um_mode' AND
1128
- meta_value = 'directory'"
1129
- );
1130
-
1131
- foreach ( $posts as $p_id ) {
1132
- delete_post_meta( $p_id, '_um_is_default' );
1133
- }
1134
-
1135
- }
1136
-
1137
- }
1138
-
1139
- $v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
1140
-
1141
- update_post_meta( $post_id, $k, $v );
1142
-
1143
- }
1144
- }
1145
-
1146
- update_post_meta( $post_id, '_um_search_filters_gmt', (int) $_POST['um-gmt-offset'] );
1147
- }
1148
-
1149
-
1150
- /**
1151
- * Save form metabox
1152
- *
1153
- * @param $post_id
1154
- * @param $post
1155
- */
1156
- function save_metabox_form( $post_id, $post ) {
1157
- global $wpdb;
1158
-
1159
- // validate nonce
1160
- if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) ||
1161
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) {
1162
- return;
1163
- }
1164
-
1165
- // validate post type
1166
- if ( $post->post_type != 'um_form' ) {
1167
- return;
1168
- }
1169
-
1170
- // validate user
1171
- $post_type = get_post_type_object( $post->post_type );
1172
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1173
- return;
1174
- }
1175
-
1176
- $where = array( 'ID' => $post_id );
1177
- if ( empty( $_POST['post_title'] ) ) {
1178
- $_POST['post_title'] = sprintf( __( 'Form #%s', 'ultimate-member' ), $post_id );
1179
- }
1180
- $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1181
-
1182
- // save
1183
- delete_post_meta( $post_id, '_um_profile_metafields' );
1184
-
1185
-
1186
- $form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
1187
-
1188
- foreach ( $form_meta as $k => $v ) {
1189
- if ( strstr( $k, '_um_' ) ) {
1190
- if ( $k === '_um_is_default' ) {
1191
- $mode = UM()->query()->get_attr( 'mode', $post_id );
1192
- if ( ! empty( $mode ) ) {
1193
- $posts = $wpdb->get_col( $wpdb->prepare(
1194
- "SELECT post_id
1195
- FROM {$wpdb->postmeta}
1196
- WHERE meta_key = '_um_mode' AND
1197
- meta_value = %s",
1198
- $mode
1199
- ) );
1200
- foreach ( $posts as $p_id ) {
1201
- delete_post_meta( $p_id, '_um_is_default' );
1202
- }
1203
- }
1204
- }
1205
-
1206
- update_post_meta( $post_id, $k, $v );
1207
- }
1208
- }
1209
-
1210
- }
1211
-
1212
-
1213
- /**
1214
- * Load modal content
1215
- */
1216
- function load_modal_content() {
1217
- $screen = get_current_screen();
1218
-
1219
- if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1220
- foreach ( glob( um_path . 'includes/admin/templates/modal/forms/*.php' ) as $modal_content ) {
1221
- include_once $modal_content;
1222
- }
1223
- }
1224
-
1225
- if ( $this->init_icon ) {
1226
- include_once um_path . 'includes/admin/templates/modal/forms/fonticons.php';
1227
- }
1228
-
1229
- if ( $screen->id == 'users' ) {
1230
- include_once um_path . 'includes/admin/templates/modal/dynamic_registration_preview.php';
1231
- }
1232
-
1233
- // needed on forms only
1234
- if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1235
- $settings['textarea_rows'] = 8;
1236
-
1237
- echo '<div class="um-hidden-editor-edit" style="display:none;">';
1238
- wp_editor( '', 'um_editor_edit', $settings );
1239
- echo '</div>';
1240
-
1241
- echo '<div class="um-hidden-editor-new" style="display:none;">';
1242
- wp_editor( '', 'um_editor_new', $settings );
1243
- echo '</div>';
1244
-
1245
- $this->is_loaded = true;
1246
- }
1247
- }
1248
-
1249
-
1250
- /**
1251
- * Show field input for edit at modal field
1252
- *
1253
- * @param $attribute
1254
- * @param null $form_id
1255
- * @param array $field_args
1256
- */
1257
- function field_input( $attribute, $form_id = null, $field_args = array() ) {
1258
-
1259
- if ( $this->in_edit == true ) { // we're editing a field
1260
- $real_attr = substr( $attribute, 1 );
1261
- $this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
1262
- }
1263
-
1264
- switch ( $attribute ) {
1265
-
1266
- default:
1267
-
1268
- /**
1269
- * UM hook
1270
- *
1271
- * @type action
1272
- * @title um_admin_field_edit_hook{$attribute}
1273
- * @description Integration for 3-d party fields at wp-admin
1274
- * @input_vars
1275
- * [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}]
1276
- * @change_log
1277
- * ["Since: 2.0"]
1278
- * @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 );
1279
- * @example
1280
- * <?php
1281
- * add_action( 'um_admin_field_edit_hook{$attribute}', 'my_admin_field_edit', 10, 1 );
1282
- * function my_admin_field_edit( $edit_mode_value ) {
1283
- * // your code here
1284
- * }
1285
- * ?>
1286
- */
1287
- do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value, $form_id, $this->edit_array );
1288
-
1289
- break;
1290
-
1291
- case '_visibility':
1292
- ?>
1293
-
1294
- <p><label for="_visibility"><?php _e( 'Visibility', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.','ultimate-member' ) ); ?></label>
1295
- <select name="_visibility" id="_visibility" style="width: 100%">
1296
- <option value="all" <?php selected( 'all', $this->edit_mode_value ); ?>><?php _e( 'View everywhere', 'ultimate-member' ) ?></option>
1297
- <option value="edit" <?php selected( 'edit', $this->edit_mode_value ); ?>><?php _e( 'Edit mode only', 'ultimate-member' ) ?></option>
1298
- <option value="view" <?php selected( 'view', $this->edit_mode_value ); ?>><?php _e( 'View mode only', 'ultimate-member' ) ?></option>
1299
- </select>
1300
- </p>
1301
-
1302
- <?php
1303
- break;
1304
-
1305
- case '_conditional_action':
1306
- case '_conditional_action1':
1307
- case '_conditional_action2':
1308
- case '_conditional_action3':
1309
- case '_conditional_action4':
1310
- ?>
1311
-
1312
- <p>
1313
- <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 90px">
1314
-
1315
- <option></option>
1316
-
1317
- <?php $actions = array( 'show', 'hide' );
1318
- foreach ( $actions as $action ) { ?>
1319
-
1320
- <option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action, $this->edit_mode_value ); ?>><?php echo $action; ?></option>
1321
-
1322
- <?php } ?>
1323
-
1324
- </select>
1325
-
1326
- &nbsp;&nbsp;<?php _e( 'If' ); ?>
1327
- </p>
1328
-
1329
- <?php
1330
- break;
1331
-
1332
- case '_conditional_field':
1333
- case '_conditional_field1':
1334
- case '_conditional_field2':
1335
- case '_conditional_field3':
1336
- case '_conditional_field4':
1337
- ?>
1338
-
1339
- <p>
1340
- <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1341
-
1342
- <option></option>
1343
-
1344
- <?php $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
1345
-
1346
- foreach ( $fields as $key => $array ) {
1347
- if ( isset( $array['title'] ) &&
1348
- ( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?>
1349
-
1350
- <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $key, $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
1351
-
1352
- <?php }
1353
- } ?>
1354
-
1355
- </select>
1356
- </p>
1357
-
1358
- <?php
1359
- break;
1360
-
1361
- case '_conditional_operator':
1362
- case '_conditional_operator1':
1363
- case '_conditional_operator2':
1364
- case '_conditional_operator3':
1365
- case '_conditional_operator4':
1366
- ?>
1367
-
1368
- <p>
1369
- <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1370
-
1371
- <option></option>
1372
-
1373
- <?php $operators = array(
1374
- 'empty',
1375
- 'not empty',
1376
- 'equals to',
1377
- 'not equals',
1378
- 'greater than',
1379
- 'less than',
1380
- 'contains'
1381
- );
1382
-
1383
- foreach ( $operators as $operator ) { ?>
1384
-
1385
- <option value="<?php echo esc_attr( $operator ); ?>" <?php selected( $operator, $this->edit_mode_value ); ?>><?php echo $operator; ?></option>
1386
-
1387
- <?php } ?>
1388
-
1389
- </select>
1390
- </p>
1391
-
1392
- <?php
1393
- break;
1394
-
1395
- case '_conditional_value':
1396
- case '_conditional_value1':
1397
- case '_conditional_value2':
1398
- case '_conditional_value3':
1399
- case '_conditional_value4':
1400
- ?>
1401
-
1402
- <p>
1403
- <input type="text" name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" value="<?php echo isset( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" placeholder="<?php esc_attr_e( 'Value', 'ultimate-member' ); ?>" style="width: 150px!important;position: relative;top: -1px;" />
1404
- </p>
1405
-
1406
- <?php
1407
- break;
1408
-
1409
- case '_validate':
1410
- ?>
1411
-
1412
- <p><label for="_validate"><?php _e( 'Validate', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Does this field require a special validation', 'ultimate-member' ) ); ?></label>
1413
- <select name="_validate" id="_validate" data-placeholder="<?php esc_attr_e( 'Select a validation type...', 'ultimate-member' ) ?>" class="um-adm-conditional" data-cond1="custom" data-cond1-show="_custom_validate" style="width: 100%">
1414
-
1415
- <option value="" <?php selected( '', $this->edit_mode_value ); ?>></option>
1416
-
1417
- <?php foreach( UM()->builtin()->validation_types() as $key => $name ) { ?>
1418
- <?php
1419
- /**
1420
- * UM hook
1421
- *
1422
- * @type filter
1423
- * @title um_builtin_validation_types_continue_loop
1424
- * @description Builtin Validation Types
1425
- * @input_vars
1426
- * [{"var":"$continue","type":"bool","desc":"Validate?"},
1427
- * {"var":"$key","type":"string","desc":"Field Key"},
1428
- * {"var":"$form_id","type":"int","desc":"Form ID"},
1429
- * {"var":"$field_args","type":"array","desc":"Field Settings"}]
1430
- * @change_log
1431
- * ["Since: 2.0"]
1432
- * @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 );
1433
- * @example
1434
- * <?php
1435
- * add_filter( 'um_builtin_validation_types_continue_loop', 'my_builtin_validation_types', 10, 4 );
1436
- * function my_builtin_validation_types( $continue, $key, $form_id, $field_args ) {
1437
- * // your code here
1438
- * return $continue;
1439
- * }
1440
- * ?>
1441
- */
1442
- $continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args );
1443
- if ( $continue ) { ?>
1444
- <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->edit_mode_value ); ?>><?php echo $name; ?></option>
1445
- <?php } ?>
1446
- <?php } ?>
1447
-
1448
- </select>
1449
- </p>
1450
-
1451
- <?php
1452
- break;
1453
-
1454
- case '_custom_validate':
1455
- ?>
1456
-
1457
- <p class="_custom_validate"><label for="_custom_validate"><?php _e( 'Custom Action', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details.', 'ultimate-member' ) ); ?></label>
1458
- <input type="text" name="_custom_validate" id="_custom_validate" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1459
- </p>
1460
-
1461
- <?php
1462
- break;
1463
-
1464
- case '_icon':
1465
-
1466
- if ( $this->set_field_type == 'row' ) {
1467
- $back = 'UM_edit_row';
1468
-
1469
- ?>
1470
-
1471
- <p class="_heading_text"><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1472
-
1473
- <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="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1474
-
1475
- <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1476
-
1477
- <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1478
-
1479
- <?php if ( $this->edit_mode_value ) { ?>
1480
- <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1481
- <?php } else { ?>
1482
- <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1483
- <?php } ?>
1484
-
1485
- </p>
1486
-
1487
- <?php } else {
1488
-
1489
- if ( $this->in_edit ) {
1490
- $back = 'UM_edit_field';
1491
- } else {
1492
- $back = 'UM_add_field';
1493
- }
1494
-
1495
- ?>
1496
-
1497
- <div class="um-admin-tri">
1498
-
1499
- <p><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1500
-
1501
- <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="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1502
-
1503
- <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1504
-
1505
- <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1506
-
1507
- <?php if ( $this->edit_mode_value ) { ?>
1508
- <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1509
- <?php } else { ?>
1510
- <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1511
- <?php } ?>
1512
-
1513
- </p>
1514
-
1515
- </div>
1516
-
1517
- <?php
1518
-
1519
- }
1520
-
1521
- break;
1522
-
1523
- case '_css_class':
1524
- ?>
1525
-
1526
- <p><label for="_css_class"><?php _e( 'CSS Class', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Specify a custom CSS class to be applied to this element', 'ultimate-member' ) ); ?></label>
1527
- <input type="text" name="_css_class" id="_css_class" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1528
- </p>
1529
-
1530
- <?php
1531
- break;
1532
-
1533
- case '_width':
1534
- ?>
1535
-
1536
- <p><label for="_width"><?php _e( 'Thickness (in pixels)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the width in pixels, e.g. 4 or 2, etc', 'ultimate-member' ) ); ?></label>
1537
- <input type="text" name="_width" id="_width" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 4; ?>" />
1538
- </p>
1539
-
1540
- <?php
1541
- break;
1542
-
1543
- case '_divider_text':
1544
- ?>
1545
-
1546
- <p><label for="_divider_text"><?php _e( 'Optional Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Optional text to include with the divider', 'ultimate-member' ) ); ?></label>
1547
- <input type="text" name="_divider_text" id="_divider_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1548
- </p>
1549
-
1550
- <?php
1551
- break;
1552
-
1553
- case '_padding':
1554
- ?>
1555
-
1556
- <p><label for="_padding"><?php _e( 'Padding', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set padding for this section', 'ultimate-member' ) ); ?></label>
1557
- <input type="text" name="_padding" id="_padding" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1558
- </p>
1559
-
1560
- <?php
1561
- break;
1562
-
1563
- case '_margin':
1564
- ?>
1565
-
1566
- <p><label for="_margin"><?php _e( 'Margin', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set margin for this section', 'ultimate-member' ) ); ?></label>
1567
- <input type="text" name="_margin" id="_margin" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 30px 0px'; ?>" />
1568
- </p>
1569
-
1570
- <?php
1571
- break;
1572
-
1573
- case '_border':
1574
- ?>
1575
-
1576
- <p><label for="_border"><?php _e( 'Border', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set border for this section', 'ultimate-member' ) ); ?></label>
1577
- <input type="text" name="_border" id="_border" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1578
- </p>
1579
-
1580
- <?php
1581
- break;
1582
-
1583
- case '_borderstyle':
1584
- ?>
1585
-
1586
- <p><label for="_borderstyle"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the border style', 'ultimate-member' ) ); ?></label>
1587
- <select name="_borderstyle" id="_borderstyle" style="width: 100%">
1588
- <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1589
- <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1590
- <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1591
- <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1592
- </select>
1593
- </p>
1594
-
1595
- <?php
1596
- break;
1597
-
1598
- case '_borderradius':
1599
- ?>
1600
-
1601
- <p><label for="_borderradius"><?php _e( 'Border Radius', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Rounded corners can be applied by setting a pixels value here. e.g. 5px', 'ultimate-member' ) ); ?></label>
1602
- <input type="text" name="_borderradius" id="_borderradius" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px'; ?>" />
1603
- </p>
1604
-
1605
- <?php
1606
- break;
1607
-
1608
- case '_bordercolor':
1609
- ?>
1610
-
1611
- <p><label for="_bordercolor"><?php _e( 'Border Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Give a color to this border', 'ultimate-member' ) ); ?></label>
1612
- <input type="text" name="_bordercolor" id="_bordercolor" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1613
- </p>
1614
-
1615
- <?php
1616
- break;
1617
-
1618
- case '_heading':
1619
- ?>
1620
-
1621
- <p><label for="_heading"><?php _e( 'Enable Row Heading', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to enable a heading for this row', 'ultimate-member' ) ); ?></label>
1622
- <input type="checkbox" name="_heading" id="_heading" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />
1623
- </p>
1624
-
1625
- <?php
1626
- break;
1627
-
1628
- case '_heading_text':
1629
- ?>
1630
-
1631
- <p class="_heading_text"><label for="_heading_text"><?php _e( 'Heading Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the row heading text here', 'ultimate-member' ) ); ?></label>
1632
- <input type="text" name="_heading_text" id="_heading_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1633
- </p>
1634
-
1635
- <?php
1636
- break;
1637
-
1638
- case '_background':
1639
- ?>
1640
-
1641
- <p><label for="_background"><?php _e( 'Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of entire section', 'ultimate-member' ) ); ?></label>
1642
- <input type="text" name="_background" id="_background" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1643
- </p>
1644
-
1645
- <?php
1646
- break;
1647
-
1648
- case '_heading_background_color':
1649
- ?>
1650
-
1651
- <p class="_heading_text"><label for="_heading_background_color"><?php _e( 'Heading Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of the heading section', 'ultimate-member' ) ); ?></label>
1652
- <input type="text" name="_heading_background_color" id="_heading_background_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1653
- </p>
1654
-
1655
- <?php
1656
- break;
1657
-
1658
- case '_heading_text_color':
1659
- ?>
1660
-
1661
- <p class="_heading_text"><label for="_heading_text_color"><?php _e( 'Heading Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of heading part only', 'ultimate-member' ) ); ?></label>
1662
- <input type="text" name="_heading_text_color" id="_heading_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1663
- </p>
1664
-
1665
- <?php
1666
- break;
1667
-
1668
- case '_text_color':
1669
- ?>
1670
-
1671
- <p><label for="_text_color"><?php _e( 'Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of entire section', 'ultimate-member' ) ); ?></label>
1672
- <input type="text" name="_text_color" id="_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1673
- </p>
1674
-
1675
- <?php
1676
- break;
1677
-
1678
- case '_icon_color':
1679
- ?>
1680
-
1681
- <p class="_heading_text"><label for="_icon_color"><?php _e( 'Icon Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the color of selected icon. By default It will be the same color as heading text color', 'ultimate-member' ) ); ?></label>
1682
- <input type="text" name="_icon_color" id="_icon_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1683
- </p>
1684
-
1685
- <?php
1686
- break;
1687
-
1688
- case '_color':
1689
- ?>
1690
-
1691
- <p><label for="_color"><?php _e( 'Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select a color for this divider', 'ultimate-member' ) ); ?></label>
1692
- <input type="text" name="_color" id="_color" class="um-admin-colorpicker" data-default-color="#eeeeee" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '#eeeeee'; ?>" />
1693
- </p>
1694
-
1695
- <?php
1696
- break;
1697
-
1698
- case '_url_text':
1699
- ?>
1700
-
1701
- <p><label for="_url_text"><?php _e( 'URL Alt Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Entering custom text here will replace the url with a text link', 'ultimate-member' ) ); ?></label>
1702
- <input type="text" name="_url_text" id="_url_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1703
- </p>
1704
-
1705
- <?php
1706
- break;
1707
-
1708
- case '_url_target':
1709
- ?>
1710
-
1711
- <p><label for="_url_target"><?php _e( 'Link Target', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether to open this link in same window or in a new window', 'ultimate-member' ) ); ?></label>
1712
- <select name="_url_target" id="_url_target" style="width: 100%">
1713
- <option value="_blank" <?php selected( '_blank', $this->edit_mode_value ); ?>><?php _e( 'Open in new window', 'ultimate-member' ) ?></option>
1714
- <option value="_self" <?php selected( '_self', $this->edit_mode_value ); ?>><?php _e( 'Same window', 'ultimate-member' ) ?></option>
1715
- </select>
1716
- </p>
1717
-
1718
- <?php
1719
- break;
1720
-
1721
- case '_url_rel':
1722
- ?>
1723
-
1724
- <p><label for="_url_rel"><?php _e( 'SEO Follow', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to follow or nofollow this link by search engines', 'ultimate-member' ) ); ?></label>
1725
- <select name="_url_rel" id="_url_rel" style="width: 100%">
1726
- <option value="follow" <?php selected( 'follow', $this->edit_mode_value ); ?>><?php _e( 'Follow', 'ultimate-member' ) ?></option>
1727
- <option value="nofollow" <?php selected( 'nofollow', $this->edit_mode_value ); ?>><?php _e( 'No-Follow', 'ultimate-member' ) ?></option>
1728
- </select>
1729
- </p>
1730
-
1731
- <?php
1732
- break;
1733
-
1734
- case '_force_good_pass':
1735
- ?>
1736
-
1737
- <p><label for="_force_good_pass"><?php _e( 'Force strong password?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
1738
- <input type="checkbox" name="_force_good_pass" id="_force_good_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
1739
- </p>
1740
-
1741
- <?php
1742
- break;
1743
-
1744
- case '_force_confirm_pass':
1745
- ?>
1746
-
1747
- <p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
1748
- <input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
1749
- </p>
1750
-
1751
- <?php
1752
- break;
1753
-
1754
- case '_style':
1755
- ?>
1756
-
1757
- <p><label for="_style"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the line-style of divider', 'ultimate-member' ) ); ?></label>
1758
- <select name="_style" id="_style" style="width: 100%">
1759
- <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1760
- <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1761
- <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1762
- <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1763
- </select>
1764
- </p>
1765
-
1766
- <?php
1767
- break;
1768
-
1769
- case '_intervals':
1770
-
1771
- ?>
1772
-
1773
- <p><label for="_intervals"><?php _e( 'Time Intervals (in minutes)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the minutes interval between each time in the time picker.', 'ultimate-member' ) ); ?></label>
1774
- <input type="text" name="_intervals" id="_intervals" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 60; ?>" placeholder="<?php esc_attr_e( 'e.g. 30, 60, 120', 'ultimate-member' ) ?>" />
1775
- </p>
1776
-
1777
- <?php
1778
- break;
1779
-
1780
-
1781
- case '_format':
1782
-
1783
- if ( $this->set_field_type == 'date' ) {
1784
- ?>
1785
-
1786
- <p><label for="_format"><?php _e( 'Date User-Friendly Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The display format of the date which is visible to user.', 'ultimate-member' ) ); ?></label>
1787
- <select name="_format" id="_format" style="width: 100%">
1788
- <option value="j M Y" <?php selected( 'j M Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j M Y'); ?></option>
1789
- <option value="M j Y" <?php selected( 'M j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('M j Y'); ?></option>
1790
- <option value="j F Y" <?php selected( 'j F Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j F Y'); ?></option>
1791
- <option value="F j Y" <?php selected( 'F j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('F j Y'); ?></option>
1792
- </select>
1793
- </p>
1794
-
1795
- <?php } else { ?>
1796
-
1797
- <p><label for="_format"><?php _e( 'Time Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the displayed time-format for this field', 'ultimate-member' ) ); ?></label>
1798
- <select name="_format" id="_format" style="width: 100%">
1799
- <option value="g:i a" <?php selected( 'g:i a', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i a'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1800
- <option value="g:i A" <?php selected( 'g:i A', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i A'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1801
- <option value="H:i" <?php selected( 'H:i', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('H:i'); ?><?php _e( '( 24-hr format )', 'ultimate-member' ) ?></option>
1802
- </select>
1803
- </p>
1804
-
1805
- <?php
1806
- }
1807
- break;
1808
-
1809
- case '_format_custom':
1810
- ?>
1811
-
1812
- <p><label for="_format_custom"><?php _e( 'Use custom Date format', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option overrides "Date User-Friendly Format" option. See https://www.php.net/manual/en/function.date.php', 'ultimate-member' ) ); ?></label>
1813
- <input type="text" name="_format_custom" id="_format_custom" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" placeholder="j M Y" />
1814
- </p>
1815
-
1816
- <?php
1817
- break;
1818
-
1819
- case '_pretty_format':
1820
- ?>
1821
-
1822
- <p><label for="_pretty_format"><?php _e( 'Displayed Date Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether you wish to show the date in full or only show the years e.g. 25 Years', 'ultimate-member' ) ); ?></label>
1823
- <select name="_pretty_format" id="_pretty_format" style="width: 100%">
1824
- <option value="0" <?php selected( 0, $this->edit_mode_value ); ?>><?php _e( 'Show full date', 'ultimate-member' ) ?></option>
1825
- <option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Show years only', 'ultimate-member' ) ?></option>
1826
- </select>
1827
- </p>
1828
-
1829
- <?php
1830
- break;
1831
-
1832
- case '_disabled_weekdays':
1833
-
1834
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1835
- $values = $this->edit_mode_value;
1836
- } else {
1837
- $values = array('');
1838
- }
1839
- ?>
1840
-
1841
- <p><label for="_disabled_weekdays"><?php _e( 'Disable specific weekdays', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Disable specific week days from being available for selection in this date picker', 'ultimate-member' ) ); ?></label>
1842
- <select name="_disabled_weekdays[]" id="_disabled_weekdays" multiple="multiple" style="width: 100%">
1843
- <option value="1" <?php if ( in_array( 1, $values ) ) { echo 'selected'; } ?>><?php _e( 'Sunday', 'ultimate-member' ) ?></option>
1844
- <option value="2" <?php if ( in_array( 2, $values ) ) { echo 'selected'; } ?>><?php _e( 'Monday', 'ultimate-member' ) ?></option>
1845
- <option value="3" <?php if ( in_array( 3, $values ) ) { echo 'selected'; } ?>><?php _e( 'Tuesday', 'ultimate-member' ) ?></option>
1846
- <option value="4" <?php if ( in_array( 4, $values ) ) { echo 'selected'; } ?>><?php _e( 'Wednesday', 'ultimate-member' ) ?></option>
1847
- <option value="5" <?php if ( in_array( 5, $values ) ) { echo 'selected'; } ?>><?php _e( 'Thursday', 'ultimate-member' ) ?></option>
1848
- <option value="6" <?php if ( in_array( 6, $values ) ) { echo 'selected'; } ?>><?php _e( 'Friday', 'ultimate-member' ) ?></option>
1849
- <option value="7" <?php if ( in_array( 7, $values ) ) { echo 'selected'; } ?>><?php _e( 'Saturday', 'ultimate-member' ) ?></option>
1850
- </select>
1851
- </p>
1852
-
1853
- <?php
1854
- break;
1855
-
1856
- case '_years':
1857
- ?>
1858
-
1859
- <p class="_years"><label for="_years"><?php _e( 'Number of Years to pick from', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Number of years available for the date selection. Default to last 50 years', 'ultimate-member' ) ); ?></label>
1860
- <input type="text" name="_years" id="_years" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 50; ?>" />
1861
- </p>
1862
-
1863
- <?php
1864
- break;
1865
-
1866
- case '_years_x':
1867
- ?>
1868
-
1869
- <p class="_years"><label for="_years_x"><?php _e( 'Years Selection', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This decides which years should be shown relative to today date', 'ultimate-member' ) ); ?></label>
1870
- <select name="_years_x" id="_years_x" style="width: 100%">
1871
- <option value="equal" <?php selected( 'equal', $this->edit_mode_value ); ?>><?php _e( 'Equal years before / after today', 'ultimate-member' ) ?></option>
1872
- <option value="past" <?php selected( 'past', $this->edit_mode_value ); ?>><?php _e( 'Past years only', 'ultimate-member' ) ?></option>
1873
- <option value="future" <?php selected( 'future', $this->edit_mode_value ); ?>><?php _e( 'Future years only', 'ultimate-member' ) ?></option>
1874
- </select>
1875
- </p>
1876
-
1877
- <?php
1878
- break;
1879
-
1880
- case '_range_start':
1881
- ?>
1882
-
1883
- <p class="_date_range"><label for="_range_start"><?php _e( 'Date Range Start', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the minimum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1884
- <input type="text" name="_range_start" id="_range_start" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1885
- </p>
1886
-
1887
- <?php
1888
- break;
1889
-
1890
- case '_range_end':
1891
- ?>
1892
-
1893
- <p class="_date_range"><label for="_range_end"><?php _e( 'Date Range End', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the maximum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1894
- <input type="text" name="_range_end" id="_range_end" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1895
- </p>
1896
-
1897
- <?php
1898
- break;
1899
-
1900
- case '_range':
1901
- ?>
1902
-
1903
- <p><label for="_range"><?php _e( 'Set Date Range', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to show a specific number of years or specify a date range to be available for the date picker.', 'ultimate-member' ) ); ?></label>
1904
- <select name="_range" id="_range" class="um-adm-conditional" data-cond1='years' data-cond1-show='_years' data-cond2="date_range" data-cond2-show="_date_range" style="width: 100%">
1905
- <option value="years" <?php selected( 'years', $this->edit_mode_value ); ?>><?php _e( 'Fixed Number of Years', 'ultimate-member' ) ?></option>
1906
- <option value="date_range" <?php selected( 'date_range', $this->edit_mode_value ); ?>><?php _e( 'Specific Date Range', 'ultimate-member' ) ?></option>
1907
- </select>
1908
- </p>
1909
-
1910
- <?php
1911
- break;
1912
-
1913
- case '_content':
1914
-
1915
- if ( $this->set_field_type == 'shortcode' ) {
1916
-
1917
- ?>
1918
-
1919
- <p><label for="_content"><?php _e( 'Enter Shortcode', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the shortcode in the following textarea and it will be displayed on the fields', 'ultimate-member' ) ); ?></label>
1920
- <textarea name="_content" id="_content" placeholder="<?php esc_attr_e( 'e.g. [my_custom_shortcode]', 'ultimate-member' ) ?>"><?php echo $this->edit_mode_value; ?></textarea>
1921
- </p>
1922
-
1923
- <?php
1924
-
1925
- } else {
1926
-
1927
- ?>
1928
-
1929
- <div class="um-admin-editor-h"><label><?php _e( 'Content Editor', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Edit the content of this field here', 'ultimate-member' ) ); ?></label></div>
1930
-
1931
- <div class="um-admin-editor"><!-- editor dynamically loaded here --></div>
1932
-
1933
- <?php
1934
-
1935
- }
1936
-
1937
- break;
1938
-
1939
- case '_crop':
1940
- ?>
1941
-
1942
- <p><label for="_crop"><?php _e( 'Crop Feature', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable crop feature for this image upload and define ratio', 'ultimate-member' ) ); ?></label>
1943
- <select name="_crop" id="_crop" style="width: 100%">
1944
- <option value="0" <?php selected( '0', $this->edit_mode_value ); ?>><?php _e( 'Turn Off (Default)', 'ultimate-member' ) ?></option>
1945
- <option value="1" <?php selected( '1', $this->edit_mode_value ); ?>><?php _e( 'Crop and force 1:1 ratio', 'ultimate-member' ) ?></option>
1946
- <option value="3" <?php selected( '3', $this->edit_mode_value ); ?>><?php _e( 'Crop and force user-defined ratio', 'ultimate-member' ) ?></option>
1947
- </select>
1948
- </p>
1949
-
1950
- <?php
1951
- break;
1952
-
1953
- case '_allowed_types':
1954
-
1955
- if ( $this->set_field_type == 'image' ) {
1956
-
1957
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1958
- $values = $this->edit_mode_value;
1959
- } else {
1960
- $values = array( 'png','jpeg','jpg','gif' );
1961
- } ?>
1962
-
1963
- <p><label for="_allowed_types"><?php _e( 'Allowed Image Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1964
- <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1965
- <?php foreach( UM()->files()->allowed_image_types() as $e => $n ) { ?>
1966
- <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1967
- <?php } ?>
1968
- </select>
1969
- </p>
1970
-
1971
- <?php
1972
-
1973
- } else {
1974
-
1975
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1976
- $values = $this->edit_mode_value;
1977
- } else {
1978
- $values = array( 'pdf', 'txt' );
1979
- } ?>
1980
-
1981
- <p><label for="_allowed_types"><?php _e( 'Allowed File Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1982
- <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1983
- <?php foreach( UM()->files()->allowed_file_types() as $e => $n ) { ?>
1984
- <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1985
- <?php } ?>
1986
- </select>
1987
- </p>
1988
-
1989
- <?php
1990
-
1991
- }
1992
-
1993
- break;
1994
-
1995
- case '_upload_text':
1996
-
1997
- if ( $this->set_field_type == 'image' ) {
1998
- $value = __( 'Drag &amp; Drop Photo', 'ultimate-member' );
1999
- }
2000
- if ( $this->set_field_type == 'file' ) {
2001
- $value = __( 'Drag &amp; Drop File', 'ultimate-member' );
2002
- }
2003
-
2004
- ?>
2005
-
2006
- <p><label for="_upload_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the headline that appears in the upload box for this field', 'ultimate-member' ) ); ?></label>
2007
- <input type="text" name="_upload_text" id="_upload_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : $value; ?>" />
2008
- </p>
2009
-
2010
- <?php
2011
- break;
2012
-
2013
- case '_upload_help_text':
2014
- ?>
2015
-
2016
- <p><label for="_upload_help_text"><?php _e( 'Additional Instructions Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you need to add information or secondary line below the headline of upload box, enter it here', 'ultimate-member' ) ); ?></label>
2017
- <input type="text" name="_upload_help_text" id="_upload_help_text" value="<?php echo $this->edit_mode_value; ?>" />
2018
- </p>
2019
-
2020
- <?php
2021
- break;
2022
-
2023
- case '_button_text':
2024
- ?>
2025
-
2026
- <p><label for="_button_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The text that appears on the button. e.g. Upload', 'ultimate-member' ) ); ?></label>
2027
- <input type="text" name="_button_text" id="_button_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : __( 'Upload', 'ultimate-member' ); ?>" />
2028
- </p>
2029
-
2030
- <?php
2031
- break;
2032
-
2033
- case '_max_size':
2034
- ?>
2035
-
2036
- <p><label for="_max_size"><?php _e( 'Maximum Size in bytes', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The maximum size for image that can be uploaded through this field. Leave empty for unlimited size.', 'ultimate-member' ) ); ?></label>
2037
- <input type="text" name="_max_size" id="_max_size" value="<?php echo $this->edit_mode_value; ?>" />
2038
- </p>
2039
-
2040
- <?php
2041
- break;
2042
-
2043
- case '_height':
2044
- ?>
2045
-
2046
- <p><label for="_height"><?php _e( 'Textarea Height', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The height of textarea in pixels. Default is 100 pixels', 'ultimate-member' ) ); ?></label>
2047
- <input type="text" name="_height" id="_height" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '100px'; ?>" />
2048
- </p>
2049
-
2050
- <?php
2051
- break;
2052
-
2053
- case '_spacing':
2054
- ?>
2055
-
2056
- <p><label for="_spacing"><?php _e( 'Spacing', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the required spacing in pixels. e.g. 20px', 'ultimate-member' ) ); ?></label>
2057
- <input type="text" name="_spacing" id="_spacing" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '20px'; ?>" />
2058
- </p>
2059
-
2060
- <?php
2061
- break;
2062
-
2063
- case '_is_multi':
2064
- ?>
2065
-
2066
- <p><label for="_is_multi"><?php _e( 'Allow multiple selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable multiple selections for this field', 'ultimate-member' ) ); ?></label>
2067
- <input type="checkbox" name="_is_multi" id="_is_multi" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />
2068
- </p>
2069
-
2070
- <?php
2071
- break;
2072
-
2073
- case '_max_selections':
2074
- ?>
2075
-
2076
- <p class="_max_selections"><label for="_max_selections"><?php _e( 'Maximum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a maximum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2077
- <input type="text" name="_max_selections" id="_max_selections" value="<?php echo $this->edit_mode_value; ?>" />
2078
- </p>
2079
-
2080
- <?php
2081
- break;
2082
-
2083
- case '_min_selections':
2084
- ?>
2085
-
2086
- <p class="_min_selections"><label for="_min_selections"><?php _e( 'Minimum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a minimum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2087
- <input type="text" name="_min_selections" id="_min_selections" value="<?php echo $this->edit_mode_value; ?>" />
2088
- </p>
2089
-
2090
- <?php
2091
- break;
2092
-
2093
- case '_max_entries':
2094
- ?>
2095
-
2096
- <p class="_max_entries"><label for="_max_selections"><?php _e( 'Maximum number of entries', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the max number of entries the user can add via field group.', 'ultimate-member' ) ); ?></label>
2097
- <input type="text" name="_max_entries" id="_max_entries" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 10; ?>" />
2098
- </p>
2099
-
2100
- <?php
2101
- break;
2102
-
2103
- case '_max_words':
2104
- ?>
2105
-
2106
- <p><label for="_max_words"><?php _e( 'Maximum allowed words', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2107
- <input type="text" name="_max_words" id="_max_words" value="<?php echo $this->edit_mode_value; ?>" />
2108
- </p>
2109
-
2110
- <?php
2111
- break;
2112
-
2113
- case '_min':
2114
- ?>
2115
-
2116
- <p><label for="_min"><?php _e( 'Minimum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Minimum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2117
- <input type="text" name="_min" id="_min" value="<?php echo $this->edit_mode_value; ?>" />
2118
- </p>
2119
-
2120
- <?php
2121
- break;
2122
-
2123
- case '_max':
2124
- ?>
2125
-
2126
- <p><label for="_max"><?php _e( 'Maximum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Maximum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2127
- <input type="text" name="_max" id="_max" value="<?php echo $this->edit_mode_value; ?>" />
2128
- </p>
2129
-
2130
- <?php
2131
- break;
2132
-
2133
- case '_min_chars':
2134
- ?>
2135
-
2136
- <p><label for="_min_chars"><?php _e( 'Minimum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2137
- <input type="text" name="_min_chars" id="_min_chars" value="<?php echo $this->edit_mode_value; ?>" />
2138
- </p>
2139
-
2140
- <?php
2141
- break;
2142
-
2143
- case '_max_chars':
2144
- ?>
2145
-
2146
- <p><label for="_max_chars"><?php _e( 'Maximum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2147
- <input type="text" name="_max_chars" id="_max_chars" value="<?php echo $this->edit_mode_value; ?>" />
2148
- </p>
2149
-
2150
- <?php
2151
- break;
2152
-
2153
- case '_html':
2154
- ?>
2155
-
2156
- <p><label for="_html"><?php _e( 'Does this textarea accept HTML?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on/off HTML tags for this textarea', 'ultimate-member' ) ); ?></label>
2157
- <input type="checkbox" name="_html" id="_html" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
2158
- </p>
2159
-
2160
- <?php
2161
- break;
2162
-
2163
- case '_options':
2164
-
2165
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2166
- $values = implode("\n", $this->edit_mode_value);
2167
- } else if ( $this->edit_mode_value ) {
2168
- $values = $this->edit_mode_value;
2169
- } else {
2170
- $values = '';
2171
- } ?>
2172
-
2173
- <p><label for="_options"><?php _e( 'Edit Choices', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter one choice per line. This will represent the available choices or selections available for user.', 'ultimate-member' ) ); ?></label>
2174
- <textarea name="_options" id="_options"><?php echo $values; ?></textarea>
2175
- </p>
2176
-
2177
- <?php
2178
- break;
2179
-
2180
- case '_title':
2181
- ?>
2182
-
2183
- <p><label for="_title"><?php _e( 'Title', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
2184
- <input type="text" name="_title" id="_title" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2185
- </p>
2186
-
2187
- <?php
2188
- break;
2189
-
2190
- case '_id':
2191
-
2192
- ?>
2193
-
2194
- <p style="display:none"><label for="_id"><?php _e( 'Unique ID', 'ultimate-member' ) ?></label>
2195
- <input type="text" name="_id" id="_id" value="<?php echo $this->edit_mode_value; ?>" />
2196
- </p>
2197
-
2198
- <?php
2199
-
2200
- break;
2201
-
2202
- case '_metakey':
2203
-
2204
- if ( $this->in_edit ) {
2205
-
2206
- ?>
2207
-
2208
- <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
2209
- <input type="text" name="_metakey_locked" id="_metakey_locked" value="<?php echo $this->edit_mode_value; ?>" disabled />
2210
- </p>
2211
-
2212
- <?php } else { ?>
2213
-
2214
- <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2215
- <input type="text" name="_metakey" id="_metakey" value="" />
2216
- </p>
2217
-
2218
- <?php
2219
-
2220
- }
2221
-
2222
- break;
2223
-
2224
- case '_help':
2225
- ?>
2226
-
2227
- <p><label for="_help"><?php _e( 'Help Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __('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.', 'ultimate-member' ) ); ?></label>
2228
- <input type="text" name="_help" id="_help" value="<?php echo $this->edit_mode_value; ?>" />
2229
- </p>
2230
-
2231
- <?php
2232
- break;
2233
-
2234
- case '_default':
2235
- ?>
2236
-
2237
- <?php if ( $this->set_field_type == 'textarea' ) { ?>
2238
-
2239
- <p><label for="_default"><?php _e( 'Default Text', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Text to display by default in this field', 'ultimate-member' ) ); ?></label>
2240
- <textarea name="_default" id="_default"><?php echo $this->edit_mode_value; ?></textarea>
2241
- </p>
2242
-
2243
- <?php } elseif ( $this->set_field_type == 'date' ) { ?>
2244
-
2245
- <p class="um"><label for="_default"><?php _e( 'Default Date', 'ultimate-member' ); ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2246
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-datepicker" data-format="yyyy/mm/dd" />
2247
- </p>
2248
-
2249
- <?php } elseif ( $this->set_field_type == 'time' ) { ?>
2250
-
2251
- <p class="um"><label for="_default"><?php _e( 'Default Time', 'ultimate-member' ); ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2252
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-timepicker" data-format="HH:i" />
2253
- </p>
2254
-
2255
- <?php } elseif ( $this->set_field_type == 'rating' ) { ?>
2256
-
2257
- <p><label for="_default"><?php _e( 'Default Rating', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'If you wish the rating field to be prefilled with a number of stars, enter it here.', 'ultimate-member' ) ); ?></label>
2258
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2259
- </p>
2260
-
2261
- <?php } else { ?>
2262
-
2263
- <p><label for="_default"><?php _e( 'Default Value', 'ultimate-member' ); ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2264
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2265
- </p>
2266
-
2267
- <?php } ?>
2268
-
2269
- <?php
2270
- break;
2271
-
2272
- case '_label':
2273
- ?>
2274
-
2275
- <p><label for="_label"><?php _e( 'Label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
2276
- <input type="text" name="_label" id="_label" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2277
- </p>
2278
-
2279
- <?php
2280
- break;
2281
-
2282
- case '_label_confirm_pass':
2283
- ?>
2284
-
2285
- <p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
2286
- <input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2287
- </p>
2288
-
2289
- <?php
2290
- break;
2291
-
2292
- case '_placeholder':
2293
- ?>
2294
-
2295
- <p><label for="_placeholder"><?php _e( 'Placeholder', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text.', 'ultimate-member' ) ); ?></label>
2296
- <input type="text" name="_placeholder" id="_placeholder" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2297
- </p>
2298
-
2299
- <?php
2300
- break;
2301
-
2302
- case '_public':
2303
- $privacy_options = array(
2304
- '1' => __( 'Everyone', 'ultimate-member' ),
2305
- '2' => __( 'Members', 'ultimate-member' ),
2306
- '-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
2307
- '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2308
- '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2309
- );
2310
-
2311
- $privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
2312
-
2313
- <p>
2314
- <label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
2315
- <select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
2316
- <?php foreach ( $privacy_options as $value => $title ) { ?>
2317
- <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
2318
- <?php echo $title ?>
2319
- </option>
2320
- <?php } ?>
2321
- </select>
2322
- </p>
2323
-
2324
- <?php
2325
- break;
2326
-
2327
- case '_roles':
2328
-
2329
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2330
- $values = $this->edit_mode_value;
2331
- } else {
2332
- $values = array('');
2333
- }
2334
-
2335
- ?>
2336
-
2337
- <p class="_roles"><label for="_roles"><?php _e( 'Select member roles', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the member roles that can view this field on the front-end.', 'ultimate-member' ) ); ?></label>
2338
- <select name="_roles[]" id="_roles" style="width: 100%" multiple="multiple">
2339
-
2340
- <?php foreach ( UM()->roles()->get_roles() as $key => $value) { ?>
2341
-
2342
- <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $values ) ) { echo 'selected'; } ?>><?php echo $value; ?></option>
2343
-
2344
- <?php } ?>
2345
-
2346
- </select>
2347
- </p>
2348
-
2349
- <?php
2350
- break;
2351
-
2352
- case '_required':
2353
-
2354
- if ( $this->set_field_type == 'password' )
2355
- $def_required = 1;
2356
- else
2357
- $def_required = 0;
2358
-
2359
- ?>
2360
-
2361
- <div class="um-admin-tri">
2362
-
2363
- <p><label for="_required"><?php _e( 'Is this field required?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether the field must be filled in before the form can be processed.', 'ultimate-member' ) ); ?></label>
2364
- <input type="checkbox" name="_required" id="_required" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />
2365
- </p>
2366
-
2367
- </div>
2368
-
2369
- <?php
2370
- break;
2371
-
2372
- case '_editable':
2373
- ?>
2374
-
2375
- <div class="um-admin-tri">
2376
-
2377
- <p><label for="_editable"><?php _e( 'Can user edit this field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether or not the user can edit the information in this field.', 'ultimate-member' ) ); ?></label>
2378
- <input type="hidden" name="_editable" id="_editable_hidden" value="0" />
2379
- <input type="checkbox" name="_editable" id="_editable" value="1" <?php checked( null === $this->edit_mode_value || $this->edit_mode_value ) ?> />
2380
- </p>
2381
-
2382
- </div>
2383
-
2384
- <?php
2385
- break;
2386
-
2387
- case '_number':
2388
- ?>
2389
-
2390
- <p><label for="_number"><?php _e( 'Rating System', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether you want a 5-stars or 10-stars ratings based here.', 'ultimate-member' ) ); ?></label>
2391
- <select name="_number" id="_number" style="width: 100%">
2392
- <option value="5" <?php selected( 5, $this->edit_mode_value ); ?>><?php _e( '5 stars rating system', 'ultimate-member' ) ?></option>
2393
- <option value="10" <?php selected( 10, $this->edit_mode_value ); ?>><?php _e( '10 stars rating system', 'ultimate-member' ) ?></option>
2394
- </select>
2395
- </p>
2396
-
2397
- <?php
2398
- break;
2399
-
2400
- case '_custom_dropdown_options_source':
2401
- ?>
2402
-
2403
- <p><label for="_custom_dropdown_options_source"><?php _e( 'Choices Callback', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Add a callback source to retrieve choices.', 'ultimate-member' ) ); ?></label>
2404
- <input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo htmlspecialchars($this->edit_mode_value, ENT_QUOTES); ?>" />
2405
- </p>
2406
-
2407
- <?php
2408
- break;
2409
-
2410
-
2411
- case '_parent_dropdown_relationship':
2412
- ?>
2413
-
2414
- <p><label for="_parent_dropdown_relationship"><?php _e( 'Parent Option', 'ultimate-member' ) ?><?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
2415
- <select name="_parent_dropdown_relationship" id="_parent_dropdown_relationship" style="width: 100%">
2416
- <option value=""><?php _e( 'No Selected', 'ultimate-member' ) ?></option>
2417
-
2418
- <?php if ( UM()->builtin()->custom_fields ) {
2419
- foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
2420
- if ( in_array( $array['type'], array( 'select' ) ) && ( ! isset( $field_args['metakey'] ) || $field_args['metakey'] != $array['metakey'] ) && isset( $array['title'] ) ) { ?>
2421
- <option value="<?php echo esc_attr( $array['metakey'] ) ?>" <?php selected( $array['metakey'], $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
2422
- <?php }
2423
- }
2424
- } ?>
2425
- </select>
2426
- </p>
2427
-
2428
- <?php
2429
- break;
2430
-
2431
-
2432
- }
2433
-
2434
- }
2435
-
2436
- }
2437
- }
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_Metabox
13
+ *
14
+ * @package um\admin\core
15
+ */
16
+ class Admin_Metabox {
17
+
18
+
19
+ /**
20
+ * @var bool
21
+ */
22
+ private $form_nonce_added = false;
23
+
24
+
25
+ /**
26
+ * @var bool
27
+ */
28
+ private $directory_nonce_added = false;
29
+
30
+
31
+ /**
32
+ * @var bool
33
+ */
34
+ private $custom_nonce_added = false;
35
+
36
+
37
+ var $init_icon = false;
38
+
39
+
40
+ /**
41
+ * Admin_Metabox constructor.
42
+ */
43
+ function __construct() {
44
+ $this->in_edit = false;
45
+ $this->edit_mode_value = null;
46
+ $this->edit_array = [];
47
+
48
+ add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
49
+ add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
50
+
51
+ add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
52
+ add_action( 'load-post-new.php', array( &$this, 'add_metabox' ), 9 );
53
+
54
+ add_action( 'admin_init', array( &$this, 'add_taxonomy_metabox' ), 9 );
55
+
56
+ //roles metaboxes
57
+ add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
58
+
59
+ add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
60
+ add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
61
+
62
+ add_filter( 'um_member_directory_meta_value_before_save', array( UM()->member_directory(), 'before_save_data' ), 10, 3 );
63
+ }
64
+
65
+
66
+ /**
67
+ * Hide Woocommerce Shop page restrict content metabox
68
+ * @param $hide
69
+ *
70
+ * @return bool
71
+ */
72
+ function hide_metabox_restrict_content_shop( $hide ) {
73
+ if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
74
+ absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) {
75
+ return true;
76
+ }
77
+
78
+ return $hide;
79
+ }
80
+
81
+
82
+ /**
83
+ * Filter validation types on loop
84
+ *
85
+ * @param $break
86
+ * @param $key
87
+ * @param $form_id
88
+ * @param $field_array
89
+ *
90
+ * @return bool
91
+ */
92
+ function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
93
+
94
+ // show unique username validation only for user_login field
95
+ if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
96
+ return false;
97
+ }
98
+
99
+ return $break;
100
+ }
101
+
102
+
103
+ /**
104
+ * Gets the role meta
105
+ *
106
+ * @param $id
107
+ *
108
+ * @return mixed
109
+ */
110
+ function get_custom_post_meta( $id ) {
111
+ $all_meta = get_post_custom( $id );
112
+ foreach ( $all_meta as $k => $v ) {
113
+ if ( strstr( $k, '_um_' ) ) {
114
+ $um_meta[ $k ] = $v;
115
+ }
116
+ }
117
+ if ( isset( $um_meta ) ) {
118
+ return $um_meta;
119
+ }
120
+
121
+ return false;
122
+ }
123
+
124
+
125
+ /**
126
+ * Runs on admin head
127
+ */
128
+ function admin_head(){
129
+ global $post;
130
+ if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
131
+ $this->postmeta = $this->get_custom_post_meta($post->ID);
132
+ }
133
+ }
134
+
135
+
136
+ /**
137
+ * Init the metaboxes
138
+ */
139
+ function add_metabox() {
140
+ global $current_screen;
141
+
142
+ if ( $current_screen->id == 'um_form' ) {
143
+ add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 );
144
+ add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 );
145
+ }
146
+
147
+ if ( $current_screen->id == 'um_directory' ) {
148
+ add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 );
149
+ add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 );
150
+ }
151
+
152
+ //restrict content metabox
153
+ $post_types = UM()->options()->get( 'restricted_access_post_metabox' );
154
+ if ( ! empty( $post_types[ $current_screen->id ] ) ) {
155
+
156
+ /**
157
+ * UM hook
158
+ *
159
+ * @type filter
160
+ * @title um_restrict_content_hide_metabox
161
+ * @description Show/Hide Restrict content metabox
162
+ * @input_vars
163
+ * [{"var":"$show","type":"bool","desc":"Show Metabox"}]
164
+ * @change_log
165
+ * ["Since: 2.0"]
166
+ * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 );
167
+ * @example
168
+ * <?php
169
+ * add_filter( 'um_restrict_content_hide_metabox', 'my_restrict_content_hide_metabox', 10, 1 );
170
+ * function my_restrict_content_hide_metabox( $show ) {
171
+ * // your code here
172
+ * return $show;
173
+ * }
174
+ * ?>
175
+ */
176
+ $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
177
+
178
+ if ( ! $hide_metabox ) {
179
+ add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
180
+ add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
181
+ }
182
+
183
+ if ( $current_screen->id == 'attachment' ) {
184
+ add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
185
+ add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
186
+ }
187
+ }
188
+
189
+
190
+ add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 );
191
+ }
192
+
193
+
194
+ /**
195
+ * @param $post_id
196
+ * @param $post
197
+ */
198
+ public function save_metabox_custom( $post_id, $post ) {
199
+ // validate nonce
200
+ if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
201
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
202
+ return;
203
+ }
204
+
205
+ /**
206
+ * UM hook
207
+ *
208
+ * @type action
209
+ * @title um_admin_custom_restrict_content_metaboxes
210
+ * @description Save metabox custom with restrict content
211
+ * @input_vars
212
+ * [{"var":"$post_id","type":"int","desc":"Post ID"},
213
+ * {"var":"$post","type":"array","desc":"Post data"}]
214
+ * @change_log
215
+ * ["Since: 2.0"]
216
+ * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 );
217
+ * @example
218
+ * <?php
219
+ * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10, 2 );
220
+ * function my_admin_custom_restrict_content( $post_id, $post ) {
221
+ * // your code here
222
+ * }
223
+ * ?>
224
+ */
225
+ do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post );
226
+ }
227
+
228
+
229
+ /**
230
+ *
231
+ */
232
+ function add_metabox_restrict_content() {
233
+ global $current_screen;
234
+
235
+ add_meta_box(
236
+ 'um-admin-restrict-content',
237
+ __( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
238
+ array( &$this, 'restrict_content_cb' ),
239
+ $current_screen->id,
240
+ 'normal',
241
+ 'default'
242
+ );
243
+
244
+ /**
245
+ * UM hook
246
+ *
247
+ * @type action
248
+ * @title um_admin_custom_restrict_content_metaboxes
249
+ * @description Add restrict content custom metabox
250
+ * @change_log
251
+ * ["Since: 2.0"]
252
+ * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 );
253
+ * @example
254
+ * <?php
255
+ * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10 );
256
+ * function my_admin_custom_restrict_content() {
257
+ * // your code here
258
+ * }
259
+ * ?>
260
+ */
261
+ do_action( 'um_admin_custom_restrict_content_metaboxes' );
262
+ }
263
+
264
+
265
+ /**
266
+ * Content restriction metabox
267
+ *
268
+ * @param $object
269
+ * @param $box
270
+ */
271
+ function restrict_content_cb( $object, $box ) {
272
+ include_once UM()->admin()->templates_path . 'access/restrict_content.php';
273
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' );
274
+ }
275
+
276
+
277
+ /**
278
+ * Init the metaboxes
279
+ */
280
+ function add_taxonomy_metabox() {
281
+ //restrict content metabox
282
+ $all_taxonomies = get_taxonomies( array( 'public' => true ) );
283
+ $tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
284
+ $exclude_taxonomies = UM()->excluded_taxonomies();
285
+
286
+ foreach ( $all_taxonomies as $key => $taxonomy ) {
287
+ if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) )
288
+ continue;
289
+
290
+ add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) );
291
+ add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) );
292
+ add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
293
+ add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
294
+ }
295
+ }
296
+
297
+
298
+ /**
299
+ * @param $post_id
300
+ * @param $post
301
+ */
302
+ function save_metabox_restrict_content( $post_id, $post ) {
303
+ // validate nonce
304
+ if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) ||
305
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
306
+ return;
307
+ }
308
+
309
+ // validate user
310
+ $post_type = get_post_type_object( $post->post_type );
311
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
312
+ return;
313
+ }
314
+
315
+ if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
316
+ $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
317
+
318
+ update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
319
+ } else {
320
+ delete_post_meta( $post_id, 'um_content_restriction' );
321
+ }
322
+ }
323
+
324
+
325
+ /**
326
+ * @param $post_id
327
+ *
328
+ */
329
+ function save_attachment_metabox_restrict_content( $post_id ) {
330
+ // validate nonce
331
+ if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] )
332
+ || ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
333
+ return;
334
+ }
335
+
336
+ $post = get_post( $post_id );
337
+
338
+ // validate user
339
+ $post_type = get_post_type_object( $post->post_type );
340
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
341
+ return;
342
+ }
343
+
344
+ if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
345
+ $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
346
+
347
+ update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
348
+ } else {
349
+ delete_post_meta( $post_id, 'um_content_restriction' );
350
+ }
351
+ }
352
+
353
+
354
+ /**
355
+ *
356
+ */
357
+ function um_category_access_fields_create() {
358
+ /**
359
+ * UM hook
360
+ *
361
+ * @type filter
362
+ * @title um_admin_category_access_settings_fields
363
+ * @description Settings fields for terms
364
+ * @input_vars
365
+ * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
366
+ * {"var":"$data","type":"array","desc":"Settings Data"},
367
+ * {"var":"$screen","type":"string","desc":"Category Screen"}]
368
+ * @change_log
369
+ * ["Since: 2.0"]
370
+ * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
371
+ * @example
372
+ * <?php
373
+ * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
374
+ * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
375
+ * // your code here
376
+ * $access_settings_fields[] = array(
377
+ * 'id' => 'my-field-key',
378
+ * 'type' => 'my-field-type',
379
+ * 'label' => __( 'My field Label', 'ultimate-member' ),
380
+ * 'description' => __( 'My Field Description', 'ultimate-member' ),
381
+ * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
382
+ * );
383
+ * return $access_settings_fields;
384
+ * }
385
+ * ?>
386
+ */
387
+ $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
388
+ array(
389
+ 'id' => '_um_custom_access_settings',
390
+ 'type' => 'checkbox',
391
+ 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
392
+ 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
393
+ 'value' => 0,
394
+ ),
395
+ array(
396
+ 'id' => '_um_accessible',
397
+ 'type' => 'select',
398
+ 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
399
+ 'value' => '0',
400
+ 'options' => array(
401
+ '0' => __( 'Everyone', 'ultimate-member' ),
402
+ '1' => __( 'Logged out users', 'ultimate-member' ),
403
+ '2' => __( 'Logged in users', 'ultimate-member' ),
404
+ ),
405
+ 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
406
+ ),
407
+ array(
408
+ 'id' => '_um_access_roles',
409
+ 'type' => 'multi_checkbox',
410
+ 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
411
+ 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
412
+ 'options' => UM()->roles()->get_roles( false ),
413
+ 'columns' => 3,
414
+ 'conditional' => array( '_um_accessible', '=', '2' ),
415
+ ),
416
+ array(
417
+ 'id' => '_um_access_hide_from_queries',
418
+ 'type' => 'checkbox',
419
+ 'label' => __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
420
+ 'description' => __( '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', 'ultimate-member' ),
421
+ 'value' => 1,
422
+ 'conditional' => array( '_um_accessible', '!=', '0' ),
423
+ ),
424
+ array(
425
+ 'id' => '_um_noaccess_action',
426
+ 'type' => 'select',
427
+ 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
428
+ 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
429
+ 'value' => '0',
430
+ 'options' => array(
431
+ '0' => __( 'Show access restricted message', 'ultimate-member' ),
432
+ '1' => __( 'Redirect user', 'ultimate-member' ),
433
+ ),
434
+ 'conditional' => array( '_um_access_hide_from_queries', '=', '0' ),
435
+ ),
436
+ array(
437
+ 'id' => '_um_restrict_by_custom_message',
438
+ 'type' => 'select',
439
+ 'label' => __( 'Restricted access message type', 'ultimate-member' ),
440
+ 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
441
+ 'value' => '0',
442
+ 'options' => array(
443
+ '0' => __( 'Global default message', 'ultimate-member' ),
444
+ '1' => __( 'Custom message', 'ultimate-member' ),
445
+ ),
446
+ 'conditional' => array( '_um_noaccess_action', '=', '0' ),
447
+ ),
448
+ array(
449
+ 'id' => '_um_restrict_custom_message',
450
+ 'type' => 'wp_editor',
451
+ 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
452
+ 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
453
+ 'value' => '',
454
+ 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
455
+ ),
456
+ array(
457
+ 'id' => '_um_access_redirect',
458
+ 'type' => 'select',
459
+ 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
460
+ 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
461
+ 'value' => '0',
462
+ 'conditional' => array( '_um_noaccess_action', '=', '1' ),
463
+ 'options' => array(
464
+ '0' => __( 'Login page', 'ultimate-member' ),
465
+ '1' => __( 'Custom URL', 'ultimate-member' ),
466
+ ),
467
+ ),
468
+ array(
469
+ 'id' => '_um_access_redirect_url',
470
+ 'type' => 'text',
471
+ 'label' => __( 'Redirect URL', 'ultimate-member' ),
472
+ 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
473
+ 'value' => '',
474
+ 'conditional' => array( '_um_access_redirect', '=', '1' ),
475
+ ),
476
+ ), array(), 'create' );
477
+
478
+ UM()->admin_forms(
479
+ array(
480
+ 'class' => 'um-restrict-content um-third-column',
481
+ 'prefix_id' => 'um_content_restriction',
482
+ 'without_wrapper' => true,
483
+ 'div_line' => true,
484
+ 'fields' => $fields,
485
+ )
486
+ )->render_form();
487
+
488
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
489
+ }
490
+
491
+
492
+ /**
493
+ * @param $term
494
+ */
495
+ function um_category_access_fields_edit( $term ) {
496
+ $termID = $term->term_id;
497
+
498
+ $data = get_term_meta( $termID, 'um_content_restriction', true );
499
+
500
+ $_um_access_roles_value = array();
501
+ if ( ! empty( $data['_um_access_roles'] ) ) {
502
+ foreach ( $data['_um_access_roles'] as $key => $value ) {
503
+ if ( $value ) {
504
+ $_um_access_roles_value[] = $key;
505
+ }
506
+ }
507
+ }
508
+
509
+ /**
510
+ * UM hook
511
+ *
512
+ * @type filter
513
+ * @title um_admin_category_access_settings_fields
514
+ * @description Settings fields for terms
515
+ * @input_vars
516
+ * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
517
+ * {"var":"$data","type":"array","desc":"Settings Data"},
518
+ * {"var":"$screen","type":"string","desc":"Category Screen"}]
519
+ * @change_log
520
+ * ["Since: 2.0"]
521
+ * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
522
+ * @example
523
+ * <?php
524
+ * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
525
+ * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
526
+ * // your code here
527
+ * $access_settings_fields[] = array(
528
+ * 'id' => 'my-field-key',
529
+ * 'type' => 'my-field-type',
530
+ * 'label' => __( 'My field Label', 'ultimate-member' ),
531
+ * 'description' => __( 'My Field Description', 'ultimate-member' ),
532
+ * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
533
+ * );
534
+ * return $access_settings_fields;
535
+ * }
536
+ * ?>
537
+ */
538
+ $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
539
+ array(
540
+ 'id' => '_um_custom_access_settings',
541
+ 'type' => 'checkbox',
542
+ 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
543
+ 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
544
+ 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
545
+ ),
546
+ array(
547
+ 'id' => '_um_accessible',
548
+ 'type' => 'select',
549
+ 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
550
+ 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : '0',
551
+ 'options' => array(
552
+ '0' => __( 'Everyone', 'ultimate-member' ),
553
+ '1' => __( 'Logged out users', 'ultimate-member' ),
554
+ '2' => __( 'Logged in users', 'ultimate-member' ),
555
+ ),
556
+ 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
557
+ ),
558
+ array(
559
+ 'id' => '_um_access_roles',
560
+ 'type' => 'multi_checkbox',
561
+ 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
562
+ 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
563
+ 'value' => $_um_access_roles_value,
564
+ 'options' => UM()->roles()->get_roles( false ),
565
+ 'columns' => 3,
566
+ 'conditional' => array( '_um_accessible', '=', '2' ),
567
+ ),
568
+ array(
569
+ 'id' => '_um_access_hide_from_queries',
570
+ 'type' => 'checkbox',
571
+ 'label' => __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
572
+ 'description' => __( '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', 'ultimate-member' ),
573
+ 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
574
+ 'conditional' => array( '_um_accessible', '!=', '0' ),
575
+ ),
576
+ array(
577
+ 'id' => '_um_noaccess_action',
578
+ 'type' => 'select',
579
+ 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
580
+ 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
581
+ 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : '0',
582
+ 'options' => array(
583
+ '0' => __( 'Show access restricted message', 'ultimate-member' ),
584
+ '1' => __( 'Redirect user', 'ultimate-member' ),
585
+ ),
586
+ 'conditional' => array( '_um_access_hide_from_queries', '=', '0' ),
587
+ ),
588
+ array(
589
+ 'id' => '_um_restrict_by_custom_message',
590
+ 'type' => 'select',
591
+ 'label' => __( 'Restricted access message type', 'ultimate-member' ),
592
+ 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
593
+ 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
594
+ 'options' => array(
595
+ '0' => __( 'Global default message', 'ultimate-member' ),
596
+ '1' => __( 'Custom message', 'ultimate-member' ),
597
+ ),
598
+ 'conditional' => array( '_um_noaccess_action', '=', '0' ),
599
+ ),
600
+ array(
601
+ 'id' => '_um_restrict_custom_message',
602
+ 'type' => 'wp_editor',
603
+ 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
604
+ 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
605
+ 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
606
+ 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
607
+ ),
608
+ array(
609
+ 'id' => '_um_access_redirect',
610
+ 'type' => 'select',
611
+ 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
612
+ 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
613
+ 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
614
+ 'options' => array(
615
+ '0' => __( 'Login page', 'ultimate-member' ),
616
+ '1' => __( 'Custom URL', 'ultimate-member' ),
617
+ ),
618
+ 'conditional' => array( '_um_noaccess_action', '=', '1' ),
619
+ ),
620
+ array(
621
+ 'id' => '_um_access_redirect_url',
622
+ 'type' => 'text',
623
+ 'label' => __( 'Redirect URL', 'ultimate-member' ),
624
+ 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
625
+ 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
626
+ 'conditional' => array( '_um_access_redirect', '=', '1' ),
627
+ ),
628
+ ), $data, 'edit' );
629
+
630
+ UM()->admin_forms(
631
+ array(
632
+ 'class' => 'um-restrict-content um-third-column',
633
+ 'prefix_id' => 'um_content_restriction',
634
+ 'without_wrapper' => true,
635
+ 'fields' => $fields,
636
+ )
637
+ )->render_form();
638
+
639
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
640
+ }
641
+
642
+
643
+ /**
644
+ * @param $termID
645
+ *
646
+ * @return mixed
647
+ */
648
+ function um_category_access_fields_save( $termID ) {
649
+
650
+ // validate nonce
651
+ if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) {
652
+ return $termID;
653
+ }
654
+
655
+ // validate user
656
+ $term = get_term( $termID );
657
+ $taxonomy = get_taxonomy( $term->taxonomy );
658
+
659
+ if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) {
660
+ return $termID;
661
+ }
662
+
663
+ if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
664
+ $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
665
+
666
+ update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
667
+ } else {
668
+ delete_term_meta( $termID, 'um_content_restriction' );
669
+ }
670
+
671
+ return $termID;
672
+ }
673
+
674
+
675
+ /**
676
+ * Load a directory metabox
677
+ *
678
+ * @param $object
679
+ * @param $box
680
+ */
681
+ function load_metabox_directory( $object, $box ) {
682
+ $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
683
+
684
+ preg_match('#\{.*?\}#s', $box['id'], $matches );
685
+
686
+ if ( isset( $matches[0] ) ) {
687
+ $path = $matches[0];
688
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
689
+ } else {
690
+ $path = um_path;
691
+ }
692
+
693
+ $path = str_replace('{','', $path );
694
+ $path = str_replace('}','', $path );
695
+
696
+
697
+ include_once $path . 'includes/admin/templates/directory/'. $box['id'] . '.php';
698
+ if ( ! $this->directory_nonce_added ) {
699
+ $this->directory_nonce_added = true;
700
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' );
701
+ }
702
+ }
703
+
704
+
705
+ /**
706
+ * Load a role metabox
707
+ *
708
+ * @param $object
709
+ * @param $box
710
+ */
711
+ function load_metabox_role( $object, $box ) {
712
+ global $post;
713
+
714
+ $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
715
+
716
+ if ( $box['id'] == 'builder' ) {
717
+ UM()->builder()->form_id = get_the_ID();
718
+ }
719
+
720
+ preg_match('#\{.*?\}#s', $box['id'], $matches);
721
+
722
+ if ( isset($matches[0]) ){
723
+ $path = $matches[0];
724
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
725
+ } else {
726
+ $path = um_path;
727
+ }
728
+
729
+ $path = str_replace('{','', $path );
730
+ $path = str_replace('}','', $path );
731
+
732
+ include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php';
733
+ //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' );
734
+ }
735
+
736
+
737
+ /**
738
+ * Load a form metabox
739
+ *
740
+ * @param $object
741
+ * @param $box
742
+ */
743
+ function load_metabox_form( $object, $box ) {
744
+ global $post;
745
+
746
+ $box['id'] = str_replace( 'um-admin-form-','', $box['id'] );
747
+
748
+ if ( $box['id'] == 'builder' ) {
749
+ UM()->builder()->form_id = get_the_ID();
750
+ }
751
+
752
+ preg_match('#\{.*?\}#s', $box['id'], $matches);
753
+
754
+ if ( isset( $matches[0] ) ) {
755
+ $path = $matches[0];
756
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
757
+ } else {
758
+ $path = um_path;
759
+ }
760
+
761
+ $path = str_replace('{','', $path );
762
+ $path = str_replace('}','', $path );
763
+
764
+ include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php';
765
+
766
+ if ( ! $this->form_nonce_added ) {
767
+ $this->form_nonce_added = true;
768
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' );
769
+ }
770
+ }
771
+
772
+
773
+ /**
774
+ * Load admin custom metabox
775
+ *
776
+ * @param $object
777
+ * @param $box
778
+ */
779
+ function load_metabox_custom( $object, $box ) {
780
+ global $post;
781
+
782
+ $box['id'] = str_replace('um-admin-custom-','', $box['id']);
783
+
784
+ preg_match('#\{.*?\}#s', $box['id'], $matches);
785
+
786
+ if ( isset($matches[0]) ){
787
+ $path = $matches[0];
788
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
789
+ } else {
790
+ $path = um_path;
791
+ }
792
+
793
+ $path = str_replace('{','', $path );
794
+ $path = str_replace('}','', $path );
795
+
796
+ include_once $path . 'includes/admin/templates/'. $box['id'] . '.php';
797
+ if ( ! $this->custom_nonce_added ) {
798
+ $this->custom_nonce_added = true;
799
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' );
800
+ }
801
+ }
802
+
803
+
804
+ /**
805
+ * Add directory metabox
806
+ */
807
+ function add_metabox_directory() {
808
+ add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
809
+ add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
810
+ add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
811
+ add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
812
+ add_meta_box( 'um-admin-form-pagination', __( 'Results &amp; Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
813
+ add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' );
814
+ add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' );
815
+ }
816
+
817
+
818
+ /**
819
+ * Add role metabox
820
+ */
821
+ function add_metabox_role() {
822
+ $callback = array( &$this, 'load_metabox_role' );
823
+
824
+ $roles_metaboxes = array(
825
+ array(
826
+ 'id' => 'um-admin-form-admin-permissions',
827
+ 'title' => __( 'Administrative Permissions', 'ultimate-member' ),
828
+ 'callback' => $callback,
829
+ 'screen' => 'um_role_meta',
830
+ 'context' => 'normal',
831
+ 'priority' => 'default'
832
+ ),
833
+ array(
834
+ 'id' => 'um-admin-form-general',
835
+ 'title' => __( 'General Permissions', 'ultimate-member' ),
836
+ 'callback' => $callback,
837
+ 'screen' => 'um_role_meta',
838
+ 'context' => 'normal',
839
+ 'priority' => 'default'
840
+ ),
841
+ array(
842
+ 'id' => 'um-admin-form-profile',
843
+ 'title' => __( 'Profile Access', 'ultimate-member' ),
844
+ 'callback' => $callback,
845
+ 'screen' => 'um_role_meta',
846
+ 'context' => 'normal',
847
+ 'priority' => 'default'
848
+ )
849
+ );
850
+
851
+ if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
852
+ $roles_metaboxes[] = array(
853
+ 'id' => 'um-admin-form-home',
854
+ 'title' => __( 'Homepage Options', 'ultimate-member' ),
855
+ 'callback' => $callback,
856
+ 'screen' => 'um_role_meta',
857
+ 'context' => 'normal',
858
+ 'priority' => 'default'
859
+ );
860
+ }
861
+
862
+ $roles_metaboxes = array_merge( $roles_metaboxes, array(
863
+ array(
864
+ 'id' => 'um-admin-form-register',
865
+ 'title' => __( 'Registration Options', 'ultimate-member' ),
866
+ 'callback' => $callback,
867
+ 'screen' => 'um_role_meta',
868
+ 'context' => 'normal',
869
+ 'priority' => 'default'
870
+ ),
871
+ array(
872
+ 'id' => 'um-admin-form-login',
873
+ 'title' => __( 'Login Options', 'ultimate-member' ),
874
+ 'callback' => $callback,
875
+ 'screen' => 'um_role_meta',
876
+ 'context' => 'normal',
877
+ 'priority' => 'default'
878
+ ),
879
+ array(
880
+ 'id' => 'um-admin-form-logout',
881
+ 'title' => __( 'Logout Options', 'ultimate-member' ),
882
+ 'callback' => $callback,
883
+ 'screen' => 'um_role_meta',
884
+ 'context' => 'normal',
885
+ 'priority' => 'default'
886
+ ),
887
+ array(
888
+ 'id' => 'um-admin-form-delete',
889
+ 'title' => __( 'Delete Options', 'ultimate-member' ),
890
+ 'callback' => $callback,
891
+ 'screen' => 'um_role_meta',
892
+ 'context' => 'normal',
893
+ 'priority' => 'default'
894
+ ),
895
+ array(
896
+ 'id' => 'um-admin-form-publish',
897
+ 'title' => __( 'Publish', 'ultimate-member' ),
898
+ 'callback' => $callback,
899
+ 'screen' => 'um_role_meta',
900
+ 'context' => 'side',
901
+ 'priority' => 'default'
902
+ )
903
+ ) );
904
+
905
+ /**
906
+ * UM hook
907
+ *
908
+ * @type filter
909
+ * @title um_admin_role_metaboxes
910
+ * @description Extend metaboxes at Add/Edit User Role
911
+ * @input_vars
912
+ * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}]
913
+ * @change_log
914
+ * ["Since: 2.0"]
915
+ * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );
916
+ * @example
917
+ * <?php
918
+ * add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );
919
+ * function my_admin_role_metaboxes( $roles_metaboxes ) {
920
+ * // your code here
921
+ * $roles_metaboxes[] = array(
922
+ * 'id' => 'um-admin-form-your-custom',
923
+ * 'title' => __( 'My Roles Metabox', 'ultimate-member' ),
924
+ * 'callback' => 'my-metabox-callback',
925
+ * 'screen' => 'um_role_meta',
926
+ * 'context' => 'side',
927
+ * 'priority' => 'default'
928
+ * );
929
+ *
930
+ * return $roles_metaboxes;
931
+ * }
932
+ * ?>
933
+ */
934
+ $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
935
+
936
+ $wp_caps_metabox = false;
937
+ if ( ! empty( $_GET['id'] ) ) {
938
+ $data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' );
939
+ if ( ! empty( $data['_um_is_custom'] ) ) {
940
+ $wp_caps_metabox = true;
941
+ }
942
+ }
943
+ if ( 'add' == sanitize_key( $_GET['tab'] ) || $wp_caps_metabox ) {
944
+ $roles_metaboxes[] = array(
945
+ 'id' => 'um-admin-form-wp-capabilities',
946
+ 'title' => __( 'WP Capabilities', 'ultimate-member' ),
947
+ 'callback' => $callback,
948
+ 'screen' => 'um_role_meta',
949
+ 'context' => 'normal',
950
+ 'priority' => 'default'
951
+ );
952
+ }
953
+
954
+
955
+ foreach ( $roles_metaboxes as $metabox ) {
956
+ add_meta_box(
957
+ $metabox['id'],
958
+ $metabox['title'],
959
+ $metabox['callback'],
960
+ $metabox['screen'],
961
+ $metabox['context'],
962
+ $metabox['priority']
963
+ );
964
+ }
965
+ }
966
+
967
+
968
+ /**
969
+ * Add form metabox
970
+ */
971
+ function add_metabox_form() {
972
+
973
+ add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
974
+ add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
975
+ add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
976
+
977
+ add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
978
+
979
+ /**
980
+ * UM hook
981
+ *
982
+ * @type action
983
+ * @title um_admin_custom_register_metaboxes
984
+ * @description Add custom metaboxes for register form
985
+ * @change_log
986
+ * ["Since: 2.0"]
987
+ * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 );
988
+ * @example
989
+ * <?php
990
+ * add_action( 'um_admin_custom_register_metaboxes', 'my_admin_custom_register_metaboxes', 10 );
991
+ * function my_admin_custom_register_metaboxes() {
992
+ * // your code here
993
+ * }
994
+ * ?>
995
+ */
996
+ do_action( 'um_admin_custom_register_metaboxes' );
997
+
998
+ add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
999
+ add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1000
+
1001
+ /**
1002
+ * UM hook
1003
+ *
1004
+ * @type action
1005
+ * @title um_admin_custom_profile_metaboxes
1006
+ * @description Add custom metaboxes for profile form
1007
+ * @change_log
1008
+ * ["Since: 2.0"]
1009
+ * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 );
1010
+ * @example
1011
+ * <?php
1012
+ * add_action( 'um_admin_custom_profile_metaboxes', 'my_admin_custom_profile_metaboxes', 10 );
1013
+ * function my_admin_custom_profile_metaboxes() {
1014
+ * // your code here
1015
+ * }
1016
+ * ?>
1017
+ */
1018
+ do_action( 'um_admin_custom_profile_metaboxes' );
1019
+
1020
+ add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1021
+ add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1022
+
1023
+ /**
1024
+ * UM hook
1025
+ *
1026
+ * @type action
1027
+ * @title um_admin_custom_login_metaboxes
1028
+ * @description Add custom metaboxes for login form
1029
+ * @change_log
1030
+ * ["Since: 2.0"]
1031
+ * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 );
1032
+ * @example
1033
+ * <?php
1034
+ * add_action( 'um_admin_custom_login_metaboxes', 'my_admin_custom_login_metaboxes', 10 );
1035
+ * function my_admin_custom_login_metaboxes() {
1036
+ * // your code here
1037
+ * }
1038
+ * ?>
1039
+ */
1040
+ do_action( 'um_admin_custom_login_metaboxes' );
1041
+ }
1042
+
1043
+
1044
+ /**
1045
+ * Save directory metabox
1046
+ *
1047
+ * @param $post_id
1048
+ * @param $post
1049
+ */
1050
+ function save_metabox_directory( $post_id, $post ) {
1051
+ global $wpdb;
1052
+
1053
+ // validate nonce
1054
+ if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) ||
1055
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
1056
+ return;
1057
+ }
1058
+
1059
+ // validate post type
1060
+ if ( $post->post_type != 'um_directory' ) {
1061
+ return;
1062
+ }
1063
+
1064
+ // validate user
1065
+ $post_type = get_post_type_object( $post->post_type );
1066
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1067
+ return;
1068
+ }
1069
+
1070
+ $where = array( 'ID' => $post_id );
1071
+
1072
+ if ( empty( $_POST['post_title'] ) ) {
1073
+ $_POST['post_title'] = sprintf( __( 'Directory #%s', 'ultimate-member' ), $post_id );
1074
+ }
1075
+
1076
+ $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1077
+
1078
+ do_action( 'um_before_member_directory_save', $post_id );
1079
+
1080
+ // save
1081
+ delete_post_meta( $post_id, '_um_roles' );
1082
+ delete_post_meta( $post_id, '_um_tagline_fields' );
1083
+ delete_post_meta( $post_id, '_um_reveal_fields' );
1084
+ delete_post_meta( $post_id, '_um_search_fields' );
1085
+ delete_post_meta( $post_id, '_um_roles_can_search' );
1086
+ delete_post_meta( $post_id, '_um_roles_can_filter' );
1087
+ delete_post_meta( $post_id, '_um_show_these_users' );
1088
+ delete_post_meta( $post_id, '_um_exclude_these_users' );
1089
+
1090
+ delete_post_meta( $post_id, '_um_search_filters' );
1091
+ delete_post_meta( $post_id, '_um_search_filters_gmt' );
1092
+
1093
+ delete_post_meta( $post_id, '_um_sorting_fields' );
1094
+
1095
+ //save metadata
1096
+ $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
1097
+ foreach ( $metadata as $k => $v ) {
1098
+
1099
+ if ( $k == '_um_show_these_users' && trim( $v ) ) {
1100
+ $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1101
+ }
1102
+
1103
+ if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
1104
+ $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1105
+ }
1106
+
1107
+ if ( strstr( $k, '_um_' ) ) {
1108
+
1109
+ if ( $k === '_um_is_default' ) {
1110
+
1111
+ $mode = UM()->query()->get_attr( 'mode', $post_id );
1112
+
1113
+ if ( ! empty( $mode ) ) {
1114
+
1115
+ $posts = $wpdb->get_col(
1116
+ "SELECT post_id
1117
+ FROM {$wpdb->postmeta}
1118
+ WHERE meta_key = '_um_mode' AND
1119
+ meta_value = 'directory'"
1120
+ );
1121
+
1122
+ foreach ( $posts as $p_id ) {
1123
+ delete_post_meta( $p_id, '_um_is_default' );
1124
+ }
1125
+
1126
+ }
1127
+
1128
+ }
1129
+
1130
+ $v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
1131
+
1132
+ update_post_meta( $post_id, $k, $v );
1133
+
1134
+ }
1135
+ }
1136
+
1137
+ update_post_meta( $post_id, '_um_search_filters_gmt', (int) $_POST['um-gmt-offset'] );
1138
+ }
1139
+
1140
+
1141
+ /**
1142
+ * Save form metabox
1143
+ *
1144
+ * @param $post_id
1145
+ * @param $post
1146
+ */
1147
+ function save_metabox_form( $post_id, $post ) {
1148
+ global $wpdb;
1149
+
1150
+ // validate nonce
1151
+ if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) ||
1152
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) {
1153
+ return;
1154
+ }
1155
+
1156
+ // validate post type
1157
+ if ( $post->post_type != 'um_form' ) {
1158
+ return;
1159
+ }
1160
+
1161
+ // validate user
1162
+ $post_type = get_post_type_object( $post->post_type );
1163
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1164
+ return;
1165
+ }
1166
+
1167
+ $where = array( 'ID' => $post_id );
1168
+ if ( empty( $_POST['post_title'] ) ) {
1169
+ $_POST['post_title'] = sprintf( __( 'Form #%s', 'ultimate-member' ), $post_id );
1170
+ }
1171
+ $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1172
+
1173
+ // save
1174
+ delete_post_meta( $post_id, '_um_profile_metafields' );
1175
+
1176
+ $form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
1177
+
1178
+ foreach ( $form_meta as $k => $v ) {
1179
+ if ( strstr( $k, '_um_' ) ) {
1180
+ if ( $k === '_um_is_default' ) {
1181
+ $mode = UM()->query()->get_attr( 'mode', $post_id );
1182
+ if ( ! empty( $mode ) ) {
1183
+ $posts = $wpdb->get_col( $wpdb->prepare(
1184
+ "SELECT post_id
1185
+ FROM {$wpdb->postmeta}
1186
+ WHERE meta_key = '_um_mode' AND
1187
+ meta_value = %s",
1188
+ $mode
1189
+ ) );
1190
+ foreach ( $posts as $p_id ) {
1191
+ delete_post_meta( $p_id, '_um_is_default' );
1192
+ }
1193
+ }
1194
+ }
1195
+
1196
+ update_post_meta( $post_id, $k, $v );
1197
+ }
1198
+ }
1199
+
1200
+ }
1201
+
1202
+
1203
+ /**
1204
+ * Load modal content
1205
+ */
1206
+ function load_modal_content() {
1207
+ $screen = get_current_screen();
1208
+
1209
+ if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1210
+ foreach ( glob( um_path . 'includes/admin/templates/modal/forms/*.php' ) as $modal_content ) {
1211
+ include_once $modal_content;
1212
+ }
1213
+ }
1214
+
1215
+ if ( $this->init_icon ) {
1216
+ include_once um_path . 'includes/admin/templates/modal/forms/fonticons.php';
1217
+ }
1218
+
1219
+ if ( $screen->id == 'users' ) {
1220
+ include_once um_path . 'includes/admin/templates/modal/dynamic_registration_preview.php';
1221
+ }
1222
+
1223
+ // needed on forms only
1224
+ if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1225
+ $settings['textarea_rows'] = 8;
1226
+
1227
+ echo '<div class="um-hidden-editor-edit" style="display:none;">';
1228
+ wp_editor( '', 'um_editor_edit', $settings );
1229
+ echo '</div>';
1230
+
1231
+ echo '<div class="um-hidden-editor-new" style="display:none;">';
1232
+ wp_editor( '', 'um_editor_new', $settings );
1233
+ echo '</div>';
1234
+
1235
+ $this->is_loaded = true;
1236
+ }
1237
+ }
1238
+
1239
+
1240
+ /**
1241
+ * Show field input for edit at modal field
1242
+ *
1243
+ * @param $attribute
1244
+ * @param null $form_id
1245
+ * @param array $field_args
1246
+ */
1247
+ function field_input( $attribute, $form_id = null, $field_args = array() ) {
1248
+
1249
+ if ( $this->in_edit == true ) { // we're editing a field
1250
+ $real_attr = substr( $attribute, 1 );
1251
+ $this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
1252
+ }
1253
+
1254
+ switch ( $attribute ) {
1255
+
1256
+ default:
1257
+
1258
+ /**
1259
+ * UM hook
1260
+ *
1261
+ * @type action
1262
+ * @title um_admin_field_edit_hook{$attribute}
1263
+ * @description Integration for 3-d party fields at wp-admin
1264
+ * @input_vars
1265
+ * [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}]
1266
+ * @change_log
1267
+ * ["Since: 2.0"]
1268
+ * @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 );
1269
+ * @example
1270
+ * <?php
1271
+ * add_action( 'um_admin_field_edit_hook{$attribute}', 'my_admin_field_edit', 10, 1 );
1272
+ * function my_admin_field_edit( $edit_mode_value ) {
1273
+ * // your code here
1274
+ * }
1275
+ * ?>
1276
+ */
1277
+ do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value, $form_id, $this->edit_array );
1278
+
1279
+ break;
1280
+
1281
+ case '_visibility':
1282
+ ?>
1283
+
1284
+ <p><label for="_visibility"><?php _e( 'Visibility', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.','ultimate-member' ) ); ?></label>
1285
+ <select name="_visibility" id="_visibility" style="width: 100%">
1286
+ <option value="all" <?php selected( 'all', $this->edit_mode_value ); ?>><?php _e( 'View everywhere', 'ultimate-member' ) ?></option>
1287
+ <option value="edit" <?php selected( 'edit', $this->edit_mode_value ); ?>><?php _e( 'Edit mode only', 'ultimate-member' ) ?></option>
1288
+ <option value="view" <?php selected( 'view', $this->edit_mode_value ); ?>><?php _e( 'View mode only', 'ultimate-member' ) ?></option>
1289
+ </select>
1290
+ </p>
1291
+
1292
+ <?php
1293
+ break;
1294
+
1295
+ case '_conditional_action':
1296
+ case '_conditional_action1':
1297
+ case '_conditional_action2':
1298
+ case '_conditional_action3':
1299
+ case '_conditional_action4':
1300
+ ?>
1301
+
1302
+ <p>
1303
+ <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 90px">
1304
+
1305
+ <option></option>
1306
+
1307
+ <?php $actions = array( 'show', 'hide' );
1308
+ foreach ( $actions as $action ) { ?>
1309
+
1310
+ <option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action, $this->edit_mode_value ); ?>><?php echo $action; ?></option>
1311
+
1312
+ <?php } ?>
1313
+
1314
+ </select>
1315
+
1316
+ &nbsp;&nbsp;<?php _e( 'If' ); ?>
1317
+ </p>
1318
+
1319
+ <?php
1320
+ break;
1321
+
1322
+ case '_conditional_field':
1323
+ case '_conditional_field1':
1324
+ case '_conditional_field2':
1325
+ case '_conditional_field3':
1326
+ case '_conditional_field4':
1327
+ ?>
1328
+
1329
+ <p>
1330
+ <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1331
+
1332
+ <option></option>
1333
+
1334
+ <?php $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
1335
+
1336
+ foreach ( $fields as $key => $array ) {
1337
+ if ( isset( $array['title'] ) &&
1338
+ ( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?>
1339
+
1340
+ <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $key, $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
1341
+
1342
+ <?php }
1343
+ } ?>
1344
+
1345
+ </select>
1346
+ </p>
1347
+
1348
+ <?php
1349
+ break;
1350
+
1351
+ case '_conditional_operator':
1352
+ case '_conditional_operator1':
1353
+ case '_conditional_operator2':
1354
+ case '_conditional_operator3':
1355
+ case '_conditional_operator4':
1356
+ ?>
1357
+
1358
+ <p>
1359
+ <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1360
+
1361
+ <option></option>
1362
+
1363
+ <?php $operators = array(
1364
+ 'empty',
1365
+ 'not empty',
1366
+ 'equals to',
1367
+ 'not equals',
1368
+ 'greater than',
1369
+ 'less than',
1370
+ 'contains'
1371
+ );
1372
+
1373
+ foreach ( $operators as $operator ) { ?>
1374
+
1375
+ <option value="<?php echo esc_attr( $operator ); ?>" <?php selected( $operator, $this->edit_mode_value ); ?>><?php echo $operator; ?></option>
1376
+
1377
+ <?php } ?>
1378
+
1379
+ </select>
1380
+ </p>
1381
+
1382
+ <?php
1383
+ break;
1384
+
1385
+ case '_conditional_value':
1386
+ case '_conditional_value1':
1387
+ case '_conditional_value2':
1388
+ case '_conditional_value3':
1389
+ case '_conditional_value4':
1390
+ ?>
1391
+
1392
+ <p>
1393
+ <input type="text" name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" value="<?php echo isset( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" placeholder="<?php esc_attr_e( 'Value', 'ultimate-member' ); ?>" style="width: 150px!important;position: relative;top: -1px;" />
1394
+ </p>
1395
+
1396
+ <?php
1397
+ break;
1398
+
1399
+ case '_validate':
1400
+ ?>
1401
+
1402
+ <p><label for="_validate"><?php _e( 'Validate', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Does this field require a special validation', 'ultimate-member' ) ); ?></label>
1403
+ <select name="_validate" id="_validate" data-placeholder="<?php esc_attr_e( 'Select a validation type...', 'ultimate-member' ) ?>" class="um-adm-conditional" data-cond1="custom" data-cond1-show="_custom_validate" style="width: 100%">
1404
+
1405
+ <option value="" <?php selected( '', $this->edit_mode_value ); ?>></option>
1406
+
1407
+ <?php foreach( UM()->builtin()->validation_types() as $key => $name ) { ?>
1408
+ <?php
1409
+ /**
1410
+ * UM hook
1411
+ *
1412
+ * @type filter
1413
+ * @title um_builtin_validation_types_continue_loop
1414
+ * @description Builtin Validation Types
1415
+ * @input_vars
1416
+ * [{"var":"$continue","type":"bool","desc":"Validate?"},
1417
+ * {"var":"$key","type":"string","desc":"Field Key"},
1418
+ * {"var":"$form_id","type":"int","desc":"Form ID"},
1419
+ * {"var":"$field_args","type":"array","desc":"Field Settings"}]
1420
+ * @change_log
1421
+ * ["Since: 2.0"]
1422
+ * @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 );
1423
+ * @example
1424
+ * <?php
1425
+ * add_filter( 'um_builtin_validation_types_continue_loop', 'my_builtin_validation_types', 10, 4 );
1426
+ * function my_builtin_validation_types( $continue, $key, $form_id, $field_args ) {
1427
+ * // your code here
1428
+ * return $continue;
1429
+ * }
1430
+ * ?>
1431
+ */
1432
+ $continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args );
1433
+ if ( $continue ) { ?>
1434
+ <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->edit_mode_value ); ?>><?php echo $name; ?></option>
1435
+ <?php } ?>
1436
+ <?php } ?>
1437
+
1438
+ </select>
1439
+ </p>
1440
+
1441
+ <?php
1442
+ break;
1443
+
1444
+ case '_custom_validate':
1445
+ ?>
1446
+
1447
+ <p class="_custom_validate"><label for="_custom_validate"><?php _e( 'Custom Action', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details.', 'ultimate-member' ) ); ?></label>
1448
+ <input type="text" name="_custom_validate" id="_custom_validate" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1449
+ </p>
1450
+
1451
+ <?php
1452
+ break;
1453
+
1454
+ case '_icon':
1455
+
1456
+ if ( $this->set_field_type == 'row' ) {
1457
+ $back = 'UM_edit_row';
1458
+
1459
+ ?>
1460
+
1461
+ <p class="_heading_text"><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1462
+
1463
+ <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="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1464
+
1465
+ <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1466
+
1467
+ <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1468
+
1469
+ <?php if ( $this->edit_mode_value ) { ?>
1470
+ <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1471
+ <?php } else { ?>
1472
+ <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1473
+ <?php } ?>
1474
+
1475
+ </p>
1476
+
1477
+ <?php } else {
1478
+
1479
+ if ( $this->in_edit ) {
1480
+ $back = 'UM_edit_field';
1481
+ } else {
1482
+ $back = 'UM_add_field';
1483
+ }
1484
+
1485
+ ?>
1486
+
1487
+ <div class="um-admin-tri">
1488
+
1489
+ <p><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1490
+
1491
+ <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="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1492
+
1493
+ <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1494
+
1495
+ <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1496
+
1497
+ <?php if ( $this->edit_mode_value ) { ?>
1498
+ <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1499
+ <?php } else { ?>
1500
+ <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1501
+ <?php } ?>
1502
+
1503
+ </p>
1504
+
1505
+ </div>
1506
+
1507
+ <?php
1508
+
1509
+ }
1510
+
1511
+ break;
1512
+
1513
+ case '_css_class':
1514
+ ?>
1515
+
1516
+ <p><label for="_css_class"><?php _e( 'CSS Class', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Specify a custom CSS class to be applied to this element', 'ultimate-member' ) ); ?></label>
1517
+ <input type="text" name="_css_class" id="_css_class" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1518
+ </p>
1519
+
1520
+ <?php
1521
+ break;
1522
+
1523
+ case '_width':
1524
+ ?>
1525
+
1526
+ <p><label for="_width"><?php _e( 'Thickness (in pixels)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the width in pixels, e.g. 4 or 2, etc', 'ultimate-member' ) ); ?></label>
1527
+ <input type="text" name="_width" id="_width" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 4; ?>" />
1528
+ </p>
1529
+
1530
+ <?php
1531
+ break;
1532
+
1533
+ case '_divider_text':
1534
+ ?>
1535
+
1536
+ <p><label for="_divider_text"><?php _e( 'Optional Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Optional text to include with the divider', 'ultimate-member' ) ); ?></label>
1537
+ <input type="text" name="_divider_text" id="_divider_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1538
+ </p>
1539
+
1540
+ <?php
1541
+ break;
1542
+
1543
+ case '_padding':
1544
+ ?>
1545
+
1546
+ <p><label for="_padding"><?php _e( 'Padding', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set padding for this section', 'ultimate-member' ) ); ?></label>
1547
+ <input type="text" name="_padding" id="_padding" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1548
+ </p>
1549
+
1550
+ <?php
1551
+ break;
1552
+
1553
+ case '_margin':
1554
+ ?>
1555
+
1556
+ <p><label for="_margin"><?php _e( 'Margin', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set margin for this section', 'ultimate-member' ) ); ?></label>
1557
+ <input type="text" name="_margin" id="_margin" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 30px 0px'; ?>" />
1558
+ </p>
1559
+
1560
+ <?php
1561
+ break;
1562
+
1563
+ case '_border':
1564
+ ?>
1565
+
1566
+ <p><label for="_border"><?php _e( 'Border', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set border for this section', 'ultimate-member' ) ); ?></label>
1567
+ <input type="text" name="_border" id="_border" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1568
+ </p>
1569
+
1570
+ <?php
1571
+ break;
1572
+
1573
+ case '_borderstyle':
1574
+ ?>
1575
+
1576
+ <p><label for="_borderstyle"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the border style', 'ultimate-member' ) ); ?></label>
1577
+ <select name="_borderstyle" id="_borderstyle" style="width: 100%">
1578
+ <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1579
+ <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1580
+ <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1581
+ <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1582
+ </select>
1583
+ </p>
1584
+
1585
+ <?php
1586
+ break;
1587
+
1588
+ case '_borderradius':
1589
+ ?>
1590
+
1591
+ <p><label for="_borderradius"><?php _e( 'Border Radius', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Rounded corners can be applied by setting a pixels value here. e.g. 5px', 'ultimate-member' ) ); ?></label>
1592
+ <input type="text" name="_borderradius" id="_borderradius" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px'; ?>" />
1593
+ </p>
1594
+
1595
+ <?php
1596
+ break;
1597
+
1598
+ case '_bordercolor':
1599
+ ?>
1600
+
1601
+ <p><label for="_bordercolor"><?php _e( 'Border Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Give a color to this border', 'ultimate-member' ) ); ?></label>
1602
+ <input type="text" name="_bordercolor" id="_bordercolor" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1603
+ </p>
1604
+
1605
+ <?php
1606
+ break;
1607
+
1608
+ case '_heading':
1609
+ ?>
1610
+
1611
+ <p><label for="_heading"><?php _e( 'Enable Row Heading', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to enable a heading for this row', 'ultimate-member' ) ); ?></label>
1612
+ <input type="checkbox" name="_heading" id="_heading" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />
1613
+ </p>
1614
+
1615
+ <?php
1616
+ break;
1617
+
1618
+ case '_heading_text':
1619
+ ?>
1620
+
1621
+ <p class="_heading_text"><label for="_heading_text"><?php _e( 'Heading Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the row heading text here', 'ultimate-member' ) ); ?></label>
1622
+ <input type="text" name="_heading_text" id="_heading_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1623
+ </p>
1624
+
1625
+ <?php
1626
+ break;
1627
+
1628
+ case '_background':
1629
+ ?>
1630
+
1631
+ <p><label for="_background"><?php _e( 'Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of entire section', 'ultimate-member' ) ); ?></label>
1632
+ <input type="text" name="_background" id="_background" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1633
+ </p>
1634
+
1635
+ <?php
1636
+ break;
1637
+
1638
+ case '_heading_background_color':
1639
+ ?>
1640
+
1641
+ <p class="_heading_text"><label for="_heading_background_color"><?php _e( 'Heading Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of the heading section', 'ultimate-member' ) ); ?></label>
1642
+ <input type="text" name="_heading_background_color" id="_heading_background_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1643
+ </p>
1644
+
1645
+ <?php
1646
+ break;
1647
+
1648
+ case '_heading_text_color':
1649
+ ?>
1650
+
1651
+ <p class="_heading_text"><label for="_heading_text_color"><?php _e( 'Heading Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of heading part only', 'ultimate-member' ) ); ?></label>
1652
+ <input type="text" name="_heading_text_color" id="_heading_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1653
+ </p>
1654
+
1655
+ <?php
1656
+ break;
1657
+
1658
+ case '_text_color':
1659
+ ?>
1660
+
1661
+ <p><label for="_text_color"><?php _e( 'Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of entire section', 'ultimate-member' ) ); ?></label>
1662
+ <input type="text" name="_text_color" id="_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1663
+ </p>
1664
+
1665
+ <?php
1666
+ break;
1667
+
1668
+ case '_icon_color':
1669
+ ?>
1670
+
1671
+ <p class="_heading_text"><label for="_icon_color"><?php _e( 'Icon Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the color of selected icon. By default It will be the same color as heading text color', 'ultimate-member' ) ); ?></label>
1672
+ <input type="text" name="_icon_color" id="_icon_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1673
+ </p>
1674
+
1675
+ <?php
1676
+ break;
1677
+
1678
+ case '_color':
1679
+ ?>
1680
+
1681
+ <p><label for="_color"><?php _e( 'Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select a color for this divider', 'ultimate-member' ) ); ?></label>
1682
+ <input type="text" name="_color" id="_color" class="um-admin-colorpicker" data-default-color="#eeeeee" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '#eeeeee'; ?>" />
1683
+ </p>
1684
+
1685
+ <?php
1686
+ break;
1687
+
1688
+ case '_url_text':
1689
+ ?>
1690
+
1691
+ <p><label for="_url_text"><?php _e( 'URL Alt Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Entering custom text here will replace the url with a text link', 'ultimate-member' ) ); ?></label>
1692
+ <input type="text" name="_url_text" id="_url_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1693
+ </p>
1694
+
1695
+ <?php
1696
+ break;
1697
+
1698
+ case '_url_target':
1699
+ ?>
1700
+
1701
+ <p><label for="_url_target"><?php _e( 'Link Target', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether to open this link in same window or in a new window', 'ultimate-member' ) ); ?></label>
1702
+ <select name="_url_target" id="_url_target" style="width: 100%">
1703
+ <option value="_blank" <?php selected( '_blank', $this->edit_mode_value ); ?>><?php _e( 'Open in new window', 'ultimate-member' ) ?></option>
1704
+ <option value="_self" <?php selected( '_self', $this->edit_mode_value ); ?>><?php _e( 'Same window', 'ultimate-member' ) ?></option>
1705
+ </select>
1706
+ </p>
1707
+
1708
+ <?php
1709
+ break;
1710
+
1711
+ case '_url_rel':
1712
+ ?>
1713
+
1714
+ <p><label for="_url_rel"><?php _e( 'SEO Follow', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to follow or nofollow this link by search engines', 'ultimate-member' ) ); ?></label>
1715
+ <select name="_url_rel" id="_url_rel" style="width: 100%">
1716
+ <option value="follow" <?php selected( 'follow', $this->edit_mode_value ); ?>><?php _e( 'Follow', 'ultimate-member' ) ?></option>
1717
+ <option value="nofollow" <?php selected( 'nofollow', $this->edit_mode_value ); ?>><?php _e( 'No-Follow', 'ultimate-member' ) ?></option>
1718
+ </select>
1719
+ </p>
1720
+
1721
+ <?php
1722
+ break;
1723
+
1724
+ case '_force_good_pass':
1725
+ ?>
1726
+
1727
+ <p><label for="_force_good_pass"><?php _e( 'Force strong password?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
1728
+ <input type="checkbox" name="_force_good_pass" id="_force_good_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
1729
+ </p>
1730
+
1731
+ <?php
1732
+ break;
1733
+
1734
+ case '_force_confirm_pass':
1735
+ ?>
1736
+
1737
+ <p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
1738
+ <input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
1739
+ </p>
1740
+
1741
+ <?php
1742
+ break;
1743
+
1744
+ case '_style':
1745
+ ?>
1746
+
1747
+ <p><label for="_style"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the line-style of divider', 'ultimate-member' ) ); ?></label>
1748
+ <select name="_style" id="_style" style="width: 100%">
1749
+ <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1750
+ <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1751
+ <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1752
+ <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1753
+ </select>
1754
+ </p>
1755
+
1756
+ <?php
1757
+ break;
1758
+
1759
+ case '_intervals':
1760
+
1761
+ ?>
1762
+
1763
+ <p><label for="_intervals"><?php _e( 'Time Intervals (in minutes)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the minutes interval between each time in the time picker.', 'ultimate-member' ) ); ?></label>
1764
+ <input type="text" name="_intervals" id="_intervals" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 60; ?>" placeholder="<?php esc_attr_e( 'e.g. 30, 60, 120', 'ultimate-member' ) ?>" />
1765
+ </p>
1766
+
1767
+ <?php
1768
+ break;
1769
+
1770
+
1771
+ case '_format':
1772
+
1773
+ if ( $this->set_field_type == 'date' ) {
1774
+ ?>
1775
+
1776
+ <p><label for="_format"><?php _e( 'Date User-Friendly Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The display format of the date which is visible to user.', 'ultimate-member' ) ); ?></label>
1777
+ <select name="_format" id="_format" style="width: 100%">
1778
+ <option value="j M Y" <?php selected( 'j M Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j M Y'); ?></option>
1779
+ <option value="M j Y" <?php selected( 'M j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('M j Y'); ?></option>
1780
+ <option value="j F Y" <?php selected( 'j F Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j F Y'); ?></option>
1781
+ <option value="F j Y" <?php selected( 'F j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('F j Y'); ?></option>
1782
+ </select>
1783
+ </p>
1784
+
1785
+ <?php } else { ?>
1786
+
1787
+ <p><label for="_format"><?php _e( 'Time Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the displayed time-format for this field', 'ultimate-member' ) ); ?></label>
1788
+ <select name="_format" id="_format" style="width: 100%">
1789
+ <option value="g:i a" <?php selected( 'g:i a', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i a'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1790
+ <option value="g:i A" <?php selected( 'g:i A', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i A'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1791
+ <option value="H:i" <?php selected( 'H:i', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('H:i'); ?><?php _e( '( 24-hr format )', 'ultimate-member' ) ?></option>
1792
+ </select>
1793
+ </p>
1794
+
1795
+ <?php
1796
+ }
1797
+ break;
1798
+
1799
+ case '_format_custom':
1800
+ ?>
1801
+
1802
+ <p><label for="_format_custom"><?php _e( 'Use custom Date format', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option overrides "Date User-Friendly Format" option. See https://www.php.net/manual/en/function.date.php', 'ultimate-member' ) ); ?></label>
1803
+ <input type="text" name="_format_custom" id="_format_custom" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" placeholder="j M Y" />
1804
+ </p>
1805
+
1806
+ <?php
1807
+ break;
1808
+
1809
+ case '_pretty_format':
1810
+ ?>
1811
+
1812
+ <p><label for="_pretty_format"><?php _e( 'Displayed Date Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether you wish to show the date in full or only show the years e.g. 25 Years', 'ultimate-member' ) ); ?></label>
1813
+ <select name="_pretty_format" id="_pretty_format" style="width: 100%">
1814
+ <option value="0" <?php selected( 0, $this->edit_mode_value ); ?>><?php _e( 'Show full date', 'ultimate-member' ) ?></option>
1815
+ <option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Show years only', 'ultimate-member' ) ?></option>
1816
+ </select>
1817
+ </p>
1818
+
1819
+ <?php
1820
+ break;
1821
+
1822
+ case '_disabled_weekdays':
1823
+
1824
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1825
+ $values = $this->edit_mode_value;
1826
+ } else {
1827
+ $values = array('');
1828
+ }
1829
+ ?>
1830
+
1831
+ <p><label for="_disabled_weekdays"><?php _e( 'Disable specific weekdays', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Disable specific week days from being available for selection in this date picker', 'ultimate-member' ) ); ?></label>
1832
+ <select name="_disabled_weekdays[]" id="_disabled_weekdays" multiple="multiple" style="width: 100%">
1833
+ <option value="1" <?php if ( in_array( 1, $values ) ) { echo 'selected'; } ?>><?php _e( 'Sunday', 'ultimate-member' ) ?></option>
1834
+ <option value="2" <?php if ( in_array( 2, $values ) ) { echo 'selected'; } ?>><?php _e( 'Monday', 'ultimate-member' ) ?></option>
1835
+ <option value="3" <?php if ( in_array( 3, $values ) ) { echo 'selected'; } ?>><?php _e( 'Tuesday', 'ultimate-member' ) ?></option>
1836
+ <option value="4" <?php if ( in_array( 4, $values ) ) { echo 'selected'; } ?>><?php _e( 'Wednesday', 'ultimate-member' ) ?></option>
1837
+ <option value="5" <?php if ( in_array( 5, $values ) ) { echo 'selected'; } ?>><?php _e( 'Thursday', 'ultimate-member' ) ?></option>
1838
+ <option value="6" <?php if ( in_array( 6, $values ) ) { echo 'selected'; } ?>><?php _e( 'Friday', 'ultimate-member' ) ?></option>
1839
+ <option value="7" <?php if ( in_array( 7, $values ) ) { echo 'selected'; } ?>><?php _e( 'Saturday', 'ultimate-member' ) ?></option>
1840
+ </select>
1841
+ </p>
1842
+
1843
+ <?php
1844
+ break;
1845
+
1846
+ case '_years':
1847
+ ?>
1848
+
1849
+ <p class="_years"><label for="_years"><?php _e( 'Number of Years to pick from', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Number of years available for the date selection. Default to last 50 years', 'ultimate-member' ) ); ?></label>
1850
+ <input type="text" name="_years" id="_years" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 50; ?>" />
1851
+ </p>
1852
+
1853
+ <?php
1854
+ break;
1855
+
1856
+ case '_years_x':
1857
+ ?>
1858
+
1859
+ <p class="_years"><label for="_years_x"><?php _e( 'Years Selection', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This decides which years should be shown relative to today date', 'ultimate-member' ) ); ?></label>
1860
+ <select name="_years_x" id="_years_x" style="width: 100%">
1861
+ <option value="equal" <?php selected( 'equal', $this->edit_mode_value ); ?>><?php _e( 'Equal years before / after today', 'ultimate-member' ) ?></option>
1862
+ <option value="past" <?php selected( 'past', $this->edit_mode_value ); ?>><?php _e( 'Past years only', 'ultimate-member' ) ?></option>
1863
+ <option value="future" <?php selected( 'future', $this->edit_mode_value ); ?>><?php _e( 'Future years only', 'ultimate-member' ) ?></option>
1864
+ </select>
1865
+ </p>
1866
+
1867
+ <?php
1868
+ break;
1869
+
1870
+ case '_range_start':
1871
+ ?>
1872
+
1873
+ <p class="_date_range"><label for="_range_start"><?php _e( 'Date Range Start', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the minimum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1874
+ <input type="text" name="_range_start" id="_range_start" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1875
+ </p>
1876
+
1877
+ <?php
1878
+ break;
1879
+
1880
+ case '_range_end':
1881
+ ?>
1882
+
1883
+ <p class="_date_range"><label for="_range_end"><?php _e( 'Date Range End', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the maximum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1884
+ <input type="text" name="_range_end" id="_range_end" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1885
+ </p>
1886
+
1887
+ <?php
1888
+ break;
1889
+
1890
+ case '_range':
1891
+ ?>
1892
+
1893
+ <p><label for="_range"><?php _e( 'Set Date Range', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to show a specific number of years or specify a date range to be available for the date picker.', 'ultimate-member' ) ); ?></label>
1894
+ <select name="_range" id="_range" class="um-adm-conditional" data-cond1='years' data-cond1-show='_years' data-cond2="date_range" data-cond2-show="_date_range" style="width: 100%">
1895
+ <option value="years" <?php selected( 'years', $this->edit_mode_value ); ?>><?php _e( 'Fixed Number of Years', 'ultimate-member' ) ?></option>
1896
+ <option value="date_range" <?php selected( 'date_range', $this->edit_mode_value ); ?>><?php _e( 'Specific Date Range', 'ultimate-member' ) ?></option>
1897
+ </select>
1898
+ </p>
1899
+
1900
+ <?php
1901
+ break;
1902
+
1903
+ case '_content':
1904
+
1905
+ if ( $this->set_field_type == 'shortcode' ) {
1906
+
1907
+ ?>
1908
+
1909
+ <p><label for="_content"><?php _e( 'Enter Shortcode', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the shortcode in the following textarea and it will be displayed on the fields', 'ultimate-member' ) ); ?></label>
1910
+ <textarea name="_content" id="_content" placeholder="<?php esc_attr_e( 'e.g. [my_custom_shortcode]', 'ultimate-member' ) ?>"><?php echo $this->edit_mode_value; ?></textarea>
1911
+ </p>
1912
+
1913
+ <?php
1914
+
1915
+ } else {
1916
+
1917
+ ?>
1918
+
1919
+ <div class="um-admin-editor-h"><label><?php _e( 'Content Editor', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Edit the content of this field here', 'ultimate-member' ) ); ?></label></div>
1920
+
1921
+ <div class="um-admin-editor"><!-- editor dynamically loaded here --></div>
1922
+
1923
+ <?php
1924
+
1925
+ }
1926
+
1927
+ break;
1928
+
1929
+ case '_crop':
1930
+ ?>
1931
+
1932
+ <p><label for="_crop"><?php _e( 'Crop Feature', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable crop feature for this image upload and define ratio', 'ultimate-member' ) ); ?></label>
1933
+ <select name="_crop" id="_crop" style="width: 100%">
1934
+ <option value="0" <?php selected( '0', $this->edit_mode_value ); ?>><?php _e( 'Turn Off (Default)', 'ultimate-member' ) ?></option>
1935
+ <option value="1" <?php selected( '1', $this->edit_mode_value ); ?>><?php _e( 'Crop and force 1:1 ratio', 'ultimate-member' ) ?></option>
1936
+ <option value="3" <?php selected( '3', $this->edit_mode_value ); ?>><?php _e( 'Crop and force user-defined ratio', 'ultimate-member' ) ?></option>
1937
+ </select>
1938
+ </p>
1939
+
1940
+ <?php
1941
+ break;
1942
+
1943
+ case '_allowed_types':
1944
+
1945
+ if ( $this->set_field_type == 'image' ) {
1946
+
1947
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1948
+ $values = $this->edit_mode_value;
1949
+ } else {
1950
+ $values = array( 'png','jpeg','jpg','gif' );
1951
+ } ?>
1952
+
1953
+ <p><label for="_allowed_types"><?php _e( 'Allowed Image Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1954
+ <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1955
+ <?php foreach( UM()->files()->allowed_image_types() as $e => $n ) { ?>
1956
+ <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1957
+ <?php } ?>
1958
+ </select>
1959
+ </p>
1960
+
1961
+ <?php
1962
+
1963
+ } else {
1964
+
1965
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1966
+ $values = $this->edit_mode_value;
1967
+ } else {
1968
+ $values = array( 'pdf', 'txt' );
1969
+ } ?>
1970
+
1971
+ <p><label for="_allowed_types"><?php _e( 'Allowed File Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1972
+ <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1973
+ <?php foreach( UM()->files()->allowed_file_types() as $e => $n ) { ?>
1974
+ <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1975
+ <?php } ?>
1976
+ </select>
1977
+ </p>
1978
+
1979
+ <?php
1980
+
1981
+ }
1982
+
1983
+ break;
1984
+
1985
+ case '_upload_text':
1986
+
1987
+ if ( $this->set_field_type == 'image' ) {
1988
+ $value = __( 'Drag &amp; Drop Photo', 'ultimate-member' );
1989
+ }
1990
+ if ( $this->set_field_type == 'file' ) {
1991
+ $value = __( 'Drag &amp; Drop File', 'ultimate-member' );
1992
+ }
1993
+
1994
+ ?>
1995
+
1996
+ <p><label for="_upload_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the headline that appears in the upload box for this field', 'ultimate-member' ) ); ?></label>
1997
+ <input type="text" name="_upload_text" id="_upload_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : $value; ?>" />
1998
+ </p>
1999
+
2000
+ <?php
2001
+ break;
2002
+
2003
+ case '_upload_help_text':
2004
+ ?>
2005
+
2006
+ <p><label for="_upload_help_text"><?php _e( 'Additional Instructions Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you need to add information or secondary line below the headline of upload box, enter it here', 'ultimate-member' ) ); ?></label>
2007
+ <input type="text" name="_upload_help_text" id="_upload_help_text" value="<?php echo $this->edit_mode_value; ?>" />
2008
+ </p>
2009
+
2010
+ <?php
2011
+ break;
2012
+
2013
+ case '_button_text':
2014
+ ?>
2015
+
2016
+ <p><label for="_button_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The text that appears on the button. e.g. Upload', 'ultimate-member' ) ); ?></label>
2017
+ <input type="text" name="_button_text" id="_button_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : __( 'Upload', 'ultimate-member' ); ?>" />
2018
+ </p>
2019
+
2020
+ <?php
2021
+ break;
2022
+
2023
+ case '_max_size':
2024
+ ?>
2025
+
2026
+ <p><label for="_max_size"><?php _e( 'Maximum Size in bytes', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The maximum size for image that can be uploaded through this field. Leave empty for unlimited size.', 'ultimate-member' ) ); ?></label>
2027
+ <input type="text" name="_max_size" id="_max_size" value="<?php echo $this->edit_mode_value; ?>" />
2028
+ </p>
2029
+
2030
+ <?php
2031
+ break;
2032
+
2033
+ case '_height':
2034
+ ?>
2035
+
2036
+ <p><label for="_height"><?php _e( 'Textarea Height', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The height of textarea in pixels. Default is 100 pixels', 'ultimate-member' ) ); ?></label>
2037
+ <input type="text" name="_height" id="_height" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '100px'; ?>" />
2038
+ </p>
2039
+
2040
+ <?php
2041
+ break;
2042
+
2043
+ case '_spacing':
2044
+ ?>
2045
+
2046
+ <p><label for="_spacing"><?php _e( 'Spacing', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the required spacing in pixels. e.g. 20px', 'ultimate-member' ) ); ?></label>
2047
+ <input type="text" name="_spacing" id="_spacing" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '20px'; ?>" />
2048
+ </p>
2049
+
2050
+ <?php
2051
+ break;
2052
+
2053
+ case '_is_multi':
2054
+ ?>
2055
+
2056
+ <p><label for="_is_multi"><?php _e( 'Allow multiple selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable multiple selections for this field', 'ultimate-member' ) ); ?></label>
2057
+ <input type="checkbox" name="_is_multi" id="_is_multi" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />
2058
+ </p>
2059
+
2060
+ <?php
2061
+ break;
2062
+
2063
+ case '_max_selections':
2064
+ ?>
2065
+
2066
+ <p class="_max_selections"><label for="_max_selections"><?php _e( 'Maximum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a maximum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2067
+ <input type="text" name="_max_selections" id="_max_selections" value="<?php echo $this->edit_mode_value; ?>" />
2068
+ </p>
2069
+
2070
+ <?php
2071
+ break;
2072
+
2073
+ case '_min_selections':
2074
+ ?>
2075
+
2076
+ <p class="_min_selections"><label for="_min_selections"><?php _e( 'Minimum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a minimum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2077
+ <input type="text" name="_min_selections" id="_min_selections" value="<?php echo $this->edit_mode_value; ?>" />
2078
+ </p>
2079
+
2080
+ <?php
2081
+ break;
2082
+
2083
+ case '_max_entries':
2084
+ ?>
2085
+
2086
+ <p class="_max_entries"><label for="_max_selections"><?php _e( 'Maximum number of entries', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the max number of entries the user can add via field group.', 'ultimate-member' ) ); ?></label>
2087
+ <input type="text" name="_max_entries" id="_max_entries" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 10; ?>" />
2088
+ </p>
2089
+
2090
+ <?php
2091
+ break;
2092
+
2093
+ case '_max_words':
2094
+ ?>
2095
+
2096
+ <p><label for="_max_words"><?php _e( 'Maximum allowed words', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2097
+ <input type="text" name="_max_words" id="_max_words" value="<?php echo $this->edit_mode_value; ?>" />
2098
+ </p>
2099
+
2100
+ <?php
2101
+ break;
2102
+
2103
+ case '_min':
2104
+ ?>
2105
+
2106
+ <p><label for="_min"><?php _e( 'Minimum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Minimum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2107
+ <input type="text" name="_min" id="_min" value="<?php echo $this->edit_mode_value; ?>" />
2108
+ </p>
2109
+
2110
+ <?php
2111
+ break;
2112
+
2113
+ case '_max':
2114
+ ?>
2115
+
2116
+ <p><label for="_max"><?php _e( 'Maximum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Maximum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2117
+ <input type="text" name="_max" id="_max" value="<?php echo $this->edit_mode_value; ?>" />
2118
+ </p>
2119
+
2120
+ <?php
2121
+ break;
2122
+
2123
+ case '_min_chars':
2124
+ ?>
2125
+
2126
+ <p><label for="_min_chars"><?php _e( 'Minimum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2127
+ <input type="text" name="_min_chars" id="_min_chars" value="<?php echo $this->edit_mode_value; ?>" />
2128
+ </p>
2129
+
2130
+ <?php
2131
+ break;
2132
+
2133
+ case '_max_chars':
2134
+ ?>
2135
+
2136
+ <p><label for="_max_chars"><?php _e( 'Maximum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2137
+ <input type="text" name="_max_chars" id="_max_chars" value="<?php echo $this->edit_mode_value; ?>" />
2138
+ </p>
2139
+
2140
+ <?php
2141
+ break;
2142
+
2143
+ case '_html':
2144
+ ?>
2145
+
2146
+ <p><label for="_html"><?php _e( 'Does this textarea accept HTML?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on/off HTML tags for this textarea', 'ultimate-member' ) ); ?></label>
2147
+ <input type="checkbox" name="_html" id="_html" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
2148
+ </p>
2149
+
2150
+ <?php
2151
+ break;
2152
+
2153
+ case '_options':
2154
+
2155
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2156
+ $values = implode("\n", $this->edit_mode_value);
2157
+ } else if ( $this->edit_mode_value ) {
2158
+ $values = $this->edit_mode_value;
2159
+ } else {
2160
+ $values = '';
2161
+ } ?>
2162
+
2163
+ <p><label for="_options"><?php _e( 'Edit Choices', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter one choice per line. This will represent the available choices or selections available for user.', 'ultimate-member' ) ); ?></label>
2164
+ <textarea name="_options" id="_options"><?php echo $values; ?></textarea>
2165
+ </p>
2166
+
2167
+ <?php
2168
+ break;
2169
+
2170
+ case '_title':
2171
+ ?>
2172
+
2173
+ <p><label for="_title"><?php _e( 'Title', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
2174
+ <input type="text" name="_title" id="_title" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2175
+ </p>
2176
+
2177
+ <?php
2178
+ break;
2179
+
2180
+ case '_id':
2181
+
2182
+ ?>
2183
+
2184
+ <p style="display:none"><label for="_id"><?php _e( 'Unique ID', 'ultimate-member' ) ?></label>
2185
+ <input type="text" name="_id" id="_id" value="<?php echo $this->edit_mode_value; ?>" />
2186
+ </p>
2187
+
2188
+ <?php
2189
+
2190
+ break;
2191
+
2192
+ case '_metakey':
2193
+
2194
+ if ( $this->in_edit ) {
2195
+
2196
+ ?>
2197
+
2198
+ <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
2199
+ <input type="text" name="_metakey_locked" id="_metakey_locked" value="<?php echo $this->edit_mode_value; ?>" disabled />
2200
+ </p>
2201
+
2202
+ <?php } else { ?>
2203
+
2204
+ <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2205
+ <input type="text" name="_metakey" id="_metakey" value="" />
2206
+ </p>
2207
+
2208
+ <?php
2209
+
2210
+ }
2211
+
2212
+ break;
2213
+
2214
+ case '_help':
2215
+ ?>
2216
+
2217
+ <p><label for="_help"><?php _e( 'Help Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __('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.', 'ultimate-member' ) ); ?></label>
2218
+ <input type="text" name="_help" id="_help" value="<?php echo $this->edit_mode_value; ?>" />
2219
+ </p>
2220
+
2221
+ <?php
2222
+ break;
2223
+
2224
+ case '_default':
2225
+ ?>
2226
+
2227
+ <?php if ( $this->set_field_type == 'textarea' ) { ?>
2228
+
2229
+ <p><label for="_default"><?php _e( 'Default Text', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Text to display by default in this field', 'ultimate-member' ) ); ?></label>
2230
+ <textarea name="_default" id="_default"><?php echo $this->edit_mode_value; ?></textarea>
2231
+ </p>
2232
+
2233
+ <?php } elseif ( $this->set_field_type == 'date' ) { ?>
2234
+
2235
+ <p class="um"><label for="_default"><?php _e( 'Default Date', 'ultimate-member' ); ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2236
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-datepicker" data-format="yyyy/mm/dd" />
2237
+ </p>
2238
+
2239
+ <?php } elseif ( $this->set_field_type == 'time' ) { ?>
2240
+
2241
+ <p class="um"><label for="_default"><?php _e( 'Default Time', 'ultimate-member' ); ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2242
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-timepicker" data-format="HH:i" />
2243
+ </p>
2244
+
2245
+ <?php } elseif ( $this->set_field_type == 'rating' ) { ?>
2246
+
2247
+ <p><label for="_default"><?php _e( 'Default Rating', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'If you wish the rating field to be prefilled with a number of stars, enter it here.', 'ultimate-member' ) ); ?></label>
2248
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2249
+ </p>
2250
+
2251
+ <?php } else { ?>
2252
+
2253
+ <p><label for="_default"><?php _e( 'Default Value', 'ultimate-member' ); ?> <?php UM()->tooltip( __( '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', 'ultimate-member' ) ); ?></label>
2254
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2255
+ </p>
2256
+
2257
+ <?php } ?>
2258
+
2259
+ <?php
2260
+ break;
2261
+
2262
+ case '_label':
2263
+ ?>
2264
+
2265
+ <p><label for="_label"><?php _e( 'Label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( '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.', 'ultimate-member' ) ); ?></label>
2266
+ <input type="text" name="_label" id="_label" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2267
+ </p>
2268
+
2269
+ <?php
2270
+ break;
2271
+
2272
+ case '_label_confirm_pass':
2273
+ ?>
2274
+
2275
+ <p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
2276
+ <input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2277
+ </p>
2278
+
2279
+ <?php
2280
+ break;
2281
+
2282
+ case '_placeholder':
2283
+ ?>
2284
+
2285
+ <p><label for="_placeholder"><?php _e( 'Placeholder', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text.', 'ultimate-member' ) ); ?></label>
2286
+ <input type="text" name="_placeholder" id="_placeholder" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2287
+ </p>
2288
+
2289
+ <?php
2290
+ break;
2291
+
2292
+ case '_public':
2293
+ $privacy_options = array(
2294
+ '1' => __( 'Everyone', 'ultimate-member' ),
2295
+ '2' => __( 'Members', 'ultimate-member' ),
2296
+ '-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
2297
+ '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2298
+ '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2299
+ );
2300
+
2301
+ $privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
2302
+
2303
+ <p>
2304
+ <label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
2305
+ <select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
2306
+ <?php foreach ( $privacy_options as $value => $title ) { ?>
2307
+ <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
2308
+ <?php echo $title ?>
2309
+ </option>
2310
+ <?php } ?>
2311
+ </select>
2312
+ </p>
2313
+
2314
+ <?php
2315
+ break;
2316
+
2317
+ case '_roles':
2318
+
2319
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2320
+ $values = $this->edit_mode_value;
2321
+ } else {
2322
+ $values = array('');
2323
+ }
2324
+
2325
+ ?>
2326
+
2327
+ <p class="_roles"><label for="_roles"><?php _e( 'Select member roles', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the member roles that can view this field on the front-end.', 'ultimate-member' ) ); ?></label>
2328
+ <select name="_roles[]" id="_roles" style="width: 100%" multiple="multiple">
2329
+
2330
+ <?php foreach ( UM()->roles()->get_roles() as $key => $value) { ?>
2331
+
2332
+ <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $values ) ) { echo 'selected'; } ?>><?php echo $value; ?></option>
2333
+
2334
+ <?php } ?>
2335
+
2336
+ </select>
2337
+ </p>
2338
+
2339
+ <?php
2340
+ break;
2341
+
2342
+ case '_required':
2343
+
2344
+ if ( $this->set_field_type == 'password' )
2345
+ $def_required = 1;
2346
+ else
2347
+ $def_required = 0;
2348
+
2349
+ ?>
2350
+
2351
+ <div class="um-admin-tri">
2352
+
2353
+ <p><label for="_required"><?php _e( 'Is this field required?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether the field must be filled in before the form can be processed.', 'ultimate-member' ) ); ?></label>
2354
+ <input type="checkbox" name="_required" id="_required" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />
2355
+ </p>
2356
+
2357
+ </div>
2358
+
2359
+ <?php
2360
+ break;
2361
+
2362
+ case '_editable':
2363
+ ?>
2364
+
2365
+ <div class="um-admin-tri">
2366
+
2367
+ <p><label for="_editable"><?php _e( 'Can user edit this field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether or not the user can edit the information in this field.', 'ultimate-member' ) ); ?></label>
2368
+ <input type="hidden" name="_editable" id="_editable_hidden" value="0" />
2369
+ <input type="checkbox" name="_editable" id="_editable" value="1" <?php checked( null === $this->edit_mode_value || $this->edit_mode_value ) ?> />
2370
+ </p>
2371
+
2372
+ </div>
2373
+
2374
+ <?php
2375
+ break;
2376
+
2377
+ case '_number':
2378
+ ?>
2379
+
2380
+ <p><label for="_number"><?php _e( 'Rating System', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether you want a 5-stars or 10-stars ratings based here.', 'ultimate-member' ) ); ?></label>
2381
+ <select name="_number" id="_number" style="width: 100%">
2382
+ <option value="5" <?php selected( 5, $this->edit_mode_value ); ?>><?php _e( '5 stars rating system', 'ultimate-member' ) ?></option>
2383
+ <option value="10" <?php selected( 10, $this->edit_mode_value ); ?>><?php _e( '10 stars rating system', 'ultimate-member' ) ?></option>
2384
+ </select>
2385
+ </p>
2386
+
2387
+ <?php
2388
+ break;
2389
+
2390
+ case '_custom_dropdown_options_source':
2391
+ ?>
2392
+
2393
+ <p><label for="_custom_dropdown_options_source"><?php _e( 'Choices Callback', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Add a callback source to retrieve choices.', 'ultimate-member' ) ); ?></label>
2394
+ <input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo htmlspecialchars($this->edit_mode_value, ENT_QUOTES); ?>" />
2395
+ </p>
2396
+
2397
+ <?php
2398
+ break;
2399
+
2400
+
2401
+ case '_parent_dropdown_relationship':
2402
+ ?>
2403
+
2404
+ <p><label for="_parent_dropdown_relationship"><?php _e( 'Parent Option', 'ultimate-member' ) ?><?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
2405
+ <select name="_parent_dropdown_relationship" id="_parent_dropdown_relationship" style="width: 100%">
2406
+ <option value=""><?php _e( 'No Selected', 'ultimate-member' ) ?></option>
2407
+
2408
+ <?php if ( UM()->builtin()->custom_fields ) {
2409
+ foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
2410
+ if ( in_array( $array['type'], array( 'select' ) ) && ( ! isset( $field_args['metakey'] ) || $field_args['metakey'] != $array['metakey'] ) && isset( $array['title'] ) ) { ?>
2411
+ <option value="<?php echo esc_attr( $array['metakey'] ) ?>" <?php selected( $array['metakey'], $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
2412
+ <?php }
2413
+ }
2414
+ } ?>
2415
+ </select>
2416
+ </p>
2417
+
2418
+ <?php
2419
+ break;
2420
+
2421
+
2422
+ }
2423
+
2424
+ }
2425
+
2426
+ }
2427
+ }
 
 
 
 
 
 
 
 
 
 
includes/admin/core/class-admin-settings.php CHANGED
@@ -1,3428 +1,3437 @@
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_access_message',
507
- 'type' => 'wp_editor',
508
- 'label' => __( 'Restricted Access Message', 'ultimate-member' ),
509
- 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
510
- ),
511
- );
512
-
513
- $settings_map = array_merge(
514
- $settings_map,
515
- array(
516
- 'accessible' => array(
517
- 'sanitize' => 'int',
518
- ),
519
- 'access_redirect' => array(
520
- 'sanitize' => 'url',
521
- ),
522
- 'access_exclude_uris' => array(
523
- 'sanitize' => 'url',
524
- ),
525
- 'home_page_accessible' => array(
526
- 'sanitize' => 'bool',
527
- ),
528
- 'category_page_accessible' => array(
529
- 'sanitize' => 'bool',
530
- ),
531
- 'restricted_access_message' => array(
532
- 'sanitize' => 'wp_kses',
533
- ),
534
- )
535
- );
536
-
537
- global $wp_version;
538
- if ( version_compare( $wp_version, '5.0', '>=' ) ) {
539
- $access_fields = array_merge(
540
- $access_fields,
541
- array(
542
- array(
543
- 'id' => 'restricted_blocks',
544
- 'type' => 'checkbox',
545
- 'label' => __( 'Allow Gutenberg Blocks restriction options', 'ultimate-member' ),
546
- ),
547
- array(
548
- 'id' => 'restricted_block_message',
549
- 'type' => 'textarea',
550
- 'label' => __( 'Restricted Block Message', 'ultimate-member' ),
551
- 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
552
- 'conditional' => array( 'restricted_blocks', '=', 1 ),
553
- ),
554
- )
555
- );
556
-
557
- $settings_map['restricted_blocks'] = array(
558
- 'sanitize' => 'bool',
559
- );
560
- $settings_map['restricted_block_message'] = array(
561
- 'sanitize' => 'textarea',
562
- );
563
- }
564
-
565
- $access_fields = array_merge(
566
- $access_fields,
567
- array(
568
- array(
569
- 'id' => 'restricted_access_post_metabox',
570
- 'type' => 'hidden',
571
- 'value' => '',
572
- ),
573
- array(
574
- 'id' => 'restricted_access_taxonomy_metabox',
575
- 'type' => 'hidden',
576
- 'value' => '',
577
- ),
578
- array(
579
- 'id' => 'restricted_access_post_metabox',
580
- 'type' => 'multi_checkbox',
581
- 'label' => __( 'Restricted Access to Posts', 'ultimate-member' ),
582
- 'tooltip' => __( 'Restriction content of the current Posts', 'ultimate-member' ),
583
- 'options' => $post_types_options,
584
- 'columns' => 3,
585
- 'value' => $restricted_access_post_metabox_value,
586
- 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
587
- ),
588
- array(
589
- 'id' => 'restricted_access_taxonomy_metabox',
590
- 'type' => 'multi_checkbox',
591
- 'label' => __( 'Restricted Access to Taxonomies', 'ultimate-member' ),
592
- 'tooltip' => __( 'Restriction content of the current Taxonomies', 'ultimate-member' ),
593
- 'options' => $taxonomies_options,
594
- 'columns' => 3,
595
- 'value' => $restricted_access_taxonomy_metabox_value,
596
- 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
597
- ),
598
- )
599
- );
600
-
601
- $settings_map = array_merge(
602
- $settings_map,
603
- array(
604
- 'restricted_access_post_metabox' => array(
605
- 'sanitize' => 'key',
606
- ),
607
- 'restricted_access_taxonomy_metabox' => array(
608
- 'sanitize' => 'key',
609
- ),
610
- )
611
- );
612
-
613
- $latest_update = get_option( 'um_member_directory_update_meta', false );
614
- $latest_truncate = get_option( 'um_member_directory_truncated', false );
615
-
616
- $same_page_update = array(
617
- 'id' => 'member_directory_own_table',
618
- 'type' => 'same_page_update',
619
- 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
620
- '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' ),
621
- );
622
-
623
- if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
624
- $same_page_update['upgrade_cb'] = 'sync_metatable';
625
- $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>
626
- <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>
627
- <p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
628
- }
629
-
630
- $settings_map = array_merge(
631
- $settings_map,
632
- array(
633
- 'permalink_base' => array(
634
- 'sanitize' => 'key',
635
- ),
636
- 'display_name' => array(
637
- 'sanitize' => 'key',
638
- ),
639
- 'display_name_field' => array(
640
- 'sanitize' => 'text',
641
- ),
642
- 'author_redirect' => array(
643
- 'sanitize' => 'bool',
644
- ),
645
- 'members_page' => array(
646
- 'sanitize' => 'bool',
647
- ),
648
- 'use_gravatars' => array(
649
- 'sanitize' => 'bool',
650
- ),
651
- 'use_um_gravatar_default_builtin_image' => array(
652
- 'sanitize' => 'key',
653
- ),
654
- 'use_um_gravatar_default_image' => array(
655
- 'sanitize' => 'bool',
656
- ),
657
- 'reset_require_strongpass' => array(
658
- 'sanitize' => 'bool',
659
- ),
660
- 'profile_noindex' => array(
661
- 'sanitize' => 'bool',
662
- ),
663
- 'activation_link_expiry_time' => array(
664
- 'sanitize' => 'absint',
665
- ),
666
- 'account_tab_password' => array(
667
- 'sanitize' => 'bool',
668
- ),
669
- 'account_tab_privacy' => array(
670
- 'sanitize' => 'bool',
671
- ),
672
- 'account_tab_notifications' => array(
673
- 'sanitize' => 'bool',
674
- ),
675
- 'account_tab_delete' => array(
676
- 'sanitize' => 'bool',
677
- ),
678
- 'delete_account_text' => array(
679
- 'sanitize' => 'textarea',
680
- ),
681
- 'delete_account_no_pass_required_text' => array(
682
- 'sanitize' => 'textarea',
683
- ),
684
- 'account_name' => array(
685
- 'sanitize' => 'bool',
686
- ),
687
- 'account_name_disable' => array(
688
- 'sanitize' => 'bool',
689
- ),
690
- 'account_name_require' => array(
691
- 'sanitize' => 'bool',
692
- ),
693
- 'account_email' => array(
694
- 'sanitize' => 'bool',
695
- ),
696
- 'account_general_password' => array(
697
- 'sanitize' => 'bool',
698
- ),
699
- 'account_require_strongpass' => array(
700
- 'sanitize' => 'bool',
701
- ),
702
- 'account_hide_in_directory' => array(
703
- 'sanitize' => 'bool',
704
- ),
705
- 'account_hide_in_directory_default' => array(
706
- 'sanitize' => 'text',
707
- ),
708
- 'profile_photo_max_size' => array(
709
- 'sanitize' => 'absint',
710
- ),
711
- 'cover_photo_max_size' => array(
712
- 'sanitize' => 'absint',
713
- ),
714
- 'photo_thumb_sizes' => array(
715
- 'sanitize' => 'absint',
716
- ),
717
- 'cover_thumb_sizes' => array(
718
- 'sanitize' => 'absint',
719
- ),
720
- 'image_orientation_by_exif' => array(
721
- 'sanitize' => 'bool',
722
- ),
723
- 'image_compression' => array(
724
- 'sanitize' => 'absint',
725
- ),
726
- 'image_max_width' => array(
727
- 'sanitize' => 'absint',
728
- ),
729
- 'cover_min_width' => array(
730
- 'sanitize' => 'absint',
731
- ),
732
- 'enable_reset_password_limit' => array(
733
- 'sanitize' => 'bool',
734
- ),
735
- 'reset_password_limit_number' => array(
736
- 'sanitize' => 'absint',
737
- ),
738
- 'blocked_emails' => array(
739
- 'sanitize' => 'textarea',
740
- ),
741
- 'blocked_words' => array(
742
- 'sanitize' => 'textarea',
743
- ),
744
- 'admin_email' => array(
745
- 'sanitize' => 'text',
746
- ),
747
- 'mail_from' => array(
748
- 'sanitize' => 'text',
749
- ),
750
- 'mail_from_addr' => array(
751
- 'sanitize' => 'text',
752
- ),
753
- 'email_html' => array(
754
- 'sanitize' => 'bool',
755
- ),
756
- 'profile_template' => array(
757
- 'sanitize' => 'text',
758
- ),
759
- 'profile_max_width' => array(
760
- 'sanitize' => 'absint',
761
- ),
762
- 'profile_area_max_width' => array(
763
- 'sanitize' => 'absint',
764
- ),
765
- 'profile_icons' => array(
766
- 'sanitize' => 'key',
767
- ),
768
- 'profile_primary_btn_word' => array(
769
- 'sanitize' => 'text',
770
- ),
771
- 'profile_secondary_btn' => array(
772
- 'sanitize' => 'bool',
773
- ),
774
- 'profile_secondary_btn_word' => array(
775
- 'sanitize' => 'text',
776
- ),
777
- 'default_avatar' => array(
778
- 'sanitize' => 'url',
779
- ),
780
- 'default_cover' => array(
781
- 'sanitize' => 'url',
782
- ),
783
- 'disable_profile_photo_upload' => array(
784
- 'sanitize' => 'bool',
785
- ),
786
- 'profile_photosize' => array(
787
- 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
788
- ),
789
- 'profile_cover_enabled' => array(
790
- 'sanitize' => 'bool',
791
- ),
792
- 'profile_coversize' => array(
793
- 'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
794
- ),
795
- 'profile_cover_ratio' => array(
796
- 'sanitize' => 'text',
797
- ),
798
- 'profile_show_metaicon' => array(
799
- 'sanitize' => 'bool',
800
- ),
801
- 'profile_show_name' => array(
802
- 'sanitize' => 'bool',
803
- ),
804
- 'profile_show_social_links' => array(
805
- 'sanitize' => 'bool',
806
- ),
807
- 'profile_show_bio' => array(
808
- 'sanitize' => 'bool',
809
- ),
810
- 'profile_show_html_bio' => array(
811
- 'sanitize' => 'bool',
812
- ),
813
- 'profile_bio_maxchars' => array(
814
- 'sanitize' => 'absint',
815
- ),
816
- 'profile_header_menu' => array(
817
- 'sanitize' => 'key',
818
- ),
819
- 'profile_empty_text' => array(
820
- 'sanitize' => 'bool',
821
- ),
822
- 'profile_empty_text_emo' => array(
823
- 'sanitize' => 'bool',
824
- ),
825
- 'register_template' => array(
826
- 'sanitize' => 'text',
827
- ),
828
- 'register_max_width' => array(
829
- 'sanitize' => 'absint',
830
- ),
831
- 'register_align' => array(
832
- 'sanitize' => 'key',
833
- ),
834
- 'register_icons' => array(
835
- 'sanitize' => 'key',
836
- ),
837
- 'register_primary_btn_word' => array(
838
- 'sanitize' => 'text',
839
- ),
840
- 'register_secondary_btn' => array(
841
- 'sanitize' => 'bool',
842
- ),
843
- 'register_secondary_btn_word' => array(
844
- 'sanitize' => 'text',
845
- ),
846
- 'register_secondary_btn_url' => array(
847
- 'sanitize' => 'url',
848
- ),
849
- 'register_role' => array(
850
- 'sanitize' => 'key',
851
- ),
852
- 'login_template' => array(
853
- 'sanitize' => 'text',
854
- ),
855
- 'login_max_width' => array(
856
- 'sanitize' => 'absint',
857
- ),
858
- 'login_align' => array(
859
- 'sanitize' => 'key',
860
- ),
861
- 'login_icons' => array(
862
- 'sanitize' => 'key',
863
- ),
864
- 'login_primary_btn_word' => array(
865
- 'sanitize' => 'text',
866
- ),
867
- 'login_secondary_btn' => array(
868
- 'sanitize' => 'bool',
869
- ),
870
- 'login_secondary_btn_word' => array(
871
- 'sanitize' => 'text',
872
- ),
873
- 'login_secondary_btn_url' => array(
874
- 'sanitize' => 'url',
875
- ),
876
- 'login_forgot_pass_link' => array(
877
- 'sanitize' => 'bool',
878
- ),
879
- 'login_show_rememberme' => array(
880
- 'sanitize' => 'bool',
881
- ),
882
- 'form_asterisk' => array(
883
- 'sanitize' => 'bool',
884
- ),
885
- 'profile_title' => array(
886
- 'sanitize' => 'text',
887
- ),
888
- 'profile_desc' => array(
889
- 'sanitize' => 'textarea',
890
- ),
891
- 'um_profile_object_cache_stop' => array(
892
- 'sanitize' => 'bool',
893
- ),
894
- 'enable_blocks' => array(
895
- 'sanitize' => 'bool',
896
- ),
897
- 'rest_api_version' => array(
898
- 'sanitize' => 'text',
899
- ),
900
- 'uninstall_on_delete' => array(
901
- 'sanitize' => 'bool',
902
- ),
903
- )
904
- );
905
-
906
- $this->settings_map = apply_filters( 'um_settings_map', $settings_map );
907
-
908
- /**
909
- * UM hook
910
- *
911
- * @type filter
912
- * @title um_settings_structure
913
- * @description Extend UM Settings
914
- * @input_vars
915
- * [{"var":"$settings","type":"array","desc":"UM Settings"}]
916
- * @change_log
917
- * ["Since: 2.0"]
918
- * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
919
- * @example
920
- * <?php
921
- * add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
922
- * function my_settings_structure( $settings ) {
923
- * // your code here
924
- * return $settings;
925
- * }
926
- * ?>
927
- */
928
- $this->settings_structure = apply_filters(
929
- 'um_settings_structure',
930
- array(
931
- '' => array(
932
- 'title' => __( 'General', 'ultimate-member' ),
933
- 'sections' => array(
934
- '' => array(
935
- 'title' => __( 'Pages', 'ultimate-member' ),
936
- 'fields' => $general_pages_fields,
937
- ),
938
- 'users' => array(
939
- 'title' => __( 'Users', 'ultimate-member' ),
940
- 'fields' => array(
941
- array(
942
- 'id' => 'permalink_base',
943
- 'type' => 'select',
944
- 'size' => 'small',
945
- 'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
946
- // translators: %s: Profile page URL
947
- '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' ) ) ),
948
- 'options' => array(
949
- 'user_login' => __( 'Username', 'ultimate-member' ),
950
- 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
951
- 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
952
- 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
953
- 'user_id' => __( 'User ID', 'ultimate-member' ),
954
- ),
955
- 'placeholder' => __( 'Select...', 'ultimate-member' ),
956
- ),
957
- array(
958
- 'id' => 'display_name',
959
- 'type' => 'select',
960
- 'size' => 'medium',
961
- 'label' => __( 'User Display Name', 'ultimate-member' ),
962
- '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' ),
963
- 'options' => array(
964
- 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
965
- 'nickname' => __( 'Nickname', 'ultimate-member' ),
966
- 'username' => __( 'Username', 'ultimate-member' ),
967
- 'full_name' => __( 'First name & last name', 'ultimate-member' ),
968
- 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
969
- 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
970
- 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
971
- 'first_name' => __( 'First name only', 'ultimate-member' ),
972
- 'field' => __( 'Custom field(s)', 'ultimate-member' ),
973
- ),
974
- 'placeholder' => __( 'Select...', 'ultimate-member' ),
975
- ),
976
- array(
977
- 'id' => 'display_name_field',
978
- 'type' => 'text',
979
- 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
980
- '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' ),
981
- 'conditional' => array( 'display_name', '=', 'field' ),
982
- ),
983
- array(
984
- 'id' => 'author_redirect',
985
- 'type' => 'checkbox',
986
- 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
987
- 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
988
- ),
989
- array(
990
- 'id' => 'members_page',
991
- 'type' => 'checkbox',
992
- 'label' => __( 'Enable Members Directory', 'ultimate-member' ),
993
- 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
994
- ),
995
- array(
996
- 'id' => 'use_gravatars',
997
- 'type' => 'checkbox',
998
- 'label' => __( 'Use Gravatars?', 'ultimate-member' ),
999
- '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' ),
1000
- ),
1001
- array(
1002
- 'id' => 'use_um_gravatar_default_builtin_image',
1003
- 'type' => 'select',
1004
- 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
1005
- 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
1006
- 'options' => array(
1007
- 'default' => __( 'Default', 'ultimate-member' ),
1008
- '404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
1009
- 'mm' => __( 'Mystery Man', 'ultimate-member' ),
1010
- 'identicon' => __( 'Identicon', 'ultimate-member' ),
1011
- 'monsterid' => __( 'Monsterid', 'ultimate-member' ),
1012
- 'wavatar' => __( 'Wavatar', 'ultimate-member' ),
1013
- 'retro' => __( 'Retro', 'ultimate-member' ),
1014
- 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
1015
- ),
1016
- 'conditional' => array( 'use_gravatars', '=', 1 ),
1017
- 'size' => 'medium',
1018
- ),
1019
- array(
1020
- 'id' => 'use_um_gravatar_default_image',
1021
- 'type' => 'checkbox',
1022
- 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
1023
- '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' ),
1024
- 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
1025
- ),
1026
- array(
1027
- 'id' => 'reset_require_strongpass',
1028
- 'type' => 'checkbox',
1029
- 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
1030
- 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
1031
- ),
1032
- array(
1033
- 'id' => 'profile_noindex',
1034
- 'type' => 'select',
1035
- 'size' => 'small',
1036
- 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
1037
- 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
1038
- 'options' => array(
1039
- '0' => __( 'No', 'ultimate-member' ),
1040
- '1' => __( 'Yes', 'ultimate-member' ),
1041
- ),
1042
- ),
1043
- array(
1044
- 'id' => 'activation_link_expiry_time',
1045
- 'type' => 'number',
1046
- 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
1047
- 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
1048
- 'size' => 'small',
1049
- ),
1050
- ),
1051
- ),
1052
- 'account' => array(
1053
- 'title' => __( 'Account', 'ultimate-member' ),
1054
- 'fields' => array(
1055
- array(
1056
- 'id' => 'account_tab_password',
1057
- 'type' => 'checkbox',
1058
- 'label' => __( 'Password Account Tab', 'ultimate-member' ),
1059
- 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
1060
- ),
1061
- array(
1062
- 'id' => 'account_tab_privacy',
1063
- 'type' => 'checkbox',
1064
- 'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
1065
- 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
1066
- ),
1067
- array(
1068
- 'id' => 'account_tab_notifications',
1069
- 'type' => 'checkbox',
1070
- 'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
1071
- 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
1072
- ),
1073
- array(
1074
- 'id' => 'account_tab_delete',
1075
- 'type' => 'checkbox',
1076
- 'label' => __( 'Delete Account Tab', 'ultimate-member' ),
1077
- 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
1078
- ),
1079
- array(
1080
- 'id' => 'delete_account_text',
1081
- 'type' => 'textarea', // bug with wp 4.4? should be editor
1082
- 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
1083
- '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' ),
1084
- 'args' => array(
1085
- 'textarea_rows' => 6,
1086
- ),
1087
- ),
1088
- array(
1089
- 'id' => 'delete_account_no_pass_required_text',
1090
- 'type' => 'textarea',
1091
- 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
1092
- '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' ),
1093
- 'args' => array(
1094
- 'textarea_rows' => 6,
1095
- ),
1096
- ),
1097
- array(
1098
- 'id' => 'account_name',
1099
- 'type' => 'checkbox',
1100
- 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
1101
- 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
1102
- ),
1103
- array(
1104
- 'id' => 'account_name_disable',
1105
- 'type' => 'checkbox',
1106
- 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
1107
- 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
1108
- 'conditional' => array( 'account_name', '=', '1' ),
1109
- ),
1110
- array(
1111
- 'id' => 'account_name_require',
1112
- 'type' => 'checkbox',
1113
- 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
1114
- 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
1115
- 'conditional' => array( 'account_name', '=', '1' ),
1116
- ),
1117
- array(
1118
- 'id' => 'account_email',
1119
- 'type' => 'checkbox',
1120
- 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
1121
- 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
1122
- ),
1123
- array(
1124
- 'id' => 'account_general_password',
1125
- 'type' => 'checkbox',
1126
- 'label' => __( 'Password is required?', 'ultimate-member' ),
1127
- 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
1128
- ),
1129
- array(
1130
- 'id' => 'account_require_strongpass',
1131
- 'type' => 'checkbox',
1132
- 'label' => __( 'Require a strong password?', 'ultimate-member' ),
1133
- 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
1134
- ),
1135
- array(
1136
- 'id' => 'account_hide_in_directory',
1137
- 'type' => 'checkbox',
1138
- 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
1139
- 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
1140
- 'conditional' => array( 'account_tab_privacy', '=', '1' ),
1141
- ),
1142
- array(
1143
- 'id' => 'account_hide_in_directory_default',
1144
- 'type' => 'select',
1145
- 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
1146
- 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
1147
- 'options' => array(
1148
- 'No' => __( 'No', 'ultimate-member' ),
1149
- 'Yes' => __( 'Yes', 'ultimate-member' ),
1150
- ),
1151
- 'size' => 'small',
1152
- 'conditional' => array( 'account_hide_in_directory', '=', '1' ),
1153
- ),
1154
- ),
1155
- ),
1156
- 'uploads' => array(
1157
- 'title' => __( 'Uploads', 'ultimate-member' ),
1158
- 'fields' => array(
1159
- array(
1160
- 'id' => 'profile_photo_max_size',
1161
- 'type' => 'text',
1162
- 'size' => 'small',
1163
- 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
1164
- 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
1165
- ),
1166
- array(
1167
- 'id' => 'cover_photo_max_size',
1168
- 'type' => 'text',
1169
- 'size' => 'small',
1170
- 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
1171
- 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
1172
- ),
1173
- array(
1174
- 'id' => 'photo_thumb_sizes',
1175
- 'type' => 'multi_text',
1176
- 'size' => 'small',
1177
- 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1178
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
1179
- 'validate' => 'numeric',
1180
- 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1181
- 'show_default_number' => 1,
1182
- ),
1183
- array(
1184
- 'id' => 'cover_thumb_sizes',
1185
- 'type' => 'multi_text',
1186
- 'size' => 'small',
1187
- 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1188
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
1189
- 'validate' => 'numeric',
1190
- 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1191
- 'show_default_number' => 1,
1192
- ),
1193
- array(
1194
- 'id' => 'image_orientation_by_exif',
1195
- 'type' => 'checkbox',
1196
- 'label' => __( 'Change image orientation', 'ultimate-member' ),
1197
- 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
1198
- ),
1199
- array(
1200
- 'id' => 'image_compression',
1201
- 'type' => 'text',
1202
- 'size' => 'small',
1203
- 'label' => __( 'Image Quality', 'ultimate-member' ),
1204
- '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' ),
1205
- ),
1206
-
1207
- array(
1208
- 'id' => 'image_max_width',
1209
- 'type' => 'text',
1210
- 'size' => 'small',
1211
- 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
1212
- 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
1213
- ),
1214
-
1215
- array(
1216
- 'id' => 'cover_min_width',
1217
- 'type' => 'text',
1218
- 'size' => 'small',
1219
- 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
1220
- 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
1221
- ),
1222
- ),
1223
- ),
1224
- ),
1225
- ),
1226
- 'access' => array(
1227
- 'title' => __( 'Access', 'ultimate-member' ),
1228
- 'sections' => array(
1229
- '' => array(
1230
- 'title' => __( 'Restriction Content', 'ultimate-member' ),
1231
- 'fields' => $access_fields,
1232
- ),
1233
- 'other' => array(
1234
- 'title' => __( 'Other', 'ultimate-member' ),
1235
- 'fields' => array(
1236
- array(
1237
- 'id' => 'enable_reset_password_limit',
1238
- 'type' => 'checkbox',
1239
- 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
1240
- ),
1241
- array(
1242
- 'id' => 'reset_password_limit_number',
1243
- 'type' => 'text',
1244
- 'label' => __( 'Reset Password Limit', 'ultimate-member' ),
1245
- 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
1246
- 'validate' => 'numeric',
1247
- 'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
1248
- 'size' => 'small',
1249
- ),
1250
- array(
1251
- 'id' => 'blocked_emails',
1252
- 'type' => 'textarea',
1253
- 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
1254
- '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' ),
1255
- ),
1256
- array(
1257
- 'id' => 'blocked_words',
1258
- 'type' => 'textarea',
1259
- 'label' => __( 'Blacklist Words', 'ultimate-member' ),
1260
- 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
1261
- ),
1262
- ),
1263
- ),
1264
- ),
1265
- ),
1266
- 'email' => array(
1267
- 'title' => __( 'Email', 'ultimate-member' ),
1268
- 'fields' => array(
1269
- array(
1270
- 'id' => 'admin_email',
1271
- 'type' => 'text',
1272
- 'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
1273
- 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1274
- ),
1275
- array(
1276
- 'id' => 'mail_from',
1277
- 'type' => 'text',
1278
- 'label' => __( 'Mail appears from', 'ultimate-member' ),
1279
- 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
1280
- ),
1281
- array(
1282
- 'id' => 'mail_from_addr',
1283
- 'type' => 'text',
1284
- 'label' => __( 'Mail appears from address', 'ultimate-member' ),
1285
- 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1286
- ),
1287
- array(
1288
- 'id' => 'email_html',
1289
- 'type' => 'checkbox',
1290
- 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
1291
- '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' ),
1292
- ),
1293
- ),
1294
- ),
1295
- 'appearance' => array(
1296
- 'title' => __( 'Appearance', 'ultimate-member' ),
1297
- 'sections' => array(
1298
- '' => array(
1299
- 'title' => __( 'Profile', 'ultimate-member' ),
1300
- 'fields' => array(
1301
- array(
1302
- 'id' => 'profile_template',
1303
- 'type' => 'select',
1304
- 'label' => __( 'Profile Default Template', 'ultimate-member' ),
1305
- 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
1306
- 'default' => um_get_metadefault( 'profile_template' ),
1307
- 'options' => UM()->shortcodes()->get_templates( 'profile' ),
1308
- 'size' => 'small',
1309
- ),
1310
- array(
1311
- 'id' => 'profile_max_width',
1312
- 'type' => 'text',
1313
- 'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
1314
- 'default' => um_get_metadefault( 'profile_max_width' ),
1315
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1316
- 'size' => 'small',
1317
- ),
1318
- array(
1319
- 'id' => 'profile_area_max_width',
1320
- 'type' => 'text',
1321
- 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
1322
- 'default' => um_get_metadefault( 'profile_area_max_width' ),
1323
- 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
1324
- 'size' => 'small',
1325
- ),
1326
- array(
1327
- 'id' => 'profile_icons',
1328
- 'type' => 'select',
1329
- 'label' => __( 'Profile Field Icons', 'ultimate-member' ),
1330
- 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
1331
- 'default' => um_get_metadefault( 'profile_icons' ),
1332
- 'options' => array(
1333
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1334
- 'label' => __( 'Show with label', 'ultimate-member' ),
1335
- 'off' => __( 'Turn off', 'ultimate-member' ),
1336
- ),
1337
- 'size' => 'small',
1338
- ),
1339
- array(
1340
- 'id' => 'profile_primary_btn_word',
1341
- 'type' => 'text',
1342
- 'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
1343
- 'default' => um_get_metadefault( 'profile_primary_btn_word' ),
1344
- 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
1345
- 'size' => 'medium',
1346
- ),
1347
- array(
1348
- 'id' => 'profile_secondary_btn',
1349
- 'type' => 'checkbox',
1350
- 'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
1351
- 'default' => um_get_metadefault( 'profile_secondary_btn' ),
1352
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1353
- ),
1354
- array(
1355
- 'id' => 'profile_secondary_btn_word',
1356
- 'type' => 'text',
1357
- 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
1358
- 'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
1359
- 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
1360
- 'conditional' => array( 'profile_secondary_btn', '=', 1 ),
1361
- 'size' => 'medium',
1362
- ),
1363
- array(
1364
- 'id' => 'default_avatar',
1365
- 'type' => 'media',
1366
- 'label' => __( 'Default Profile Photo', 'ultimate-member' ),
1367
- 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
1368
- 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
1369
- 'default' => array(
1370
- 'url' => um_url . 'assets/img/default_avatar.jpg',
1371
- ),
1372
- ),
1373
- array(
1374
- 'id' => 'default_cover',
1375
- 'type' => 'media',
1376
- 'url' => true,
1377
- 'preview' => false,
1378
- 'label' => __( 'Default Cover Photo', 'ultimate-member' ),
1379
- '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' ),
1380
- 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
1381
- ),
1382
- array(
1383
- 'id' => 'disable_profile_photo_upload',
1384
- 'type' => 'checkbox',
1385
- 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
1386
- 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
1387
- 'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
1388
- ),
1389
- array(
1390
- 'id' => 'profile_photosize',
1391
- 'type' => 'select',
1392
- 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
1393
- 'default' => um_get_metadefault( 'profile_photosize' ),
1394
- 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
1395
- 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1396
- 'size' => 'small',
1397
- ),
1398
- array(
1399
- 'id' => 'profile_cover_enabled',
1400
- 'type' => 'checkbox',
1401
- 'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
1402
- 'default' => um_get_metadefault( 'profile_cover_enabled' ),
1403
- 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
1404
- ),
1405
- array(
1406
- 'id' => 'profile_coversize',
1407
- 'type' => 'select',
1408
- 'label' => __( 'Profile Cover Size', 'ultimate-member' ),
1409
- 'default' => um_get_metadefault( 'profile_coversize' ),
1410
- 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
1411
- 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1412
- 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1413
- 'size' => 'small',
1414
- ),
1415
- array(
1416
- 'id' => 'profile_cover_ratio',
1417
- 'type' => 'select',
1418
- 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
1419
- 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
1420
- 'default' => um_get_metadefault( 'profile_cover_ratio' ),
1421
- 'options' => array(
1422
- '1.6:1' => '1.6:1',
1423
- '2.7:1' => '2.7:1',
1424
- '2.2:1' => '2.2:1',
1425
- '3.2:1' => '3.2:1',
1426
- ),
1427
- 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1428
- 'size' => 'small',
1429
- ),
1430
- array(
1431
- 'id' => 'profile_show_metaicon',
1432
- 'type' => 'checkbox',
1433
- 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
1434
- 'default' => 0,
1435
- 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
1436
- ),
1437
- array(
1438
- 'id' => 'profile_show_name',
1439
- 'type' => 'checkbox',
1440
- 'label' => __( 'Show display name in profile header', 'ultimate-member' ),
1441
- 'default' => um_get_metadefault( 'profile_show_name' ),
1442
- 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
1443
- ),
1444
- array(
1445
- 'id' => 'profile_show_social_links',
1446
- 'type' => 'checkbox',
1447
- 'label' => __( 'Show social links in profile header', 'ultimate-member' ),
1448
- 'default' => um_get_metadefault( 'profile_show_social_links' ),
1449
- 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
1450
- ),
1451
- array(
1452
- 'id' => 'profile_show_bio',
1453
- 'type' => 'checkbox',
1454
- 'label' => __( 'Show user description in header', 'ultimate-member' ),
1455
- 'default' => um_get_metadefault( 'profile_show_bio' ),
1456
- 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
1457
- ),
1458
- array(
1459
- 'id' => 'profile_show_html_bio',
1460
- 'type' => 'checkbox',
1461
- 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
1462
- 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
1463
- ),
1464
- array(
1465
- 'id' => 'profile_bio_maxchars',
1466
- 'type' => 'text',
1467
- 'label' => __( 'User description maximum chars', 'ultimate-member' ),
1468
- 'default' => um_get_metadefault( 'profile_bio_maxchars' ),
1469
- 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
1470
- 'conditional' => array( 'profile_show_bio', '=', 1 ),
1471
- 'size' => 'small',
1472
- ),
1473
- array(
1474
- 'id' => 'profile_header_menu',
1475
- 'type' => 'select',
1476
- 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
1477
- 'default' => um_get_metadefault( 'profile_header_menu' ),
1478
- 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
1479
- 'options' => array(
1480
- 'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
1481
- 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
1482
- ),
1483
- 'size' => 'small',
1484
- ),
1485
- array(
1486
- 'id' => 'profile_empty_text',
1487
- 'type' => 'checkbox',
1488
- 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
1489
- 'default' => um_get_metadefault( 'profile_empty_text' ),
1490
- 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
1491
- ),
1492
- array(
1493
- 'id' => 'profile_empty_text_emo',
1494
- 'type' => 'checkbox',
1495
- 'label' => __( 'Show the emoticon', 'ultimate-member' ),
1496
- 'default' => um_get_metadefault( 'profile_empty_text_emo' ),
1497
- 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
1498
- 'conditional' => array( 'profile_empty_text', '=', 1 ),
1499
- ),
1500
- ),
1501
- ),
1502
- 'profile_menu' => array(
1503
- 'title' => __( 'Profile Menu', 'ultimate-member' ),
1504
- 'fields' => $appearances_profile_menu_fields,
1505
- ),
1506
- 'registration_form' => array(
1507
- 'title' => __( 'Registration Form', 'ultimate-member' ),
1508
- 'fields' => array(
1509
- array(
1510
- 'id' => 'register_template',
1511
- 'type' => 'select',
1512
- 'label' => __( 'Registration Default Template', 'ultimate-member' ),
1513
- 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
1514
- 'default' => um_get_metadefault( 'register_template' ),
1515
- 'options' => UM()->shortcodes()->get_templates( 'register' ),
1516
- 'size' => 'small',
1517
- ),
1518
- array(
1519
- 'id' => 'register_max_width',
1520
- 'type' => 'text',
1521
- 'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
1522
- 'default' => um_get_metadefault( 'register_max_width' ),
1523
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1524
- 'size' => 'small',
1525
- ),
1526
- array(
1527
- 'id' => 'register_align',
1528
- 'type' => 'select',
1529
- 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
1530
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1531
- 'default' => um_get_metadefault( 'register_align' ),
1532
- 'options' => array(
1533
- 'center' => __( 'Centered', 'ultimate-member' ),
1534
- 'left' => __( 'Left aligned', 'ultimate-member' ),
1535
- 'right' => __( 'Right aligned', 'ultimate-member' ),
1536
- ),
1537
- 'size' => 'small',
1538
- ),
1539
- array(
1540
- 'id' => 'register_icons',
1541
- 'type' => 'select',
1542
- 'label' => __( 'Registration Field Icons', 'ultimate-member' ),
1543
- 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
1544
- 'default' => um_get_metadefault( 'register_icons' ),
1545
- 'options' => array(
1546
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1547
- 'label' => __( 'Show with label', 'ultimate-member' ),
1548
- 'off' => __( 'Turn off', 'ultimate-member' ),
1549
- ),
1550
- 'size' => 'small',
1551
- ),
1552
- array(
1553
- 'id' => 'register_primary_btn_word',
1554
- 'type' => 'text',
1555
- 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
1556
- 'default' => um_get_metadefault( 'register_primary_btn_word' ),
1557
- 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1558
- 'size' => 'medium',
1559
- ),
1560
- array(
1561
- 'id' => 'register_secondary_btn',
1562
- 'type' => 'checkbox',
1563
- 'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
1564
- 'default' => 1,
1565
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1566
- ),
1567
- array(
1568
- 'id' => 'register_secondary_btn_word',
1569
- 'type' => 'text',
1570
- 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
1571
- 'default' => um_get_metadefault( 'register_secondary_btn_word' ),
1572
- 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1573
- 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1574
- 'size' => 'medium',
1575
- ),
1576
- array(
1577
- 'id' => 'register_secondary_btn_url',
1578
- 'type' => 'text',
1579
- 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
1580
- 'default' => um_get_metadefault( 'register_secondary_btn_url' ),
1581
- 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1582
- 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1583
- 'size' => 'medium',
1584
- ),
1585
- array(
1586
- 'id' => 'register_role',
1587
- 'type' => 'select',
1588
- 'label' => __( 'Registration Default Role', 'ultimate-member' ),
1589
- 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
1590
- 'default' => um_get_metadefault( 'register_role' ),
1591
- 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
1592
- 'size' => 'small',
1593
- ),
1594
- ),
1595
- ),
1596
- 'login_form' => array(
1597
- 'title' => __( 'Login Form', 'ultimate-member' ),
1598
- 'fields' => array(
1599
- array(
1600
- 'id' => 'login_template',
1601
- 'type' => 'select',
1602
- 'label' => __( 'Login Default Template', 'ultimate-member' ),
1603
- 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
1604
- 'default' => um_get_metadefault( 'login_template' ),
1605
- 'options' => UM()->shortcodes()->get_templates( 'login' ),
1606
- 'size' => 'small',
1607
- ),
1608
- array(
1609
- 'id' => 'login_max_width',
1610
- 'type' => 'text',
1611
- 'label' => __( 'Login Maximum Width', 'ultimate-member' ),
1612
- 'default' => um_get_metadefault( 'login_max_width' ),
1613
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1614
- 'size' => 'small',
1615
- ),
1616
- array(
1617
- 'id' => 'login_align',
1618
- 'type' => 'select',
1619
- 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
1620
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1621
- 'default' => um_get_metadefault( 'login_align' ),
1622
- 'options' => array(
1623
- 'center' => __( 'Centered', 'ultimate-member' ),
1624
- 'left' => __( 'Left aligned', 'ultimate-member' ),
1625
- 'right' => __( 'Right aligned', 'ultimate-member' ),
1626
- ),
1627
- 'size' => 'small',
1628
- ),
1629
- array(
1630
- 'id' => 'login_icons',
1631
- 'type' => 'select',
1632
- 'label' => __( 'Login Field Icons', 'ultimate-member' ),
1633
- 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
1634
- 'default' => um_get_metadefault( 'login_icons' ),
1635
- 'options' => array(
1636
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1637
- 'label' => __( 'Show with label', 'ultimate-member' ),
1638
- 'off' => __( 'Turn off', 'ultimate-member' ),
1639
- ),
1640
- 'size' => 'small',
1641
- ),
1642
- array(
1643
- 'id' => 'login_primary_btn_word',
1644
- 'type' => 'text',
1645
- 'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
1646
- 'default' => um_get_metadefault( 'login_primary_btn_word' ),
1647
- 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1648
- 'size' => 'medium',
1649
- ),
1650
- array(
1651
- 'id' => 'login_secondary_btn',
1652
- 'type' => 'checkbox',
1653
- 'label' => __( 'Login Secondary Button', 'ultimate-member' ),
1654
- 'default' => 1,
1655
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1656
- ),
1657
- array(
1658
- 'id' => 'login_secondary_btn_word',
1659
- 'type' => 'text',
1660
- 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
1661
- 'default' => um_get_metadefault( 'login_secondary_btn_word' ),
1662
- 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1663
- 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1664
- 'size' => 'medium',
1665
- ),
1666
- array(
1667
- 'id' => 'login_secondary_btn_url',
1668
- 'type' => 'text',
1669
- 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
1670
- 'default' => um_get_metadefault( 'login_secondary_btn_url' ),
1671
- 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1672
- 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1673
- 'size' => 'medium',
1674
- ),
1675
- array(
1676
- 'id' => 'login_forgot_pass_link',
1677
- 'type' => 'checkbox',
1678
- 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
1679
- 'default' => 1,
1680
- 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
1681
- ),
1682
- array(
1683
- 'id' => 'login_show_rememberme',
1684
- 'type' => 'checkbox',
1685
- 'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
1686
- 'default' => 1,
1687
- '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' ),
1688
- ),
1689
- ),
1690
- ),
1691
- ),
1692
- ),
1693
- 'extensions' => array(
1694
- 'title' => __( 'Extensions', 'ultimate-member' ),
1695
- ),
1696
- 'licenses' => array(
1697
- 'title' => __( 'Licenses', 'ultimate-member' ),
1698
- ),
1699
- 'misc' => array(
1700
- 'title' => __( 'Misc', 'ultimate-member' ),
1701
- 'fields' => array(
1702
- array(
1703
- 'id' => 'form_asterisk',
1704
- 'type' => 'checkbox',
1705
- 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
1706
- ),
1707
- array(
1708
- 'id' => 'profile_title',
1709
- 'type' => 'text',
1710
- 'label' => __( 'User Profile Title', 'ultimate-member' ),
1711
- 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
1712
- 'size' => 'medium',
1713
- ),
1714
- array(
1715
- 'id' => 'profile_desc',
1716
- 'type' => 'textarea',
1717
- 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
1718
- 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
1719
- 'args' => array(
1720
- 'textarea_rows' => 6,
1721
- ),
1722
- ),
1723
- array(
1724
- 'id' => 'um_profile_object_cache_stop',
1725
- 'type' => 'checkbox',
1726
- 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
1727
- 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
1728
- ),
1729
- array(
1730
- 'id' => 'enable_blocks',
1731
- 'type' => 'checkbox',
1732
- 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
1733
- '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' ),
1734
- ),
1735
- array(
1736
- 'id' => 'rest_api_version',
1737
- 'type' => 'select',
1738
- 'label' => __( 'REST API version', 'ultimate-member' ),
1739
- 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
1740
- 'options' => array(
1741
- '1.0' => __( '1.0 version', 'ultimate-member' ),
1742
- '2.0' => __( '2.0 version', 'ultimate-member' ),
1743
- ),
1744
- ),
1745
- $same_page_update,
1746
- array(
1747
- 'id' => 'uninstall_on_delete',
1748
- 'type' => 'checkbox',
1749
- 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
1750
- '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' ),
1751
- ),
1752
- ),
1753
- ),
1754
- 'install_info' => array(
1755
- 'title' => __( 'Install Info', 'ultimate-member' ),
1756
- 'fields' => array(
1757
- array(
1758
- 'type' => 'install_info',
1759
- ),
1760
- ),
1761
- ),
1762
- )
1763
- );
1764
-
1765
- }
1766
-
1767
-
1768
- /**
1769
- * @param array $settings
1770
- *
1771
- * @return array
1772
- */
1773
- public function sorting_licenses_options( $settings ) {
1774
- //sorting licenses
1775
- if ( empty( $settings['licenses']['fields'] ) ) {
1776
- return $settings;
1777
- }
1778
-
1779
- $licenses = $settings['licenses']['fields'];
1780
- @uasort( $licenses, function( $a, $b ) {
1781
- return strnatcasecmp( $a['label'], $b['label'] );
1782
- } );
1783
- $settings['licenses']['fields'] = $licenses;
1784
-
1785
- //sorting extensions
1786
- if ( empty( $settings['extensions']['sections'] ) ) {
1787
- return $settings;
1788
- }
1789
-
1790
- $extensions = $settings['extensions']['sections'];
1791
- @uasort( $extensions, function( $a, $b ) {
1792
- return strnatcasecmp( $a['title'], $b['title'] );
1793
- } );
1794
-
1795
- $keys = array_keys( $extensions );
1796
- if ( $keys[0] !== '' ) {
1797
- $new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
1798
- $temp = $extensions[''];
1799
- $extensions[ $new_key ] = $temp;
1800
- $extensions[''] = $extensions[ $keys[0] ];
1801
- unset( $extensions[ $keys[0] ] );
1802
- @uasort( $extensions, function( $a, $b ) {
1803
- return strnatcasecmp( $a['title'], $b['title'] );
1804
- } );
1805
- }
1806
-
1807
- $settings['extensions']['sections'] = $extensions;
1808
-
1809
- return $settings;
1810
- }
1811
-
1812
-
1813
- /**
1814
- * @param $tab
1815
- * @param $section
1816
- *
1817
- * @return array
1818
- */
1819
- function get_section_fields( $tab, $section ) {
1820
-
1821
- if ( empty( $this->settings_structure[ $tab ] ) ) {
1822
- return array();
1823
- }
1824
-
1825
- if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
1826
- return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
1827
- } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
1828
- return $this->settings_structure[ $tab ]['fields'];
1829
- }
1830
-
1831
- return array();
1832
- }
1833
-
1834
-
1835
- /**
1836
- * Setup admin menu
1837
- */
1838
- function primary_admin_menu() {
1839
- add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
1840
- }
1841
-
1842
-
1843
- /**
1844
- * Settings page callback
1845
- */
1846
- function settings_page() {
1847
- $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
1848
- $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
1849
-
1850
- $settings_struct = $this->settings_structure[ $current_tab ];
1851
-
1852
- //remove not option hidden fields
1853
- if ( ! empty( $settings_struct['fields'] ) ) {
1854
- foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
1855
-
1856
- if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
1857
- unset( $settings_struct['fields'][ $field_key ] );
1858
- }
1859
-
1860
- }
1861
- }
1862
-
1863
- if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
1864
- um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
1865
- }
1866
-
1867
- if ( ! empty( $settings_struct['sections'] ) ) {
1868
- if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
1869
- um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
1870
- }
1871
- }
1872
-
1873
- echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
1874
-
1875
- echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
1876
-
1877
- /**
1878
- * UM hook
1879
- *
1880
- * @type action
1881
- * @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
1882
- * @description Show some content before settings page content
1883
- * @change_log
1884
- * ["Since: 2.0"]
1885
- * @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
1886
- * @example
1887
- * <?php
1888
- * add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
1889
- * function my_settings_page_before() {
1890
- * // your code here
1891
- * }
1892
- * ?>
1893
- */
1894
- do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
1895
-
1896
- 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 ) ) ) {
1897
-
1898
- /**
1899
- * UM hook
1900
- *
1901
- * @type action
1902
- * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1903
- * @description Show some content before section content at settings page
1904
- * @change_log
1905
- * ["Since: 2.0"]
1906
- * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1907
- * @example
1908
- * <?php
1909
- * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1910
- * function my_settings_page_before_section() {
1911
- * // your code here
1912
- * }
1913
- * ?>
1914
- */
1915
- do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1916
-
1917
- $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1918
- $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1919
-
1920
- /**
1921
- * UM hook
1922
- *
1923
- * @type filter
1924
- * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1925
- *
1926
- * @description Render settings section
1927
- * @input_vars
1928
- * [{"var":"$content","type":"string","desc":"Section content"},
1929
- * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1930
- * @change_log
1931
- * ["Since: 2.0"]
1932
- * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1933
- * @example
1934
- * <?php
1935
- * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1936
- * function my_settings_section( $content ) {
1937
- * // your code here
1938
- * return $content;
1939
- * }
1940
- * ?>
1941
- */
1942
- echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
1943
- $settings_section,
1944
- $section_fields
1945
- );
1946
-
1947
- } else { ?>
1948
-
1949
- <form method="post" action="" name="um-settings-form" id="um-settings-form">
1950
- <input type="hidden" value="save" name="um-settings-action" />
1951
-
1952
- <?php
1953
- /**
1954
- * UM hook
1955
- *
1956
- * @type action
1957
- * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1958
- * @description Show some content before section content at settings page
1959
- * @change_log
1960
- * ["Since: 2.0"]
1961
- * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1962
- * @example
1963
- * <?php
1964
- * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1965
- * function my_settings_page_before_section() {
1966
- * // your code here
1967
- * }
1968
- * ?>
1969
- */
1970
- do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1971
-
1972
- $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1973
- $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1974
-
1975
- /**
1976
- * UM hook
1977
- *
1978
- * @type filter
1979
- * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1980
- * @description Render settings section
1981
- * @input_vars
1982
- * [{"var":"$content","type":"string","desc":"Section content"},
1983
- * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1984
- * @change_log
1985
- * ["Since: 2.0"]
1986
- * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1987
- * @example
1988
- * <?php
1989
- * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1990
- * function my_settings_section( $content ) {
1991
- * // your code here
1992
- * return $content;
1993
- * }
1994
- * ?>
1995
- */
1996
- echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
1997
- $settings_section,
1998
- $section_fields
1999
- ); ?>
2000
-
2001
-
2002
- <p class="submit">
2003
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
2004
- <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2005
- <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2006
- </p>
2007
- </form>
2008
-
2009
- <?php }
2010
- }
2011
-
2012
-
2013
- /**
2014
- * Generate pages tabs
2015
- *
2016
- * @param string $page
2017
- * @return string
2018
- */
2019
- function generate_tabs_menu( $page = 'settings' ) {
2020
-
2021
- $tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
2022
-
2023
- switch( $page ) {
2024
- case 'settings':
2025
- $menu_tabs = array();
2026
- foreach ( $this->settings_structure as $slug => $tab ) {
2027
- if ( ! empty( $tab['fields'] ) ) {
2028
- foreach ( $tab['fields'] as $field_key => $field_options ) {
2029
- if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
2030
- unset( $tab['fields'][ $field_key ] );
2031
- }
2032
- }
2033
- }
2034
-
2035
- if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
2036
- $menu_tabs[ $slug ] = $tab['title'];
2037
- }
2038
- }
2039
-
2040
- $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2041
- foreach ( $menu_tabs as $name => $label ) {
2042
- $active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
2043
- $tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
2044
- $label .
2045
- '</a>';
2046
- }
2047
-
2048
- break;
2049
- default:
2050
- /**
2051
- * UM hook
2052
- *
2053
- * @type filter
2054
- * @title um_generate_tabs_menu_{$page}
2055
- * @description Generate tabs menu
2056
- * @input_vars
2057
- * [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
2058
- * @change_log
2059
- * ["Since: 2.0"]
2060
- * @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
2061
- * @example
2062
- * <?php
2063
- * add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
2064
- * function my_tabs_menu( $tabs ) {
2065
- * // your code here
2066
- * return $tabs;
2067
- * }
2068
- * ?>
2069
- */
2070
- $tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
2071
- break;
2072
- }
2073
-
2074
- return $tabs . '</h2>';
2075
- }
2076
-
2077
-
2078
- /**
2079
- * @param string $tab
2080
- *
2081
- * @return string
2082
- */
2083
- function generate_subtabs_menu( $tab = '' ) {
2084
- if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
2085
- return '';
2086
- }
2087
-
2088
- $menu_subtabs = array();
2089
- foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
2090
- $menu_subtabs[ $slug ] = $subtab['title'];
2091
- }
2092
-
2093
- $subtabs = '<div><ul class="subsubsub">';
2094
-
2095
- $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2096
- $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
2097
- foreach ( $menu_subtabs as $name => $label ) {
2098
- $active = ( $current_subtab == $name ) ? 'current' : '';
2099
- $subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '&section=' . $name ) ) ) . '" class="' . $active . '">'
2100
- . $label .
2101
- '</a> | ';
2102
- }
2103
-
2104
- return substr( $subtabs, 0, -3 ) . '</ul></div>';
2105
- }
2106
-
2107
-
2108
- /**
2109
- * Handler for settings forms
2110
- * when "Save Settings" button click
2111
- *
2112
- */
2113
- function save_settings_handler() {
2114
-
2115
- if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
2116
-
2117
- $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
2118
-
2119
- if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
2120
- // This nonce is not valid.
2121
- wp_die( __( 'Security Check', 'ultimate-member' ) );
2122
- }
2123
-
2124
- /**
2125
- * UM hook
2126
- *
2127
- * @type action
2128
- * @title um_settings_before_save
2129
- * @description Before settings save action
2130
- * @change_log
2131
- * ["Since: 2.0"]
2132
- * @usage add_action( 'um_settings_before_save', 'function_name', 10 );
2133
- * @example
2134
- * <?php
2135
- * add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
2136
- * function my_settings_before_save() {
2137
- * // your code here
2138
- * }
2139
- * ?>
2140
- */
2141
- do_action( "um_settings_before_save" );
2142
-
2143
- /**
2144
- * UM hook
2145
- *
2146
- * @type filter
2147
- * @title um_change_settings_before_save
2148
- * @description Change settings before save
2149
- * @input_vars
2150
- * [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
2151
- * @change_log
2152
- * ["Since: 2.0"]
2153
- * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
2154
- * @example
2155
- * <?php
2156
- * add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
2157
- * function my_change_settings_before_save( $settings ) {
2158
- * // your code here
2159
- * return $settings;
2160
- * }
2161
- * ?>
2162
- */
2163
- $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
2164
-
2165
- $settings = UM()->admin()->sanitize_options( $settings );
2166
-
2167
- foreach ( $settings as $key => $value ) {
2168
- UM()->options()->update( $key, $value );
2169
- }
2170
-
2171
- /**
2172
- * UM hook
2173
- *
2174
- * @type action
2175
- * @title um_settings_save
2176
- * @description After settings save action
2177
- * @change_log
2178
- * ["Since: 2.0"]
2179
- * @usage add_action( 'um_settings_save', 'function_name', 10 );
2180
- * @example
2181
- * <?php
2182
- * add_action( 'um_settings_save', 'my_settings_save', 10 );
2183
- * function my_settings_save() {
2184
- * // your code here
2185
- * }
2186
- * ?>
2187
- */
2188
- do_action( 'um_settings_save' );
2189
-
2190
- //redirect after save settings
2191
- $arg = array(
2192
- 'page' => 'um_options',
2193
- );
2194
-
2195
- if ( ! empty( $_GET['tab'] ) ) {
2196
- $arg['tab'] = sanitize_key( $_GET['tab'] );
2197
- }
2198
-
2199
- if ( ! empty( $_GET['section'] ) ) {
2200
- $arg['section'] = sanitize_key( $_GET['section'] );
2201
- }
2202
-
2203
- um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
2204
- }
2205
- }
2206
-
2207
-
2208
- function set_default_if_empty( $settings ) {
2209
- $tab = '';
2210
- if ( ! empty( $_GET['tab'] ) ) {
2211
- $tab = sanitize_key( $_GET['tab'] );
2212
- }
2213
-
2214
- $section = '';
2215
- if ( ! empty( $_GET['section'] ) ) {
2216
- $section = sanitize_key( $_GET['section'] );
2217
- }
2218
-
2219
-
2220
- if ( 'access' === $tab && empty( $section ) ) {
2221
- if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
2222
- $settings['access_exclude_uris'] = array();
2223
- }
2224
- }
2225
-
2226
- return $settings;
2227
- }
2228
-
2229
-
2230
- /**
2231
- * Remove empty values from multi text fields
2232
- *
2233
- * @param $settings
2234
- * @return array
2235
- */
2236
- function remove_empty_values( $settings ) {
2237
- $tab = '';
2238
- if ( ! empty( $_GET['tab'] ) ) {
2239
- $tab = sanitize_key( $_GET['tab'] );
2240
- }
2241
-
2242
- $section = '';
2243
- if ( ! empty( $_GET['section'] ) ) {
2244
- $section = sanitize_key( $_GET['section'] );
2245
- }
2246
-
2247
- if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
2248
- $fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
2249
- } else {
2250
- $fields = $this->settings_structure[ $tab ]['fields'];
2251
- }
2252
-
2253
- if ( empty( $fields ) ) {
2254
- return $settings;
2255
- }
2256
-
2257
-
2258
- $filtered_settings = array();
2259
- foreach ( $settings as $key => $value ) {
2260
-
2261
- $filtered_settings[ $key ] = $value;
2262
-
2263
- foreach ( $fields as $field ) {
2264
- if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
2265
- $filtered_settings[ $key ] = array_filter( $settings[ $key ] );
2266
- }
2267
- }
2268
- }
2269
-
2270
- return $filtered_settings;
2271
- }
2272
-
2273
-
2274
- /**
2275
- *
2276
- */
2277
- function check_permalinks_changes() {
2278
- if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2279
- if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
2280
- $this->need_change_permalinks = true;
2281
- }
2282
- }
2283
-
2284
- // set variable if gravatar settings were changed
2285
- // update for um_member_directory_data metakey
2286
- if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2287
- $use_gravatar = UM()->options()->get( 'use_gravatars' );
2288
- if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
2289
- $this->gravatar_changed = true;
2290
- }
2291
- }
2292
- }
2293
-
2294
-
2295
- /**
2296
- *
2297
- */
2298
- function on_settings_save() {
2299
- if ( ! empty( $_POST['um_options'] ) ) {
2300
-
2301
- if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
2302
- $post_ids = new \WP_Query( array(
2303
- 'post_type' => 'page',
2304
- 'meta_query' => array(
2305
- array(
2306
- 'key' => '_um_core',
2307
- 'compare' => 'EXISTS'
2308
- )
2309
- ),
2310
- 'posts_per_page' => -1,
2311
- 'fields' => 'ids'
2312
- ) );
2313
-
2314
- $post_ids = $post_ids->get_posts();
2315
-
2316
- if ( ! empty( $post_ids ) ) {
2317
- foreach ( $post_ids as $post_id ) {
2318
- delete_post_meta( $post_id, '_um_core' );
2319
- }
2320
- }
2321
-
2322
- foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
2323
- $slug = str_replace( 'core_', '', $option_slug );
2324
- update_post_meta( $post_id, '_um_core', $slug );
2325
- }
2326
-
2327
- // reset rewrite rules after re-save pages
2328
- UM()->rewrite()->reset_rules();
2329
-
2330
- } elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2331
- if ( ! empty( $this->need_change_permalinks ) ) {
2332
- $users = get_users( array(
2333
- 'fields' => 'ids',
2334
- ) );
2335
- if ( ! empty( $users ) ) {
2336
- foreach ( $users as $user_id ) {
2337
- UM()->user()->generate_profile_slug( $user_id );
2338
- }
2339
- }
2340
- }
2341
-
2342
-
2343
- // update for um_member_directory_data metakey
2344
- if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2345
- if ( $this->gravatar_changed ) {
2346
- global $wpdb;
2347
-
2348
- if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
2349
-
2350
- $results = $wpdb->get_col(
2351
- "SELECT u.ID FROM {$wpdb->users} AS u
2352
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
2353
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2354
- WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
2355
- um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
2356
- );
2357
-
2358
- } else {
2359
-
2360
- $results = $wpdb->get_col(
2361
- "SELECT u.ID FROM {$wpdb->users} AS u
2362
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
2363
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2364
- WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
2365
- um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
2366
- );
2367
-
2368
- }
2369
-
2370
- if ( ! empty( $results ) ) {
2371
- foreach ( $results as $user_id ) {
2372
- $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2373
- if ( ! empty( $md_data ) ) {
2374
- $md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
2375
- update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2376
- }
2377
- }
2378
- }
2379
- }
2380
- }
2381
-
2382
- } elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
2383
- if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
2384
- global $wpdb;
2385
-
2386
- $results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
2387
-
2388
- if ( ! empty( $results ) ) {
2389
- $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
2390
- }
2391
-
2392
- update_option( 'um_member_directory_truncated', time() );
2393
- }
2394
- } elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
2395
-
2396
- global $wpdb;
2397
-
2398
- if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
2399
-
2400
- $results = $wpdb->get_col(
2401
- "SELECT u.ID FROM {$wpdb->users} AS u
2402
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2403
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2404
- WHERE um.meta_value IS NULL AND
2405
- um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
2406
- );
2407
-
2408
- } else {
2409
-
2410
- $results = $wpdb->get_col(
2411
- "SELECT u.ID FROM {$wpdb->users} AS u
2412
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2413
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2414
- WHERE um.meta_value IS NULL AND
2415
- um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
2416
- );
2417
-
2418
- }
2419
-
2420
- if ( ! empty( $results ) ) {
2421
- foreach ( $results as $user_id ) {
2422
- $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2423
- if ( ! empty( $md_data ) ) {
2424
- $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
2425
- update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2426
- }
2427
- }
2428
- }
2429
-
2430
- }
2431
- }
2432
- }
2433
-
2434
-
2435
- /**
2436
- *
2437
- */
2438
- function before_licenses_save() {
2439
- if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2440
- return;
2441
- }
2442
-
2443
- foreach ( $_POST['um_options'] as $key => $value ) {
2444
- $this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
2445
- }
2446
- }
2447
-
2448
-
2449
- /**
2450
- *
2451
- */
2452
- function licenses_save() {
2453
- if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2454
- return;
2455
- }
2456
-
2457
- foreach ( $_POST['um_options'] as $key => $value ) {
2458
- $key = sanitize_key( $key );
2459
- $value = sanitize_text_field( $value );
2460
-
2461
- $edd_action = '';
2462
- $license_key = '';
2463
- if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
2464
- $edd_action = 'activate_license';
2465
- $license_key = $value;
2466
- } elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
2467
- $edd_action = 'deactivate_license';
2468
- $license_key = $this->previous_licenses[ $key ];
2469
- } elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
2470
- $edd_action = 'check_license';
2471
- $license_key = $value;
2472
- }
2473
-
2474
- if ( empty( $edd_action ) ) {
2475
- continue;
2476
- }
2477
-
2478
- $item_name = false;
2479
- $version = false;
2480
- $author = false;
2481
- foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
2482
- if ( $field_data['id'] == $key ) {
2483
- $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
2484
- $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
2485
- $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
2486
- }
2487
- }
2488
-
2489
- $api_params = array(
2490
- 'edd_action' => $edd_action,
2491
- 'license' => $license_key,
2492
- 'item_name' => $item_name,
2493
- 'version' => $version,
2494
- 'author' => $author,
2495
- 'url' => home_url(),
2496
- );
2497
-
2498
- $request = wp_remote_post(
2499
- UM()->store_url,
2500
- array(
2501
- 'timeout' => UM()->request_timeout,
2502
- 'sslverify' => false,
2503
- 'body' => $api_params
2504
- )
2505
- );
2506
-
2507
- if ( ! is_wp_error( $request ) ) {
2508
- $request = json_decode( wp_remote_retrieve_body( $request ) );
2509
- } else {
2510
- $request = wp_remote_post(
2511
- UM()->store_url,
2512
- array(
2513
- 'timeout' => UM()->request_timeout,
2514
- 'sslverify' => true,
2515
- 'body' => $api_params
2516
- )
2517
- );
2518
-
2519
- if ( ! is_wp_error( $request ) ) {
2520
- $request = json_decode( wp_remote_retrieve_body( $request ) );
2521
- }
2522
- }
2523
-
2524
- $request = ( $request ) ? maybe_unserialize( $request ) : false;
2525
-
2526
- if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
2527
- update_option( "{$key}_edd_answer", $request );
2528
- } else {
2529
- delete_option( "{$key}_edd_answer" );
2530
- }
2531
-
2532
- }
2533
- }
2534
-
2535
-
2536
- /**
2537
- *
2538
- */
2539
- function settings_before_email_tab() {
2540
- $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2541
- $emails = UM()->config()->email_notifications;
2542
-
2543
- if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2544
- include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
2545
- }
2546
- }
2547
-
2548
-
2549
- /**
2550
- * @param $section
2551
- *
2552
- * @return string
2553
- */
2554
- function settings_email_tab( $section ) {
2555
- $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2556
- $emails = UM()->config()->email_notifications;
2557
-
2558
- if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2559
- return $section;
2560
- }
2561
-
2562
- $in_theme = UM()->mail()->template_in_theme( $email_key );
2563
-
2564
- /**
2565
- * UM hook
2566
- *
2567
- * @type filter
2568
- * @title um_admin_settings_email_section_fields
2569
- * @description Extend UM Email Settings
2570
- * @input_vars
2571
- * [{"var":"$settings","type":"array","desc":"UM Email Settings"},
2572
- * {"var":"$email_key","type":"string","desc":"Email Key"}]
2573
- * @change_log
2574
- * ["Since: 2.0"]
2575
- * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
2576
- * @example
2577
- * <?php
2578
- * add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
2579
- * function my_admin_settings_email_section( $settings, $email_key ) {
2580
- * // your code here
2581
- * return $settings;
2582
- * }
2583
- * ?>
2584
- */
2585
- $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
2586
- array(
2587
- 'id' => 'um_email_template',
2588
- 'type' => 'hidden',
2589
- 'value' => $email_key,
2590
- ),
2591
- array(
2592
- 'id' => $email_key . '_on',
2593
- 'type' => 'checkbox',
2594
- 'label' => $emails[ $email_key ]['title'],
2595
- 'tooltip' => $emails[ $email_key ]['description'],
2596
- ),
2597
- array(
2598
- 'id' => $email_key . '_sub',
2599
- 'type' => 'text',
2600
- 'label' => __( 'Subject Line', 'ultimate-member' ),
2601
- 'conditional' => array( $email_key . '_on', '=', 1 ),
2602
- 'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
2603
- ),
2604
- array(
2605
- 'id' => $email_key,
2606
- 'type' => 'email_template',
2607
- 'label' => __( 'Message Body', 'ultimate-member' ),
2608
- 'conditional' => array( $email_key . '_on', '=', 1 ),
2609
- 'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
2610
- 'value' => UM()->mail()->get_email_template( $email_key ),
2611
- 'in_theme' => $in_theme
2612
- ),
2613
- ), $email_key );
2614
-
2615
- return $this->render_settings_section( $section_fields, 'email', $email_key );
2616
- }
2617
-
2618
-
2619
- /**
2620
- *
2621
- */
2622
- function settings_appearance_profile_tab() {
2623
- wp_enqueue_media();
2624
- }
2625
-
2626
-
2627
- /**
2628
- * @param $html
2629
- * @param $section_fields
2630
- *
2631
- * @return string
2632
- */
2633
- function settings_licenses_tab( $html, $section_fields ) {
2634
- ob_start(); ?>
2635
-
2636
- <div class="wrap-licenses">
2637
- <input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
2638
- <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2639
- <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2640
- <table class="form-table um-settings-section">
2641
- <tbody>
2642
- <?php foreach ( $section_fields as $field_data ) {
2643
- $option_value = UM()->options()->get( $field_data['id'] );
2644
- $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
2645
-
2646
- $license = get_option( "{$field_data['id']}_edd_answer" );
2647
-
2648
- if ( is_object( $license ) && ! empty( $value ) ) {
2649
- // activate_license 'invalid' on anything other than valid, so if there was an error capture it
2650
- if ( empty( $license->success ) ) {
2651
-
2652
- if ( ! empty( $license->error ) ) {
2653
- switch ( $license->error ) {
2654
-
2655
- case 'expired' :
2656
-
2657
- $class = 'expired';
2658
- $messages[] = sprintf(
2659
- __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2660
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2661
- 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2662
- );
2663
-
2664
- $license_status = 'license-' . $class . '-notice';
2665
-
2666
- break;
2667
-
2668
- case 'revoked' :
2669
-
2670
- $class = 'error';
2671
- $messages[] = sprintf(
2672
- __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2673
- 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2674
- );
2675
-
2676
- $license_status = 'license-' . $class . '-notice';
2677
-
2678
- break;
2679
-
2680
- case 'missing' :
2681
-
2682
- $class = 'error';
2683
- $messages[] = sprintf(
2684
- __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2685
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2686
- );
2687
-
2688
- $license_status = 'license-' . $class . '-notice';
2689
-
2690
- break;
2691
-
2692
- case 'invalid' :
2693
- case 'site_inactive' :
2694
-
2695
- $class = 'error';
2696
- $messages[] = sprintf(
2697
- __( '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' ),
2698
- $field_data['item_name'],
2699
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2700
- );
2701
-
2702
- $license_status = 'license-' . $class . '-notice';
2703
-
2704
- break;
2705
-
2706
- case 'item_name_mismatch' :
2707
-
2708
- $class = 'error';
2709
- $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2710
-
2711
- $license_status = 'license-' . $class . '-notice';
2712
-
2713
- break;
2714
-
2715
- case 'no_activations_left':
2716
-
2717
- $class = 'error';
2718
- $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2719
-
2720
- $license_status = 'license-' . $class . '-notice';
2721
-
2722
- break;
2723
-
2724
- case 'license_not_activable':
2725
-
2726
- $class = 'error';
2727
- $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2728
-
2729
- $license_status = 'license-' . $class . '-notice';
2730
- break;
2731
-
2732
- default :
2733
-
2734
- $class = 'error';
2735
- $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2736
- $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' );
2737
-
2738
- $license_status = 'license-' . $class . '-notice';
2739
- break;
2740
- }
2741
- } else {
2742
- $class = 'error';
2743
- $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2744
- $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' );
2745
-
2746
- $license_status = 'license-' . $class . '-notice';
2747
- }
2748
-
2749
- } elseif ( ! empty( $license->errors ) ) {
2750
-
2751
- $errors = array_keys( $license->errors );
2752
- $errors_data = array_values( $license->errors );
2753
-
2754
- $class = 'error';
2755
- $error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
2756
- $errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
2757
- $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' );
2758
-
2759
- $license_status = 'license-' . $class . '-notice';
2760
-
2761
- } else {
2762
-
2763
- switch( $license->license ) {
2764
-
2765
- case 'expired' :
2766
-
2767
- $class = 'expired';
2768
- $messages[] = sprintf(
2769
- __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2770
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2771
- 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2772
- );
2773
-
2774
- $license_status = 'license-' . $class . '-notice';
2775
-
2776
- break;
2777
-
2778
- case 'revoked' :
2779
-
2780
- $class = 'error';
2781
- $messages[] = sprintf(
2782
- __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2783
- 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2784
- );
2785
-
2786
- $license_status = 'license-' . $class . '-notice';
2787
-
2788
- break;
2789
-
2790
- case 'missing' :
2791
-
2792
- $class = 'error';
2793
- $messages[] = sprintf(
2794
- __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2795
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2796
- );
2797
-
2798
- $license_status = 'license-' . $class . '-notice';
2799
-
2800
- break;
2801
-
2802
- case 'invalid' :
2803
- case 'site_inactive' :
2804
-
2805
- $class = 'error';
2806
- $messages[] = sprintf(
2807
- __( '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' ),
2808
- $field_data['item_name'],
2809
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2810
- );
2811
-
2812
- $license_status = 'license-' . $class . '-notice';
2813
-
2814
- break;
2815
-
2816
- case 'item_name_mismatch' :
2817
-
2818
- $class = 'error';
2819
- $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2820
-
2821
- $license_status = 'license-' . $class . '-notice';
2822
-
2823
- break;
2824
-
2825
- case 'no_activations_left':
2826
-
2827
- $class = 'error';
2828
- $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2829
-
2830
- $license_status = 'license-' . $class . '-notice';
2831
-
2832
- break;
2833
-
2834
- case 'license_not_activable':
2835
-
2836
- $class = 'error';
2837
- $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2838
-
2839
- $license_status = 'license-' . $class . '-notice';
2840
- break;
2841
-
2842
- case 'valid' :
2843
- default:
2844
-
2845
- $class = 'valid';
2846
-
2847
- $now = current_time( 'timestamp' );
2848
- $expiration = strtotime( $license->expires, $now );
2849
-
2850
- if( 'lifetime' === $license->expires ) {
2851
-
2852
- $messages[] = __( 'License key never expires.', 'ultimate-member' );
2853
-
2854
- $license_status = 'license-lifetime-notice';
2855
-
2856
- } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
2857
-
2858
- $messages[] = sprintf(
2859
- __( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
2860
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2861
- 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
2862
- );
2863
-
2864
- $license_status = 'license-expires-soon-notice';
2865
-
2866
- } else {
2867
-
2868
- $messages[] = sprintf(
2869
- __( 'Your license key expires on %s.', 'ultimate-member' ),
2870
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
2871
- );
2872
-
2873
- $license_status = 'license-expiration-date-notice';
2874
-
2875
- }
2876
-
2877
- break;
2878
-
2879
- }
2880
-
2881
- }
2882
-
2883
- } else {
2884
- $class = 'empty';
2885
-
2886
- $messages[] = sprintf(
2887
- __( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
2888
- $field_data['item_name']
2889
- );
2890
-
2891
- $license_status = null;
2892
-
2893
- } ?>
2894
-
2895
- <tr class="um-settings-line">
2896
- <th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
2897
- <td>
2898
- <form method="post" action="" name="um-settings-form" class="um-settings-form">
2899
- <input type="hidden" value="save" name="um-settings-action" />
2900
- <input type="hidden" name="licenses_settings" value="1" />
2901
- <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2902
- <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2903
- <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'] ) ?>" />
2904
- <?php if ( ! empty( $field_data['description'] ) ) { ?>
2905
- <div class="description"><?php echo $field_data['description'] ?></div>
2906
- <?php } ?>
2907
-
2908
- <?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
2909
- <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' ) ?>"/>
2910
- <?php } elseif ( empty( $value ) ) { ?>
2911
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
2912
- <?php } else { ?>
2913
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
2914
- <?php }
2915
-
2916
- if ( ! empty( $messages ) ) {
2917
- foreach ( $messages as $message ) { ?>
2918
- <div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
2919
- <p><?php echo $message ?></p>
2920
- </div>
2921
- <?php }
2922
- } ?>
2923
- </form>
2924
- </td>
2925
- </tr>
2926
- <?php } ?>
2927
- </tbody>
2928
- </table>
2929
- </div>
2930
- <?php $section = ob_get_clean();
2931
-
2932
- return $section;
2933
- }
2934
-
2935
-
2936
- /**
2937
- * @param $html
2938
- * @param $section_fields
2939
- */
2940
- function settings_install_info_tab( $html, $section_fields ) {
2941
- global $wpdb;
2942
-
2943
- if ( ! class_exists( '\Browser' ) )
2944
- require_once um_path . 'includes/lib/browser.php';
2945
-
2946
- // Detect browser
2947
- $browser = new \Browser();
2948
-
2949
- // Get theme info
2950
- $theme_data = wp_get_theme();
2951
- $theme = $theme_data->Name . ' ' . $theme_data->Version;
2952
-
2953
- // Identify Hosting Provider
2954
- $host = um_get_host();
2955
-
2956
- um_fetch_user( get_current_user_id() );
2957
-
2958
- if ( isset( $this->content ) ) {
2959
- echo $this->content;
2960
- } else { ?>
2961
-
2962
- <h3>Install Info</h3>
2963
-
2964
- <form action="" method="post" dir="ltr">
2965
- <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' ); ?>">
2966
- ### Begin Install Info ###
2967
-
2968
- ## Please include this information when posting support requests ##
2969
-
2970
- <?php
2971
- /**
2972
- * UM hook
2973
- *
2974
- * @type action
2975
- * @title um_install_info_before
2976
- * @description Before install info settings
2977
- * @change_log
2978
- * ["Since: 2.0"]
2979
- * @usage add_action( 'um_install_info_before', 'function_name', 10 );
2980
- * @example
2981
- * <?php
2982
- * add_action( 'um_install_info_before', 'my_install_info_before', 10 );
2983
- * function my_install_info_before() {
2984
- * // your code here
2985
- * }
2986
- * ?>
2987
- */
2988
- do_action( 'um_install_info_before' ); ?>
2989
-
2990
- --- Site Info ---
2991
-
2992
- Site URL: <?php echo site_url() . "\n"; ?>
2993
- Home URL: <?php echo home_url() . "\n"; ?>
2994
- Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
2995
-
2996
- --- Hosting Provider ---
2997
-
2998
- <?php if( $host ) : ?>
2999
- Host: <?php echo $host . "\n"; ?>
3000
- <?php endif; ?>
3001
-
3002
- --- User Browser ---
3003
-
3004
- <?php echo $browser ; ?>
3005
-
3006
- ---- Current User Details --
3007
-
3008
- <?php $user = wp_get_current_user(); ?>
3009
- Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
3010
-
3011
-
3012
- --- WordPress Configurations ---
3013
-
3014
- Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
3015
- Language: <?php echo get_locale()."\n"; ?>
3016
- Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
3017
- Active Theme: <?php echo $theme . "\n"; ?>
3018
- <?php $show_on_front = get_option( 'show_on_front' ); ?>
3019
- <?php if( $show_on_front == "posts" ): ?>
3020
- Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
3021
- <?php elseif( $show_on_front == "page" ): ?>
3022
- Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3023
- Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3024
- <?php endif; ?>
3025
- ABSPATH: <?php echo ABSPATH."\n"; ?>
3026
- <?php $wp_count_posts = wp_count_posts(); ?>
3027
- All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
3028
- <?php
3029
- $request['cmd'] = '_notify-validate';
3030
-
3031
- $params = array(
3032
- 'sslverify' => false,
3033
- 'timeout' => 60,
3034
- 'user-agent' => 'UltimateMember/' . ultimatemember_version,
3035
- 'body' => $request
3036
- );
3037
-
3038
- $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
3039
-
3040
- if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
3041
- $WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
3042
- } else {
3043
- $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
3044
- }
3045
- ?>
3046
- WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
3047
- WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
3048
- 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"; ?>
3049
- Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
3050
-
3051
-
3052
- --- UM Configurations ---
3053
-
3054
- Version: <?php echo ultimatemember_version . "\n"; ?>
3055
- Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
3056
- Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
3057
- Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3058
- Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3059
- Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3060
- JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3061
- <?php if( is_multisite() ): ?>
3062
- Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
3063
- <?php endif; ?>
3064
- Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3065
- Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3066
-
3067
-
3068
- --- UM Pages Configuration ---
3069
-
3070
- <?php
3071
- /**
3072
- * UM hook
3073
- *
3074
- * @type action
3075
- * @title um_install_info_before_page_config
3076
- * @description Before page config install info
3077
- * @change_log
3078
- * ["Since: 2.0"]
3079
- * @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
3080
- * @example
3081
- * <?php
3082
- * add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
3083
- * function my_install_info_before_page_config() {
3084
- * // your code here
3085
- * }
3086
- * ?>
3087
- */
3088
- do_action( "um_install_info_before_page_config" ); ?>
3089
- User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
3090
- Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
3091
- Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
3092
- Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
3093
- Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
3094
- Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
3095
- Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
3096
- <?php
3097
- /**
3098
- * UM hook
3099
- *
3100
- * @type action
3101
- * @title um_install_info_after_page_config
3102
- * @description After page config install info
3103
- * @change_log
3104
- * ["Since: 2.0"]
3105
- * @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
3106
- * @example
3107
- * <?php
3108
- * add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
3109
- * function my_install_info_after_page_config() {
3110
- * // your code here
3111
- * }
3112
- * ?>
3113
- */
3114
- do_action( "um_install_info_after_page_config" ); ?>
3115
-
3116
-
3117
- --- UM Users Configuration ---
3118
-
3119
- Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
3120
- Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
3121
- User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
3122
- Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
3123
- Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
3124
- Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
3125
- Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
3126
- <?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
3127
- UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
3128
- Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
3129
-
3130
-
3131
- --- UM Access Configuration ---
3132
-
3133
- Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
3134
- Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
3135
- <?php if( UM()->options()->get('accessible') == 2 ) { ?>
3136
- Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
3137
- 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";?>
3138
- <?php } ?>
3139
- Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
3140
- <?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
3141
- 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"; }?>
3142
- <?php } ?>
3143
- Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
3144
- <?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
3145
- 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"; }?>
3146
- <?php } ?>
3147
- Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
3148
- Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
3149
- <?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
3150
- Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
3151
- Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
3152
- <?php } ?>
3153
- <?php $wpadmin_allow_ips = UM()->options()->get( 'wpadmin_allow_ips' ); if( ! empty( $wpadmin_allow_ips ) ) { ?>
3154
- Whitelisted Backend IPs: <?php echo count( explode("\n",trim(UM()->options()->get('wpadmin_allow_ips') ) ) )."\n"; ?>
3155
- <?php } ?>
3156
- <?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
3157
- Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
3158
- <?php } ?>
3159
- <?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
3160
- Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
3161
- <?php } ?>
3162
- <?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
3163
- Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
3164
- <?php } ?>
3165
-
3166
-
3167
- --- UM Email Configurations ---
3168
-
3169
- 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";?>
3170
- 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";?>
3171
- Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
3172
- Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
3173
- Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
3174
- Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
3175
- Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
3176
- Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
3177
- Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
3178
- Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
3179
- Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
3180
- Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
3181
-
3182
-
3183
- --- UM Total Users ---
3184
-
3185
- <?php $result = count_users();
3186
- echo 'All Users('.$result['total_users'].")\n";
3187
- foreach( $result['avail_roles'] as $role => $count ) {
3188
- echo $role."(".$count.")\n";
3189
- } ?>
3190
-
3191
-
3192
- --- UM Roles ---
3193
-
3194
- <?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
3195
- echo $role." ({$role_id})\n";
3196
- } ?>
3197
-
3198
-
3199
- --- UM Custom Templates ---
3200
-
3201
- <?php // Show templates that have been copied to the theme's edd_templates dir
3202
- $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
3203
- if ( ! empty( $dir ) ) {
3204
- $found = glob( $dir );
3205
- if ( ! empty( $found ) ) {
3206
- foreach ( glob( $dir ) as $file ) {
3207
- echo "File: " . $file . "\n";
3208
- }
3209
- } else {
3210
- echo 'N/A'."\n";
3211
- }
3212
- } ?>
3213
-
3214
-
3215
- --- UM Email HTML Templates ---
3216
-
3217
- <?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
3218
-
3219
- if ( ! empty( $dir ) ) {
3220
- $found = glob( $dir );
3221
- if ( ! empty( $found ) ){
3222
- foreach ( glob( $dir ) as $file ) {
3223
- echo "File: ". $file . "\n";
3224
- }
3225
- } else {
3226
- echo 'N/A'."\n";
3227
- }
3228
- } ?>
3229
-
3230
-
3231
- --- Web Server Configurations ---
3232
-
3233
- PHP Version: <?php echo PHP_VERSION . "\n"; ?>
3234
- MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
3235
- Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
3236
-
3237
-
3238
- --- PHP Configurations ---
3239
-
3240
- PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
3241
- PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3242
- PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
3243
- PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3244
- PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
3245
- PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
3246
- PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
3247
- PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
3248
-
3249
-
3250
- --- Web Server Extensions/Modules ---
3251
-
3252
- DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
3253
- FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
3254
- cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
3255
- 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"; ?>
3256
- SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
3257
- 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"; ?>
3258
- 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"; ?>
3259
- 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"; ?>
3260
-
3261
-
3262
- --- Session Configurations ---
3263
-
3264
- Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
3265
- Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
3266
- Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
3267
- Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
3268
- Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3269
- Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3270
-
3271
-
3272
- --- WordPress Active Plugins ---
3273
-
3274
- <?php $plugins = get_plugins();
3275
- $active_plugins = get_option( 'active_plugins', array() );
3276
-
3277
- foreach ( $plugins as $plugin_path => $plugin ) {
3278
- // If the plugin isn't active, don't show it.
3279
- if ( ! in_array( $plugin_path, $active_plugins ) )
3280
- continue;
3281
-
3282
- echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
3283
- }
3284
-
3285
- if ( is_multisite() ) { ?>
3286
-
3287
- --- WordPress Network Active Plugins ---
3288
-
3289
- <?php $plugins = wp_get_active_network_plugins();
3290
- $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
3291
-
3292
- foreach ( $plugins as $plugin_path ) {
3293
- $plugin_base = plugin_basename( $plugin_path );
3294
-
3295
- // If the plugin isn't active, don't show it.
3296
- if ( ! array_key_exists( $plugin_base, $active_plugins ) )
3297
- continue;
3298
-
3299
- $plugin = get_plugin_data( $plugin_path );
3300
-
3301
- echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
3302
- }
3303
-
3304
- }
3305
-
3306
- /**
3307
- * UM hook
3308
- *
3309
- * @type action
3310
- * @title um_install_info_after
3311
- * @description After install info
3312
- * @change_log
3313
- * ["Since: 2.0"]
3314
- * @usage add_action( 'um_install_info_after', 'function_name', 10 );
3315
- * @example
3316
- * <?php
3317
- * add_action( 'um_install_info_after', 'my_install_info_after', 10 );
3318
- * function my_install_info_after() {
3319
- * // your code here
3320
- * }
3321
- * ?>
3322
- */
3323
- do_action( 'um_install_info_after' ); ?>
3324
-
3325
- ### End Install Info ###
3326
- </textarea>
3327
- <p class="submit">
3328
- <input type="hidden" name="um-addon-hook" value="download_install_info" />
3329
- <?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
3330
- </p>
3331
- </form>
3332
-
3333
- <?php }
3334
- }
3335
-
3336
-
3337
- /**
3338
- *
3339
- */
3340
- function um_download_install_info() {
3341
- if ( ! empty( $_POST['download_install_info'] ) ) {
3342
- nocache_headers();
3343
-
3344
- header( "Content-type: text/plain" );
3345
- header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
3346
-
3347
- echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
3348
- exit;
3349
- }
3350
- }
3351
-
3352
-
3353
- /**
3354
- * @param string $raw_value
3355
- * @param string $type
3356
- * @param string $default
3357
- *
3358
- * @return string
3359
- */
3360
- function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
3361
-
3362
- if ( $type == 'yesno' ) {
3363
- $raw_value = ( $default == $raw_value ) ? "Yes" : "No";
3364
- } elseif( $type == 'onoff' ) {
3365
- $raw_value = ( $default == $raw_value ) ? "On" : "Off";
3366
- }
3367
-
3368
- return $raw_value."\n";
3369
- }
3370
-
3371
-
3372
- /**
3373
- * Render settings section
3374
- *
3375
- * @param array $section_fields
3376
- * @param string $current_tab
3377
- * @param string $current_subtab
3378
- *
3379
- * @return string
3380
- */
3381
- function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
3382
- ob_start();
3383
-
3384
- UM()->admin_forms_settings( array(
3385
- 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
3386
- 'prefix_id' => 'um_options',
3387
- 'fields' => $section_fields
3388
- ) )->render_form(); ?>
3389
-
3390
- <?php $section = ob_get_clean();
3391
-
3392
- return $section;
3393
- }
3394
-
3395
-
3396
- /**
3397
- * @param array $settings
3398
- *
3399
- * @return array
3400
- */
3401
- function save_email_templates( $settings ) {
3402
-
3403
- if ( empty( $settings['um_email_template'] ) ) {
3404
- return $settings;
3405
- }
3406
-
3407
- $template = $settings['um_email_template'];
3408
- $content = wp_kses_post( stripslashes( $settings[ $template ] ) );
3409
-
3410
- $theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
3411
-
3412
- if ( ! file_exists( $theme_template_path ) ) {
3413
- UM()->mail()->copy_email_template( $template );
3414
- }
3415
-
3416
- $fp = fopen( $theme_template_path, "w" );
3417
- $result = fputs( $fp, $content );
3418
- fclose( $fp );
3419
-
3420
- if ( $result !== false ) {
3421
- unset( $settings['um_email_template'] );
3422
- unset( $settings[ $template ] );
3423
- }
3424
-
3425
- return $settings;
3426
- }
3427
- }
3428
- }
 
 
 
 
 
 
 
 
 
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_access_post_title',
507
+ 'type' => 'text',
508
+ 'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
509
+ 'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
510
+ ),
511
+ array(
512
+ 'id' => 'restricted_access_message',
513
+ 'type' => 'wp_editor',
514
+ 'label' => __( 'Restricted Access Message', 'ultimate-member' ),
515
+ 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
516
+ ),
517
+ );
518
+
519
+ $settings_map = array_merge(
520
+ $settings_map,
521
+ array(
522
+ 'accessible' => array(
523
+ 'sanitize' => 'int',
524
+ ),
525
+ 'access_redirect' => array(
526
+ 'sanitize' => 'url',
527
+ ),
528
+ 'access_exclude_uris' => array(
529
+ 'sanitize' => 'url',
530
+ ),
531
+ 'home_page_accessible' => array(
532
+ 'sanitize' => 'bool',
533
+ ),
534
+ 'category_page_accessible' => array(
535
+ 'sanitize' => 'bool',
536
+ ),
537
+ 'restricted_access_post_title' => array(
538
+ 'sanitize' => 'text',
539
+ ),
540
+ 'restricted_access_message' => array(
541
+ 'sanitize' => 'wp_kses',
542
+ ),
543
+ )
544
+ );
545
+
546
+ global $wp_version;
547
+ if ( version_compare( $wp_version, '5.0', '>=' ) ) {
548
+ $access_fields = array_merge(
549
+ $access_fields,
550
+ array(
551
+ array(
552
+ 'id' => 'restricted_blocks',
553
+ 'type' => 'checkbox',
554
+ 'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
555
+ ),
556
+ array(
557
+ 'id' => 'restricted_block_message',
558
+ 'type' => 'textarea',
559
+ 'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
560
+ 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
561
+ 'conditional' => array( 'restricted_blocks', '=', 1 ),
562
+ ),
563
+ )
564
+ );
565
+
566
+ $settings_map['restricted_blocks'] = array(
567
+ 'sanitize' => 'bool',
568
+ );
569
+ $settings_map['restricted_block_message'] = array(
570
+ 'sanitize' => 'textarea',
571
+ );
572
+ }
573
+
574
+ $access_fields = array_merge(
575
+ $access_fields,
576
+ array(
577
+ array(
578
+ 'id' => 'restricted_access_post_metabox',
579
+ 'type' => 'hidden',
580
+ 'value' => '',
581
+ ),
582
+ array(
583
+ 'id' => 'restricted_access_taxonomy_metabox',
584
+ 'type' => 'hidden',
585
+ 'value' => '',
586
+ ),
587
+ array(
588
+ 'id' => 'restricted_access_post_metabox',
589
+ 'type' => 'multi_checkbox',
590
+ 'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
591
+ 'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
592
+ 'options' => $post_types_options,
593
+ 'columns' => 3,
594
+ 'value' => $restricted_access_post_metabox_value,
595
+ 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
596
+ ),
597
+ array(
598
+ 'id' => 'restricted_access_taxonomy_metabox',
599
+ 'type' => 'multi_checkbox',
600
+ 'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
601
+ 'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
602
+ 'options' => $taxonomies_options,
603
+ 'columns' => 3,
604
+ 'value' => $restricted_access_taxonomy_metabox_value,
605
+ 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
606
+ ),
607
+ )
608
+ );
609
+
610
+ $settings_map = array_merge(
611
+ $settings_map,
612
+ array(
613
+ 'restricted_access_post_metabox' => array(
614
+ 'sanitize' => 'key',
615
+ ),
616
+ 'restricted_access_taxonomy_metabox' => array(
617
+ 'sanitize' => 'key',
618
+ ),
619
+ )
620
+ );
621
+
622
+ $latest_update = get_option( 'um_member_directory_update_meta', false );
623
+ $latest_truncate = get_option( 'um_member_directory_truncated', false );
624
+
625
+ $same_page_update = array(
626
+ 'id' => 'member_directory_own_table',
627
+ 'type' => 'same_page_update',
628
+ 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
629
+ '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' ),
630
+ );
631
+
632
+ if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
633
+ $same_page_update['upgrade_cb'] = 'sync_metatable';
634
+ $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>
635
+ <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>
636
+ <p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
637
+ }
638
+
639
+ $settings_map = array_merge(
640
+ $settings_map,
641
+ array(
642
+ 'permalink_base' => array(
643
+ 'sanitize' => 'key',
644
+ ),
645
+ 'display_name' => array(
646
+ 'sanitize' => 'key',
647
+ ),
648
+ 'display_name_field' => array(
649
+ 'sanitize' => 'text',
650
+ ),
651
+ 'author_redirect' => array(
652
+ 'sanitize' => 'bool',
653
+ ),
654
+ 'members_page' => array(
655
+ 'sanitize' => 'bool',
656
+ ),
657
+ 'use_gravatars' => array(
658
+ 'sanitize' => 'bool',
659
+ ),
660
+ 'use_um_gravatar_default_builtin_image' => array(
661
+ 'sanitize' => 'key',
662
+ ),
663
+ 'use_um_gravatar_default_image' => array(
664
+ 'sanitize' => 'bool',
665
+ ),
666
+ 'reset_require_strongpass' => array(
667
+ 'sanitize' => 'bool',
668
+ ),
669
+ 'profile_noindex' => array(
670
+ 'sanitize' => 'bool',
671
+ ),
672
+ 'activation_link_expiry_time' => array(
673
+ 'sanitize' => 'absint',
674
+ ),
675
+ 'account_tab_password' => array(
676
+ 'sanitize' => 'bool',
677
+ ),
678
+ 'account_tab_privacy' => array(
679
+ 'sanitize' => 'bool',
680
+ ),
681
+ 'account_tab_notifications' => array(
682
+ 'sanitize' => 'bool',
683
+ ),
684
+ 'account_tab_delete' => array(
685
+ 'sanitize' => 'bool',
686
+ ),
687
+ 'delete_account_text' => array(
688
+ 'sanitize' => 'textarea',
689
+ ),
690
+ 'delete_account_no_pass_required_text' => array(
691
+ 'sanitize' => 'textarea',
692
+ ),
693
+ 'account_name' => array(
694
+ 'sanitize' => 'bool',
695
+ ),
696
+ 'account_name_disable' => array(
697
+ 'sanitize' => 'bool',
698
+ ),
699
+ 'account_name_require' => array(
700
+ 'sanitize' => 'bool',
701
+ ),
702
+ 'account_email' => array(
703
+ 'sanitize' => 'bool',
704
+ ),
705
+ 'account_general_password' => array(
706
+ 'sanitize' => 'bool',
707
+ ),
708
+ 'account_require_strongpass' => array(
709
+ 'sanitize' => 'bool',
710
+ ),
711
+ 'account_hide_in_directory' => array(
712
+ 'sanitize' => 'bool',
713
+ ),
714
+ 'account_hide_in_directory_default' => array(
715
+ 'sanitize' => 'text',
716
+ ),
717
+ 'profile_photo_max_size' => array(
718
+ 'sanitize' => 'absint',
719
+ ),
720
+ 'cover_photo_max_size' => array(
721
+ 'sanitize' => 'absint',
722
+ ),
723
+ 'photo_thumb_sizes' => array(
724
+ 'sanitize' => 'absint',
725
+ ),
726
+ 'cover_thumb_sizes' => array(
727
+ 'sanitize' => 'absint',
728
+ ),
729
+ 'image_orientation_by_exif' => array(
730
+ 'sanitize' => 'bool',
731
+ ),
732
+ 'image_compression' => array(
733
+ 'sanitize' => 'absint',
734
+ ),
735
+ 'image_max_width' => array(
736
+ 'sanitize' => 'absint',
737
+ ),
738
+ 'cover_min_width' => array(
739
+ 'sanitize' => 'absint',
740
+ ),
741
+ 'enable_reset_password_limit' => array(
742
+ 'sanitize' => 'bool',
743
+ ),
744
+ 'reset_password_limit_number' => array(
745
+ 'sanitize' => 'absint',
746
+ ),
747
+ 'blocked_emails' => array(
748
+ 'sanitize' => 'textarea',
749
+ ),
750
+ 'blocked_words' => array(
751
+ 'sanitize' => 'textarea',
752
+ ),
753
+ 'admin_email' => array(
754
+ 'sanitize' => 'text',
755
+ ),
756
+ 'mail_from' => array(
757
+ 'sanitize' => 'text',
758
+ ),
759
+ 'mail_from_addr' => array(
760
+ 'sanitize' => 'text',
761
+ ),
762
+ 'email_html' => array(
763
+ 'sanitize' => 'bool',
764
+ ),
765
+ 'profile_template' => array(
766
+ 'sanitize' => 'text',
767
+ ),
768
+ 'profile_max_width' => array(
769
+ 'sanitize' => 'text',
770
+ ),
771
+ 'profile_area_max_width' => array(
772
+ 'sanitize' => 'text',
773
+ ),
774
+ 'profile_icons' => array(
775
+ 'sanitize' => 'key',
776
+ ),
777
+ 'profile_primary_btn_word' => array(
778
+ 'sanitize' => 'text',
779
+ ),
780
+ 'profile_secondary_btn' => array(
781
+ 'sanitize' => 'bool',
782
+ ),
783
+ 'profile_secondary_btn_word' => array(
784
+ 'sanitize' => 'text',
785
+ ),
786
+ 'default_avatar' => array(
787
+ 'sanitize' => 'url',
788
+ ),
789
+ 'default_cover' => array(
790
+ 'sanitize' => 'url',
791
+ ),
792
+ 'disable_profile_photo_upload' => array(
793
+ 'sanitize' => 'bool',
794
+ ),
795
+ 'profile_photosize' => array(
796
+ 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
797
+ ),
798
+ 'profile_cover_enabled' => array(
799
+ 'sanitize' => 'bool',
800
+ ),
801
+ 'profile_coversize' => array(
802
+ 'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
803
+ ),
804
+ 'profile_cover_ratio' => array(
805
+ 'sanitize' => 'text',
806
+ ),
807
+ 'profile_show_metaicon' => array(
808
+ 'sanitize' => 'bool',
809
+ ),
810
+ 'profile_show_name' => array(
811
+ 'sanitize' => 'bool',
812
+ ),
813
+ 'profile_show_social_links' => array(
814
+ 'sanitize' => 'bool',
815
+ ),
816
+ 'profile_show_bio' => array(
817
+ 'sanitize' => 'bool',
818
+ ),
819
+ 'profile_show_html_bio' => array(
820
+ 'sanitize' => 'bool',
821
+ ),
822
+ 'profile_bio_maxchars' => array(
823
+ 'sanitize' => 'absint',
824
+ ),
825
+ 'profile_header_menu' => array(
826
+ 'sanitize' => 'key',
827
+ ),
828
+ 'profile_empty_text' => array(
829
+ 'sanitize' => 'bool',
830
+ ),
831
+ 'profile_empty_text_emo' => array(
832
+ 'sanitize' => 'bool',
833
+ ),
834
+ 'register_template' => array(
835
+ 'sanitize' => 'text',
836
+ ),
837
+ 'register_max_width' => array(
838
+ 'sanitize' => 'text',
839
+ ),
840
+ 'register_align' => array(
841
+ 'sanitize' => 'key',
842
+ ),
843
+ 'register_icons' => array(
844
+ 'sanitize' => 'key',
845
+ ),
846
+ 'register_primary_btn_word' => array(
847
+ 'sanitize' => 'text',
848
+ ),
849
+ 'register_secondary_btn' => array(
850
+ 'sanitize' => 'bool',
851
+ ),
852
+ 'register_secondary_btn_word' => array(
853
+ 'sanitize' => 'text',
854
+ ),
855
+ 'register_secondary_btn_url' => array(
856
+ 'sanitize' => 'url',
857
+ ),
858
+ 'register_role' => array(
859
+ 'sanitize' => 'key',
860
+ ),
861
+ 'login_template' => array(
862
+ 'sanitize' => 'text',
863
+ ),
864
+ 'login_max_width' => array(
865
+ 'sanitize' => 'text',
866
+ ),
867
+ 'login_align' => array(
868
+ 'sanitize' => 'key',
869
+ ),
870
+ 'login_icons' => array(
871
+ 'sanitize' => 'key',
872
+ ),
873
+ 'login_primary_btn_word' => array(
874
+ 'sanitize' => 'text',
875
+ ),
876
+ 'login_secondary_btn' => array(
877
+ 'sanitize' => 'bool',
878
+ ),
879
+ 'login_secondary_btn_word' => array(
880
+ 'sanitize' => 'text',
881
+ ),
882
+ 'login_secondary_btn_url' => array(
883
+ 'sanitize' => 'url',
884
+ ),
885
+ 'login_forgot_pass_link' => array(
886
+ 'sanitize' => 'bool',
887
+ ),
888
+ 'login_show_rememberme' => array(
889
+ 'sanitize' => 'bool',
890
+ ),
891
+ 'form_asterisk' => array(
892
+ 'sanitize' => 'bool',
893
+ ),
894
+ 'profile_title' => array(
895
+ 'sanitize' => 'text',
896
+ ),
897
+ 'profile_desc' => array(
898
+ 'sanitize' => 'textarea',
899
+ ),
900
+ 'um_profile_object_cache_stop' => array(
901
+ 'sanitize' => 'bool',
902
+ ),
903
+ 'enable_blocks' => array(
904
+ 'sanitize' => 'bool',
905
+ ),
906
+ 'rest_api_version' => array(
907
+ 'sanitize' => 'text',
908
+ ),
909
+ 'uninstall_on_delete' => array(
910
+ 'sanitize' => 'bool',
911
+ ),
912
+ )
913
+ );
914
+
915
+ $this->settings_map = apply_filters( 'um_settings_map', $settings_map );
916
+
917
+ /**
918
+ * UM hook
919
+ *
920
+ * @type filter
921
+ * @title um_settings_structure
922
+ * @description Extend UM Settings
923
+ * @input_vars
924
+ * [{"var":"$settings","type":"array","desc":"UM Settings"}]
925
+ * @change_log
926
+ * ["Since: 2.0"]
927
+ * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
928
+ * @example
929
+ * <?php
930
+ * add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
931
+ * function my_settings_structure( $settings ) {
932
+ * // your code here
933
+ * return $settings;
934
+ * }
935
+ * ?>
936
+ */
937
+ $this->settings_structure = apply_filters(
938
+ 'um_settings_structure',
939
+ array(
940
+ '' => array(
941
+ 'title' => __( 'General', 'ultimate-member' ),
942
+ 'sections' => array(
943
+ '' => array(
944
+ 'title' => __( 'Pages', 'ultimate-member' ),
945
+ 'fields' => $general_pages_fields,
946
+ ),
947
+ 'users' => array(
948
+ 'title' => __( 'Users', 'ultimate-member' ),
949
+ 'fields' => array(
950
+ array(
951
+ 'id' => 'permalink_base',
952
+ 'type' => 'select',
953
+ 'size' => 'small',
954
+ 'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
955
+ // translators: %s: Profile page URL
956
+ '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' ) ) ),
957
+ 'options' => array(
958
+ 'user_login' => __( 'Username', 'ultimate-member' ),
959
+ 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
960
+ 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
961
+ 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
962
+ 'user_id' => __( 'User ID', 'ultimate-member' ),
963
+ ),
964
+ 'placeholder' => __( 'Select...', 'ultimate-member' ),
965
+ ),
966
+ array(
967
+ 'id' => 'display_name',
968
+ 'type' => 'select',
969
+ 'size' => 'medium',
970
+ 'label' => __( 'User Display Name', 'ultimate-member' ),
971
+ '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' ),
972
+ 'options' => array(
973
+ 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
974
+ 'nickname' => __( 'Nickname', 'ultimate-member' ),
975
+ 'username' => __( 'Username', 'ultimate-member' ),
976
+ 'full_name' => __( 'First name & last name', 'ultimate-member' ),
977
+ 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
978
+ 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
979
+ 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
980
+ 'first_name' => __( 'First name only', 'ultimate-member' ),
981
+ 'field' => __( 'Custom field(s)', 'ultimate-member' ),
982
+ ),
983
+ 'placeholder' => __( 'Select...', 'ultimate-member' ),
984
+ ),
985
+ array(
986
+ 'id' => 'display_name_field',
987
+ 'type' => 'text',
988
+ 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
989
+ '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' ),
990
+ 'conditional' => array( 'display_name', '=', 'field' ),
991
+ ),
992
+ array(
993
+ 'id' => 'author_redirect',
994
+ 'type' => 'checkbox',
995
+ 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
996
+ 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
997
+ ),
998
+ array(
999
+ 'id' => 'members_page',
1000
+ 'type' => 'checkbox',
1001
+ 'label' => __( 'Enable Members Directory', 'ultimate-member' ),
1002
+ 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
1003
+ ),
1004
+ array(
1005
+ 'id' => 'use_gravatars',
1006
+ 'type' => 'checkbox',
1007
+ 'label' => __( 'Use Gravatars?', 'ultimate-member' ),
1008
+ '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' ),
1009
+ ),
1010
+ array(
1011
+ 'id' => 'use_um_gravatar_default_builtin_image',
1012
+ 'type' => 'select',
1013
+ 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
1014
+ 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
1015
+ 'options' => array(
1016
+ 'default' => __( 'Default', 'ultimate-member' ),
1017
+ '404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
1018
+ 'mm' => __( 'Mystery Man', 'ultimate-member' ),
1019
+ 'identicon' => __( 'Identicon', 'ultimate-member' ),
1020
+ 'monsterid' => __( 'Monsterid', 'ultimate-member' ),
1021
+ 'wavatar' => __( 'Wavatar', 'ultimate-member' ),
1022
+ 'retro' => __( 'Retro', 'ultimate-member' ),
1023
+ 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
1024
+ ),
1025
+ 'conditional' => array( 'use_gravatars', '=', 1 ),
1026
+ 'size' => 'medium',
1027
+ ),
1028
+ array(
1029
+ 'id' => 'use_um_gravatar_default_image',
1030
+ 'type' => 'checkbox',
1031
+ 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
1032
+ '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' ),
1033
+ 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
1034
+ ),
1035
+ array(
1036
+ 'id' => 'reset_require_strongpass',
1037
+ 'type' => 'checkbox',
1038
+ 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
1039
+ 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
1040
+ ),
1041
+ array(
1042
+ 'id' => 'profile_noindex',
1043
+ 'type' => 'select',
1044
+ 'size' => 'small',
1045
+ 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
1046
+ 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
1047
+ 'options' => array(
1048
+ '0' => __( 'No', 'ultimate-member' ),
1049
+ '1' => __( 'Yes', 'ultimate-member' ),
1050
+ ),
1051
+ ),
1052
+ array(
1053
+ 'id' => 'activation_link_expiry_time',
1054
+ 'type' => 'number',
1055
+ 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
1056
+ 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
1057
+ 'size' => 'small',
1058
+ ),
1059
+ ),
1060
+ ),
1061
+ 'account' => array(
1062
+ 'title' => __( 'Account', 'ultimate-member' ),
1063
+ 'fields' => array(
1064
+ array(
1065
+ 'id' => 'account_tab_password',
1066
+ 'type' => 'checkbox',
1067
+ 'label' => __( 'Password Account Tab', 'ultimate-member' ),
1068
+ 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
1069
+ ),
1070
+ array(
1071
+ 'id' => 'account_tab_privacy',
1072
+ 'type' => 'checkbox',
1073
+ 'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
1074
+ 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
1075
+ ),
1076
+ array(
1077
+ 'id' => 'account_tab_notifications',
1078
+ 'type' => 'checkbox',
1079
+ 'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
1080
+ 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
1081
+ ),
1082
+ array(
1083
+ 'id' => 'account_tab_delete',
1084
+ 'type' => 'checkbox',
1085
+ 'label' => __( 'Delete Account Tab', 'ultimate-member' ),
1086
+ 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
1087
+ ),
1088
+ array(
1089
+ 'id' => 'delete_account_text',
1090
+ 'type' => 'textarea', // bug with wp 4.4? should be editor
1091
+ 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
1092
+ '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' ),
1093
+ 'args' => array(
1094
+ 'textarea_rows' => 6,
1095
+ ),
1096
+ ),
1097
+ array(
1098
+ 'id' => 'delete_account_no_pass_required_text',
1099
+ 'type' => 'textarea',
1100
+ 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
1101
+ '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' ),
1102
+ 'args' => array(
1103
+ 'textarea_rows' => 6,
1104
+ ),
1105
+ ),
1106
+ array(
1107
+ 'id' => 'account_name',
1108
+ 'type' => 'checkbox',
1109
+ 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
1110
+ 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
1111
+ ),
1112
+ array(
1113
+ 'id' => 'account_name_disable',
1114
+ 'type' => 'checkbox',
1115
+ 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
1116
+ 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
1117
+ 'conditional' => array( 'account_name', '=', '1' ),
1118
+ ),
1119
+ array(
1120
+ 'id' => 'account_name_require',
1121
+ 'type' => 'checkbox',
1122
+ 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
1123
+ 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
1124
+ 'conditional' => array( 'account_name', '=', '1' ),
1125
+ ),
1126
+ array(
1127
+ 'id' => 'account_email',
1128
+ 'type' => 'checkbox',
1129
+ 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
1130
+ 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
1131
+ ),
1132
+ array(
1133
+ 'id' => 'account_general_password',
1134
+ 'type' => 'checkbox',
1135
+ 'label' => __( 'Password is required?', 'ultimate-member' ),
1136
+ 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
1137
+ ),
1138
+ array(
1139
+ 'id' => 'account_require_strongpass',
1140
+ 'type' => 'checkbox',
1141
+ 'label' => __( 'Require a strong password?', 'ultimate-member' ),
1142
+ 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
1143
+ ),
1144
+ array(
1145
+ 'id' => 'account_hide_in_directory',
1146
+ 'type' => 'checkbox',
1147
+ 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
1148
+ 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
1149
+ 'conditional' => array( 'account_tab_privacy', '=', '1' ),
1150
+ ),
1151
+ array(
1152
+ 'id' => 'account_hide_in_directory_default',
1153
+ 'type' => 'select',
1154
+ 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
1155
+ 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
1156
+ 'options' => array(
1157
+ 'No' => __( 'No', 'ultimate-member' ),
1158
+ 'Yes' => __( 'Yes', 'ultimate-member' ),
1159
+ ),
1160
+ 'size' => 'small',
1161
+ 'conditional' => array( 'account_hide_in_directory', '=', '1' ),
1162
+ ),
1163
+ ),
1164
+ ),
1165
+ 'uploads' => array(
1166
+ 'title' => __( 'Uploads', 'ultimate-member' ),
1167
+ 'fields' => array(
1168
+ array(
1169
+ 'id' => 'profile_photo_max_size',
1170
+ 'type' => 'text',
1171
+ 'size' => 'small',
1172
+ 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
1173
+ 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
1174
+ ),
1175
+ array(
1176
+ 'id' => 'cover_photo_max_size',
1177
+ 'type' => 'text',
1178
+ 'size' => 'small',
1179
+ 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
1180
+ 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
1181
+ ),
1182
+ array(
1183
+ 'id' => 'photo_thumb_sizes',
1184
+ 'type' => 'multi_text',
1185
+ 'size' => 'small',
1186
+ 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1187
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
1188
+ 'validate' => 'numeric',
1189
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1190
+ 'show_default_number' => 1,
1191
+ ),
1192
+ array(
1193
+ 'id' => 'cover_thumb_sizes',
1194
+ 'type' => 'multi_text',
1195
+ 'size' => 'small',
1196
+ 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1197
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
1198
+ 'validate' => 'numeric',
1199
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1200
+ 'show_default_number' => 1,
1201
+ ),
1202
+ array(
1203
+ 'id' => 'image_orientation_by_exif',
1204
+ 'type' => 'checkbox',
1205
+ 'label' => __( 'Change image orientation', 'ultimate-member' ),
1206
+ 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
1207
+ ),
1208
+ array(
1209
+ 'id' => 'image_compression',
1210
+ 'type' => 'text',
1211
+ 'size' => 'small',
1212
+ 'label' => __( 'Image Quality', 'ultimate-member' ),
1213
+ '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' ),
1214
+ ),
1215
+
1216
+ array(
1217
+ 'id' => 'image_max_width',
1218
+ 'type' => 'text',
1219
+ 'size' => 'small',
1220
+ 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
1221
+ 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
1222
+ ),
1223
+
1224
+ array(
1225
+ 'id' => 'cover_min_width',
1226
+ 'type' => 'text',
1227
+ 'size' => 'small',
1228
+ 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
1229
+ 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
1230
+ ),
1231
+ ),
1232
+ ),
1233
+ ),
1234
+ ),
1235
+ 'access' => array(
1236
+ 'title' => __( 'Access', 'ultimate-member' ),
1237
+ 'sections' => array(
1238
+ '' => array(
1239
+ 'title' => __( 'Restriction Content', 'ultimate-member' ),
1240
+ 'fields' => $access_fields,
1241
+ ),
1242
+ 'other' => array(
1243
+ 'title' => __( 'Other', 'ultimate-member' ),
1244
+ 'fields' => array(
1245
+ array(
1246
+ 'id' => 'enable_reset_password_limit',
1247
+ 'type' => 'checkbox',
1248
+ 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
1249
+ ),
1250
+ array(
1251
+ 'id' => 'reset_password_limit_number',
1252
+ 'type' => 'text',
1253
+ 'label' => __( 'Reset Password Limit', 'ultimate-member' ),
1254
+ 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
1255
+ 'validate' => 'numeric',
1256
+ 'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
1257
+ 'size' => 'small',
1258
+ ),
1259
+ array(
1260
+ 'id' => 'blocked_emails',
1261
+ 'type' => 'textarea',
1262
+ 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
1263
+ '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' ),
1264
+ ),
1265
+ array(
1266
+ 'id' => 'blocked_words',
1267
+ 'type' => 'textarea',
1268
+ 'label' => __( 'Blacklist Words', 'ultimate-member' ),
1269
+ 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
1270
+ ),
1271
+ ),
1272
+ ),
1273
+ ),
1274
+ ),
1275
+ 'email' => array(
1276
+ 'title' => __( 'Email', 'ultimate-member' ),
1277
+ 'fields' => array(
1278
+ array(
1279
+ 'id' => 'admin_email',
1280
+ 'type' => 'text',
1281
+ 'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
1282
+ 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1283
+ ),
1284
+ array(
1285
+ 'id' => 'mail_from',
1286
+ 'type' => 'text',
1287
+ 'label' => __( 'Mail appears from', 'ultimate-member' ),
1288
+ 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
1289
+ ),
1290
+ array(
1291
+ 'id' => 'mail_from_addr',
1292
+ 'type' => 'text',
1293
+ 'label' => __( 'Mail appears from address', 'ultimate-member' ),
1294
+ 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1295
+ ),
1296
+ array(
1297
+ 'id' => 'email_html',
1298
+ 'type' => 'checkbox',
1299
+ 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
1300
+ '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' ),
1301
+ ),
1302
+ ),
1303
+ ),
1304
+ 'appearance' => array(
1305
+ 'title' => __( 'Appearance', 'ultimate-member' ),
1306
+ 'sections' => array(
1307
+ '' => array(
1308
+ 'title' => __( 'Profile', 'ultimate-member' ),
1309
+ 'fields' => array(
1310
+ array(
1311
+ 'id' => 'profile_template',
1312
+ 'type' => 'select',
1313
+ 'label' => __( 'Profile Default Template', 'ultimate-member' ),
1314
+ 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
1315
+ 'default' => um_get_metadefault( 'profile_template' ),
1316
+ 'options' => UM()->shortcodes()->get_templates( 'profile' ),
1317
+ 'size' => 'small',
1318
+ ),
1319
+ array(
1320
+ 'id' => 'profile_max_width',
1321
+ 'type' => 'text',
1322
+ 'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
1323
+ 'default' => um_get_metadefault( 'profile_max_width' ),
1324
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1325
+ 'size' => 'small',
1326
+ ),
1327
+ array(
1328
+ 'id' => 'profile_area_max_width',
1329
+ 'type' => 'text',
1330
+ 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
1331
+ 'default' => um_get_metadefault( 'profile_area_max_width' ),
1332
+ 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
1333
+ 'size' => 'small',
1334
+ ),
1335
+ array(
1336
+ 'id' => 'profile_icons',
1337
+ 'type' => 'select',
1338
+ 'label' => __( 'Profile Field Icons', 'ultimate-member' ),
1339
+ 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
1340
+ 'default' => um_get_metadefault( 'profile_icons' ),
1341
+ 'options' => array(
1342
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1343
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1344
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1345
+ ),
1346
+ 'size' => 'small',
1347
+ ),
1348
+ array(
1349
+ 'id' => 'profile_primary_btn_word',
1350
+ 'type' => 'text',
1351
+ 'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
1352
+ 'default' => um_get_metadefault( 'profile_primary_btn_word' ),
1353
+ 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
1354
+ 'size' => 'medium',
1355
+ ),
1356
+ array(
1357
+ 'id' => 'profile_secondary_btn',
1358
+ 'type' => 'checkbox',
1359
+ 'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
1360
+ 'default' => um_get_metadefault( 'profile_secondary_btn' ),
1361
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1362
+ ),
1363
+ array(
1364
+ 'id' => 'profile_secondary_btn_word',
1365
+ 'type' => 'text',
1366
+ 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
1367
+ 'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
1368
+ 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
1369
+ 'conditional' => array( 'profile_secondary_btn', '=', 1 ),
1370
+ 'size' => 'medium',
1371
+ ),
1372
+ array(
1373
+ 'id' => 'default_avatar',
1374
+ 'type' => 'media',
1375
+ 'label' => __( 'Default Profile Photo', 'ultimate-member' ),
1376
+ 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
1377
+ 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
1378
+ 'default' => array(
1379
+ 'url' => um_url . 'assets/img/default_avatar.jpg',
1380
+ ),
1381
+ ),
1382
+ array(
1383
+ 'id' => 'default_cover',
1384
+ 'type' => 'media',
1385
+ 'url' => true,
1386
+ 'preview' => false,
1387
+ 'label' => __( 'Default Cover Photo', 'ultimate-member' ),
1388
+ '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' ),
1389
+ 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
1390
+ ),
1391
+ array(
1392
+ 'id' => 'disable_profile_photo_upload',
1393
+ 'type' => 'checkbox',
1394
+ 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
1395
+ 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
1396
+ 'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
1397
+ ),
1398
+ array(
1399
+ 'id' => 'profile_photosize',
1400
+ 'type' => 'select',
1401
+ 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
1402
+ 'default' => um_get_metadefault( 'profile_photosize' ),
1403
+ 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
1404
+ 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1405
+ 'size' => 'small',
1406
+ ),
1407
+ array(
1408
+ 'id' => 'profile_cover_enabled',
1409
+ 'type' => 'checkbox',
1410
+ 'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
1411
+ 'default' => um_get_metadefault( 'profile_cover_enabled' ),
1412
+ 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
1413
+ ),
1414
+ array(
1415
+ 'id' => 'profile_coversize',
1416
+ 'type' => 'select',
1417
+ 'label' => __( 'Profile Cover Size', 'ultimate-member' ),
1418
+ 'default' => um_get_metadefault( 'profile_coversize' ),
1419
+ 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
1420
+ 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1421
+ 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1422
+ 'size' => 'small',
1423
+ ),
1424
+ array(
1425
+ 'id' => 'profile_cover_ratio',
1426
+ 'type' => 'select',
1427
+ 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
1428
+ 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
1429
+ 'default' => um_get_metadefault( 'profile_cover_ratio' ),
1430
+ 'options' => array(
1431
+ '1.6:1' => '1.6:1',
1432
+ '2.7:1' => '2.7:1',
1433
+ '2.2:1' => '2.2:1',
1434
+ '3.2:1' => '3.2:1',
1435
+ ),
1436
+ 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1437
+ 'size' => 'small',
1438
+ ),
1439
+ array(
1440
+ 'id' => 'profile_show_metaicon',
1441
+ 'type' => 'checkbox',
1442
+ 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
1443
+ 'default' => 0,
1444
+ 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
1445
+ ),
1446
+ array(
1447
+ 'id' => 'profile_show_name',
1448
+ 'type' => 'checkbox',
1449
+ 'label' => __( 'Show display name in profile header', 'ultimate-member' ),
1450
+ 'default' => um_get_metadefault( 'profile_show_name' ),
1451
+ 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
1452
+ ),
1453
+ array(
1454
+ 'id' => 'profile_show_social_links',
1455
+ 'type' => 'checkbox',
1456
+ 'label' => __( 'Show social links in profile header', 'ultimate-member' ),
1457
+ 'default' => um_get_metadefault( 'profile_show_social_links' ),
1458
+ 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
1459
+ ),
1460
+ array(
1461
+ 'id' => 'profile_show_bio',
1462
+ 'type' => 'checkbox',
1463
+ 'label' => __( 'Show user description in header', 'ultimate-member' ),
1464
+ 'default' => um_get_metadefault( 'profile_show_bio' ),
1465
+ 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
1466
+ ),
1467
+ array(
1468
+ 'id' => 'profile_show_html_bio',
1469
+ 'type' => 'checkbox',
1470
+ 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
1471
+ 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
1472
+ ),
1473
+ array(
1474
+ 'id' => 'profile_bio_maxchars',
1475
+ 'type' => 'text',
1476
+ 'label' => __( 'User description maximum chars', 'ultimate-member' ),
1477
+ 'default' => um_get_metadefault( 'profile_bio_maxchars' ),
1478
+ 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
1479
+ 'conditional' => array( 'profile_show_bio', '=', 1 ),
1480
+ 'size' => 'small',
1481
+ ),
1482
+ array(
1483
+ 'id' => 'profile_header_menu',
1484
+ 'type' => 'select',
1485
+ 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
1486
+ 'default' => um_get_metadefault( 'profile_header_menu' ),
1487
+ 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
1488
+ 'options' => array(
1489
+ 'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
1490
+ 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
1491
+ ),
1492
+ 'size' => 'small',
1493
+ ),
1494
+ array(
1495
+ 'id' => 'profile_empty_text',
1496
+ 'type' => 'checkbox',
1497
+ 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
1498
+ 'default' => um_get_metadefault( 'profile_empty_text' ),
1499
+ 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
1500
+ ),
1501
+ array(
1502
+ 'id' => 'profile_empty_text_emo',
1503
+ 'type' => 'checkbox',
1504
+ 'label' => __( 'Show the emoticon', 'ultimate-member' ),
1505
+ 'default' => um_get_metadefault( 'profile_empty_text_emo' ),
1506
+ 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
1507
+ 'conditional' => array( 'profile_empty_text', '=', 1 ),
1508
+ ),
1509
+ ),
1510
+ ),
1511
+ 'profile_menu' => array(
1512
+ 'title' => __( 'Profile Menu', 'ultimate-member' ),
1513
+ 'fields' => $appearances_profile_menu_fields,
1514
+ ),
1515
+ 'registration_form' => array(
1516
+ 'title' => __( 'Registration Form', 'ultimate-member' ),
1517
+ 'fields' => array(
1518
+ array(
1519
+ 'id' => 'register_template',
1520
+ 'type' => 'select',
1521
+ 'label' => __( 'Registration Default Template', 'ultimate-member' ),
1522
+ 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
1523
+ 'default' => um_get_metadefault( 'register_template' ),
1524
+ 'options' => UM()->shortcodes()->get_templates( 'register' ),
1525
+ 'size' => 'small',
1526
+ ),
1527
+ array(
1528
+ 'id' => 'register_max_width',
1529
+ 'type' => 'text',
1530
+ 'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
1531
+ 'default' => um_get_metadefault( 'register_max_width' ),
1532
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1533
+ 'size' => 'small',
1534
+ ),
1535
+ array(
1536
+ 'id' => 'register_align',
1537
+ 'type' => 'select',
1538
+ 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
1539
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1540
+ 'default' => um_get_metadefault( 'register_align' ),
1541
+ 'options' => array(
1542
+ 'center' => __( 'Centered', 'ultimate-member' ),
1543
+ 'left' => __( 'Left aligned', 'ultimate-member' ),
1544
+ 'right' => __( 'Right aligned', 'ultimate-member' ),
1545
+ ),
1546
+ 'size' => 'small',
1547
+ ),
1548
+ array(
1549
+ 'id' => 'register_icons',
1550
+ 'type' => 'select',
1551
+ 'label' => __( 'Registration Field Icons', 'ultimate-member' ),
1552
+ 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
1553
+ 'default' => um_get_metadefault( 'register_icons' ),
1554
+ 'options' => array(
1555
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1556
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1557
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1558
+ ),
1559
+ 'size' => 'small',
1560
+ ),
1561
+ array(
1562
+ 'id' => 'register_primary_btn_word',
1563
+ 'type' => 'text',
1564
+ 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
1565
+ 'default' => um_get_metadefault( 'register_primary_btn_word' ),
1566
+ 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1567
+ 'size' => 'medium',
1568
+ ),
1569
+ array(
1570
+ 'id' => 'register_secondary_btn',
1571
+ 'type' => 'checkbox',
1572
+ 'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
1573
+ 'default' => 1,
1574
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1575
+ ),
1576
+ array(
1577
+ 'id' => 'register_secondary_btn_word',
1578
+ 'type' => 'text',
1579
+ 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
1580
+ 'default' => um_get_metadefault( 'register_secondary_btn_word' ),
1581
+ 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1582
+ 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1583
+ 'size' => 'medium',
1584
+ ),
1585
+ array(
1586
+ 'id' => 'register_secondary_btn_url',
1587
+ 'type' => 'text',
1588
+ 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
1589
+ 'default' => um_get_metadefault( 'register_secondary_btn_url' ),
1590
+ 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1591
+ 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1592
+ 'size' => 'medium',
1593
+ ),
1594
+ array(
1595
+ 'id' => 'register_role',
1596
+ 'type' => 'select',
1597
+ 'label' => __( 'Registration Default Role', 'ultimate-member' ),
1598
+ 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
1599
+ 'default' => um_get_metadefault( 'register_role' ),
1600
+ 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
1601
+ 'size' => 'small',
1602
+ ),
1603
+ ),
1604
+ ),
1605
+ 'login_form' => array(
1606
+ 'title' => __( 'Login Form', 'ultimate-member' ),
1607
+ 'fields' => array(
1608
+ array(
1609
+ 'id' => 'login_template',
1610
+ 'type' => 'select',
1611
+ 'label' => __( 'Login Default Template', 'ultimate-member' ),
1612
+ 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
1613
+ 'default' => um_get_metadefault( 'login_template' ),
1614
+ 'options' => UM()->shortcodes()->get_templates( 'login' ),
1615
+ 'size' => 'small',
1616
+ ),
1617
+ array(
1618
+ 'id' => 'login_max_width',
1619
+ 'type' => 'text',
1620
+ 'label' => __( 'Login Maximum Width', 'ultimate-member' ),
1621
+ 'default' => um_get_metadefault( 'login_max_width' ),
1622
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1623
+ 'size' => 'small',
1624
+ ),
1625
+ array(
1626
+ 'id' => 'login_align',
1627
+ 'type' => 'select',
1628
+ 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
1629
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1630
+ 'default' => um_get_metadefault( 'login_align' ),
1631
+ 'options' => array(
1632
+ 'center' => __( 'Centered', 'ultimate-member' ),
1633
+ 'left' => __( 'Left aligned', 'ultimate-member' ),
1634
+ 'right' => __( 'Right aligned', 'ultimate-member' ),
1635
+ ),
1636
+ 'size' => 'small',
1637
+ ),
1638
+ array(
1639
+ 'id' => 'login_icons',
1640
+ 'type' => 'select',
1641
+ 'label' => __( 'Login Field Icons', 'ultimate-member' ),
1642
+ 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
1643
+ 'default' => um_get_metadefault( 'login_icons' ),
1644
+ 'options' => array(
1645
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1646
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1647
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1648
+ ),
1649
+ 'size' => 'small',
1650
+ ),
1651
+ array(
1652
+ 'id' => 'login_primary_btn_word',
1653
+ 'type' => 'text',
1654
+ 'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
1655
+ 'default' => um_get_metadefault( 'login_primary_btn_word' ),
1656
+ 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1657
+ 'size' => 'medium',
1658
+ ),
1659
+ array(
1660
+ 'id' => 'login_secondary_btn',
1661
+ 'type' => 'checkbox',
1662
+ 'label' => __( 'Login Secondary Button', 'ultimate-member' ),
1663
+ 'default' => 1,
1664
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1665
+ ),
1666
+ array(
1667
+ 'id' => 'login_secondary_btn_word',
1668
+ 'type' => 'text',
1669
+ 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
1670
+ 'default' => um_get_metadefault( 'login_secondary_btn_word' ),
1671
+ 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1672
+ 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1673
+ 'size' => 'medium',
1674
+ ),
1675
+ array(
1676
+ 'id' => 'login_secondary_btn_url',
1677
+ 'type' => 'text',
1678
+ 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
1679
+ 'default' => um_get_metadefault( 'login_secondary_btn_url' ),
1680
+ 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1681
+ 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1682
+ 'size' => 'medium',
1683
+ ),
1684
+ array(
1685
+ 'id' => 'login_forgot_pass_link',
1686
+ 'type' => 'checkbox',
1687
+ 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
1688
+ 'default' => 1,
1689
+ 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
1690
+ ),
1691
+ array(
1692
+ 'id' => 'login_show_rememberme',
1693
+ 'type' => 'checkbox',
1694
+ 'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
1695
+ 'default' => 1,
1696
+ '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' ),
1697
+ ),
1698
+ ),
1699
+ ),
1700
+ ),
1701
+ ),
1702
+ 'extensions' => array(
1703
+ 'title' => __( 'Extensions', 'ultimate-member' ),
1704
+ ),
1705
+ 'licenses' => array(
1706
+ 'title' => __( 'Licenses', 'ultimate-member' ),
1707
+ ),
1708
+ 'misc' => array(
1709
+ 'title' => __( 'Misc', 'ultimate-member' ),
1710
+ 'fields' => array(
1711
+ array(
1712
+ 'id' => 'form_asterisk',
1713
+ 'type' => 'checkbox',
1714
+ 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
1715
+ ),
1716
+ array(
1717
+ 'id' => 'profile_title',
1718
+ 'type' => 'text',
1719
+ 'label' => __( 'User Profile Title', 'ultimate-member' ),
1720
+ 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
1721
+ 'size' => 'medium',
1722
+ ),
1723
+ array(
1724
+ 'id' => 'profile_desc',
1725
+ 'type' => 'textarea',
1726
+ 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
1727
+ 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
1728
+ 'args' => array(
1729
+ 'textarea_rows' => 6,
1730
+ ),
1731
+ ),
1732
+ array(
1733
+ 'id' => 'um_profile_object_cache_stop',
1734
+ 'type' => 'checkbox',
1735
+ 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
1736
+ 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
1737
+ ),
1738
+ array(
1739
+ 'id' => 'enable_blocks',
1740
+ 'type' => 'checkbox',
1741
+ 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
1742
+ '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' ),
1743
+ ),
1744
+ array(
1745
+ 'id' => 'rest_api_version',
1746
+ 'type' => 'select',
1747
+ 'label' => __( 'REST API version', 'ultimate-member' ),
1748
+ 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
1749
+ 'options' => array(
1750
+ '1.0' => __( '1.0 version', 'ultimate-member' ),
1751
+ '2.0' => __( '2.0 version', 'ultimate-member' ),
1752
+ ),
1753
+ ),
1754
+ $same_page_update,
1755
+ array(
1756
+ 'id' => 'uninstall_on_delete',
1757
+ 'type' => 'checkbox',
1758
+ 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
1759
+ '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' ),
1760
+ ),
1761
+ ),
1762
+ ),
1763
+ 'install_info' => array(
1764
+ 'title' => __( 'Install Info', 'ultimate-member' ),
1765
+ 'fields' => array(
1766
+ array(
1767
+ 'type' => 'install_info',
1768
+ ),
1769
+ ),
1770
+ ),
1771
+ )
1772
+ );
1773
+
1774
+ }
1775
+
1776
+
1777
+ /**
1778
+ * @param array $settings
1779
+ *
1780
+ * @return array
1781
+ */
1782
+ public function sorting_licenses_options( $settings ) {
1783
+ //sorting licenses
1784
+ if ( empty( $settings['licenses']['fields'] ) ) {
1785
+ return $settings;
1786
+ }
1787
+
1788
+ $licenses = $settings['licenses']['fields'];
1789
+ @uasort( $licenses, function( $a, $b ) {
1790
+ return strnatcasecmp( $a['label'], $b['label'] );
1791
+ } );
1792
+ $settings['licenses']['fields'] = $licenses;
1793
+
1794
+ //sorting extensions
1795
+ if ( empty( $settings['extensions']['sections'] ) ) {
1796
+ return $settings;
1797
+ }
1798
+
1799
+ $extensions = $settings['extensions']['sections'];
1800
+ @uasort( $extensions, function( $a, $b ) {
1801
+ return strnatcasecmp( $a['title'], $b['title'] );
1802
+ } );
1803
+
1804
+ $keys = array_keys( $extensions );
1805
+ if ( $keys[0] !== '' ) {
1806
+ $new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
1807
+ $temp = $extensions[''];
1808
+ $extensions[ $new_key ] = $temp;
1809
+ $extensions[''] = $extensions[ $keys[0] ];
1810
+ unset( $extensions[ $keys[0] ] );
1811
+ @uasort( $extensions, function( $a, $b ) {
1812
+ return strnatcasecmp( $a['title'], $b['title'] );
1813
+ } );
1814
+ }
1815
+
1816
+ $settings['extensions']['sections'] = $extensions;
1817
+
1818
+ return $settings;
1819
+ }
1820
+
1821
+
1822
+ /**
1823
+ * @param $tab
1824
+ * @param $section
1825
+ *
1826
+ * @return array
1827
+ */
1828
+ function get_section_fields( $tab, $section ) {
1829
+
1830
+ if ( empty( $this->settings_structure[ $tab ] ) ) {
1831
+ return array();
1832
+ }
1833
+
1834
+ if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
1835
+ return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
1836
+ } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
1837
+ return $this->settings_structure[ $tab ]['fields'];
1838
+ }
1839
+
1840
+ return array();
1841
+ }
1842
+
1843
+
1844
+ /**
1845
+ * Setup admin menu
1846
+ */
1847
+ function primary_admin_menu() {
1848
+ add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
1849
+ }
1850
+
1851
+
1852
+ /**
1853
+ * Settings page callback
1854
+ */
1855
+ function settings_page() {
1856
+ $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
1857
+ $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
1858
+
1859
+ $settings_struct = $this->settings_structure[ $current_tab ];
1860
+
1861
+ //remove not option hidden fields
1862
+ if ( ! empty( $settings_struct['fields'] ) ) {
1863
+ foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
1864
+
1865
+ if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
1866
+ unset( $settings_struct['fields'][ $field_key ] );
1867
+ }
1868
+
1869
+ }
1870
+ }
1871
+
1872
+ if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
1873
+ um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
1874
+ }
1875
+
1876
+ if ( ! empty( $settings_struct['sections'] ) ) {
1877
+ if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
1878
+ um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
1879
+ }
1880
+ }
1881
+
1882
+ echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
1883
+
1884
+ echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
1885
+
1886
+ /**
1887
+ * UM hook
1888
+ *
1889
+ * @type action
1890
+ * @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
1891
+ * @description Show some content before settings page content
1892
+ * @change_log
1893
+ * ["Since: 2.0"]
1894
+ * @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
1895
+ * @example
1896
+ * <?php
1897
+ * add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
1898
+ * function my_settings_page_before() {
1899
+ * // your code here
1900
+ * }
1901
+ * ?>
1902
+ */
1903
+ do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
1904
+
1905
+ 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 ) ) ) {
1906
+
1907
+ /**
1908
+ * UM hook
1909
+ *
1910
+ * @type action
1911
+ * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1912
+ * @description Show some content before section content at settings page
1913
+ * @change_log
1914
+ * ["Since: 2.0"]
1915
+ * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1916
+ * @example
1917
+ * <?php
1918
+ * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1919
+ * function my_settings_page_before_section() {
1920
+ * // your code here
1921
+ * }
1922
+ * ?>
1923
+ */
1924
+ do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1925
+
1926
+ $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1927
+ $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1928
+
1929
+ /**
1930
+ * UM hook
1931
+ *
1932
+ * @type filter
1933
+ * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1934
+ *
1935
+ * @description Render settings section
1936
+ * @input_vars
1937
+ * [{"var":"$content","type":"string","desc":"Section content"},
1938
+ * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1939
+ * @change_log
1940
+ * ["Since: 2.0"]
1941
+ * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1942
+ * @example
1943
+ * <?php
1944
+ * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1945
+ * function my_settings_section( $content ) {
1946
+ * // your code here
1947
+ * return $content;
1948
+ * }
1949
+ * ?>
1950
+ */
1951
+ echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
1952
+ $settings_section,
1953
+ $section_fields
1954
+ );
1955
+
1956
+ } else { ?>
1957
+
1958
+ <form method="post" action="" name="um-settings-form" id="um-settings-form">
1959
+ <input type="hidden" value="save" name="um-settings-action" />
1960
+
1961
+ <?php
1962
+ /**
1963
+ * UM hook
1964
+ *
1965
+ * @type action
1966
+ * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1967
+ * @description Show some content before section content at settings page
1968
+ * @change_log
1969
+ * ["Since: 2.0"]
1970
+ * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1971
+ * @example
1972
+ * <?php
1973
+ * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1974
+ * function my_settings_page_before_section() {
1975
+ * // your code here
1976
+ * }
1977
+ * ?>
1978
+ */
1979
+ do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1980
+
1981
+ $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1982
+ $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1983
+
1984
+ /**
1985
+ * UM hook
1986
+ *
1987
+ * @type filter
1988
+ * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1989
+ * @description Render settings section
1990
+ * @input_vars
1991
+ * [{"var":"$content","type":"string","desc":"Section content"},
1992
+ * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1993
+ * @change_log
1994
+ * ["Since: 2.0"]
1995
+ * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1996
+ * @example
1997
+ * <?php
1998
+ * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1999
+ * function my_settings_section( $content ) {
2000
+ * // your code here
2001
+ * return $content;
2002
+ * }
2003
+ * ?>
2004
+ */
2005
+ echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
2006
+ $settings_section,
2007
+ $section_fields
2008
+ ); ?>
2009
+
2010
+
2011
+ <p class="submit">
2012
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
2013
+ <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2014
+ <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2015
+ </p>
2016
+ </form>
2017
+
2018
+ <?php }
2019
+ }
2020
+
2021
+
2022
+ /**
2023
+ * Generate pages tabs
2024
+ *
2025
+ * @param string $page
2026
+ * @return string
2027
+ */
2028
+ function generate_tabs_menu( $page = 'settings' ) {
2029
+
2030
+ $tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
2031
+
2032
+ switch( $page ) {
2033
+ case 'settings':
2034
+ $menu_tabs = array();
2035
+ foreach ( $this->settings_structure as $slug => $tab ) {
2036
+ if ( ! empty( $tab['fields'] ) ) {
2037
+ foreach ( $tab['fields'] as $field_key => $field_options ) {
2038
+ if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
2039
+ unset( $tab['fields'][ $field_key ] );
2040
+ }
2041
+ }
2042
+ }
2043
+
2044
+ if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
2045
+ $menu_tabs[ $slug ] = $tab['title'];
2046
+ }
2047
+ }
2048
+
2049
+ $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2050
+ foreach ( $menu_tabs as $name => $label ) {
2051
+ $active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
2052
+ $tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
2053
+ $label .
2054
+ '</a>';
2055
+ }
2056
+
2057
+ break;
2058
+ default:
2059
+ /**
2060
+ * UM hook
2061
+ *
2062
+ * @type filter
2063
+ * @title um_generate_tabs_menu_{$page}
2064
+ * @description Generate tabs menu
2065
+ * @input_vars
2066
+ * [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
2067
+ * @change_log
2068
+ * ["Since: 2.0"]
2069
+ * @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
2070
+ * @example
2071
+ * <?php
2072
+ * add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
2073
+ * function my_tabs_menu( $tabs ) {
2074
+ * // your code here
2075
+ * return $tabs;
2076
+ * }
2077
+ * ?>
2078
+ */
2079
+ $tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
2080
+ break;
2081
+ }
2082
+
2083
+ return $tabs . '</h2>';
2084
+ }
2085
+
2086
+
2087
+ /**
2088
+ * @param string $tab
2089
+ *
2090
+ * @return string
2091
+ */
2092
+ function generate_subtabs_menu( $tab = '' ) {
2093
+ if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
2094
+ return '';
2095
+ }
2096
+
2097
+ $menu_subtabs = array();
2098
+ foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
2099
+ $menu_subtabs[ $slug ] = $subtab['title'];
2100
+ }
2101
+
2102
+ $subtabs = '<div><ul class="subsubsub">';
2103
+
2104
+ $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2105
+ $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
2106
+ foreach ( $menu_subtabs as $name => $label ) {
2107
+ $active = ( $current_subtab == $name ) ? 'current' : '';
2108
+ $subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '&section=' . $name ) ) ) . '" class="' . $active . '">'
2109
+ . $label .
2110
+ '</a> | ';
2111
+ }
2112
+
2113
+ return substr( $subtabs, 0, -3 ) . '</ul></div>';
2114
+ }
2115
+
2116
+
2117
+ /**
2118
+ * Handler for settings forms
2119
+ * when "Save Settings" button click
2120
+ *
2121
+ */
2122
+ function save_settings_handler() {
2123
+
2124
+ if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
2125
+
2126
+ $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
2127
+
2128
+ if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
2129
+ // This nonce is not valid.
2130
+ wp_die( __( 'Security Check', 'ultimate-member' ) );
2131
+ }
2132
+
2133
+ /**
2134
+ * UM hook
2135
+ *
2136
+ * @type action
2137
+ * @title um_settings_before_save
2138
+ * @description Before settings save action
2139
+ * @change_log
2140
+ * ["Since: 2.0"]
2141
+ * @usage add_action( 'um_settings_before_save', 'function_name', 10 );
2142
+ * @example
2143
+ * <?php
2144
+ * add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
2145
+ * function my_settings_before_save() {
2146
+ * // your code here
2147
+ * }
2148
+ * ?>
2149
+ */
2150
+ do_action( "um_settings_before_save" );
2151
+
2152
+ /**
2153
+ * UM hook
2154
+ *
2155
+ * @type filter
2156
+ * @title um_change_settings_before_save
2157
+ * @description Change settings before save
2158
+ * @input_vars
2159
+ * [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
2160
+ * @change_log
2161
+ * ["Since: 2.0"]
2162
+ * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
2163
+ * @example
2164
+ * <?php
2165
+ * add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
2166
+ * function my_change_settings_before_save( $settings ) {
2167
+ * // your code here
2168
+ * return $settings;
2169
+ * }
2170
+ * ?>
2171
+ */
2172
+ $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
2173
+
2174
+ $settings = UM()->admin()->sanitize_options( $settings );
2175
+
2176
+ foreach ( $settings as $key => $value ) {
2177
+ UM()->options()->update( $key, $value );
2178
+ }
2179
+
2180
+ /**
2181
+ * UM hook
2182
+ *
2183
+ * @type action
2184
+ * @title um_settings_save
2185
+ * @description After settings save action
2186
+ * @change_log
2187
+ * ["Since: 2.0"]
2188
+ * @usage add_action( 'um_settings_save', 'function_name', 10 );
2189
+ * @example
2190
+ * <?php
2191
+ * add_action( 'um_settings_save', 'my_settings_save', 10 );
2192
+ * function my_settings_save() {
2193
+ * // your code here
2194
+ * }
2195
+ * ?>
2196
+ */
2197
+ do_action( 'um_settings_save' );
2198
+
2199
+ //redirect after save settings
2200
+ $arg = array(
2201
+ 'page' => 'um_options',
2202
+ );
2203
+
2204
+ if ( ! empty( $_GET['tab'] ) ) {
2205
+ $arg['tab'] = sanitize_key( $_GET['tab'] );
2206
+ }
2207
+
2208
+ if ( ! empty( $_GET['section'] ) ) {
2209
+ $arg['section'] = sanitize_key( $_GET['section'] );
2210
+ }
2211
+
2212
+ um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
2213
+ }
2214
+ }
2215
+
2216
+
2217
+ function set_default_if_empty( $settings ) {
2218
+ $tab = '';
2219
+ if ( ! empty( $_GET['tab'] ) ) {
2220
+ $tab = sanitize_key( $_GET['tab'] );
2221
+ }
2222
+
2223
+ $section = '';
2224
+ if ( ! empty( $_GET['section'] ) ) {
2225
+ $section = sanitize_key( $_GET['section'] );
2226
+ }
2227
+
2228
+
2229
+ if ( 'access' === $tab && empty( $section ) ) {
2230
+ if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
2231
+ $settings['access_exclude_uris'] = array();
2232
+ }
2233
+ }
2234
+
2235
+ return $settings;
2236
+ }
2237
+
2238
+
2239
+ /**
2240
+ * Remove empty values from multi text fields
2241
+ *
2242
+ * @param $settings
2243
+ * @return array
2244
+ */
2245
+ function remove_empty_values( $settings ) {
2246
+ $tab = '';
2247
+ if ( ! empty( $_GET['tab'] ) ) {
2248
+ $tab = sanitize_key( $_GET['tab'] );
2249
+ }
2250
+
2251
+ $section = '';
2252
+ if ( ! empty( $_GET['section'] ) ) {
2253
+ $section = sanitize_key( $_GET['section'] );
2254
+ }
2255
+
2256
+ if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
2257
+ $fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
2258
+ } else {
2259
+ $fields = $this->settings_structure[ $tab ]['fields'];
2260
+ }
2261
+
2262
+ if ( empty( $fields ) ) {
2263
+ return $settings;
2264
+ }
2265
+
2266
+
2267
+ $filtered_settings = array();
2268
+ foreach ( $settings as $key => $value ) {
2269
+
2270
+ $filtered_settings[ $key ] = $value;
2271
+
2272
+ foreach ( $fields as $field ) {
2273
+ if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
2274
+ $filtered_settings[ $key ] = array_filter( $settings[ $key ] );
2275
+ }
2276
+ }
2277
+ }
2278
+
2279
+ return $filtered_settings;
2280
+ }
2281
+
2282
+
2283
+ /**
2284
+ *
2285
+ */
2286
+ function check_permalinks_changes() {
2287
+ if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2288
+ if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
2289
+ $this->need_change_permalinks = true;
2290
+ }
2291
+ }
2292
+
2293
+ // set variable if gravatar settings were changed
2294
+ // update for um_member_directory_data metakey
2295
+ if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2296
+ $use_gravatar = UM()->options()->get( 'use_gravatars' );
2297
+ if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
2298
+ $this->gravatar_changed = true;
2299
+ }
2300
+ }
2301
+ }
2302
+
2303
+
2304
+ /**
2305
+ *
2306
+ */
2307
+ function on_settings_save() {
2308
+ if ( ! empty( $_POST['um_options'] ) ) {
2309
+
2310
+ if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
2311
+ $post_ids = new \WP_Query( array(
2312
+ 'post_type' => 'page',
2313
+ 'meta_query' => array(
2314
+ array(
2315
+ 'key' => '_um_core',
2316
+ 'compare' => 'EXISTS'
2317
+ )
2318
+ ),
2319
+ 'posts_per_page' => -1,
2320
+ 'fields' => 'ids'
2321
+ ) );
2322
+
2323
+ $post_ids = $post_ids->get_posts();
2324
+
2325
+ if ( ! empty( $post_ids ) ) {
2326
+ foreach ( $post_ids as $post_id ) {
2327
+ delete_post_meta( $post_id, '_um_core' );
2328
+ }
2329
+ }
2330
+
2331
+ foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
2332
+ $slug = str_replace( 'core_', '', $option_slug );
2333
+ update_post_meta( $post_id, '_um_core', $slug );
2334
+ }
2335
+
2336
+ // reset rewrite rules after re-save pages
2337
+ UM()->rewrite()->reset_rules();
2338
+
2339
+ } elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2340
+ if ( ! empty( $this->need_change_permalinks ) ) {
2341
+ $users = get_users( array(
2342
+ 'fields' => 'ids',
2343
+ ) );
2344
+ if ( ! empty( $users ) ) {
2345
+ foreach ( $users as $user_id ) {
2346
+ UM()->user()->generate_profile_slug( $user_id );
2347
+ }
2348
+ }
2349
+ }
2350
+
2351
+
2352
+ // update for um_member_directory_data metakey
2353
+ if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2354
+ if ( $this->gravatar_changed ) {
2355
+ global $wpdb;
2356
+
2357
+ if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
2358
+
2359
+ $results = $wpdb->get_col(
2360
+ "SELECT u.ID FROM {$wpdb->users} AS u
2361
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
2362
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2363
+ WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
2364
+ um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
2365
+ );
2366
+
2367
+ } else {
2368
+
2369
+ $results = $wpdb->get_col(
2370
+ "SELECT u.ID FROM {$wpdb->users} AS u
2371
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
2372
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2373
+ WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
2374
+ um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
2375
+ );
2376
+
2377
+ }
2378
+
2379
+ if ( ! empty( $results ) ) {
2380
+ foreach ( $results as $user_id ) {
2381
+ $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2382
+ if ( ! empty( $md_data ) ) {
2383
+ $md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
2384
+ update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2385
+ }
2386
+ }
2387
+ }
2388
+ }
2389
+ }
2390
+
2391
+ } elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
2392
+ if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
2393
+ global $wpdb;
2394
+
2395
+ $results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
2396
+
2397
+ if ( ! empty( $results ) ) {
2398
+ $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
2399
+ }
2400
+
2401
+ update_option( 'um_member_directory_truncated', time() );
2402
+ }
2403
+ } elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
2404
+
2405
+ global $wpdb;
2406
+
2407
+ if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
2408
+
2409
+ $results = $wpdb->get_col(
2410
+ "SELECT u.ID FROM {$wpdb->users} AS u
2411
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2412
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2413
+ WHERE um.meta_value IS NULL AND
2414
+ um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
2415
+ );
2416
+
2417
+ } else {
2418
+
2419
+ $results = $wpdb->get_col(
2420
+ "SELECT u.ID FROM {$wpdb->users} AS u
2421
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2422
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2423
+ WHERE um.meta_value IS NULL AND
2424
+ um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
2425
+ );
2426
+
2427
+ }
2428
+
2429
+ if ( ! empty( $results ) ) {
2430
+ foreach ( $results as $user_id ) {
2431
+ $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2432
+ if ( ! empty( $md_data ) ) {
2433
+ $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
2434
+ update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2435
+ }
2436
+ }
2437
+ }
2438
+
2439
+ }
2440
+ }
2441
+ }
2442
+
2443
+
2444
+ /**
2445
+ *
2446
+ */
2447
+ function before_licenses_save() {
2448
+ if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2449
+ return;
2450
+ }
2451
+
2452
+ foreach ( $_POST['um_options'] as $key => $value ) {
2453
+ $this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
2454
+ }
2455
+ }
2456
+
2457
+
2458
+ /**
2459
+ *
2460
+ */
2461
+ function licenses_save() {
2462
+ if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2463
+ return;
2464
+ }
2465
+
2466
+ foreach ( $_POST['um_options'] as $key => $value ) {
2467
+ $key = sanitize_key( $key );
2468
+ $value = sanitize_text_field( $value );
2469
+
2470
+ $edd_action = '';
2471
+ $license_key = '';
2472
+ if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
2473
+ $edd_action = 'activate_license';
2474
+ $license_key = $value;
2475
+ } elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
2476
+ $edd_action = 'deactivate_license';
2477
+ $license_key = $this->previous_licenses[ $key ];
2478
+ } elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
2479
+ $edd_action = 'check_license';
2480
+ $license_key = $value;
2481
+ }
2482
+
2483
+ if ( empty( $edd_action ) ) {
2484
+ continue;
2485
+ }
2486
+
2487
+ $item_name = false;
2488
+ $version = false;
2489
+ $author = false;
2490
+ foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
2491
+ if ( $field_data['id'] == $key ) {
2492
+ $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
2493
+ $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
2494
+ $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
2495
+ }
2496
+ }
2497
+
2498
+ $api_params = array(
2499
+ 'edd_action' => $edd_action,
2500
+ 'license' => $license_key,
2501
+ 'item_name' => $item_name,
2502
+ 'version' => $version,
2503
+ 'author' => $author,
2504
+ 'url' => home_url(),
2505
+ );
2506
+
2507
+ $request = wp_remote_post(
2508
+ UM()->store_url,
2509
+ array(
2510
+ 'timeout' => UM()->request_timeout,
2511
+ 'sslverify' => false,
2512
+ 'body' => $api_params
2513
+ )
2514
+ );
2515
+
2516
+ if ( ! is_wp_error( $request ) ) {
2517
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
2518
+ } else {
2519
+ $request = wp_remote_post(
2520
+ UM()->store_url,
2521
+ array(
2522
+ 'timeout' => UM()->request_timeout,
2523
+ 'sslverify' => true,
2524
+ 'body' => $api_params
2525
+ )
2526
+ );
2527
+
2528
+ if ( ! is_wp_error( $request ) ) {
2529
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
2530
+ }
2531
+ }
2532
+
2533
+ $request = ( $request ) ? maybe_unserialize( $request ) : false;
2534
+
2535
+ if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
2536
+ update_option( "{$key}_edd_answer", $request );
2537
+ } else {
2538
+ delete_option( "{$key}_edd_answer" );
2539
+ }
2540
+
2541
+ }
2542
+ }
2543
+
2544
+
2545
+ /**
2546
+ *
2547
+ */
2548
+ function settings_before_email_tab() {
2549
+ $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2550
+ $emails = UM()->config()->email_notifications;
2551
+
2552
+ if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2553
+ include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
2554
+ }
2555
+ }
2556
+
2557
+
2558
+ /**
2559
+ * @param $section
2560
+ *
2561
+ * @return string
2562
+ */
2563
+ function settings_email_tab( $section ) {
2564
+ $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2565
+ $emails = UM()->config()->email_notifications;
2566
+
2567
+ if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2568
+ return $section;
2569
+ }
2570
+
2571
+ $in_theme = UM()->mail()->template_in_theme( $email_key );
2572
+
2573
+ /**
2574
+ * UM hook
2575
+ *
2576
+ * @type filter
2577
+ * @title um_admin_settings_email_section_fields
2578
+ * @description Extend UM Email Settings
2579
+ * @input_vars
2580
+ * [{"var":"$settings","type":"array","desc":"UM Email Settings"},
2581
+ * {"var":"$email_key","type":"string","desc":"Email Key"}]
2582
+ * @change_log
2583
+ * ["Since: 2.0"]
2584
+ * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
2585
+ * @example
2586
+ * <?php
2587
+ * add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
2588
+ * function my_admin_settings_email_section( $settings, $email_key ) {
2589
+ * // your code here
2590
+ * return $settings;
2591
+ * }
2592
+ * ?>
2593
+ */
2594
+ $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
2595
+ array(
2596
+ 'id' => 'um_email_template',
2597
+ 'type' => 'hidden',
2598
+ 'value' => $email_key,
2599
+ ),
2600
+ array(
2601
+ 'id' => $email_key . '_on',
2602
+ 'type' => 'checkbox',
2603
+ 'label' => $emails[ $email_key ]['title'],
2604
+ 'tooltip' => $emails[ $email_key ]['description'],
2605
+ ),
2606
+ array(
2607
+ 'id' => $email_key . '_sub',
2608
+ 'type' => 'text',
2609
+ 'label' => __( 'Subject Line', 'ultimate-member' ),
2610
+ 'conditional' => array( $email_key . '_on', '=', 1 ),
2611
+ 'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
2612
+ ),
2613
+ array(
2614
+ 'id' => $email_key,
2615
+ 'type' => 'email_template',
2616
+ 'label' => __( 'Message Body', 'ultimate-member' ),
2617
+ 'conditional' => array( $email_key . '_on', '=', 1 ),
2618
+ 'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
2619
+ 'value' => UM()->mail()->get_email_template( $email_key ),
2620
+ 'in_theme' => $in_theme
2621
+ ),
2622
+ ), $email_key );
2623
+
2624
+ return $this->render_settings_section( $section_fields, 'email', $email_key );
2625
+ }
2626
+
2627
+
2628
+ /**
2629
+ *
2630
+ */
2631
+ function settings_appearance_profile_tab() {
2632
+ wp_enqueue_media();
2633
+ }
2634
+
2635
+
2636
+ /**
2637
+ * @param $html
2638
+ * @param $section_fields
2639
+ *
2640
+ * @return string
2641
+ */
2642
+ function settings_licenses_tab( $html, $section_fields ) {
2643
+ ob_start(); ?>
2644
+
2645
+ <div class="wrap-licenses">
2646
+ <input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
2647
+ <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2648
+ <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2649
+ <table class="form-table um-settings-section">
2650
+ <tbody>
2651
+ <?php foreach ( $section_fields as $field_data ) {
2652
+ $option_value = UM()->options()->get( $field_data['id'] );
2653
+ $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
2654
+
2655
+ $license = get_option( "{$field_data['id']}_edd_answer" );
2656
+
2657
+ if ( is_object( $license ) && ! empty( $value ) ) {
2658
+ // activate_license 'invalid' on anything other than valid, so if there was an error capture it
2659
+ if ( empty( $license->success ) ) {
2660
+
2661
+ if ( ! empty( $license->error ) ) {
2662
+ switch ( $license->error ) {
2663
+
2664
+ case 'expired' :
2665
+
2666
+ $class = 'expired';
2667
+ $messages[] = sprintf(
2668
+ __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2669
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2670
+ 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2671
+ );
2672
+
2673
+ $license_status = 'license-' . $class . '-notice';
2674
+
2675
+ break;
2676
+
2677
+ case 'revoked' :
2678
+
2679
+ $class = 'error';
2680
+ $messages[] = sprintf(
2681
+ __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2682
+ 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2683
+ );
2684
+
2685
+ $license_status = 'license-' . $class . '-notice';
2686
+
2687
+ break;
2688
+
2689
+ case 'missing' :
2690
+
2691
+ $class = 'error';
2692
+ $messages[] = sprintf(
2693
+ __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2694
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2695
+ );
2696
+
2697
+ $license_status = 'license-' . $class . '-notice';
2698
+
2699
+ break;
2700
+
2701
+ case 'invalid' :
2702
+ case 'site_inactive' :
2703
+
2704
+ $class = 'error';
2705
+ $messages[] = sprintf(
2706
+ __( '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' ),
2707
+ $field_data['item_name'],
2708
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2709
+ );
2710
+
2711
+ $license_status = 'license-' . $class . '-notice';
2712
+
2713
+ break;
2714
+
2715
+ case 'item_name_mismatch' :
2716
+
2717
+ $class = 'error';
2718
+ $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2719
+
2720
+ $license_status = 'license-' . $class . '-notice';
2721
+
2722
+ break;
2723
+
2724
+ case 'no_activations_left':
2725
+
2726
+ $class = 'error';
2727
+ $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2728
+
2729
+ $license_status = 'license-' . $class . '-notice';
2730
+
2731
+ break;
2732
+
2733
+ case 'license_not_activable':
2734
+
2735
+ $class = 'error';
2736
+ $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2737
+
2738
+ $license_status = 'license-' . $class . '-notice';
2739
+ break;
2740
+
2741
+ default :
2742
+
2743
+ $class = 'error';
2744
+ $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2745
+ $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' );
2746
+
2747
+ $license_status = 'license-' . $class . '-notice';
2748
+ break;
2749
+ }
2750
+ } else {
2751
+ $class = 'error';
2752
+ $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2753
+ $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' );
2754
+
2755
+ $license_status = 'license-' . $class . '-notice';
2756
+ }
2757
+
2758
+ } elseif ( ! empty( $license->errors ) ) {
2759
+
2760
+ $errors = array_keys( $license->errors );
2761
+ $errors_data = array_values( $license->errors );
2762
+
2763
+ $class = 'error';
2764
+ $error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
2765
+ $errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
2766
+ $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' );
2767
+
2768
+ $license_status = 'license-' . $class . '-notice';
2769
+
2770
+ } else {
2771
+
2772
+ switch( $license->license ) {
2773
+
2774
+ case 'expired' :
2775
+
2776
+ $class = 'expired';
2777
+ $messages[] = sprintf(
2778
+ __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2779
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2780
+ 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2781
+ );
2782
+
2783
+ $license_status = 'license-' . $class . '-notice';
2784
+
2785
+ break;
2786
+
2787
+ case 'revoked' :
2788
+
2789
+ $class = 'error';
2790
+ $messages[] = sprintf(
2791
+ __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2792
+ 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2793
+ );
2794
+
2795
+ $license_status = 'license-' . $class . '-notice';
2796
+
2797
+ break;
2798
+
2799
+ case 'missing' :
2800
+
2801
+ $class = 'error';
2802
+ $messages[] = sprintf(
2803
+ __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2804
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2805
+ );
2806
+
2807
+ $license_status = 'license-' . $class . '-notice';
2808
+
2809
+ break;
2810
+
2811
+ case 'invalid' :
2812
+ case 'site_inactive' :
2813
+
2814
+ $class = 'error';
2815
+ $messages[] = sprintf(
2816
+ __( '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' ),
2817
+ $field_data['item_name'],
2818
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2819
+ );
2820
+
2821
+ $license_status = 'license-' . $class . '-notice';
2822
+
2823
+ break;
2824
+
2825
+ case 'item_name_mismatch' :
2826
+
2827
+ $class = 'error';
2828
+ $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2829
+
2830
+ $license_status = 'license-' . $class . '-notice';
2831
+
2832
+ break;
2833
+
2834
+ case 'no_activations_left':
2835
+
2836
+ $class = 'error';
2837
+ $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2838
+
2839
+ $license_status = 'license-' . $class . '-notice';
2840
+
2841
+ break;
2842
+
2843
+ case 'license_not_activable':
2844
+
2845
+ $class = 'error';
2846
+ $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2847
+
2848
+ $license_status = 'license-' . $class . '-notice';
2849
+ break;
2850
+
2851
+ case 'valid' :
2852
+ default:
2853
+
2854
+ $class = 'valid';
2855
+
2856
+ $now = current_time( 'timestamp' );
2857
+ $expiration = strtotime( $license->expires, $now );
2858
+
2859
+ if( 'lifetime' === $license->expires ) {
2860
+
2861
+ $messages[] = __( 'License key never expires.', 'ultimate-member' );
2862
+
2863
+ $license_status = 'license-lifetime-notice';
2864
+
2865
+ } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
2866
+
2867
+ $messages[] = sprintf(
2868
+ __( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
2869
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2870
+ 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
2871
+ );
2872
+
2873
+ $license_status = 'license-expires-soon-notice';
2874
+
2875
+ } else {
2876
+
2877
+ $messages[] = sprintf(
2878
+ __( 'Your license key expires on %s.', 'ultimate-member' ),
2879
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
2880
+ );
2881
+
2882
+ $license_status = 'license-expiration-date-notice';
2883
+
2884
+ }
2885
+
2886
+ break;
2887
+
2888
+ }
2889
+
2890
+ }
2891
+
2892
+ } else {
2893
+ $class = 'empty';
2894
+
2895
+ $messages[] = sprintf(
2896
+ __( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
2897
+ $field_data['item_name']
2898
+ );
2899
+
2900
+ $license_status = null;
2901
+
2902
+ } ?>
2903
+
2904
+ <tr class="um-settings-line">
2905
+ <th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
2906
+ <td>
2907
+ <form method="post" action="" name="um-settings-form" class="um-settings-form">
2908
+ <input type="hidden" value="save" name="um-settings-action" />
2909
+ <input type="hidden" name="licenses_settings" value="1" />
2910
+ <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2911
+ <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2912
+ <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'] ) ?>" />
2913
+ <?php if ( ! empty( $field_data['description'] ) ) { ?>
2914
+ <div class="description"><?php echo $field_data['description'] ?></div>
2915
+ <?php } ?>
2916
+
2917
+ <?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
2918
+ <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' ) ?>"/>
2919
+ <?php } elseif ( empty( $value ) ) { ?>
2920
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
2921
+ <?php } else { ?>
2922
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
2923
+ <?php }
2924
+
2925
+ if ( ! empty( $messages ) ) {
2926
+ foreach ( $messages as $message ) { ?>
2927
+ <div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
2928
+ <p><?php echo $message ?></p>
2929
+ </div>
2930
+ <?php }
2931
+ } ?>
2932
+ </form>
2933
+ </td>
2934
+ </tr>
2935
+ <?php } ?>
2936
+ </tbody>
2937
+ </table>
2938
+ </div>
2939
+ <?php $section = ob_get_clean();
2940
+
2941
+ return $section;
2942
+ }
2943
+
2944
+
2945
+ /**
2946
+ * @param $html
2947
+ * @param $section_fields
2948
+ */
2949
+ function settings_install_info_tab( $html, $section_fields ) {
2950
+ global $wpdb;
2951
+
2952
+ if ( ! class_exists( '\Browser' ) )
2953
+ require_once um_path . 'includes/lib/browser.php';
2954
+
2955
+ // Detect browser
2956
+ $browser = new \Browser();
2957
+
2958
+ // Get theme info
2959
+ $theme_data = wp_get_theme();
2960
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
2961
+
2962
+ // Identify Hosting Provider
2963
+ $host = um_get_host();
2964
+
2965
+ um_fetch_user( get_current_user_id() );
2966
+
2967
+ if ( isset( $this->content ) ) {
2968
+ echo $this->content;
2969
+ } else { ?>
2970
+
2971
+ <h3>Install Info</h3>
2972
+
2973
+ <form action="" method="post" dir="ltr">
2974
+ <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' ); ?>">
2975
+ ### Begin Install Info ###
2976
+
2977
+ ## Please include this information when posting support requests ##
2978
+
2979
+ <?php
2980
+ /**
2981
+ * UM hook
2982
+ *
2983
+ * @type action
2984
+ * @title um_install_info_before
2985
+ * @description Before install info settings
2986
+ * @change_log
2987
+ * ["Since: 2.0"]
2988
+ * @usage add_action( 'um_install_info_before', 'function_name', 10 );
2989
+ * @example
2990
+ * <?php
2991
+ * add_action( 'um_install_info_before', 'my_install_info_before', 10 );
2992
+ * function my_install_info_before() {
2993
+ * // your code here
2994
+ * }
2995
+ * ?>
2996
+ */
2997
+ do_action( 'um_install_info_before' ); ?>
2998
+
2999
+ --- Site Info ---
3000
+
3001
+ Site URL: <?php echo site_url() . "\n"; ?>
3002
+ Home URL: <?php echo home_url() . "\n"; ?>
3003
+ Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
3004
+
3005
+ --- Hosting Provider ---
3006
+
3007
+ <?php if( $host ) : ?>
3008
+ Host: <?php echo $host . "\n"; ?>
3009
+ <?php endif; ?>
3010
+
3011
+ --- User Browser ---
3012
+
3013
+ <?php echo $browser ; ?>
3014
+
3015
+ ---- Current User Details --
3016
+
3017
+ <?php $user = wp_get_current_user(); ?>
3018
+ Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
3019
+
3020
+
3021
+ --- WordPress Configurations ---
3022
+
3023
+ Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
3024
+ Language: <?php echo get_locale()."\n"; ?>
3025
+ Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
3026
+ Active Theme: <?php echo $theme . "\n"; ?>
3027
+ <?php $show_on_front = get_option( 'show_on_front' ); ?>
3028
+ <?php if( $show_on_front == "posts" ): ?>
3029
+ Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
3030
+ <?php elseif( $show_on_front == "page" ): ?>
3031
+ Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3032
+ Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3033
+ <?php endif; ?>
3034
+ ABSPATH: <?php echo ABSPATH."\n"; ?>
3035
+ <?php $wp_count_posts = wp_count_posts(); ?>
3036
+ All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
3037
+ <?php
3038
+ $request['cmd'] = '_notify-validate';
3039
+
3040
+ $params = array(
3041
+ 'sslverify' => false,
3042
+ 'timeout' => 60,
3043
+ 'user-agent' => 'UltimateMember/' . ultimatemember_version,
3044
+ 'body' => $request
3045
+ );
3046
+
3047
+ $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
3048
+
3049
+ if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
3050
+ $WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
3051
+ } else {
3052
+ $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
3053
+ }
3054
+ ?>
3055
+ WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
3056
+ WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
3057
+ 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"; ?>
3058
+ Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
3059
+
3060
+
3061
+ --- UM Configurations ---
3062
+
3063
+ Version: <?php echo ultimatemember_version . "\n"; ?>
3064
+ Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
3065
+ Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
3066
+ Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3067
+ Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3068
+ Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3069
+ JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3070
+ <?php if( is_multisite() ): ?>
3071
+ Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
3072
+ <?php endif; ?>
3073
+ Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3074
+ Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3075
+
3076
+
3077
+ --- UM Pages Configuration ---
3078
+
3079
+ <?php
3080
+ /**
3081
+ * UM hook
3082
+ *
3083
+ * @type action
3084
+ * @title um_install_info_before_page_config
3085
+ * @description Before page config install info
3086
+ * @change_log
3087
+ * ["Since: 2.0"]
3088
+ * @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
3089
+ * @example
3090
+ * <?php
3091
+ * add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
3092
+ * function my_install_info_before_page_config() {
3093
+ * // your code here
3094
+ * }
3095
+ * ?>
3096
+ */
3097
+ do_action( "um_install_info_before_page_config" ); ?>
3098
+ User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
3099
+ Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
3100
+ Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
3101
+ Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
3102
+ Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
3103
+ Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
3104
+ Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
3105
+ <?php
3106
+ /**
3107
+ * UM hook
3108
+ *
3109
+ * @type action
3110
+ * @title um_install_info_after_page_config
3111
+ * @description After page config install info
3112
+ * @change_log
3113
+ * ["Since: 2.0"]
3114
+ * @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
3115
+ * @example
3116
+ * <?php
3117
+ * add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
3118
+ * function my_install_info_after_page_config() {
3119
+ * // your code here
3120
+ * }
3121
+ * ?>
3122
+ */
3123
+ do_action( "um_install_info_after_page_config" ); ?>
3124
+
3125
+
3126
+ --- UM Users Configuration ---
3127
+
3128
+ Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
3129
+ Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
3130
+ User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
3131
+ Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
3132
+ Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
3133
+ Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
3134
+ Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
3135
+ <?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
3136
+ UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
3137
+ Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
3138
+
3139
+
3140
+ --- UM Access Configuration ---
3141
+
3142
+ Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
3143
+ Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
3144
+ <?php if( UM()->options()->get('accessible') == 2 ) { ?>
3145
+ Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
3146
+ 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";?>
3147
+ <?php } ?>
3148
+ Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
3149
+ <?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
3150
+ 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"; }?>
3151
+ <?php } ?>
3152
+ Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
3153
+ <?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
3154
+ 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"; }?>
3155
+ <?php } ?>
3156
+ Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
3157
+ Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
3158
+ <?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
3159
+ Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
3160
+ Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
3161
+ <?php } ?>
3162
+ <?php $wpadmin_allow_ips = UM()->options()->get( 'wpadmin_allow_ips' ); if( ! empty( $wpadmin_allow_ips ) ) { ?>
3163
+ Whitelisted Backend IPs: <?php echo count( explode("\n",trim(UM()->options()->get('wpadmin_allow_ips') ) ) )."\n"; ?>
3164
+ <?php } ?>
3165
+ <?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
3166
+ Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
3167
+ <?php } ?>
3168
+ <?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
3169
+ Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
3170
+ <?php } ?>
3171
+ <?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
3172
+ Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
3173
+ <?php } ?>
3174
+
3175
+
3176
+ --- UM Email Configurations ---
3177
+
3178
+ 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";?>
3179
+ 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";?>
3180
+ Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
3181
+ Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
3182
+ Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
3183
+ Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
3184
+ Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
3185
+ Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
3186
+ Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
3187
+ Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
3188
+ Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
3189
+ Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
3190
+
3191
+
3192
+ --- UM Total Users ---
3193
+
3194
+ <?php $result = count_users();
3195
+ echo 'All Users('.$result['total_users'].")\n";
3196
+ foreach( $result['avail_roles'] as $role => $count ) {
3197
+ echo $role."(".$count.")\n";
3198
+ } ?>
3199
+
3200
+
3201
+ --- UM Roles ---
3202
+
3203
+ <?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
3204
+ echo $role." ({$role_id})\n";
3205
+ } ?>
3206
+
3207
+
3208
+ --- UM Custom Templates ---
3209
+
3210
+ <?php // Show templates that have been copied to the theme's edd_templates dir
3211
+ $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
3212
+ if ( ! empty( $dir ) ) {
3213
+ $found = glob( $dir );
3214
+ if ( ! empty( $found ) ) {
3215
+ foreach ( glob( $dir ) as $file ) {
3216
+ echo "File: " . $file . "\n";
3217
+ }
3218
+ } else {
3219
+ echo 'N/A'."\n";
3220
+ }
3221
+ } ?>
3222
+
3223
+
3224
+ --- UM Email HTML Templates ---
3225
+
3226
+ <?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
3227
+
3228
+ if ( ! empty( $dir ) ) {
3229
+ $found = glob( $dir );
3230
+ if ( ! empty( $found ) ){
3231
+ foreach ( glob( $dir ) as $file ) {
3232
+ echo "File: ". $file . "\n";
3233
+ }
3234
+ } else {
3235
+ echo 'N/A'."\n";
3236
+ }
3237
+ } ?>
3238
+
3239
+
3240
+ --- Web Server Configurations ---
3241
+
3242
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
3243
+ MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
3244
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
3245
+
3246
+
3247
+ --- PHP Configurations ---
3248
+
3249
+ PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
3250
+ PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3251
+ PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
3252
+ PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3253
+ PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
3254
+ PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
3255
+ PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
3256
+ PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
3257
+
3258
+
3259
+ --- Web Server Extensions/Modules ---
3260
+
3261
+ DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
3262
+ FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
3263
+ cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
3264
+ 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"; ?>
3265
+ SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
3266
+ 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"; ?>
3267
+ 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"; ?>
3268
+ 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"; ?>
3269
+
3270
+
3271
+ --- Session Configurations ---
3272
+
3273
+ Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
3274
+ Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
3275
+ Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
3276
+ Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
3277
+ Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3278
+ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3279
+
3280
+
3281
+ --- WordPress Active Plugins ---
3282
+
3283
+ <?php $plugins = get_plugins();
3284
+ $active_plugins = get_option( 'active_plugins', array() );
3285
+
3286
+ foreach ( $plugins as $plugin_path => $plugin ) {
3287
+ // If the plugin isn't active, don't show it.
3288
+ if ( ! in_array( $plugin_path, $active_plugins ) )
3289
+ continue;
3290
+
3291
+ echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
3292
+ }
3293
+
3294
+ if ( is_multisite() ) { ?>
3295
+
3296
+ --- WordPress Network Active Plugins ---
3297
+
3298
+ <?php $plugins = wp_get_active_network_plugins();
3299
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
3300
+
3301
+ foreach ( $plugins as $plugin_path ) {
3302
+ $plugin_base = plugin_basename( $plugin_path );
3303
+
3304
+ // If the plugin isn't active, don't show it.
3305
+ if ( ! array_key_exists( $plugin_base, $active_plugins ) )
3306
+ continue;
3307
+
3308
+ $plugin = get_plugin_data( $plugin_path );
3309
+
3310
+ echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
3311
+ }
3312
+
3313
+ }
3314
+
3315
+ /**
3316
+ * UM hook
3317
+ *
3318
+ * @type action
3319
+ * @title um_install_info_after
3320
+ * @description After install info
3321
+ * @change_log
3322
+ * ["Since: 2.0"]
3323
+ * @usage add_action( 'um_install_info_after', 'function_name', 10 );
3324
+ * @example
3325
+ * <?php
3326
+ * add_action( 'um_install_info_after', 'my_install_info_after', 10 );
3327
+ * function my_install_info_after() {
3328
+ * // your code here
3329
+ * }
3330
+ * ?>
3331
+ */
3332
+ do_action( 'um_install_info_after' ); ?>
3333
+
3334
+ ### End Install Info ###
3335
+ </textarea>
3336
+ <p class="submit">
3337
+ <input type="hidden" name="um-addon-hook" value="download_install_info" />
3338
+ <?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
3339
+ </p>
3340
+ </form>
3341
+
3342
+ <?php }
3343
+ }
3344
+
3345
+
3346
+ /**
3347
+ *
3348
+ */
3349
+ function um_download_install_info() {
3350
+ if ( ! empty( $_POST['download_install_info'] ) ) {
3351
+ nocache_headers();
3352
+
3353
+ header( "Content-type: text/plain" );
3354
+ header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
3355
+
3356
+ echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
3357
+ exit;
3358
+ }
3359
+ }
3360
+
3361
+
3362
+ /**
3363
+ * @param string $raw_value
3364
+ * @param string $type
3365
+ * @param string $default
3366
+ *
3367
+ * @return string
3368
+ */
3369
+ function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
3370
+
3371
+ if ( $type == 'yesno' ) {
3372
+ $raw_value = ( $default == $raw_value ) ? "Yes" : "No";
3373
+ } elseif( $type == 'onoff' ) {
3374
+ $raw_value = ( $default == $raw_value ) ? "On" : "Off";
3375
+ }
3376
+
3377
+ return $raw_value."\n";
3378
+ }
3379
+
3380
+
3381
+ /**
3382
+ * Render settings section
3383
+ *
3384
+ * @param array $section_fields
3385
+ * @param string $current_tab
3386
+ * @param string $current_subtab
3387
+ *
3388
+ * @return string
3389
+ */
3390
+ function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
3391
+ ob_start();
3392
+
3393
+ UM()->admin_forms_settings( array(
3394
+ 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
3395
+ 'prefix_id' => 'um_options',
3396
+ 'fields' => $section_fields
3397
+ ) )->render_form(); ?>
3398
+
3399
+ <?php $section = ob_get_clean();
3400
+
3401
+ return $section;
3402
+ }
3403
+
3404
+
3405
+ /**
3406
+ * @param array $settings
3407
+ *
3408
+ * @return array
3409
+ */
3410
+ function save_email_templates( $settings ) {
3411
+
3412
+ if ( empty( $settings['um_email_template'] ) ) {
3413
+ return $settings;
3414
+ }
3415
+
3416
+ $template = $settings['um_email_template'];
3417
+ $content = wp_kses_post( stripslashes( $settings[ $template ] ) );
3418
+
3419
+ $theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
3420
+
3421
+ if ( ! file_exists( $theme_template_path ) ) {
3422
+ UM()->mail()->copy_email_template( $template );
3423
+ }
3424
+
3425
+ $fp = fopen( $theme_template_path, "w" );
3426
+ $result = fputs( $fp, $content );
3427
+ fclose( $fp );
3428
+
3429
+ if ( $result !== false ) {
3430
+ unset( $settings['um_email_template'] );
3431
+ unset( $settings[ $template ] );
3432
+ }
3433
+
3434
+ return $settings;
3435
+ }
3436
+ }
3437
+ }
includes/admin/templates/access/restrict_content.php CHANGED
@@ -1,160 +1,164 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
- ?>
5
-
6
- <div class="um-admin-metabox">
7
- <?php if ( ! empty( $object->ID ) ) {
8
- $data = get_post_meta( $object->ID, 'um_content_restriction', true );
9
- } else {
10
- $data = array();
11
- }
12
-
13
- $_um_access_roles_value = array();
14
- if ( ! empty( $data['_um_access_roles'] ) ) {
15
- foreach ( $data['_um_access_roles'] as $key => $value ) {
16
- if ( $value ) {
17
- $_um_access_roles_value[] = $key;
18
- }
19
- }
20
- }
21
-
22
- if ( ! empty( $object->post_type ) ) {
23
- $post_type_object = get_post_type_object( $object->post_type );
24
- } else {
25
- $post_type_object = array();
26
- }
27
-
28
- /**
29
- * UM hook
30
- *
31
- * @type filter
32
- * @title um_admin_access_settings_fields
33
- * @description Extend Admin Access Settings Fields
34
- * @input_vars
35
- * [{"var":"$fields","type":"array","desc":"Access Settings Fields"},
36
- * {"var":"$data","type":"array","desc":"Form Data"}]
37
- * @change_log
38
- * ["Since: 2.0"]
39
- * @usage add_filter( 'um_admin_access_settings_fields', 'function_name', 10, 2 );
40
- * @example
41
- * <?php
42
- * add_filter( 'um_admin_access_settings_fields', 'my_admin_access_settings_fields', 10, 2 );
43
- * function my_admin_access_settings_fields( $fields, $data ) {
44
- * // your code here
45
- * return $fields;
46
- * }
47
- * ?>
48
- */
49
- $fields = apply_filters( 'um_admin_access_settings_fields', array(
50
- array(
51
- 'id' => '_um_custom_access_settings',
52
- 'type' => 'checkbox',
53
- 'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
54
- 'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ),
55
- 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
56
- ),
57
- array(
58
- 'id' => '_um_accessible',
59
- 'type' => 'select',
60
- 'label' => __( 'Who can access this content?', 'ultimate-member' ),
61
- 'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ),
62
- 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
63
- 'options' => array(
64
- '0' => __( 'Everyone', 'ultimate-member' ),
65
- '1' => __( 'Logged out users', 'ultimate-member' ),
66
- '2' => __( 'Logged in users', 'ultimate-member' ),
67
- ),
68
- 'conditional' => array( '_um_custom_access_settings', '=', '1' )
69
- ),
70
- array(
71
- 'id' => '_um_access_roles',
72
- 'type' => 'multi_checkbox',
73
- 'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
74
- 'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ),
75
- 'value' => $_um_access_roles_value,
76
- 'options' => UM()->roles()->get_roles( false ),
77
- 'columns' => 3,
78
- 'conditional' => array( '_um_accessible', '=', '2' )
79
- ),
80
- array(
81
- 'id' => '_um_noaccess_action',
82
- 'type' => 'select',
83
- 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
84
- 'tooltip' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
85
- 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
86
- 'options' => array(
87
- '0' => __( 'Show access restricted message', 'ultimate-member' ),
88
- '1' => __( 'Redirect user', 'ultimate-member' ),
89
- ),
90
- 'conditional' => array( '_um_accessible', '!=', '0' )
91
- ),
92
- array(
93
- 'id' => '_um_restrict_by_custom_message',
94
- 'type' => 'select',
95
- 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
96
- 'tooltip' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
97
- 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
98
- 'options' => array(
99
- '0' => __( 'Global default message (default)', 'ultimate-member' ),
100
- '1' => __( 'Custom message', 'ultimate-member' ),
101
- ),
102
- 'conditional' => array( '_um_noaccess_action', '=', '0' )
103
- ),
104
- array(
105
- 'id' => '_um_restrict_custom_message',
106
- 'type' => 'wp_editor',
107
- 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
108
- 'tooltip' => __( 'Changed global restrict message', 'ultimate-member' ),
109
- 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
110
- 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
111
- ),
112
- array(
113
- 'id' => '_um_access_redirect',
114
- 'type' => 'select',
115
- 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
116
- 'tooltip' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
117
- 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
118
- 'conditional' => array( '_um_noaccess_action', '=', '1' ),
119
- 'options' => array(
120
- '0' => __( 'Login page', 'ultimate-member' ),
121
- '1' => __( 'Custom URL', 'ultimate-member' ),
122
- ),
123
- ),
124
- array(
125
- 'id' => '_um_access_redirect_url',
126
- 'type' => 'text',
127
- 'label' => __( 'Redirect URL', 'ultimate-member' ),
128
- 'tooltip' => __( 'Changed global restrict message', 'ultimate-member' ),
129
- 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
130
- 'conditional' => array( '_um_access_redirect', '=', '1' )
131
- ),
132
- array(
133
- 'id' => '_um_access_hide_from_queries',
134
- 'type' => 'checkbox',
135
- 'label' => __( 'Hide from queries', 'ultimate-member' ),
136
- 'tooltip' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
137
- 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
138
- 'conditional' => array( '_um_accessible', '!=', '0' )
139
- )
140
- ), $data, $object, $post_type_object );
141
-
142
- // Hierarchical
143
- // if ( $post_type_object->hierarchical ) {
144
- // $fields[] = array(
145
- // 'id' => '_um_access_hierarchical',
146
- // 'type' => 'checkbox',
147
- // 'label' => __( 'Hierarchical', 'ultimate-member' ),
148
- // 'tooltip' => __( 'Use parent page settings for the child pages that doesn\'t have own restriction settings.', 'ultimate-member' ),
149
- // 'value' => empty( $data['_um_access_hierarchical'] ) ? 0 : $data['_um_access_hierarchical'],
150
- // 'conditional' => array( '_um_custom_access_settings', '=', '1' )
151
- // );
152
- // }
153
-
154
- UM()->admin_forms( array(
155
- 'class' => 'um-restrict-content um-third-column',
156
- 'prefix_id' => 'um_content_restriction',
157
- 'fields' => $fields
158
- ) )->render_form(); ?>
159
-
160
- </div>
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+ ?>
6
+
7
+ <div class="um-admin-metabox">
8
+ <?php
9
+ if ( ! empty( $object->ID ) ) {
10
+ $data = get_post_meta( $object->ID, 'um_content_restriction', true );
11
+ } else {
12
+ $data = array();
13
+ }
14
+
15
+ $_um_access_roles_value = array();
16
+ if ( ! empty( $data['_um_access_roles'] ) ) {
17
+ foreach ( $data['_um_access_roles'] as $key => $value ) {
18
+ if ( $value ) {
19
+ $_um_access_roles_value[] = $key;
20
+ }
21
+ }
22
+ }
23
+
24
+ if ( ! empty( $object->post_type ) ) {
25
+ $post_type_object = get_post_type_object( $object->post_type );
26
+ } else {
27
+ $post_type_object = array();
28
+ }
29
+
30
+ /**
31
+ * UM hook
32
+ *
33
+ * @type filter
34
+ * @title um_admin_access_settings_fields
35
+ * @description Extend Admin Access Settings Fields
36
+ * @input_vars
37
+ * [{"var":"$fields","type":"array","desc":"Access Settings Fields"},
38
+ * {"var":"$data","type":"array","desc":"Form Data"}]
39
+ * @change_log
40
+ * ["Since: 2.0"]
41
+ * @usage add_filter( 'um_admin_access_settings_fields', 'function_name', 10, 2 );
42
+ * @example
43
+ * <?php
44
+ * add_filter( 'um_admin_access_settings_fields', 'my_admin_access_settings_fields', 10, 2 );
45
+ * function my_admin_access_settings_fields( $fields, $data ) {
46
+ * // your code here
47
+ * return $fields;
48
+ * }
49
+ * ?>
50
+ */
51
+ $fields = apply_filters( 'um_admin_access_settings_fields', array(
52
+ array(
53
+ 'id' => '_um_custom_access_settings',
54
+ 'type' => 'checkbox',
55
+ 'label' => __( 'Restrict access to this post?', 'ultimate-member' ),
56
+ 'tooltip' => __( 'Activate individual content restriction settings for this post. Then ignore all terms restriction content settings if they exists.', 'ultimate-member' ),
57
+ 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
58
+ ),
59
+ array(
60
+ 'id' => '_um_accessible',
61
+ 'type' => 'select',
62
+ 'label' => __( 'Who can access this post?', 'ultimate-member' ),
63
+ 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
64
+ 'options' => array(
65
+ '0' => __( 'Everyone', 'ultimate-member' ),
66
+ '1' => __( 'Logged out users', 'ultimate-member' ),
67
+ '2' => __( 'Logged in users', 'ultimate-member' ),
68
+ ),
69
+ 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
70
+ ),
71
+ array(
72
+ 'id' => '_um_access_roles',
73
+ 'type' => 'multi_checkbox',
74
+ 'label' => __( 'Select which roles can access this post', 'ultimate-member' ),
75
+ 'tooltip' => __( 'Leave empty if you want to display a post for all logged in users', 'ultimate-member' ),
76
+ 'value' => $_um_access_roles_value,
77
+ 'options' => UM()->roles()->get_roles( false ),
78
+ 'columns' => 3,
79
+ 'conditional' => array( '_um_accessible', '=', '2' ),
80
+ ),
81
+ array(
82
+ 'id' => '_um_access_hide_from_queries',
83
+ 'type' => 'checkbox',
84
+ 'label' => __( 'Would you like to display 404 page when users haven\'t access?', 'ultimate-member' ),
85
+ 'tooltip' => __( 'Recommended to be enabled. Restricted post 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', 'ultimate-member' ),
86
+ 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
87
+ 'conditional' => array( '_um_accessible', '!=', '0' ),
88
+ ),
89
+ array(
90
+ 'id' => '_um_noaccess_action',
91
+ 'type' => 'select',
92
+ 'label' => __( 'What happens when users without access try to view the post?', 'ultimate-member' ),
93
+ 'tooltip' => __( 'Action when users without access tries to view the post', 'ultimate-member' ),
94
+ 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
95
+ 'options' => array(
96
+ '0' => __( 'Show access restricted message', 'ultimate-member' ),
97
+ '1' => __( 'Redirect user', 'ultimate-member' ),
98
+ ),
99
+ 'conditional' => array( '_um_access_hide_from_queries', '=', '0' ),
100
+ ),
101
+ array(
102
+ 'id' => '_um_restrict_by_custom_message',
103
+ 'type' => 'select',
104
+ 'label' => __( 'Restricted access message type', 'ultimate-member' ),
105
+ 'tooltip' => __( 'Would you like to use the global default message or apply a custom message to this post?', 'ultimate-member' ),
106
+ 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
107
+ 'options' => array(
108
+ '0' => __( 'Global default message', 'ultimate-member' ),
109
+ '1' => __( 'Custom message', 'ultimate-member' ),
110
+ ),
111
+ 'conditional' => array( '_um_noaccess_action', '=', '0' ),
112
+ ),
113
+ array(
114
+ 'id' => '_um_restrict_custom_message',
115
+ 'type' => 'wp_editor',
116
+ 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
117
+ 'tooltip' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
118
+ 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
119
+ 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
120
+ ),
121
+ array(
122
+ 'id' => '_um_access_redirect',
123
+ 'type' => 'select',
124
+ 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
125
+ 'tooltip' => __( 'Select redirect to page when user hasn\'t access to post', 'ultimate-member' ),
126
+ 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
127
+ 'options' => array(
128
+ '0' => __( 'Login page', 'ultimate-member' ),
129
+ '1' => __( 'Custom URL', 'ultimate-member' ),
130
+ ),
131
+ 'conditional' => array( '_um_noaccess_action', '=', '1' ),
132
+ ),
133
+ array(
134
+ 'id' => '_um_access_redirect_url',
135
+ 'type' => 'text',
136
+ 'label' => __( 'Redirect URL', 'ultimate-member' ),
137
+ 'tooltip' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
138
+ 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
139
+ 'conditional' => array( '_um_access_redirect', '=', '1' ),
140
+ ),
141
+ ), $data, $object, $post_type_object );
142
+
143
+ // Hierarchical
144
+ // if ( $post_type_object->hierarchical ) {
145
+ // $fields[] = array(
146
+ // 'id' => '_um_access_hierarchical',
147
+ // 'type' => 'checkbox',
148
+ // 'label' => __( 'Hierarchical', 'ultimate-member' ),
149
+ // 'tooltip' => __( 'Use parent page settings for the child pages that doesn\'t have own restriction settings.', 'ultimate-member' ),
150
+ // 'value' => empty( $data['_um_access_hierarchical'] ) ? 0 : $data['_um_access_hierarchical'],
151
+ // 'conditional' => array( '_um_custom_access_settings', '=', '1' )
152
+ // );
153
+ // }
154
+
155
+ UM()->admin_forms(
156
+ array(
157
+ 'class' => 'um-restrict-content um-third-column',
158
+ 'prefix_id' => 'um_content_restriction',
159
+ 'fields' => $fields,
160
+ )
161
+ )->render_form();
162
+ ?>
163
+
164
+ </div>
includes/admin/templates/directory/appearance.php CHANGED
@@ -1,23 +1,25 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- } ?>
4
-
5
- <div class="um-admin-metabox">
6
- <?php
7
- UM()->admin_forms(
8
- array(
9
- 'class' => 'um-member-directory-appearance um-top-label',
10
- 'prefix_id' => 'um_metadata',
11
- 'fields' => array(
12
- array(
13
- 'id' => '_um_directory_template',
14
- 'type' => 'select',
15
- 'label' => __( 'Template', 'ultimate-member' ),
16
- 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ),
17
- 'options' => UM()->shortcodes()->get_templates( 'members' ),
18
- ),
19
- ),
20
- )
21
- )->render_form();
22
- ?>
23
- </div>
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id; ?>
6
+
7
+ <div class="um-admin-metabox">
8
+ <?php
9
+ UM()->admin_forms(
10
+ array(
11
+ 'class' => 'um-member-directory-appearance um-top-label',
12
+ 'prefix_id' => 'um_metadata',
13
+ 'fields' => array(
14
+ array(
15
+ 'id' => '_um_directory_template',
16
+ 'type' => 'select',
17
+ 'label' => __( 'Template', 'ultimate-member' ),
18
+ 'value' => get_post_meta( $post_id, '_um_directory_template', true ),
19
+ 'options' => UM()->shortcodes()->get_templates( 'members' ),
20
+ ),
21
+ ),
22
+ )
23
+ )->render_form();
24
+ ?>
25
+ </div>
includes/admin/templates/directory/general.php CHANGED
@@ -1,131 +1,133 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- }
4
-
5
- global $post_id;
6
-
7
- $_um_roles_value = get_post_meta( $post_id, '_um_roles', true );
8
- $_um_roles_value = empty( $_um_roles_value ) ? array() : $_um_roles_value;
9
-
10
- $show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
11
- if ( $show_these_users ) {
12
- $show_these_users = implode( "\n", str_replace( "\r", '', $show_these_users ) );
13
- }
14
-
15
- $exclude_these_users = get_post_meta( get_the_ID(), '_um_exclude_these_users', true );
16
- if ( $exclude_these_users ) {
17
- $exclude_these_users = implode( "\n", str_replace( "\r", '', $exclude_these_users ) );
18
- }
19
-
20
- $_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
21
- $_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid', 'list' ) : $_um_view_types_value;
22
-
23
- $view_types_options = array_map(
24
- function( $item ) {
25
- return $item['title'];
26
- },
27
- UM()->member_directory()->view_types
28
- );
29
-
30
- $conditional = array();
31
- foreach ( $view_types_options as $key => $value ) {
32
- $conditional[] = '_um_view_types_' . $key;
33
- }
34
-
35
-
36
- $fields = array(
37
- array(
38
- 'id' => '_um_mode',
39
- 'type' => 'hidden',
40
- 'value' => 'directory',
41
- ),
42
- array(
43
- 'id' => '_um_view_types',
44
- 'type' => 'multi_checkbox',
45
- 'label' => __( 'View type(s)', 'ultimate-member' ),
46
- 'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
47
- 'options' => $view_types_options,
48
- 'columns' => 3,
49
- 'value' => $_um_view_types_value,
50
- 'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
51
- ),
52
- array(
53
- 'id' => '_um_default_view',
54
- 'type' => 'select',
55
- 'label' => __( 'Default view type', 'ultimate-member' ),
56
- 'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
57
- 'options' => $view_types_options,
58
- 'value' => UM()->query()->get_meta_value( '_um_default_view', null, 'grid' ),
59
- 'conditional' => array( implode( '|', $conditional ), '~', 1 ),
60
- ),
61
- array(
62
- 'id' => '_um_roles',
63
- 'type' => 'multi_checkbox',
64
- 'label' => __( 'User Roles to Display', 'ultimate-member' ),
65
- 'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
66
- 'options' => UM()->roles()->get_roles(),
67
- 'columns' => 3,
68
- 'value' => $_um_roles_value,
69
- ),
70
- array(
71
- 'id' => '_um_has_profile_photo',
72
- 'type' => 'checkbox',
73
- 'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ),
74
- 'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ),
75
- 'value' => UM()->query()->get_meta_value( '_um_has_profile_photo' ),
76
- ),
77
- array(
78
- 'id' => '_um_has_cover_photo',
79
- 'type' => 'checkbox',
80
- 'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
81
- 'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ),
82
- ),
83
- array(
84
- 'id' => '_um_show_these_users',
85
- 'type' => 'textarea',
86
- 'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ),
87
- 'value' => $show_these_users,
88
- ),
89
- array(
90
- 'id' => '_um_exclude_these_users',
91
- 'type' => 'textarea',
92
- 'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ),
93
- 'value' => $exclude_these_users,
94
- ),
95
- );
96
-
97
- /**
98
- * UM hook
99
- *
100
- * @type filter
101
- * @title um_admin_extend_directory_options_general
102
- * @description Extend Directory options fields
103
- * @input_vars
104
- * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
105
- * @change_log
106
- * ["Since: 2.0"]
107
- * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
108
- * @example
109
- * <?php
110
- * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
111
- * function my_directory_sort_users_select( $sort_types ) {
112
- * // your code here
113
- * return $sort_types;
114
- * }
115
- * ?>
116
- */
117
- $fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); ?>
118
-
119
- <div class="um-admin-metabox">
120
- <?php
121
- UM()->admin_forms(
122
- array(
123
- 'class' => 'um-member-directory-general um-half-column',
124
- 'prefix_id' => 'um_metadata',
125
- 'fields' => $fields,
126
- )
127
- )->render_form();
128
- ?>
129
-
130
- <div class="um-admin-clear"></div>
131
- </div>
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id;
6
+
7
+ $_um_roles_value = get_post_meta( $post_id, '_um_roles', true );
8
+ $_um_roles_value = empty( $_um_roles_value ) ? array() : $_um_roles_value;
9
+
10
+ $show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
11
+ if ( $show_these_users ) {
12
+ $show_these_users = implode( "\n", str_replace( "\r", '', $show_these_users ) );
13
+ }
14
+
15
+ $exclude_these_users = get_post_meta( get_the_ID(), '_um_exclude_these_users', true );
16
+ if ( $exclude_these_users ) {
17
+ $exclude_these_users = implode( "\n", str_replace( "\r", '', $exclude_these_users ) );
18
+ }
19
+
20
+ $_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
21
+ $_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid', 'list' ) : $_um_view_types_value;
22
+
23
+ $view_types_options = array_map(
24
+ function( $item ) {
25
+ return $item['title'];
26
+ },
27
+ UM()->member_directory()->view_types
28
+ );
29
+
30
+ $conditional = array();
31
+ foreach ( $view_types_options as $key => $value ) {
32
+ $conditional[] = '_um_view_types_' . $key;
33
+ }
34
+
35
+ $default_view = get_post_meta( $post_id, '_um_default_view', true );
36
+ $default_view = empty( $default_view ) ? 'grid' : $default_view;
37
+
38
+ $fields = array(
39
+ array(
40
+ 'id' => '_um_mode',
41
+ 'type' => 'hidden',
42
+ 'value' => 'directory',
43
+ ),
44
+ array(
45
+ 'id' => '_um_view_types',
46
+ 'type' => 'multi_checkbox',
47
+ 'label' => __( 'View type(s)', 'ultimate-member' ),
48
+ 'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
49
+ 'options' => $view_types_options,
50
+ 'columns' => 3,
51
+ 'value' => $_um_view_types_value,
52
+ 'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
53
+ ),
54
+ array(
55
+ 'id' => '_um_default_view',
56
+ 'type' => 'select',
57
+ 'label' => __( 'Default view type', 'ultimate-member' ),
58
+ 'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
59
+ 'options' => $view_types_options,
60
+ 'value' => $default_view,
61
+ 'conditional' => array( implode( '|', $conditional ), '~', 1 ),
62
+ ),
63
+ array(
64
+ 'id' => '_um_roles',
65
+ 'type' => 'multi_checkbox',
66
+ 'label' => __( 'User Roles to Display', 'ultimate-member' ),
67
+ 'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
68
+ 'options' => UM()->roles()->get_roles(),
69
+ 'columns' => 3,
70
+ 'value' => $_um_roles_value,
71
+ ),
72
+ array(
73
+ 'id' => '_um_has_profile_photo',
74
+ 'type' => 'checkbox',
75
+ 'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ),
76
+ 'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ),
77
+ 'value' => (bool) get_post_meta( $post_id, '_um_has_profile_photo', true ),
78
+ ),
79
+ array(
80
+ 'id' => '_um_has_cover_photo',
81
+ 'type' => 'checkbox',
82
+ 'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
83
+ 'value' => (bool) get_post_meta( $post_id, '_um_has_cover_photo', true ),
84
+ ),
85
+ array(
86
+ 'id' => '_um_show_these_users',
87
+ 'type' => 'textarea',
88
+ 'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ),
89
+ 'value' => $show_these_users,
90
+ ),
91
+ array(
92
+ 'id' => '_um_exclude_these_users',
93
+ 'type' => 'textarea',
94
+ 'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ),
95
+ 'value' => $exclude_these_users,
96
+ ),
97
+ );
98
+
99
+ /**
100
+ * UM hook
101
+ *
102
+ * @type filter
103
+ * @title um_admin_extend_directory_options_general
104
+ * @description Extend Directory options fields
105
+ * @input_vars
106
+ * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
107
+ * @change_log
108
+ * ["Since: 2.0"]
109
+ * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
110
+ * @example
111
+ * <?php
112
+ * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
113
+ * function my_directory_sort_users_select( $sort_types ) {
114
+ * // your code here
115
+ * return $sort_types;
116
+ * }
117
+ * ?>
118
+ */
119
+ $fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); ?>
120
+
121
+ <div class="um-admin-metabox">
122
+ <?php
123
+ UM()->admin_forms(
124
+ array(
125
+ 'class' => 'um-member-directory-general um-half-column',
126
+ 'prefix_id' => 'um_metadata',
127
+ 'fields' => $fields,
128
+ )
129
+ )->render_form();
130
+ ?>
131
+
132
+ <div class="um-admin-clear"></div>
133
+ </div>
includes/admin/templates/directory/pagination.php CHANGED
@@ -1,72 +1,74 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- } ?>
4
-
5
- <div class="um-admin-metabox">
6
- <?php
7
- UM()->admin_forms(
8
- array(
9
- 'class' => 'um-member-directory-pagination um-half-column',
10
- 'prefix_id' => 'um_metadata',
11
- 'fields' => array(
12
- array(
13
- 'id' => '_um_must_search',
14
- 'type' => 'checkbox',
15
- 'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
16
- 'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
17
- 'value' => UM()->query()->get_meta_value( '_um_must_search' ),
18
- 'conditional' => array( '_um_search||_um_filters', '=', 1 ),
19
- ),
20
- array(
21
- 'id' => '_um_max_users',
22
- 'type' => 'number',
23
- 'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
24
- 'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
25
- 'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
26
- 'size' => 'small',
27
- ),
28
- array(
29
- 'id' => '_um_profiles_per_page',
30
- 'type' => 'number',
31
- 'label' => __( 'Number of profiles per page', 'ultimate-member' ),
32
- 'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
33
- 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
34
- 'size' => 'small',
35
- ),
36
- array(
37
- 'id' => '_um_profiles_per_page_mobile',
38
- 'type' => 'number',
39
- 'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
40
- 'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
41
- 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
42
- 'size' => 'small',
43
- ),
44
- array(
45
- 'id' => '_um_directory_header',
46
- 'type' => 'text',
47
- 'label' => __( 'Results Text', 'ultimate-member' ),
48
- 'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
49
- 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
50
- 'value' => UM()->query()->get_meta_value( '_um_directory_header', null, 'na' ),
51
- ),
52
- array(
53
- 'id' => '_um_directory_header_single',
54
- 'type' => 'text',
55
- 'label' => __( 'Single Result Text', 'ultimate-member' ),
56
- 'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
57
- 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
58
- 'value' => UM()->query()->get_meta_value( '_um_directory_header_single', null, 'na' ),
59
- ),
60
- array(
61
- 'id' => '_um_directory_no_users',
62
- 'type' => 'text',
63
- 'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
64
- 'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
65
- 'value' => UM()->query()->get_meta_value( '_um_directory_no_users', null, 'na' ),
66
- ),
67
- ),
68
- )
69
- )->render_form();
70
- ?>
71
- <div class="um-admin-clear"></div>
72
- </div>
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id; ?>
6
+
7
+ <div class="um-admin-metabox">
8
+ <?php
9
+ UM()->admin_forms(
10
+ array(
11
+ 'class' => 'um-member-directory-pagination um-half-column',
12
+ 'prefix_id' => 'um_metadata',
13
+ 'fields' => array(
14
+ array(
15
+ 'id' => '_um_must_search',
16
+ 'type' => 'checkbox',
17
+ 'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
18
+ 'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
19
+ 'value' => (bool) get_post_meta( $post_id, '_um_must_search', true ),
20
+ 'conditional' => array( '_um_search||_um_filters', '=', 1 ),
21
+ ),
22
+ array(
23
+ 'id' => '_um_max_users',
24
+ 'type' => 'number',
25
+ 'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
26
+ 'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
27
+ 'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
28
+ 'size' => 'small',
29
+ ),
30
+ array(
31
+ 'id' => '_um_profiles_per_page',
32
+ 'type' => 'number',
33
+ 'label' => __( 'Number of profiles per page', 'ultimate-member' ),
34
+ 'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
35
+ 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
36
+ 'size' => 'small',
37
+ ),
38
+ array(
39
+ 'id' => '_um_profiles_per_page_mobile',
40
+ 'type' => 'number',
41
+ 'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
42
+ 'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
43
+ 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
44
+ 'size' => 'small',
45
+ ),
46
+ array(
47
+ 'id' => '_um_directory_header',
48
+ 'type' => 'text',
49
+ 'label' => __( 'Results Text', 'ultimate-member' ),
50
+ 'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
51
+ 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
52
+ 'value' => UM()->query()->get_meta_value( '_um_directory_header', null, 'na' ),
53
+ ),
54
+ array(
55
+ 'id' => '_um_directory_header_single',
56
+ 'type' => 'text',
57
+ 'label' => __( 'Single Result Text', 'ultimate-member' ),
58
+ 'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
59
+ 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
60
+ 'value' => UM()->query()->get_meta_value( '_um_directory_header_single', null, 'na' ),
61
+ ),
62
+ array(
63
+ 'id' => '_um_directory_no_users',
64
+ 'type' => 'text',
65
+ 'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
66
+ 'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
67
+ 'value' => UM()->query()->get_meta_value( '_um_directory_no_users', null, 'na' ),
68
+ ),
69
+ ),
70
+ )
71
+ )->render_form();
72
+ ?>
73
+ <div class="um-admin-clear"></div>
74
+ </div>
includes/admin/templates/directory/profile.php CHANGED
@@ -1,120 +1,120 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- }
4
-
5
- $user_fields = array();
6
- foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
7
- $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
8
- }
9
-
10
- $post_id = get_the_ID();
11
- $_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
12
- $_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
13
-
14
-
15
- $fields = array(
16
- array(
17
- 'id' => '_um_profile_photo',
18
- 'type' => 'checkbox',
19
- 'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
20
- 'value' => UM()->query()->get_meta_value( '_um_profile_photo' ),
21
- ),
22
- array(
23
- 'id' => '_um_cover_photos',
24
- 'type' => 'checkbox',
25
- 'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
26
- 'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
27
- 'value' => UM()->query()->get_meta_value( '_um_cover_photos' ),
28
- ),
29
- array(
30
- 'id' => '_um_show_name',
31
- 'type' => 'checkbox',
32
- 'label' => __( 'Show display name', 'ultimate-member' ),
33
- 'value' => UM()->query()->get_meta_value( '_um_show_name' ),
34
- ),
35
- array(
36
- 'id' => '_um_show_tagline',
37
- 'type' => 'checkbox',
38
- 'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
39
- 'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
40
- ),
41
- array(
42
- 'id' => '_um_tagline_fields',
43
- 'type' => 'multi_selects',
44
- 'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
45
- 'value' => $_um_tagline_fields,
46
- 'conditional' => array( '_um_show_tagline', '=', 1 ),
47
- 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
48
- 'options' => $user_fields,
49
- 'show_default_number' => 1,
50
- 'sorting' => true,
51
- ),
52
- array(
53
- 'id' => '_um_show_userinfo',
54
- 'type' => 'checkbox',
55
- 'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
56
- 'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
57
- ),
58
- array(
59
- 'id' => '_um_reveal_fields',
60
- 'type' => 'multi_selects',
61
- 'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ),
62
- 'value' => $_um_reveal_fields,
63
- 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
64
- 'conditional' => array( '_um_show_userinfo', '=', 1 ),
65
- 'options' => $user_fields,
66
- 'show_default_number' => 1,
67
- 'sorting' => true,
68
- ),
69
- array(
70
- 'id' => '_um_show_social',
71
- 'type' => 'checkbox',
72
- 'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ),
73
- 'value' => UM()->query()->get_meta_value( '_um_show_social' ),
74
- 'conditional' => array( '_um_show_userinfo', '=', 1 ),
75
- ),
76
- array(
77
- 'id' => '_um_userinfo_animate',
78
- 'type' => 'checkbox',
79
- 'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ),
80
- 'tooltip' => __( 'If not checked always shown', 'ultimate-member' ),
81
- 'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
82
- 'conditional' => array( '_um_show_userinfo', '=', 1 ),
83
- ),
84
- );
85
-
86
-
87
- /**
88
- * UM hook
89
- *
90
- * @type filter
91
- * @title um_admin_extend_directory_options_general
92
- * @description Extend Directory options fields
93
- * @input_vars
94
- * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
95
- * @change_log
96
- * ["Since: 2.0"]
97
- * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
98
- * @example
99
- * <?php
100
- * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
101
- * function my_directory_sort_users_select( $sort_types ) {
102
- * // your code here
103
- * return $sort_types;
104
- * }
105
- * ?>
106
- */
107
- $fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields ); ?>
108
-
109
- <div class="um-admin-metabox">
110
- <?php
111
- UM()->admin_forms(
112
- array(
113
- 'class' => 'um-member-directory-profile um-half-column',
114
- 'prefix_id' => 'um_metadata',
115
- 'fields' => $fields,
116
- )
117
- )->render_form();
118
- ?>
119
- <div class="um-admin-clear"></div>
120
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id;
6
+
7
+ $user_fields = array();
8
+ foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
9
+ $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
10
+ }
11
+
12
+ $_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
13
+ $_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
14
+
15
+ $fields = array(
16
+ array(
17
+ 'id' => '_um_profile_photo',
18
+ 'type' => 'checkbox',
19
+ 'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
20
+ 'value' => (bool) get_post_meta( $post_id, '_um_profile_photo', true ),
21
+ ),
22
+ array(
23
+ 'id' => '_um_cover_photos',
24
+ 'type' => 'checkbox',
25
+ 'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
26
+ 'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
27
+ 'value' => (bool) get_post_meta( $post_id, '_um_cover_photos', true ),
28
+ ),
29
+ array(
30
+ 'id' => '_um_show_name',
31
+ 'type' => 'checkbox',
32
+ 'label' => __( 'Show display name', 'ultimate-member' ),
33
+ 'value' => (bool) get_post_meta( $post_id, '_um_show_name', true ),
34
+ ),
35
+ array(
36
+ 'id' => '_um_show_tagline',
37
+ 'type' => 'checkbox',
38
+ 'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
39
+ 'value' => (bool) get_post_meta( $post_id, '_um_show_tagline', true ),
40
+ ),
41
+ array(
42
+ 'id' => '_um_tagline_fields',
43
+ 'type' => 'multi_selects',
44
+ 'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
45
+ 'value' => $_um_tagline_fields,
46
+ 'conditional' => array( '_um_show_tagline', '=', 1 ),
47
+ 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
48
+ 'options' => $user_fields,
49
+ 'show_default_number' => 1,
50
+ 'sorting' => true,
51
+ ),
52
+ array(
53
+ 'id' => '_um_show_userinfo',
54
+ 'type' => 'checkbox',
55
+ 'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
56
+ 'value' => (bool) get_post_meta( $post_id, '_um_show_userinfo', true ),
57
+ ),
58
+ array(
59
+ 'id' => '_um_reveal_fields',
60
+ 'type' => 'multi_selects',
61
+ 'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ),
62
+ 'value' => $_um_reveal_fields,
63
+ 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
64
+ 'conditional' => array( '_um_show_userinfo', '=', 1 ),
65
+ 'options' => $user_fields,
66
+ 'show_default_number' => 1,
67
+ 'sorting' => true,
68
+ ),
69
+ array(
70
+ 'id' => '_um_show_social',
71
+ 'type' => 'checkbox',
72
+ 'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ),
73
+ 'value' => (bool) get_post_meta( $post_id, '_um_show_social', true ),
74
+ 'conditional' => array( '_um_show_userinfo', '=', 1 ),
75
+ ),
76
+ array(
77
+ 'id' => '_um_userinfo_animate',
78
+ 'type' => 'checkbox',
79
+ 'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ),
80
+ 'tooltip' => __( 'If not checked always shown', 'ultimate-member' ),
81
+ 'value' => (bool) get_post_meta( $post_id, '_um_userinfo_animate', true ),
82
+ 'conditional' => array( '_um_show_userinfo', '=', 1 ),
83
+ ),
84
+ );
85
+
86
+
87
+ /**
88
+ * UM hook
89
+ *
90
+ * @type filter
91
+ * @title um_admin_extend_directory_options_general
92
+ * @description Extend Directory options fields
93
+ * @input_vars
94
+ * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
95
+ * @change_log
96
+ * ["Since: 2.0"]
97
+ * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
98
+ * @example
99
+ * <?php
100
+ * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
101
+ * function my_directory_sort_users_select( $sort_types ) {
102
+ * // your code here
103
+ * return $sort_types;
104
+ * }
105
+ * ?>
106
+ */
107
+ $fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields ); ?>
108
+
109
+ <div class="um-admin-metabox">
110
+ <?php
111
+ UM()->admin_forms(
112
+ array(
113
+ 'class' => 'um-member-directory-profile um-half-column',
114
+ 'prefix_id' => 'um_metadata',
115
+ 'fields' => $fields,
116
+ )
117
+ )->render_form();
118
+ ?>
119
+ <div class="um-admin-clear"></div>
120
+ </div>
includes/admin/templates/directory/search.php CHANGED
@@ -1,100 +1,100 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- }
4
-
5
- global $post_id;
6
-
7
- $_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
8
- $_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
9
-
10
- $_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
11
- $_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
12
-
13
- $_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
14
- $_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true ); ?>
15
-
16
-
17
- <div class="um-admin-metabox">
18
- <?php
19
- UM()->admin_forms(
20
- array(
21
- 'class' => 'um-member-directory-search um-half-column',
22
- 'prefix_id' => 'um_metadata',
23
- 'fields' => array(
24
- array(
25
- 'id' => '_um_search',
26
- 'type' => 'checkbox',
27
- 'label' => __( 'Enable Search feature', 'ultimate-member' ),
28
- 'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
29
- 'value' => UM()->query()->get_meta_value( '_um_search' ),
30
- ),
31
- array(
32
- 'id' => '_um_roles_can_search',
33
- 'type' => 'multi_checkbox',
34
- 'label' => __( 'User Roles that can use search', 'ultimate-member' ),
35
- 'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
36
- 'value' => $_um_roles_search_value,
37
- 'options' => UM()->roles()->get_roles(),
38
- 'columns' => 3,
39
- 'conditional' => array( '_um_search', '=', 1 ),
40
- ),
41
- array(
42
- 'id' => '_um_filters',
43
- 'type' => 'checkbox',
44
- 'label' => __( 'Enable Filters feature', 'ultimate-member' ),
45
- 'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
46
- 'value' => UM()->query()->get_meta_value( '_um_filters' ),
47
- ),
48
- array(
49
- 'id' => '_um_roles_can_filter',
50
- 'type' => 'multi_checkbox',
51
- 'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
52
- 'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
53
- 'value' => $_um_roles_filter_value,
54
- 'options' => UM()->roles()->get_roles(),
55
- 'columns' => 3,
56
- 'conditional' => array( '_um_filters', '=', 1 ),
57
- ),
58
- array(
59
- 'id' => '_um_search_fields',
60
- 'type' => 'multi_selects',
61
- 'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
62
- 'value' => $_um_search_fields,
63
- 'conditional' => array( '_um_filters', '=', 1 ),
64
- 'options' => UM()->member_directory()->filter_fields,
65
- 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
66
- 'show_default_number' => 0,
67
- 'sorting' => true,
68
- ),
69
- array(
70
- 'id' => '_um_filters_expanded',
71
- 'type' => 'checkbox',
72
- 'label' => __( 'Expand the filter bar by default', 'ultimate-member' ),
73
- 'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ),
74
- 'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ),
75
- 'conditional' => array( '_um_filters', '=', 1 ),
76
- ),
77
- array(
78
- 'id' => '_um_filters_is_collapsible',
79
- 'type' => 'checkbox',
80
- 'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ),
81
- 'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ),
82
- 'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ),
83
- 'conditional' => array( '_um_filters_expanded', '=', 1 ),
84
- ),
85
- array(
86
- 'id' => '_um_search_filters',
87
- 'type' => 'md_default_filters',
88
- 'label' => __( 'Admin filtering', 'ultimate-member' ),
89
- 'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ),
90
- 'value' => $_um_search_filters,
91
- 'options' => UM()->member_directory()->filter_fields,
92
- 'add_text' => __( 'Add New Filter', 'ultimate-member' ),
93
- 'show_default_number' => 0,
94
- ),
95
- ),
96
- )
97
- )->render_form();
98
- ?>
99
- <div class="um-admin-clear"></div>
100
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id;
6
+
7
+ $_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
8
+ $_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
9
+
10
+ $_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
11
+ $_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
12
+
13
+ $_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
14
+ $_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true ); ?>
15
+
16
+
17
+ <div class="um-admin-metabox">
18
+ <?php
19
+ UM()->admin_forms(
20
+ array(
21
+ 'class' => 'um-member-directory-search um-half-column',
22
+ 'prefix_id' => 'um_metadata',
23
+ 'fields' => array(
24
+ array(
25
+ 'id' => '_um_search',
26
+ 'type' => 'checkbox',
27
+ 'label' => __( 'Enable Search feature', 'ultimate-member' ),
28
+ 'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
29
+ 'value' => (bool) get_post_meta( $post_id, '_um_search', true ),
30
+ ),
31
+ array(
32
+ 'id' => '_um_roles_can_search',
33
+ 'type' => 'multi_checkbox',
34
+ 'label' => __( 'User Roles that can use search', 'ultimate-member' ),
35
+ 'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
36
+ 'value' => $_um_roles_search_value,
37
+ 'options' => UM()->roles()->get_roles(),
38
+ 'columns' => 3,
39
+ 'conditional' => array( '_um_search', '=', 1 ),
40
+ ),
41
+ array(
42
+ 'id' => '_um_filters',
43
+ 'type' => 'checkbox',
44
+ 'label' => __( 'Enable Filters feature', 'ultimate-member' ),
45
+ 'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
46
+ 'value' => (bool) get_post_meta( $post_id, '_um_filters', true ),
47
+ ),
48
+ array(
49
+ 'id' => '_um_roles_can_filter',
50
+ 'type' => 'multi_checkbox',
51
+ 'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
52
+ 'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
53
+ 'value' => $_um_roles_filter_value,
54
+ 'options' => UM()->roles()->get_roles(),
55
+ 'columns' => 3,
56
+ 'conditional' => array( '_um_filters', '=', 1 ),
57
+ ),
58
+ array(
59
+ 'id' => '_um_search_fields',
60
+ 'type' => 'multi_selects',
61
+ 'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
62
+ 'value' => $_um_search_fields,
63
+ 'conditional' => array( '_um_filters', '=', 1 ),
64
+ 'options' => UM()->member_directory()->filter_fields,
65
+ 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
66
+ 'show_default_number' => 0,
67
+ 'sorting' => true,
68
+ ),
69
+ array(
70
+ 'id' => '_um_filters_expanded',
71
+ 'type' => 'checkbox',
72
+ 'label' => __( 'Expand the filter bar by default', 'ultimate-member' ),
73
+ 'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ),
74
+ 'value' => (bool) get_post_meta( $post_id, '_um_filters_expanded', true ),
75
+ 'conditional' => array( '_um_filters', '=', 1 ),
76
+ ),
77
+ array(
78
+ 'id' => '_um_filters_is_collapsible',
79
+ 'type' => 'checkbox',
80
+ 'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ),
81
+ 'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ),
82
+ 'value' => (bool) get_post_meta( $post_id, '_um_filters_is_collapsible', true ),
83
+ 'conditional' => array( '_um_filters_expanded', '=', 1 ),
84
+ ),
85
+ array(
86
+ 'id' => '_um_search_filters',
87
+ 'type' => 'md_default_filters',
88
+ 'label' => __( 'Admin filtering', 'ultimate-member' ),
89
+ 'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ),
90
+ 'value' => $_um_search_filters,
91
+ 'options' => UM()->member_directory()->filter_fields,
92
+ 'add_text' => __( 'Add New Filter', 'ultimate-member' ),
93
+ 'show_default_number' => 0,
94
+ ),
95
+ ),
96
+ )
97
+ )->render_form();
98
+ ?>
99
+ <div class="um-admin-clear"></div>
100
+ </div>
includes/admin/templates/directory/sorting.php CHANGED
@@ -1,65 +1,65 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- }
4
-
5
- global $post_id;
6
-
7
- $_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
8
- $_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields;
9
-
10
- $fields = array(
11
- array(
12
- 'id' => '_um_sortby',
13
- 'type' => 'select',
14
- 'label' => __( 'Default sort users by', 'ultimate-member' ),
15
- 'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
16
- 'options' => UM()->member_directory()->default_sorting,
17
- 'value' => UM()->query()->get_meta_value( '_um_sortby' ),
18
- ),
19
- array(
20
- 'id' => '_um_sortby_custom',
21
- 'type' => 'text',
22
- 'label' => __( 'Meta key', 'ultimate-member' ),
23
- 'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
24
- 'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
25
- 'conditional' => array( '_um_sortby', '=', 'other' ),
26
- ),
27
- array(
28
- 'id' => '_um_sortby_custom_label',
29
- 'type' => 'text',
30
- 'label' => __( 'Label of custom sort', 'ultimate-member' ),
31
- 'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ),
32
- 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ),
33
- 'conditional' => array( '_um_sortby', '=', 'other' ),
34
- ),
35
- array(
36
- 'id' => '_um_enable_sorting',
37
- 'type' => 'checkbox',
38
- 'label' => __( 'Enable custom sorting', 'ultimate-member' ),
39
- 'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
40
- 'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ),
41
- ),
42
- array(
43
- 'id' => '_um_sorting_fields',
44
- 'type' => 'md_sorting_fields',
45
- 'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
46
- 'value' => $_um_sorting_fields,
47
- 'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ),
48
- 'add_text' => __( 'Add New Field', 'ultimate-member' ),
49
- 'show_default_number' => 0,
50
- 'conditional' => array( '_um_enable_sorting', '=', 1 ),
51
- ),
52
- ); ?>
53
-
54
- <div class="um-admin-metabox">
55
- <?php
56
- UM()->admin_forms(
57
- array(
58
- 'class' => 'um-member-directory-sorting um-half-column',
59
- 'prefix_id' => 'um_metadata',
60
- 'fields' => $fields,
61
- )
62
- )->render_form();
63
- ?>
64
- <div class="um-admin-clear"></div>
65
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id;
6
+
7
+ $_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
8
+ $_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields;
9
+
10
+ $fields = array(
11
+ array(
12
+ 'id' => '_um_sortby',
13
+ 'type' => 'select',
14
+ 'label' => __( 'Default sort users by', 'ultimate-member' ),
15
+ 'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
16
+ 'options' => UM()->member_directory()->default_sorting,
17
+ 'value' => UM()->query()->get_meta_value( '_um_sortby' ),
18
+ ),
19
+ array(
20
+ 'id' => '_um_sortby_custom',
21
+ 'type' => 'text',
22
+ 'label' => __( 'Meta key', 'ultimate-member' ),
23
+ 'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
24
+ 'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
25
+ 'conditional' => array( '_um_sortby', '=', 'other' ),
26
+ ),
27
+ array(
28
+ 'id' => '_um_sortby_custom_label',
29
+ 'type' => 'text',
30
+ 'label' => __( 'Label of custom sort', 'ultimate-member' ),
31
+ 'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ),
32
+ 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ),
33
+ 'conditional' => array( '_um_sortby', '=', 'other' ),
34
+ ),
35
+ array(
36
+ 'id' => '_um_enable_sorting',
37
+ 'type' => 'checkbox',
38
+ 'label' => __( 'Enable custom sorting', 'ultimate-member' ),
39
+ 'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
40
+ 'value' => (bool) get_post_meta( $post_id, '_um_enable_sorting', true ),
41
+ ),
42
+ array(
43
+ 'id' => '_um_sorting_fields',
44
+ 'type' => 'md_sorting_fields',
45
+ 'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
46
+ 'value' => $_um_sorting_fields,
47
+ 'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ),
48
+ 'add_text' => __( 'Add New Field', 'ultimate-member' ),
49
+ 'show_default_number' => 0,
50
+ 'conditional' => array( '_um_enable_sorting', '=', 1 ),
51
+ ),
52
+ ); ?>
53
+
54
+ <div class="um-admin-metabox">
55
+ <?php
56
+ UM()->admin_forms(
57
+ array(
58
+ 'class' => 'um-member-directory-sorting um-half-column',
59
+ 'prefix_id' => 'um_metadata',
60
+ 'fields' => $fields,
61
+ )
62
+ )->render_form();
63
+ ?>
64
+ <div class="um-admin-clear"></div>
65
+ </div>
includes/admin/templates/form/login_customize.php CHANGED
@@ -1,106 +1,114 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- } ?>
4
-
5
- <div class="um-admin-metabox">
6
- <?php
7
- UM()->admin_forms(
8
- array(
9
- 'class' => 'um-form-login-customize um-top-label',
10
- 'prefix_id' => 'form',
11
- 'fields' => array(
12
- array(
13
- 'id' => '_um_login_use_custom_settings',
14
- 'type' => 'select',
15
- 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
16
- 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
17
- 'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ),
18
- 'options' => array(
19
- 0 => __( 'No', 'ultimate-member' ),
20
- 1 => __( 'Yes', 'ultimate-member' ),
21
- ),
22
- ),
23
- array(
24
- 'id' => '_um_login_template',
25
- 'type' => 'select',
26
- 'label' => __( 'Template', 'ultimate-member' ),
27
- 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ),
28
- 'options' => UM()->shortcodes()->get_templates( 'login' ),
29
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
30
- ),
31
- array(
32
- 'id' => '_um_login_max_width',
33
- 'type' => 'text',
34
- 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
35
- 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
36
- 'value' => UM()->query()->get_meta_value( '_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ),
37
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
38
- ),
39
- array(
40
- 'id' => '_um_login_icons',
41
- 'type' => 'select',
42
- 'label' => __( 'Field Icons', 'ultimate-member' ),
43
- 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
44
- 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ),
45
- 'options' => array(
46
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
47
- 'label' => __( 'Show with label', 'ultimate-member' ),
48
- 'off' => __( 'Turn off', 'ultimate-member' ),
49
- ),
50
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
51
- ),
52
- array(
53
- 'id' => '_um_login_primary_btn_word',
54
- 'type' => 'text',
55
- 'label' => __( 'Primary Button Text', 'ultimate-member' ),
56
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
57
- 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ),
58
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
59
- ),
60
- array(
61
- 'id' => '_um_login_secondary_btn',
62
- 'type' => 'select',
63
- 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
64
- 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ),
65
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
66
- 'options' => array(
67
- 0 => __( 'No', 'ultimate-member' ),
68
- 1 => __( 'Yes', 'ultimate-member' ),
69
- ),
70
- ),
71
- array(
72
- 'id' => '_um_login_secondary_btn_word',
73
- 'type' => 'text',
74
- 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
75
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
76
- 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
77
- 'conditional' => array( '_um_login_secondary_btn', '=', 1 ),
78
- ),
79
- array(
80
- 'id' => '_um_login_forgot_pass_link',
81
- 'type' => 'select',
82
- 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ),
83
- 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get( 'login_forgot_pass_link' ) ),
84
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
85
- 'options' => array(
86
- 0 => __( 'No', 'ultimate-member' ),
87
- 1 => __( 'Yes', 'ultimate-member' ),
88
- ),
89
- ),
90
- array(
91
- 'id' => '_um_login_show_rememberme',
92
- 'type' => 'select',
93
- 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ),
94
- 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get( 'login_show_rememberme' ) ),
95
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
96
- 'options' => array(
97
- 0 => __( 'No', 'ultimate-member' ),
98
- 1 => __( 'Yes', 'ultimate-member' ),
99
- ),
100
- ),
101
- ),
102
- )
103
- )->render_form();
104
- ?>
105
- <div class="um-admin-clear"></div>
106
- </div>
 
 
 
 
 
 
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id;
6
+
7
+ $use_custom_settings = ! isset( $post_id ) ? false : get_post_meta( $post_id, '_um_login_use_custom_settings', true );
8
+ $login_secondary_btn = ! isset( $post_id ) ? UM()->options()->get( 'login_secondary_btn' ) : get_post_meta( $post_id, '_um_login_secondary_btn', true );
9
+ $login_forgot_pass_link = ! isset( $post_id ) ? UM()->options()->get( 'login_forgot_pass_link' ) : get_post_meta( $post_id, '_um_login_forgot_pass_link', true );
10
+ $login_show_rememberme = ! isset( $post_id ) ? UM()->options()->get( 'login_show_rememberme' ) : get_post_meta( $post_id, '_um_login_show_rememberme', true );
11
+ ?>
12
+
13
+ <div class="um-admin-metabox">
14
+ <?php
15
+ UM()->admin_forms(
16
+ array(
17
+ 'class' => 'um-form-login-customize um-top-label',
18
+ 'prefix_id' => 'form',
19
+ 'fields' => array(
20
+ array(
21
+ 'id' => '_um_login_use_custom_settings',
22
+ 'type' => 'select',
23
+ 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
24
+ 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
25
+ 'value' => $use_custom_settings,
26
+ 'options' => array(
27
+ 0 => __( 'No', 'ultimate-member' ),
28
+ 1 => __( 'Yes', 'ultimate-member' ),
29
+ ),
30
+ ),
31
+ array(
32
+ 'id' => '_um_login_template',
33
+ 'type' => 'select',
34
+ 'label' => __( 'Template', 'ultimate-member' ),
35
+ 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ),
36
+ 'options' => UM()->shortcodes()->get_templates( 'login' ),
37
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
38
+ ),
39
+ array(
40
+ 'id' => '_um_login_max_width',
41
+ 'type' => 'text',
42
+ 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
43
+ 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
44
+ 'value' => UM()->query()->get_meta_value( '_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ),
45
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
46
+ ),
47
+ array(
48
+ 'id' => '_um_login_icons',
49
+ 'type' => 'select',
50
+ 'label' => __( 'Field Icons', 'ultimate-member' ),
51
+ 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
52
+ 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ),
53
+ 'options' => array(
54
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
55
+ 'label' => __( 'Show with label', 'ultimate-member' ),
56
+ 'off' => __( 'Turn off', 'ultimate-member' ),
57
+ ),
58
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
59
+ ),
60
+ array(
61
+ 'id' => '_um_login_primary_btn_word',
62
+ 'type' => 'text',
63
+ 'label' => __( 'Primary Button Text', 'ultimate-member' ),
64
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
65
+ 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ),
66
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
67
+ ),
68
+ array(
69
+ 'id' => '_um_login_secondary_btn',
70
+ 'type' => 'select',
71
+ 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
72
+ 'value' => $login_secondary_btn,
73
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
74
+ 'options' => array(
75
+ 0 => __( 'No', 'ultimate-member' ),
76
+ 1 => __( 'Yes', 'ultimate-member' ),
77
+ ),
78
+ ),
79
+ array(
80
+ 'id' => '_um_login_secondary_btn_word',
81
+ 'type' => 'text',
82
+ 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
83
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
84
+ 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
85
+ 'conditional' => array( '_um_login_secondary_btn', '=', 1 ),
86
+ ),
87
+ array(
88
+ 'id' => '_um_login_forgot_pass_link',
89
+ 'type' => 'select',
90
+ 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ),
91
+ 'value' => $login_forgot_pass_link,
92
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
93
+ 'options' => array(
94
+ 0 => __( 'No', 'ultimate-member' ),
95
+ 1 => __( 'Yes', 'ultimate-member' ),
96
+ ),
97
+ ),
98
+ array(
99
+ 'id' => '_um_login_show_rememberme',
100
+ 'type' => 'select',
101
+ 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ),
102
+ 'value' => $login_show_rememberme,
103
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
104
+ 'options' => array(
105
+ 0 => __( 'No', 'ultimate-member' ),
106
+ 1 => __( 'Yes', 'ultimate-member' ),
107
+ ),
108
+ ),
109
+ ),
110
+ )
111
+ )->render_form();
112
+ ?>
113
+ <div class="um-admin-clear"></div>
114
+ </div>
includes/admin/templates/form/profile_customize.php CHANGED
@@ -1,211 +1,225 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) {
2
- exit;
3
- }
4
-
5
- $profile_role_array = array();
6
- foreach ( UM()->roles()->get_roles() as $key => $value ) {
7
- $_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
8
- if ( ! empty( $_um_profile_role ) ) {
9
- $profile_role_array[] = $_um_profile_role;
10
- }
11
- } ?>
12
-
13
-
14
- <div class="um-admin-metabox">
15
- <?php
16
- UM()->admin_forms(
17
- array(
18
- 'class' => 'um-form-profile-customize um-top-label',
19
- 'prefix_id' => 'form',
20
- 'fields' => array(
21
- array(
22
- 'id' => '_um_profile_use_custom_settings',
23
- 'type' => 'select',
24
- 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
25
- 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
26
- 'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
27
- 'options' => array(
28
- 0 => __( 'No', 'ultimate-member' ),
29
- 1 => __( 'Yes', 'ultimate-member' ),
30
- ),
31
- ),
32
- array(
33
- 'id' => '_um_profile_role',
34
- 'type' => 'select',
35
- 'multi' => true,
36
- 'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
37
- 'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
38
- 'value' => $profile_role_array,
39
- 'options' => UM()->roles()->get_roles(),
40
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
41
- ),
42
- array(
43
- 'id' => '_um_profile_template',
44
- 'type' => 'select',
45
- 'label' => __( 'Template', 'ultimate-member' ),
46
- 'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
47
- 'options' => UM()->shortcodes()->get_templates( 'profile' ),
48
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
49
- ),
50
- array(
51
- 'id' => '_um_profile_max_width',
52
- 'type' => 'text',
53
- 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
54
- 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
55
- 'value' => UM()->query()->get_meta_value( '_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
56
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
57
- ),
58
- array(
59
- 'id' => '_um_profile_area_max_width',
60
- 'type' => 'text',
61
- 'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
62
- 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
63
- 'value' => UM()->query()->get_meta_value( '_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
64
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
65
- ),
66
- array(
67
- 'id' => '_um_profile_icons',
68
- 'type' => 'select',
69
- 'label' => __( 'Field Icons', 'ultimate-member' ),
70
- 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
71
- 'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ),
72
- 'options' => array(
73
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
74
- 'label' => __( 'Show with label', 'ultimate-member' ),
75
- 'off' => __( 'Turn off', 'ultimate-member' ),
76
- ),
77
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
78
- ),
79
- array(
80
- 'id' => '_um_profile_primary_btn_word',
81
- 'type' => 'text',
82
- 'label' => __( 'Primary Button Text', 'ultimate-member' ),
83
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
84
- 'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
85
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
86
- ),
87
- array(
88
- 'id' => '_um_profile_secondary_btn',
89
- 'type' => 'select',
90
- 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
91
- 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
92
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
93
- 'options' => array(
94
- 0 => __( 'No', 'ultimate-member' ),
95
- 1 => __( 'Yes', 'ultimate-member' ),
96
- ),
97
- ),
98
- array(
99
- 'id' => '_um_profile_secondary_btn_word',
100
- 'type' => 'text',
101
- 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
102
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
103
- 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
104
- 'conditional' => array( '_um_profile_secondary_btn', '=', 1 ),
105
- ),
106
- array(
107
- 'id' => '_um_profile_cover_enabled',
108
- 'type' => 'select',
109
- 'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
110
- 'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
111
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
112
- 'options' => array(
113
- 0 => __( 'No', 'ultimate-member' ),
114
- 1 => __( 'Yes', 'ultimate-member' ),
115
- ),
116
- ),
117
- array(
118
- 'id' => '_um_profile_coversize',
119
- 'type' => 'select',
120
- 'label' => __( 'Cover Photo Size', 'ultimate-member' ),
121
- 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
122
- 'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
123
- 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
124
- 'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
125
- ),
126
- array(
127
- 'id' => '_um_profile_cover_ratio',
128
- 'type' => 'select',
129
- 'label' => __( 'Cover photo ratio', 'ultimate-member' ),
130
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
131
- 'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ),
132
- 'options' => array(
133
- '1.6:1' => '1.6:1',
134
- '2.7:1' => '2.7:1',
135
- '2.2:1' => '2.2:1',
136
- '3.2:1' => '3.2:1',
137
- ),
138
- 'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
139
- ),
140
- array(
141
- 'id' => '_um_profile_disable_photo_upload',
142
- 'type' => 'select',
143
- 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
144
- 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
145
- 'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
146
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
147
- 'options' => array(
148
- 0 => __( 'No', 'ultimate-member' ),
149
- 1 => __( 'Yes', 'ultimate-member' ),
150
- ),
151
- ),
152
- array(
153
- 'id' => '_um_profile_photosize',
154
- 'type' => 'select',
155
- 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
156
- 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
157
- 'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
158
- 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
159
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
160
- ),
161
- array(
162
- 'id' => '_um_profile_photo_required',
163
- 'type' => 'select',
164
- 'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
165
- 'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
166
- 'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
167
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
168
- 'options' => array(
169
- 0 => __( 'No', 'ultimate-member' ),
170
- 1 => __( 'Yes', 'ultimate-member' ),
171
- ),
172
- ),
173
- array(
174
- 'id' => '_um_profile_show_name',
175
- 'type' => 'select',
176
- 'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
177
- 'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
178
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
179
- 'options' => array(
180
- 0 => __( 'No', 'ultimate-member' ),
181
- 1 => __( 'Yes', 'ultimate-member' ),
182
- ),
183
- ),
184
- array(
185
- 'id' => '_um_profile_show_social_links',
186
- 'type' => 'select',
187
- 'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
188
- 'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
189
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
190
- 'options' => array(
191
- 0 => __( 'No', 'ultimate-member' ),
192
- 1 => __( 'Yes', 'ultimate-member' ),
193
- ),
194
- ),
195
- array(
196
- 'id' => '_um_profile_show_bio',
197
- 'type' => 'select',
198
- 'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
199
- 'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
200
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
201
- 'options' => array(
202
- 0 => __( 'No', 'ultimate-member' ),
203
- 1 => __( 'Yes', 'ultimate-member' ),
204
- ),
205
- ),
206
- ),
207
- )
208
- )->render_form();
209
- ?>
210
- <div class="um-admin-clear"></div>
211
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
+
5
+ global $post_id;
6
+
7
+ $use_custom_settings = ! isset( $post_id ) ? false : get_post_meta( $post_id, '_um_profile_use_custom_settings', true );
8
+
9
+ $profile_role_array = array();
10
+ foreach ( UM()->roles()->get_roles() as $key => $value ) {
11
+ $_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
12
+ if ( ! empty( $_um_profile_role ) ) {
13
+ $profile_role_array[] = $_um_profile_role;
14
+ }
15
+ }
16
+
17
+ $profile_secondary_btn = ! isset( $post_id ) ? UM()->options()->get( 'profile_secondary_btn' ) : get_post_meta( $post_id, '_um_profile_secondary_btn', true );
18
+ $profile_cover_enabled = ! isset( $post_id ) ? true : get_post_meta( $post_id, '_um_profile_cover_enabled', true );
19
+ $profile_disable_photo_upload = ! isset( $post_id ) ? UM()->options()->get( 'disable_profile_photo_upload' ) : get_post_meta( $post_id, '_um_profile_disable_photo_upload', true );
20
+ $profile_photo_required = ! isset( $post_id ) ? false : get_post_meta( $post_id, '_um_profile_photo_required', true );
21
+ $profile_show_name = ! isset( $post_id ) ? true : get_post_meta( $post_id, '_um_profile_show_name', true );
22
+ $profile_show_social_links = ! isset( $post_id ) ? UM()->options()->get( 'profile_show_social_links' ) : get_post_meta( $post_id, '_um_profile_show_social_links', true );
23
+ $profile_show_bio = ! isset( $post_id ) ? true : get_post_meta( $post_id, '_um_profile_show_bio', true );
24
+
25
+ ?>
26
+
27
+
28
+ <div class="um-admin-metabox">
29
+ <?php
30
+ UM()->admin_forms(
31
+ array(
32
+ 'class' => 'um-form-profile-customize um-top-label',
33
+ 'prefix_id' => 'form',
34
+ 'fields' => array(
35
+ array(
36
+ 'id' => '_um_profile_use_custom_settings',
37
+ 'type' => 'select',
38
+ 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
39
+ 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
40
+ 'value' => $use_custom_settings,
41
+ 'options' => array(
42
+ 0 => __( 'No', 'ultimate-member' ),
43
+ 1 => __( 'Yes', 'ultimate-member' ),
44
+ ),
45
+ ),
46
+ array(
47
+ 'id' => '_um_profile_role',
48
+ 'type' => 'select',
49
+ 'multi' => true,
50
+ 'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
51
+ 'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
52
+ 'value' => $profile_role_array,
53
+ 'options' => UM()->roles()->get_roles(),
54
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
55
+ ),
56
+ array(
57
+ 'id' => '_um_profile_template',
58
+ 'type' => 'select',
59
+ 'label' => __( 'Template', 'ultimate-member' ),
60
+ 'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
61
+ 'options' => UM()->shortcodes()->get_templates( 'profile' ),
62
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
63
+ ),
64
+ array(
65
+ 'id' => '_um_profile_max_width',
66
+ 'type' => 'text',
67
+ 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
68
+ 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
69
+ 'value' => UM()->query()->get_meta_value( '_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
70
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
71
+ ),
72
+ array(
73
+ 'id' => '_um_profile_area_max_width',
74
+ 'type' => 'text',
75
+ 'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
76
+ 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
77
+ 'value' => UM()->query()->get_meta_value( '_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
78
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
79
+ ),
80
+ array(
81
+ 'id' => '_um_profile_icons',
82
+ 'type' => 'select',
83
+ 'label' => __( 'Field Icons', 'ultimate-member' ),
84
+ 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
85
+ 'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ),
86
+ 'options' => array(
87
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
88
+ 'label' => __( 'Show with label', 'ultimate-member' ),
89
+ 'off' => __( 'Turn off', 'ultimate-member' ),
90
+ ),
91
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
92
+ ),
93
+ array(
94
+ 'id' => '_um_profile_primary_btn_word',
95
+ 'type' => 'text',
96
+ 'label' => __( 'Primary Button Text', 'ultimate-member' ),
97
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
98
+ 'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
99
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
100
+ ),
101
+ array(
102
+ 'id' => '_um_profile_secondary_btn',
103
+ 'type' => 'select',
104
+ 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
105
+ 'value' => $profile_secondary_btn,
106
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
107
+ 'options' => array(
108
+ 0 => __( 'No', 'ultimate-member' ),
109
+ 1 => __( 'Yes', 'ultimate-member' ),
110
+ ),
111
+ ),
112
+ array(
113
+ 'id' => '_um_profile_secondary_btn_word',
114
+ 'type' => 'text',
115
+ 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
116
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
117
+ 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
118
+ 'conditional' => array( '_um_profile_secondary_btn', '=', 1 ),
119
+ ),
120
+ array(
121
+ 'id' => '_um_profile_cover_enabled',
122
+ 'type' => 'select',
123
+ 'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
124
+ 'value' => $profile_cover_enabled,
125
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
126
+ 'options' => array(
127
+ 0 => __( 'No', 'ultimate-member' ),
128
+ 1 => __( 'Yes', 'ultimate-member' ),
129
+ ),
130
+ ),
131
+ array(
132
+ 'id' => '_um_profile_coversize',
133
+ 'type' => 'select',
134
+ 'label' => __( 'Cover Photo Size', 'ultimate-member' ),
135
+ 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
136
+ 'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
137
+ 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
138
+ 'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
139
+ ),
140
+ array(
141
+ 'id' => '_um_profile_cover_ratio',
142
+ 'type' => 'select',
143
+ 'label' => __( 'Cover photo ratio', 'ultimate-member' ),
144
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
145
+ 'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ),
146
+ 'options' => array(
147
+ '1.6:1' => '1.6:1',
148
+ '2.7:1' => '2.7:1',
149
+ '2.2:1' => '2.2:1',
150
+ '3.2:1' => '3.2:1',
151
+ ),
152
+ 'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
153
+ ),
154
+ array(
155
+ 'id' => '_um_profile_disable_photo_upload',
156
+ 'type' => 'select',
157
+ 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
158
+ 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
159
+ 'value' => $profile_disable_photo_upl