Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | Ultimate Member – User Profile & Membership Plugin |
Version | 2.2.5 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.2.5
- assets/js/um-members.js +1790 -1785
- assets/js/um-members.min.js +1 -1
- includes/admin/assets/js/um-admin-forms.js +7 -3
- includes/admin/class-admin.php +12 -2
- includes/admin/core/class-admin-metabox.php +2 -2
- includes/admin/core/class-admin-settings.php +3475 -3455
- includes/admin/core/list-tables/roles-list-table.php +17 -12
- includes/admin/templates/access/restrict_content.php +1 -1
- includes/admin/templates/role/role-edit.php +10 -4
- includes/class-config.php +809 -807
- includes/class-functions.php +410 -395
- includes/core/class-access.php +33 -4
- includes/core/class-builtin.php +1917 -1917
- includes/core/class-fields.php +2 -2
- includes/core/class-member-directory.php +2644 -2640
- includes/core/class-password.php +721 -716
- includes/core/class-user-posts.php +14 -12
- includes/core/class-user.php +2185 -2177
- includes/core/um-actions-account.php +0 -52
assets/js/um-members.js
CHANGED
@@ -1,1785 +1,1790 @@
|
|
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 |
-
|
139 |
-
|
140 |
-
|
141 |
-
.replace( '\{
|
142 |
-
.
|
143 |
-
|
144 |
-
|
145 |
-
.replace( '\{
|
146 |
-
.replace( '\{
|
147 |
-
.
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
.
|
157 |
-
|
158 |
-
.
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
*
|
217 |
-
*
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
var
|
234 |
-
|
235 |
-
var
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
directory.
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
var
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
var
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
var
|
277 |
-
if (
|
278 |
-
|
279 |
-
}
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
um_members_hide_preloader( directory );
|
357 |
-
}
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
var
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
var
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
var
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
var
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
var
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
}
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
if ( filter_value_from === filter_value_to ) {
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
}
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
}
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
var
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
/**
|
725 |
-
*
|
726 |
-
*/
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
directory.
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
if (
|
800 |
-
return;
|
801 |
-
}
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
}
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
/**
|
875 |
-
*
|
876 |
-
*/
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
search_bar.
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
current_value = current_value.
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
current_value =
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
select
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
jQuery( '.um-search-filter #' + filter_name + '_min' ).
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
um_set_url_from_data( directory, 'filter_' + filter_name + '
|
1177 |
-
|
1178 |
-
|
1179 |
-
jQuery( '.um-search-filter #' + filter_name + '
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
jQuery( '.um-search-filter #' + filter_name + '_min' ).
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
um_set_url_from_data( directory, 'filter_' + filter_name + '
|
1302 |
-
|
1303 |
-
|
1304 |
-
jQuery( '.um-search-filter #' + filter_name + '
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
//
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
var
|
1383 |
-
var
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
um_set_url_from_data( directory, '
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
var
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
um_set_url_from_data( directory, '
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
var
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
var
|
1524 |
-
var
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
var
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
um_set_url_from_data( directory, '
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
var
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
directory
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
}
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
directory.
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
min_default_value =
|
1731 |
-
|
1732 |
-
if ( typeof
|
1733 |
-
|
1734 |
-
}
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
|
|
|
|
|
|
|
|
|
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 |
+
var um_range_min, um_range_max;
|
138 |
+
|
139 |
+
if ( ui ) {
|
140 |
+
if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
|
141 |
+
placeholder = placeholder_s.replace( '\{value\}', ui.values[ 0 ] )
|
142 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
143 |
+
.data('label') );
|
144 |
+
} else {
|
145 |
+
placeholder = placeholder_p.replace( '\{min_range\}', ui.values[ 0 ] )
|
146 |
+
.replace( '\{max_range\}', ui.values[ 1 ] )
|
147 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
148 |
+
.data('label') );
|
149 |
+
}
|
150 |
+
um_range_min = ui.values[0];
|
151 |
+
um_range_max = ui.values[1];
|
152 |
+
} else {
|
153 |
+
if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
|
154 |
+
placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
|
155 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
156 |
+
.data('label') );
|
157 |
+
} else {
|
158 |
+
placeholder = placeholder_p.replace( '\{min_range\}', slider.slider( "values", 0 ) )
|
159 |
+
.replace( '\{max_range\}', slider.slider( "values", 1 ) )
|
160 |
+
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
161 |
+
.data('label') );
|
162 |
+
}
|
163 |
+
um_range_min = slider.slider( "values", 0 );
|
164 |
+
um_range_max = slider.slider( "values", 1 );
|
165 |
+
}
|
166 |
+
slider.siblings( '.um-slider-range' ).html( placeholder );
|
167 |
+
|
168 |
+
slider.siblings( ".um_range_min" ).val( um_range_min );
|
169 |
+
slider.siblings( ".um_range_max" ).val( um_range_max );
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
+
function um_get_search( directory ) {
|
174 |
+
if ( directory.find('.um-search-line').length ) {
|
175 |
+
return directory.find( '.um-search-line' ).val();
|
176 |
+
} else {
|
177 |
+
return '';
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
function um_get_sort( directory ) {
|
182 |
+
return directory.data( 'sorting' );
|
183 |
+
}
|
184 |
+
|
185 |
+
function um_get_current_page( directory ) {
|
186 |
+
var page = directory.data( 'page' );
|
187 |
+
if ( ! page || typeof page == 'undefined' ) {
|
188 |
+
page = 1;
|
189 |
+
}
|
190 |
+
return page;
|
191 |
+
}
|
192 |
+
|
193 |
+
function um_time_convert( time, range ) {
|
194 |
+
var hours = Math.floor( time / 60 );
|
195 |
+
var minutes = time % 60;
|
196 |
+
|
197 |
+
if ( minutes >= 60 ) {
|
198 |
+
minutes = 0;
|
199 |
+
hours = hours + 1;
|
200 |
+
|
201 |
+
if ( hours >= 24 ) {
|
202 |
+
hours = 0;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
if ( minutes < 10 ) {
|
207 |
+
minutes = '0' + minutes;
|
208 |
+
}
|
209 |
+
|
210 |
+
return hours + ":" + minutes;
|
211 |
+
}
|
212 |
+
|
213 |
+
function um_ajax_get_members( directory, args ) {
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Operates with the next data:
|
217 |
+
*
|
218 |
+
* 1) Page - getting from directory data 'page'
|
219 |
+
* 2) Sort - getting from 'um-member-directory-sorting-options' field value
|
220 |
+
* 3) Search - getting from 'um-search-line' field value
|
221 |
+
* 4) Filters - getting from URL data by 'um_get_data_for_directory' function
|
222 |
+
*
|
223 |
+
*/
|
224 |
+
|
225 |
+
var hash = um_members_get_hash( directory );
|
226 |
+
|
227 |
+
var allow = wp.hooks.applyFilters( 'um_member_directory_get_members_allow', true, hash, directory );
|
228 |
+
if ( ! allow ) {
|
229 |
+
setTimeout( um_ajax_get_members, 600, directory, args );
|
230 |
+
return;
|
231 |
+
}
|
232 |
+
|
233 |
+
var page = um_get_current_page( directory );
|
234 |
+
var search = um_get_search( directory );
|
235 |
+
var sorting = um_get_sort( directory );
|
236 |
+
|
237 |
+
var local_date = new Date();
|
238 |
+
var gmt_hours = -local_date.getTimezoneOffset() / 60;
|
239 |
+
|
240 |
+
var request = {
|
241 |
+
directory_id: hash,
|
242 |
+
page: page,
|
243 |
+
search: search,
|
244 |
+
sorting: sorting,
|
245 |
+
gmt_offset: gmt_hours,
|
246 |
+
post_refferer: directory.data('base-post'),
|
247 |
+
nonce: um_scripts.nonce
|
248 |
+
};
|
249 |
+
|
250 |
+
if ( directory.find('.um-search-filter').length ) {
|
251 |
+
directory.find('.um-search-filter').each( function() {
|
252 |
+
var filter = jQuery(this);
|
253 |
+
|
254 |
+
if ( filter.find( '.um-slider' ).length ) {
|
255 |
+
var filter_name = filter.find( '.um-slider' ).data('field_name');
|
256 |
+
|
257 |
+
var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
258 |
+
var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
259 |
+
if ( typeof value_from != 'undefined' || typeof value_to != 'undefined' ) {
|
260 |
+
request[ filter_name ] = [ value_from, value_to ];
|
261 |
+
}
|
262 |
+
} else if ( filter.find( '.um-datepicker-filter' ).length ) {
|
263 |
+
var filter_name = filter.find( '.um-datepicker-filter' ).data('filter_name');
|
264 |
+
var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
265 |
+
var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
266 |
+
if ( typeof value_from != 'undefined' || typeof value_to != 'undefined') {
|
267 |
+
request[ filter_name ] = [ value_from, value_to ];
|
268 |
+
}
|
269 |
+
} else if ( filter.find( '.um-timepicker-filter' ).length ) {
|
270 |
+
var filter_name = filter.find( '.um-timepicker-filter' ).data('filter_name');
|
271 |
+
var value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
272 |
+
var value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
273 |
+
|
274 |
+
if ( typeof value_from != 'undefined' ) {
|
275 |
+
var value_from = value_from.split(':');
|
276 |
+
var hours = value_from[0]*1;
|
277 |
+
if ( hours < 10 ) {
|
278 |
+
hours = '0' + hours;
|
279 |
+
}
|
280 |
+
|
281 |
+
var minutes = value_from[1]*1;
|
282 |
+
if ( minutes < 10 ) {
|
283 |
+
minutes = '0' + minutes;
|
284 |
+
}
|
285 |
+
|
286 |
+
value_from = hours + ':' + minutes + ':00';
|
287 |
+
}
|
288 |
+
if ( typeof value_to != 'undefined' ) {
|
289 |
+
var val_to = value_to.split(':');
|
290 |
+
var minutes = val_to[1]*1;
|
291 |
+
|
292 |
+
var hours = val_to[0]*1;
|
293 |
+
if ( hours < 10 ) {
|
294 |
+
hours = '0' + hours;
|
295 |
+
}
|
296 |
+
|
297 |
+
if ( minutes < 10 ) {
|
298 |
+
minutes = '0' + minutes;
|
299 |
+
}
|
300 |
+
|
301 |
+
value_to = hours + ':' + minutes + ':59';
|
302 |
+
}
|
303 |
+
|
304 |
+
if ( typeof value_from != 'undefined' || typeof value_to != 'undefined' ) {
|
305 |
+
request[ filter_name ] = [ value_from, value_to ];
|
306 |
+
}
|
307 |
+
} else if ( filter.find( 'select' ).length ) {
|
308 |
+
var filter_name = filter.find('select').attr('name');
|
309 |
+
var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
310 |
+
if ( typeof value != 'undefined' ) {
|
311 |
+
value = um_unsanitize_value( value );
|
312 |
+
request[ filter_name ] = value.split( '||' );
|
313 |
+
}
|
314 |
+
} else if ( filter.hasClass( 'um-text-filter-type' ) && filter.find('input[type="text"]').length ) {
|
315 |
+
var filter_name = filter.find('input[type="text"]').attr('name');
|
316 |
+
var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
317 |
+
if ( typeof value != 'undefined' ) {
|
318 |
+
value = um_unsanitize_value( value );
|
319 |
+
request[ filter_name ] = value;
|
320 |
+
}
|
321 |
+
} else {
|
322 |
+
request = wp.hooks.applyFilters( 'um_member_directory_custom_filter_handler', request, filter, directory );
|
323 |
+
}
|
324 |
+
});
|
325 |
+
}
|
326 |
+
|
327 |
+
request = wp.hooks.applyFilters( 'um_member_directory_filter_request', request );
|
328 |
+
|
329 |
+
wp.ajax.send( 'um_get_members', {
|
330 |
+
data: request,
|
331 |
+
success: function( answer ) {
|
332 |
+
//set last data hard for using on layouts reloading
|
333 |
+
um_member_directory_last_data[ hash ] = answer;
|
334 |
+
|
335 |
+
um_build_template( directory, answer );
|
336 |
+
|
337 |
+
var pagination_template = wp.template( 'um-members-pagination' );
|
338 |
+
directory.find('.um-members-pagination-box').html( pagination_template( answer ) );
|
339 |
+
|
340 |
+
directory.data( 'total_pages', answer.pagination.total_pages );
|
341 |
+
|
342 |
+
if ( answer.pagination.total_pages ) {
|
343 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
344 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
345 |
+
} else {
|
346 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
|
347 |
+
directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
|
348 |
+
}
|
349 |
+
|
350 |
+
//args.directory = directory;
|
351 |
+
wp.hooks.doAction( 'um_member_directory_loaded', directory, answer );
|
352 |
+
//jQuery( document ).trigger('um_members_rendered', [ directory, answer ] );
|
353 |
+
|
354 |
+
um_init_new_dropdown();
|
355 |
+
|
356 |
+
um_members_hide_preloader( directory );
|
357 |
+
},
|
358 |
+
error: function( data ) {
|
359 |
+
console.log( data );
|
360 |
+
|
361 |
+
um_members_hide_preloader( directory );
|
362 |
+
}
|
363 |
+
});
|
364 |
+
}
|
365 |
+
|
366 |
+
|
367 |
+
function um_build_template( directory, data ) {
|
368 |
+
var layout = directory.data('view_type');
|
369 |
+
var template = wp.template( 'um-member-' + layout + '-' + um_members_get_hash( directory ) );
|
370 |
+
|
371 |
+
directory.find('.um-members-grid, .um-members-list').remove();
|
372 |
+
directory.find('.um-members-wrapper').prepend( template( data.users ) );
|
373 |
+
|
374 |
+
var header_template = wp.template( 'um-members-header' );
|
375 |
+
directory.find('.um-members-intro').remove();
|
376 |
+
|
377 |
+
var generate_header = wp.hooks.applyFilters( 'um_member_directory_generate_header', false, directory );
|
378 |
+
|
379 |
+
if ( ( typeof data.is_search != 'undefined' && data.is_search ) || generate_header ) {
|
380 |
+
directory.find('.um-members-wrapper').prepend( header_template( data ) );
|
381 |
+
}
|
382 |
+
|
383 |
+
directory.addClass('um-loaded');
|
384 |
+
|
385 |
+
if ( directory.find('.um-members.um-members-grid').length ) {
|
386 |
+
UM_Member_Grid( directory.find('.um-members.um-members-grid') );
|
387 |
+
}
|
388 |
+
|
389 |
+
jQuery( document ).trigger( 'um_build_template', [ directory, data ] );
|
390 |
+
jQuery( window ).trigger( 'resize' );
|
391 |
+
|
392 |
+
init_tipsy();
|
393 |
+
}
|
394 |
+
|
395 |
+
|
396 |
+
|
397 |
+
function UM_Member_Grid( container ) {
|
398 |
+
if ( container.find( '.um-member' ).length ) {
|
399 |
+
container.imagesLoaded( function() {
|
400 |
+
|
401 |
+
var masonry_args = wp.hooks.applyFilters( 'um_member_directory_grid_masonry_attrs', {
|
402 |
+
itemSelector: '.um-member',
|
403 |
+
columnWidth: '.um-member',
|
404 |
+
gutter: '.um-gutter-sizer'
|
405 |
+
}, container );
|
406 |
+
|
407 |
+
var $grid = container.masonry( masonry_args );
|
408 |
+
|
409 |
+
$grid.on( 'layoutComplete', function( event, laidOutItems ) {
|
410 |
+
jQuery( document ).trigger( "um_grid_initialized", [ event, laidOutItems ] );
|
411 |
+
});
|
412 |
+
});
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
|
417 |
+
function um_get_filters_data( directory ) {
|
418 |
+
var filters_data = [];
|
419 |
+
|
420 |
+
directory.find('.um-search-filter').each( function() {
|
421 |
+
|
422 |
+
var filter = jQuery(this);
|
423 |
+
var filter_name,
|
424 |
+
filter_title;
|
425 |
+
|
426 |
+
var filter_type;
|
427 |
+
if ( filter.find('input.um-datepicker-filter').length ) {
|
428 |
+
filter_type = 'datepicker';
|
429 |
+
|
430 |
+
filter.find('input.um-datepicker-filter').each( function() {
|
431 |
+
var range = jQuery(this).data('range');
|
432 |
+
if ( range === 'to' ) {
|
433 |
+
return;
|
434 |
+
}
|
435 |
+
|
436 |
+
var filter_name = jQuery(this).data('filter_name');
|
437 |
+
|
438 |
+
var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
439 |
+
var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
440 |
+
if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
|
441 |
+
return;
|
442 |
+
}
|
443 |
+
|
444 |
+
var from_val = jQuery(this).val();
|
445 |
+
var to_val = directory.find('input.um-datepicker-filter[data-range="to"][data-filter_name="' + filter_name + '"]').val();
|
446 |
+
|
447 |
+
var value;
|
448 |
+
if ( from_val === to_val ) {
|
449 |
+
value = to_val;
|
450 |
+
} else if ( from_val !== '' && to_val !== '' ) {
|
451 |
+
value = from_val + ' - ' + to_val;
|
452 |
+
} else if ( from_val === '' ) {
|
453 |
+
value = 'before ' + to_val;
|
454 |
+
} else if ( to_val === '' ) {
|
455 |
+
value = 'since ' + from_val;
|
456 |
+
}
|
457 |
+
|
458 |
+
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} );
|
459 |
+
});
|
460 |
+
|
461 |
+
} else if( filter.find('input.um-timepicker-filter').length ) {
|
462 |
+
filter_type = 'timepicker';
|
463 |
+
|
464 |
+
filter.find('input.um-timepicker-filter').each( function() {
|
465 |
+
var range = jQuery(this).data('range');
|
466 |
+
if ( range === 'to' ) {
|
467 |
+
return;
|
468 |
+
}
|
469 |
+
|
470 |
+
var filter_name = jQuery(this).data('filter_name');
|
471 |
+
|
472 |
+
var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
473 |
+
var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
474 |
+
if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
|
475 |
+
return;
|
476 |
+
}
|
477 |
+
|
478 |
+
var from_val = jQuery(this).val();
|
479 |
+
var to_val = directory.find('input.um-timepicker-filter[data-range="to"][data-filter_name="' + filter_name + '"]').val();
|
480 |
+
|
481 |
+
var value;
|
482 |
+
if ( from_val === to_val ) {
|
483 |
+
value = to_val;
|
484 |
+
} else if ( from_val !== '' && to_val !== '' ) {
|
485 |
+
value = from_val + ' - ' + to_val;
|
486 |
+
} else if ( from_val === '' ) {
|
487 |
+
value = 'before ' + to_val;
|
488 |
+
} else if ( to_val === '' ) {
|
489 |
+
value = 'since ' + from_val;
|
490 |
+
}
|
491 |
+
|
492 |
+
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} );
|
493 |
+
});
|
494 |
+
} else if( filter.find('select').length ) {
|
495 |
+
|
496 |
+
filter_type = 'select';
|
497 |
+
filter_name = filter.find('select').attr('name');
|
498 |
+
filter_title = filter.find('select').data('placeholder');
|
499 |
+
|
500 |
+
var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
501 |
+
|
502 |
+
if ( typeof filter_value == 'undefined' ) {
|
503 |
+
filter_value = [];
|
504 |
+
} else {
|
505 |
+
filter_value = um_unsanitize_value( filter_value );
|
506 |
+
filter_value = filter_value.split( '||' );
|
507 |
+
}
|
508 |
+
|
509 |
+
jQuery.each( filter_value, function(i) {
|
510 |
+
var filter_value_title = filter.find('select option[value="' + filter_value[ i ] + '"]').data('value_label');
|
511 |
+
filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value_title, 'value':filter_value[ i ], 'type':filter_type} );
|
512 |
+
});
|
513 |
+
|
514 |
+
} else if( filter.hasClass('um-text-filter-type') && filter.find('input[type="text"]').length ) {
|
515 |
+
|
516 |
+
filter_type = 'text';
|
517 |
+
filter_name = filter.find('input[type="text"]').attr('name');
|
518 |
+
filter_title = filter.find('input[type="text"]').attr('placeholder');
|
519 |
+
|
520 |
+
var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
521 |
+
if ( typeof filter_value == 'undefined' ) {
|
522 |
+
filter_value = '';
|
523 |
+
}
|
524 |
+
|
525 |
+
if ( filter_value != '' ) {
|
526 |
+
filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value, 'value':filter_value, 'type':filter_type} );
|
527 |
+
}
|
528 |
+
|
529 |
+
} else if( filter.find('div.ui-slider').length ) {
|
530 |
+
filter_type = 'slider';
|
531 |
+
|
532 |
+
filter_name = filter.find('div.ui-slider').data( 'field_name' );
|
533 |
+
var filter_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
534 |
+
var filter_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
535 |
+
|
536 |
+
if ( typeof filter_value_from === 'undefined' && typeof filter_value_to === 'undefined' ) {
|
537 |
+
return;
|
538 |
+
}
|
539 |
+
|
540 |
+
var filter_value_title;
|
541 |
+
if ( filter_value_from === filter_value_to ) {
|
542 |
+
filter_value_title = filter.find('div.um-slider-range').data( 'placeholder-s' ).replace( '\{value\}', filter_value_from )
|
543 |
+
.replace( '\{field_label\}', filter.find('div.um-slider-range').data('label') );
|
544 |
+
} else {
|
545 |
+
filter_value_title = filter.find('div.um-slider-range').data( 'placeholder-p' ).replace( '\{min_range\}', filter_value_from )
|
546 |
+
.replace( '\{max_range\}', filter_value_to )
|
547 |
+
.replace( '\{field_label\}', filter.find('div.um-slider-range').data('label') );
|
548 |
+
}
|
549 |
+
|
550 |
+
filter_title = filter.find('div.um-slider-range').data('label');
|
551 |
+
|
552 |
+
filters_data.push( {'name':filter_name, 'label':filter_title, 'value_label':filter_value_title, 'value':[filter_value_from, filter_value_to], 'type':filter_type} );
|
553 |
+
} else {
|
554 |
+
|
555 |
+
filters_data = wp.hooks.applyFilters( 'um_member_directory_get_filter_data', filters_data, directory, filter );
|
556 |
+
|
557 |
+
}
|
558 |
+
});
|
559 |
+
|
560 |
+
return filters_data;
|
561 |
+
}
|
562 |
+
|
563 |
+
|
564 |
+
function um_change_tag( directory ) {
|
565 |
+
var filters_data = um_get_filters_data( directory );
|
566 |
+
|
567 |
+
directory.find('.um-members-filter-tag').remove();
|
568 |
+
|
569 |
+
var filtered_line = directory.find('.um-filtered-line');
|
570 |
+
if ( filtered_line.length ) {
|
571 |
+
var filters_template = wp.template( 'um-members-filtered-line' );
|
572 |
+
filtered_line.prepend( filters_template( {'filters': filters_data} ) );
|
573 |
+
|
574 |
+
if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
|
575 |
+
directory.find('.um-clear-filters').hide();
|
576 |
+
directory.find('.um-clear-filters').parents('.um-member-directory-header-row').addClass( 'um-header-row-invisible' );
|
577 |
+
} else {
|
578 |
+
directory.find('.um-clear-filters').show();
|
579 |
+
directory.find('.um-clear-filters').parents('.um-member-directory-header-row').removeClass( 'um-header-row-invisible' );
|
580 |
+
}
|
581 |
+
}
|
582 |
+
|
583 |
+
|
584 |
+
}
|
585 |
+
|
586 |
+
|
587 |
+
|
588 |
+
function um_run_search( directory ) {
|
589 |
+
if ( um_is_directory_busy( directory ) ) {
|
590 |
+
return;
|
591 |
+
}
|
592 |
+
um_members_show_preloader( directory );
|
593 |
+
|
594 |
+
var pre_search = um_get_data_for_directory( directory, 'search' );
|
595 |
+
|
596 |
+
var search = um_sanitize_value( directory.find('.um-search-line').val() );
|
597 |
+
if ( search === pre_search || ( search === '' && typeof pre_search == 'undefined' ) ) {
|
598 |
+
um_members_hide_preloader( directory );
|
599 |
+
return;
|
600 |
+
}
|
601 |
+
|
602 |
+
directory.data( 'general_search', search );
|
603 |
+
um_set_url_from_data( directory, 'search', search );
|
604 |
+
|
605 |
+
//set 1st page after search
|
606 |
+
directory.data( 'page', 1 );
|
607 |
+
um_set_url_from_data( directory, 'page', '' );
|
608 |
+
|
609 |
+
|
610 |
+
var ignore_after_search = false;
|
611 |
+
ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
|
612 |
+
|
613 |
+
if ( ! ignore_after_search ) {
|
614 |
+
var show_after_search = directory.data('must-search');
|
615 |
+
if ( show_after_search === 1 ) {
|
616 |
+
search = um_get_search( directory );
|
617 |
+
if ( directory.find( '.um-members-filter-remove' ).length === 0 && ! search ) {
|
618 |
+
directory.data( 'searched', 0 );
|
619 |
+
directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
|
620 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
|
621 |
+
directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
|
622 |
+
|
623 |
+
wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
|
624 |
+
|
625 |
+
um_members_hide_preloader( directory );
|
626 |
+
return;
|
627 |
+
}
|
628 |
+
}
|
629 |
+
}
|
630 |
+
|
631 |
+
directory.data( 'searched', 1 );
|
632 |
+
|
633 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
634 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
635 |
+
|
636 |
+
um_ajax_get_members( directory );
|
637 |
+
}
|
638 |
+
|
639 |
+
|
640 |
+
jQuery(document.body).ready( function() {
|
641 |
+
|
642 |
+
|
643 |
+
jQuery( '.um-directory .um-search-filter select' ).each( function() {
|
644 |
+
if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
|
645 |
+
jQuery(this).prop('disabled', true);
|
646 |
+
}
|
647 |
+
|
648 |
+
var obj = jQuery(this);
|
649 |
+
obj.select2('destroy').select2({
|
650 |
+
dropdownParent: obj.parent()
|
651 |
+
});
|
652 |
+
});
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Change View Type Handlers
|
656 |
+
*/
|
657 |
+
|
658 |
+
|
659 |
+
//UI for change view type button
|
660 |
+
jQuery( document.body ).on( 'mouseover', '.um-directory .um-member-directory-view-type', function() {
|
661 |
+
if ( jQuery(this).hasClass('um-disabled') ) {
|
662 |
+
return;
|
663 |
+
}
|
664 |
+
|
665 |
+
var $obj = jQuery(this).find('.um-member-directory-view-type-a:visible');
|
666 |
+
|
667 |
+
$obj.hide();
|
668 |
+
|
669 |
+
if ( $obj.next().length ) {
|
670 |
+
$obj.next().show().tipsy('show');
|
671 |
+
} else {
|
672 |
+
jQuery(this).find( '.um-member-directory-view-type-a:first' ).show().tipsy('show');
|
673 |
+
}
|
674 |
+
}).on( 'mouseout', '.um-directory .um-member-directory-view-type', function() {
|
675 |
+
if ( jQuery(this).hasClass('um-disabled') ) {
|
676 |
+
return;
|
677 |
+
}
|
678 |
+
|
679 |
+
jQuery(this).find('.um-member-directory-view-type-a').hide().tipsy('hide');
|
680 |
+
jQuery(this).find('.um-member-directory-view-type-a[data-type="' + jQuery(this).parents( '.um-directory' ).data('view_type') + '"]').show();
|
681 |
+
});
|
682 |
+
|
683 |
+
//change layout handler
|
684 |
+
jQuery( document.body ).on( 'click', '.um-directory .um-member-directory-view-type-a', function() {
|
685 |
+
var directory = jQuery(this).parents('.um-directory');
|
686 |
+
if ( um_is_directory_busy( directory ) ) {
|
687 |
+
return false;
|
688 |
+
}
|
689 |
+
|
690 |
+
var $this = jQuery(this);
|
691 |
+
var views = $this.parents('.um-member-directory-view-type');
|
692 |
+
|
693 |
+
if ( views.hasClass('um-disabled') ) {
|
694 |
+
return;
|
695 |
+
}
|
696 |
+
|
697 |
+
um_members_show_preloader( directory );
|
698 |
+
|
699 |
+
var $obj = views.find('.um-member-directory-view-type-a:visible');
|
700 |
+
|
701 |
+
$obj.hide();
|
702 |
+
|
703 |
+
if ( $obj.next().length ) {
|
704 |
+
$obj.next().show().tipsy('show');
|
705 |
+
} else {
|
706 |
+
views.find( '.um-member-directory-view-type-a:first' ).show().tipsy('show');
|
707 |
+
}
|
708 |
+
|
709 |
+
var data = um_member_directory_last_data[ um_members_get_hash( directory ) ];
|
710 |
+
if ( data !== null ) {
|
711 |
+
var layout = $this.data('type');
|
712 |
+
|
713 |
+
um_set_url_from_data( directory, 'view_type', layout );
|
714 |
+
directory.data( 'view_type', layout );
|
715 |
+
|
716 |
+
um_build_template( directory, data );
|
717 |
+
|
718 |
+
um_init_new_dropdown();
|
719 |
+
}
|
720 |
+
um_members_hide_preloader( directory );
|
721 |
+
});
|
722 |
+
|
723 |
+
|
724 |
+
/**
|
725 |
+
* END: Change View Type Handlers
|
726 |
+
*/
|
727 |
+
|
728 |
+
|
729 |
+
/**
|
730 |
+
* General Search
|
731 |
+
*/
|
732 |
+
|
733 |
+
|
734 |
+
//searching
|
735 |
+
jQuery( document.body ).on( 'click', '.um-directory .um-do-search', function() {
|
736 |
+
var directory = jQuery(this).parents('.um-directory');
|
737 |
+
um_run_search( directory );
|
738 |
+
});
|
739 |
+
|
740 |
+
|
741 |
+
//make search on Enter click
|
742 |
+
jQuery( document.body ).on( 'keypress', '.um-directory .um-search-line', function(e) {
|
743 |
+
if ( e.which === 13 ) {
|
744 |
+
var directory = jQuery(this).parents('.um-directory');
|
745 |
+
um_run_search( directory );
|
746 |
+
}
|
747 |
+
});
|
748 |
+
|
749 |
+
|
750 |
+
/**
|
751 |
+
* END: General Search
|
752 |
+
*/
|
753 |
+
|
754 |
+
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Sorting
|
758 |
+
*/
|
759 |
+
|
760 |
+
jQuery( document.body ).on( 'click', '.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a', function() {
|
761 |
+
if ( jQuery( this ).data('selected') === 1 ) {
|
762 |
+
return;
|
763 |
+
}
|
764 |
+
|
765 |
+
var directory_hash = jQuery(this).data('directory-hash');
|
766 |
+
var directory = jQuery('.um-directory[data-hash="' + directory_hash + '"]');
|
767 |
+
|
768 |
+
if ( um_is_directory_busy( directory ) ) {
|
769 |
+
return;
|
770 |
+
}
|
771 |
+
|
772 |
+
um_members_show_preloader( directory );
|
773 |
+
|
774 |
+
var sorting_label = jQuery( this ).html();
|
775 |
+
var sort = jQuery(this).data('value');
|
776 |
+
|
777 |
+
directory.data( 'sorting', sort );
|
778 |
+
um_set_url_from_data( directory, 'sort', sort );
|
779 |
+
|
780 |
+
um_ajax_get_members( directory );
|
781 |
+
|
782 |
+
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);
|
783 |
+
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);
|
784 |
+
directory.find('.um-member-directory-sorting-a').find('> a').html( sorting_label );
|
785 |
+
});
|
786 |
+
|
787 |
+
/**
|
788 |
+
* END: Sorting
|
789 |
+
*/
|
790 |
+
|
791 |
+
|
792 |
+
|
793 |
+
/**
|
794 |
+
* Pagination
|
795 |
+
*/
|
796 |
+
|
797 |
+
|
798 |
+
jQuery( document.body ).on( 'click', '.um-directory .pagi:not(.current)', function() {
|
799 |
+
if ( jQuery(this).hasClass('disabled') ) {
|
800 |
+
return;
|
801 |
+
}
|
802 |
+
|
803 |
+
var directory = jQuery(this).parents('.um-directory');
|
804 |
+
if ( um_is_directory_busy( directory ) ) {
|
805 |
+
return;
|
806 |
+
}
|
807 |
+
|
808 |
+
um_members_show_preloader( directory );
|
809 |
+
|
810 |
+
var page;
|
811 |
+
if ( 'first' === jQuery(this).data('page') ) {
|
812 |
+
page = 1;
|
813 |
+
} else if ( 'prev' === jQuery(this).data('page') ) {
|
814 |
+
page = directory.data( 'page' )*1 - 1;
|
815 |
+
} else if ( 'next' === jQuery(this).data('page') ) {
|
816 |
+
page = directory.data( 'page' )*1 + 1;
|
817 |
+
} else if ( 'last' === jQuery(this).data('page') ) {
|
818 |
+
page = parseInt( directory.data( 'total_pages' ) );
|
819 |
+
} else {
|
820 |
+
page = parseInt( jQuery(this).data('page') );
|
821 |
+
}
|
822 |
+
|
823 |
+
if ( page === 1 ) {
|
824 |
+
directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass('disabled');
|
825 |
+
directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
|
826 |
+
} else if ( page === parseInt( directory.data( 'total_pages' ) ) ) {
|
827 |
+
directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass('disabled');
|
828 |
+
directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass('disabled');
|
829 |
+
} else {
|
830 |
+
directory.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass('disabled');
|
831 |
+
directory.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass('disabled');
|
832 |
+
}
|
833 |
+
|
834 |
+
directory.find('.pagi').removeClass('current');
|
835 |
+
directory.find('.pagi[data-page="' + page + '"]').addClass('current');
|
836 |
+
|
837 |
+
directory.data( 'page', page );
|
838 |
+
if ( page === 1 ) {
|
839 |
+
um_set_url_from_data( directory, 'page', '' );
|
840 |
+
} else {
|
841 |
+
um_set_url_from_data( directory, 'page', page );
|
842 |
+
}
|
843 |
+
|
844 |
+
um_ajax_get_members( directory );
|
845 |
+
});
|
846 |
+
|
847 |
+
|
848 |
+
//mobile pagination
|
849 |
+
jQuery( document.body ).on( 'change', '.um-directory .um-members-pagi-dropdown', function() {
|
850 |
+
var directory = jQuery(this).parents('.um-directory');
|
851 |
+
|
852 |
+
if ( um_is_directory_busy( directory ) ) {
|
853 |
+
return;
|
854 |
+
}
|
855 |
+
|
856 |
+
um_members_show_preloader( directory );
|
857 |
+
|
858 |
+
var page = jQuery(this).val();
|
859 |
+
|
860 |
+
directory.find('.pagi').removeClass('current');
|
861 |
+
directory.find('.pagi[data-page="' + page + '"]').addClass('current');
|
862 |
+
|
863 |
+
directory.data( 'page', page );
|
864 |
+
if ( page === 1 ) {
|
865 |
+
um_set_url_from_data( directory, 'page', '' );
|
866 |
+
} else {
|
867 |
+
um_set_url_from_data( directory, 'page', page );
|
868 |
+
}
|
869 |
+
|
870 |
+
um_ajax_get_members( directory );
|
871 |
+
});
|
872 |
+
|
873 |
+
|
874 |
+
/**
|
875 |
+
* END: Pagination
|
876 |
+
*/
|
877 |
+
|
878 |
+
|
879 |
+
/**
|
880 |
+
* Profile Cards actions
|
881 |
+
*/
|
882 |
+
|
883 |
+
jQuery( document.body ).on('click', '.um-directory .um-members.um-members-list .um-member-more a', function(e){
|
884 |
+
e.preventDefault();
|
885 |
+
|
886 |
+
var block = jQuery(this).parents('.um-member');
|
887 |
+
|
888 |
+
block.find('.um-member-more').hide();
|
889 |
+
block.find('.um-member-meta-main').slideDown();
|
890 |
+
block.find('.um-member-less').fadeIn();
|
891 |
+
|
892 |
+
return false;
|
893 |
+
});
|
894 |
+
|
895 |
+
jQuery( document.body ).on('click', '.um-directory .um-members.um-members-list .um-member-less a', function(e){
|
896 |
+
e.preventDefault();
|
897 |
+
|
898 |
+
var block = jQuery(this).parents('.um-member');
|
899 |
+
|
900 |
+
block.find('.um-member-less').hide();
|
901 |
+
block.find('.um-member-meta-main').slideUp();
|
902 |
+
block.find('.um-member-more').fadeIn();
|
903 |
+
|
904 |
+
return false;
|
905 |
+
});
|
906 |
+
|
907 |
+
|
908 |
+
jQuery( document.body ).on('click', '.um-directory .um-members.um-members-grid .um-member-more a', function(e){
|
909 |
+
e.preventDefault();
|
910 |
+
|
911 |
+
var block = jQuery(this).parents('.um-member');
|
912 |
+
var container = jQuery(this).parents('.um-members');
|
913 |
+
block.find('.um-member-more').hide();
|
914 |
+
block.find('.um-member-meta').slideDown( function(){ UM_Member_Grid( container ) } );
|
915 |
+
block.find('.um-member-less').fadeIn( );
|
916 |
+
|
917 |
+
setTimeout(function(){ UM_Member_Grid( container ) }, 100);
|
918 |
+
|
919 |
+
return false;
|
920 |
+
});
|
921 |
+
|
922 |
+
jQuery( document.body ).on('click', '.um-directory .um-members.um-members-grid .um-member-less a', function(e){
|
923 |
+
e.preventDefault();
|
924 |
+
|
925 |
+
var block = jQuery(this).parents('.um-member');
|
926 |
+
var container = jQuery(this).parents('.um-members');
|
927 |
+
block.find('.um-member-less').hide();
|
928 |
+
block.find('.um-member-meta').slideUp( function() {
|
929 |
+
block.find('.um-member-more').fadeIn();
|
930 |
+
UM_Member_Grid( container );
|
931 |
+
});
|
932 |
+
|
933 |
+
return false;
|
934 |
+
});
|
935 |
+
|
936 |
+
/**
|
937 |
+
* END: Profile Cards actions
|
938 |
+
*/
|
939 |
+
|
940 |
+
|
941 |
+
//filters controls
|
942 |
+
jQuery('.um-member-directory-filters-a').on( 'click', function() {
|
943 |
+
var obj = jQuery(this);
|
944 |
+
var search_bar = obj.parents('.um-directory').find('.um-search');
|
945 |
+
|
946 |
+
if ( search_bar.is( ':visible' ) ) {
|
947 |
+
search_bar.slideUp( 250, function(){
|
948 |
+
obj.toggleClass('um-member-directory-filters-visible');
|
949 |
+
search_bar.parents('.um-member-directory-header-row').toggleClass('um-header-row-invisible');
|
950 |
+
});
|
951 |
+
} else {
|
952 |
+
search_bar.slideDown({
|
953 |
+
duration: 250,
|
954 |
+
start: function() {
|
955 |
+
jQuery(this).css({
|
956 |
+
display: "grid"
|
957 |
+
});
|
958 |
+
obj.toggleClass('um-member-directory-filters-visible');
|
959 |
+
search_bar.parents('.um-member-directory-header-row').toggleClass('um-header-row-invisible');
|
960 |
+
}
|
961 |
+
} );
|
962 |
+
}
|
963 |
+
});
|
964 |
+
|
965 |
+
|
966 |
+
//filtration process
|
967 |
+
jQuery( document.body ).on( 'change', '.um-directory .um-search-filter select', function() {
|
968 |
+
var selected_val_raw = jQuery(this).val();
|
969 |
+
var selected_val = um_sanitize_value( selected_val_raw );
|
970 |
+
|
971 |
+
if ( selected_val === '' ) {
|
972 |
+
return;
|
973 |
+
}
|
974 |
+
|
975 |
+
var directory = jQuery(this).parents('.um-directory');
|
976 |
+
|
977 |
+
if ( um_is_directory_busy( directory ) ) {
|
978 |
+
return;
|
979 |
+
}
|
980 |
+
|
981 |
+
um_members_show_preloader( directory );
|
982 |
+
|
983 |
+
var filter_name = jQuery(this).prop('name');
|
984 |
+
|
985 |
+
var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
986 |
+
if ( typeof current_value == 'undefined' ) {
|
987 |
+
current_value = [];
|
988 |
+
} else {
|
989 |
+
current_value = current_value.split( '||' );
|
990 |
+
}
|
991 |
+
|
992 |
+
if ( -1 === jQuery.inArray( selected_val, current_value ) ) {
|
993 |
+
current_value.push( selected_val );
|
994 |
+
current_value = current_value.join( '||' );
|
995 |
+
|
996 |
+
um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
|
997 |
+
|
998 |
+
//set 1st page after filtration
|
999 |
+
directory.data( 'page', 1 );
|
1000 |
+
um_set_url_from_data( directory, 'page', '' );
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
//disable options and disable select if all options are disabled
|
1004 |
+
jQuery(this).find('option[value="' + selected_val_raw + '"]').prop('disabled', true).hide();
|
1005 |
+
if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
|
1006 |
+
jQuery(this).prop('disabled', true);
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
var obj = jQuery(this);
|
1010 |
+
obj.select2('destroy').select2({
|
1011 |
+
dropdownParent: obj.parent()
|
1012 |
+
});
|
1013 |
+
obj.val('').trigger( 'change' );
|
1014 |
+
|
1015 |
+
um_ajax_get_members( directory );
|
1016 |
+
|
1017 |
+
um_change_tag( directory );
|
1018 |
+
|
1019 |
+
directory.data( 'searched', 1 );
|
1020 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1021 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1022 |
+
// if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
|
1023 |
+
// jQuery(this).trigger('change');
|
1024 |
+
// }
|
1025 |
+
});
|
1026 |
+
|
1027 |
+
|
1028 |
+
jQuery( document.body ).on( 'blur', '.um-directory .um-search-filter.um-text-filter-type input[type="text"]', function() {
|
1029 |
+
var directory = jQuery(this).parents('.um-directory');
|
1030 |
+
|
1031 |
+
if ( um_is_directory_busy( directory ) ) {
|
1032 |
+
return;
|
1033 |
+
}
|
1034 |
+
|
1035 |
+
var current_value = um_sanitize_value( jQuery(this).val() );
|
1036 |
+
var filter_name = jQuery(this).prop('name');
|
1037 |
+
var url_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
1038 |
+
|
1039 |
+
if ( typeof url_value == 'undefined' ) {
|
1040 |
+
url_value = '';
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
if ( current_value === url_value ) {
|
1044 |
+
return;
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
um_members_show_preloader( directory );
|
1048 |
+
um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
|
1049 |
+
|
1050 |
+
//set 1st page after filtration
|
1051 |
+
directory.data( 'page', 1 );
|
1052 |
+
um_set_url_from_data( directory, 'page', '' );
|
1053 |
+
|
1054 |
+
um_ajax_get_members( directory );
|
1055 |
+
|
1056 |
+
um_change_tag( directory );
|
1057 |
+
|
1058 |
+
directory.data( 'searched', 1 );
|
1059 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1060 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1061 |
+
});
|
1062 |
+
|
1063 |
+
|
1064 |
+
//make search on Enter click
|
1065 |
+
jQuery( document.body ).on( 'keypress', '.um-directory .um-search-filter.um-text-filter-type input[type="text"]', function(e) {
|
1066 |
+
if ( e.which === 13 ) {
|
1067 |
+
var directory = jQuery(this).parents('.um-directory');
|
1068 |
+
|
1069 |
+
if ( um_is_directory_busy( directory ) ) {
|
1070 |
+
return;
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
var current_value = um_sanitize_value( jQuery(this).val() );
|
1074 |
+
var filter_name = jQuery(this).prop('name');
|
1075 |
+
var url_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
1076 |
+
|
1077 |
+
if ( typeof url_value == 'undefined' ) {
|
1078 |
+
url_value = '';
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
if ( current_value === url_value ) {
|
1082 |
+
return;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
um_members_show_preloader( directory );
|
1086 |
+
um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
|
1087 |
+
|
1088 |
+
//set 1st page after filtration
|
1089 |
+
directory.data( 'page', 1 );
|
1090 |
+
um_set_url_from_data( directory, 'page', '' );
|
1091 |
+
|
1092 |
+
um_ajax_get_members( directory );
|
1093 |
+
|
1094 |
+
um_change_tag( directory );
|
1095 |
+
|
1096 |
+
directory.data( 'searched', 1 );
|
1097 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1098 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1099 |
+
}
|
1100 |
+
});
|
1101 |
+
|
1102 |
+
|
1103 |
+
|
1104 |
+
jQuery( document.body ).on( 'click', '.um-directory .um-members-filter-remove', function() {
|
1105 |
+
var directory = jQuery(this).parents('.um-directory');
|
1106 |
+
|
1107 |
+
if ( um_is_directory_busy(directory) || ! directory ) {
|
1108 |
+
return;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
um_members_show_preloader( directory );
|
1112 |
+
|
1113 |
+
var removeItem = jQuery(this).data('value');
|
1114 |
+
var filter_name = jQuery(this).data('name');
|
1115 |
+
|
1116 |
+
var type = jQuery(this).data('type');
|
1117 |
+
if ( type === 'text' ) {
|
1118 |
+
um_set_url_from_data( directory, 'filter_' + filter_name,'' );
|
1119 |
+
|
1120 |
+
jQuery( '.um-search-filter input[name="' + filter_name + '"]' ).val('');
|
1121 |
+
|
1122 |
+
} else if ( type === 'select' ) {
|
1123 |
+
|
1124 |
+
var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
1125 |
+
if ( typeof current_value == 'undefined' ) {
|
1126 |
+
current_value = [];
|
1127 |
+
} else {
|
1128 |
+
current_value = um_unsanitize_value( current_value );
|
1129 |
+
current_value = current_value.split( '||' );
|
1130 |
+
}
|
1131 |
+
|
1132 |
+
if ( -1 !== jQuery.inArray( removeItem.toString(), current_value ) ) {
|
1133 |
+
current_value = jQuery.grep( current_value, function( value ) {
|
1134 |
+
return value !== removeItem.toString();
|
1135 |
+
});
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
if ( ! current_value.length ) {
|
1139 |
+
current_value = '';
|
1140 |
+
}
|
1141 |
+
|
1142 |
+
um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
|
1143 |
+
|
1144 |
+
var select = jQuery( '.um-search-filter select[name="' + filter_name + '"]' );
|
1145 |
+
select.find('option[value="' + removeItem + '"]').prop('disabled', false).show();
|
1146 |
+
|
1147 |
+
//disable options and disable select if all options are disabled
|
1148 |
+
if ( select.find('option:not(:disabled)').length > 1 ) {
|
1149 |
+
select.prop('disabled', false);
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
select.select2('destroy').select2({
|
1153 |
+
dropdownParent: select.parent()
|
1154 |
+
});
|
1155 |
+
|
1156 |
+
if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
|
1157 |
+
select.trigger('change');
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
} else if ( type === 'slider' ) {
|
1161 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
|
1162 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
|
1163 |
+
|
1164 |
+
|
1165 |
+
var $slider = jQuery( '.um-search-filter #' + filter_name + '_min' ).siblings('.um-slider');
|
1166 |
+
var options = $slider.slider( 'option' );
|
1167 |
+
|
1168 |
+
$slider.slider( 'values', [ options.min, options.max ] );
|
1169 |
+
|
1170 |
+
jQuery( '.um-search-filter #' + filter_name + '_min' ).val('');
|
1171 |
+
jQuery( '.um-search-filter #' + filter_name + '_max' ).val('');
|
1172 |
+
|
1173 |
+
um_set_range_label( $slider );
|
1174 |
+
} else if ( type === 'datepicker' ) {
|
1175 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
|
1176 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
|
1177 |
+
|
1178 |
+
jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
|
1179 |
+
jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
|
1180 |
+
} else if ( type === 'timepicker' ) {
|
1181 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
|
1182 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
|
1183 |
+
|
1184 |
+
jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
|
1185 |
+
jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
|
1186 |
+
} else {
|
1187 |
+
wp.hooks.doAction( 'um_member_directory_filter_remove', type, directory, filter_name, removeItem );
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
|
1191 |
+
//set 1st page after filtration
|
1192 |
+
directory.data( 'page', 1 );
|
1193 |
+
um_set_url_from_data( directory, 'page', '' );
|
1194 |
+
|
1195 |
+
jQuery(this).tipsy('hide');
|
1196 |
+
jQuery(this).parents('.um-members-filter-tag').remove();
|
1197 |
+
|
1198 |
+
if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
|
1199 |
+
directory.find('.um-clear-filters').hide();
|
1200 |
+
} else {
|
1201 |
+
directory.find('.um-clear-filters').show();
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
var ignore_after_search = false;
|
1205 |
+
ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
|
1206 |
+
|
1207 |
+
if ( ! ignore_after_search ) {
|
1208 |
+
var show_after_search = directory.data('must-search');
|
1209 |
+
if ( show_after_search === 1 ) {
|
1210 |
+
var search = um_get_search( directory );
|
1211 |
+
if ( directory.find( '.um-members-filter-remove' ).length === 0 && ! search ) {
|
1212 |
+
directory.data( 'searched', 0 );
|
1213 |
+
directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
|
1214 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
|
1215 |
+
directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
|
1216 |
+
|
1217 |
+
wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
|
1218 |
+
|
1219 |
+
um_members_hide_preloader( directory );
|
1220 |
+
return;
|
1221 |
+
}
|
1222 |
+
}
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1226 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1227 |
+
|
1228 |
+
um_ajax_get_members( directory );
|
1229 |
+
});
|
1230 |
+
|
1231 |
+
|
1232 |
+
jQuery( document.body ).on( 'click', '.um-directory .um-clear-filters-a', function() {
|
1233 |
+
var directory = jQuery(this).parents('.um-directory');
|
1234 |
+
if ( um_is_directory_busy( directory ) ) {
|
1235 |
+
return;
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
um_members_show_preloader( directory );
|
1239 |
+
|
1240 |
+
directory.find( '.um-members-filter-remove' ).each( function() {
|
1241 |
+
var removeItem = jQuery(this).data('value');
|
1242 |
+
var filter_name = jQuery(this).data('name');
|
1243 |
+
|
1244 |
+
var type = jQuery(this).data('type');
|
1245 |
+
if ( type === 'text' ) {
|
1246 |
+
um_set_url_from_data( directory, 'filter_' + filter_name,'' );
|
1247 |
+
|
1248 |
+
jQuery( '.um-search-filter input[name="' + filter_name + '"]' ).val('');
|
1249 |
+
|
1250 |
+
} else if ( type === 'select' ) {
|
1251 |
+
|
1252 |
+
var current_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
|
1253 |
+
if ( typeof current_value == 'undefined' ) {
|
1254 |
+
current_value = [];
|
1255 |
+
} else {
|
1256 |
+
current_value = current_value.split( '||' );
|
1257 |
+
}
|
1258 |
+
|
1259 |
+
if ( -1 !== jQuery.inArray( removeItem.toString(), current_value ) ) {
|
1260 |
+
current_value = jQuery.grep( current_value, function( value ) {
|
1261 |
+
return value !== removeItem.toString();
|
1262 |
+
});
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
if ( ! current_value.length ) {
|
1266 |
+
current_value = '';
|
1267 |
+
}
|
1268 |
+
|
1269 |
+
um_set_url_from_data( directory, 'filter_' + filter_name, current_value );
|
1270 |
+
|
1271 |
+
var select = jQuery( '.um-search-filter select[name="' + filter_name + '"]' );
|
1272 |
+
select.find('option[value="' + removeItem + '"]').prop('disabled', false).show();
|
1273 |
+
|
1274 |
+
//disable options and disable select if all options are disabled
|
1275 |
+
if ( select.find('option:not(:disabled)').length > 1 ) {
|
1276 |
+
select.prop('disabled', false);
|
1277 |
+
}
|
1278 |
+
select.select2('destroy').select2({
|
1279 |
+
dropdownParent: select.parent()
|
1280 |
+
});
|
1281 |
+
|
1282 |
+
if ( directory.find( '.um-search-filter select[data-um-parent="' + filter_name + '"]' ).length > 0 ) {
|
1283 |
+
select.trigger('change');
|
1284 |
+
}
|
1285 |
+
|
1286 |
+
} else if ( type === 'slider' ) {
|
1287 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
|
1288 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
|
1289 |
+
|
1290 |
+
var $slider = jQuery( '.um-search-filter #' + filter_name + '_min' ).siblings('.um-slider');
|
1291 |
+
var options = $slider.slider( 'option' );
|
1292 |
+
|
1293 |
+
$slider.slider( 'values', [ options.min, options.max ] );
|
1294 |
+
|
1295 |
+
jQuery( '.um-search-filter #' + filter_name + '_min' ).val('');
|
1296 |
+
jQuery( '.um-search-filter #' + filter_name + '_max' ).val('');
|
1297 |
+
|
1298 |
+
um_set_range_label( $slider );
|
1299 |
+
} else if ( type === 'datepicker' ) {
|
1300 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
|
1301 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
|
1302 |
+
|
1303 |
+
jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
|
1304 |
+
jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
|
1305 |
+
} else if ( type === 'timepicker' ) {
|
1306 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from','' );
|
1307 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', '' );
|
1308 |
+
|
1309 |
+
jQuery( '.um-search-filter #' + filter_name + '_from' ).val('');
|
1310 |
+
jQuery( '.um-search-filter #' + filter_name + '_to' ).val('');
|
1311 |
+
} else {
|
1312 |
+
wp.hooks.doAction( 'um_member_directory_clear_filters', type, directory, filter_name, removeItem );
|
1313 |
+
}
|
1314 |
+
});
|
1315 |
+
|
1316 |
+
//set 1st page after filtration
|
1317 |
+
directory.data( 'page', 1 );
|
1318 |
+
um_set_url_from_data( directory, 'page', '' );
|
1319 |
+
directory.find('.um-members-filter-tag').remove();
|
1320 |
+
|
1321 |
+
//jQuery(this).hide();
|
1322 |
+
if ( directory.find( '.um-members-filter-remove' ).length === 0 ) {
|
1323 |
+
directory.find('.um-clear-filters').hide();
|
1324 |
+
directory.find('.um-clear-filters').parents('.um-member-directory-header-row').addClass( 'um-header-row-invisible' );
|
1325 |
+
} else {
|
1326 |
+
directory.find('.um-clear-filters').show();
|
1327 |
+
directory.find('.um-clear-filters').parents('.um-member-directory-header-row').removeClass( 'um-header-row-invisible' );
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
var ignore_after_search = false;
|
1331 |
+
ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
|
1332 |
+
|
1333 |
+
if ( ! ignore_after_search ) {
|
1334 |
+
var show_after_search = directory.data('must-search');
|
1335 |
+
if ( show_after_search === 1 ) {
|
1336 |
+
var search = um_get_search( directory );
|
1337 |
+
if ( ! search ) {
|
1338 |
+
directory.data( 'searched', 0 );
|
1339 |
+
directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
|
1340 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', true );
|
1341 |
+
directory.find( '.um-member-directory-view-type' ).addClass( 'um-disabled' );
|
1342 |
+
|
1343 |
+
wp.hooks.doAction( 'um_member_directory_clear_not_searched', directory );
|
1344 |
+
|
1345 |
+
um_members_hide_preloader( directory );
|
1346 |
+
return;
|
1347 |
+
}
|
1348 |
+
}
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1352 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1353 |
+
|
1354 |
+
um_ajax_get_members( directory );
|
1355 |
+
});
|
1356 |
+
|
1357 |
+
|
1358 |
+
/**
|
1359 |
+
* First Page Loading
|
1360 |
+
*/
|
1361 |
+
|
1362 |
+
wp.hooks.doAction( 'um_member_directory_on_first_pages_loading' );
|
1363 |
+
|
1364 |
+
//Init Directories
|
1365 |
+
jQuery( '.um-directory' ).each( function() {
|
1366 |
+
var directory = jQuery(this);
|
1367 |
+
var hash = um_members_get_hash( directory );
|
1368 |
+
|
1369 |
+
um_member_directories.push( hash );
|
1370 |
+
|
1371 |
+
// slideup/slidedown animation fix for grid filters bar
|
1372 |
+
if ( directory.find('.um-search').length ) {
|
1373 |
+
if ( ! directory.find('.um-search').is(':visible') ) {
|
1374 |
+
directory.find('.um-search').css({
|
1375 |
+
display: "grid"
|
1376 |
+
}).slideUp( 1 );
|
1377 |
+
}
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
//slider filter
|
1381 |
+
directory.find('.um-slider').each( function() {
|
1382 |
+
var slider = jQuery( this );
|
1383 |
+
var directory = slider.parents('.um-directory');
|
1384 |
+
|
1385 |
+
var filter_name = slider.data('field_name');
|
1386 |
+
|
1387 |
+
var min_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
1388 |
+
var max_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
1389 |
+
if ( typeof min_default_value == 'undefined' ) {
|
1390 |
+
min_default_value = parseInt( slider.data('min') );
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
if ( typeof max_default_value == 'undefined' ) {
|
1394 |
+
max_default_value = parseInt( slider.data('max') );
|
1395 |
+
}
|
1396 |
+
|
1397 |
+
var default_value = [ min_default_value, max_default_value ];
|
1398 |
+
|
1399 |
+
slider.slider({
|
1400 |
+
range: true,
|
1401 |
+
min: parseInt( slider.data('min') ),
|
1402 |
+
max: parseInt( slider.data('max') ),
|
1403 |
+
values: default_value,
|
1404 |
+
create: function( event, ui ) {
|
1405 |
+
//console.log( ui );
|
1406 |
+
},
|
1407 |
+
step: 1,
|
1408 |
+
slide: function( event, ui ) {
|
1409 |
+
um_set_range_label( jQuery( this ), ui );
|
1410 |
+
},
|
1411 |
+
stop: function( event, ui ) {
|
1412 |
+
if ( ! um_is_directory_busy( directory ) ) {
|
1413 |
+
|
1414 |
+
um_members_show_preloader( directory );
|
1415 |
+
|
1416 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from', ui.values[0] );
|
1417 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', ui.values[1] );
|
1418 |
+
|
1419 |
+
//set 1st page after filtration
|
1420 |
+
directory.data( 'page', 1 );
|
1421 |
+
um_set_url_from_data( directory, 'page', '' );
|
1422 |
+
um_ajax_get_members( directory );
|
1423 |
+
|
1424 |
+
um_change_tag( directory );
|
1425 |
+
|
1426 |
+
directory.data( 'searched', 1 );
|
1427 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1428 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1429 |
+
}
|
1430 |
+
}
|
1431 |
+
});
|
1432 |
+
|
1433 |
+
um_set_range_label( slider );
|
1434 |
+
});
|
1435 |
+
|
1436 |
+
|
1437 |
+
//datepicker filter
|
1438 |
+
directory.find('.um-datepicker-filter').each( function() {
|
1439 |
+
var elem = jQuery(this);
|
1440 |
+
|
1441 |
+
var min = new Date( elem.data('date_min')*1000 );
|
1442 |
+
var max = new Date( elem.data('date_max')*1000 );
|
1443 |
+
|
1444 |
+
var $input = elem.pickadate({
|
1445 |
+
selectYears: true,
|
1446 |
+
min: min,
|
1447 |
+
max: max,
|
1448 |
+
formatSubmit: 'yyyy/mm/dd',
|
1449 |
+
hiddenName: true,
|
1450 |
+
onOpen: function() {
|
1451 |
+
elem.blur();
|
1452 |
+
},
|
1453 |
+
onClose: function() {
|
1454 |
+
elem.blur();
|
1455 |
+
},
|
1456 |
+
onSet: function( context ) {
|
1457 |
+
|
1458 |
+
if ( ! context.select ) {
|
1459 |
+
return;
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
var directory = elem.parents('.um-directory');
|
1463 |
+
|
1464 |
+
if ( um_is_directory_busy( directory ) ) {
|
1465 |
+
return;
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
um_members_show_preloader( directory );
|
1469 |
+
|
1470 |
+
var filter_name = elem.data( 'filter_name' );
|
1471 |
+
var range = elem.data( 'range' );
|
1472 |
+
|
1473 |
+
var current_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
1474 |
+
var current_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
1475 |
+
if ( typeof current_value_from === "undefined" ) {
|
1476 |
+
current_value_from = min / 1000;
|
1477 |
+
}
|
1478 |
+
if ( typeof current_value_to === "undefined" ) {
|
1479 |
+
current_value_to = max / 1000;
|
1480 |
+
}
|
1481 |
+
|
1482 |
+
var select_val = context.select / 1000;
|
1483 |
+
var change_val = elem.val();
|
1484 |
+
|
1485 |
+
if ( range === 'from' ) {
|
1486 |
+
current_value_from = select_val;
|
1487 |
+
} else if ( range === 'to' ) {
|
1488 |
+
current_value_to = select_val;
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from', current_value_from );
|
1492 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', current_value_to );
|
1493 |
+
|
1494 |
+
//set 1st page after filtration
|
1495 |
+
directory.data( 'page', 1 );
|
1496 |
+
um_set_url_from_data( directory, 'page', '' );
|
1497 |
+
|
1498 |
+
um_ajax_get_members( directory );
|
1499 |
+
|
1500 |
+
um_change_tag( directory );
|
1501 |
+
|
1502 |
+
directory.data( 'searched', 1 );
|
1503 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1504 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1505 |
+
}
|
1506 |
+
});
|
1507 |
+
|
1508 |
+
var $picker = $input.pickadate('picker');
|
1509 |
+
var $fname = elem.data('filter_name');
|
1510 |
+
var $frange = elem.data('range');
|
1511 |
+
var $directory = elem.parents('.um-directory');
|
1512 |
+
|
1513 |
+
var query_value = um_get_data_for_directory( $directory, 'filter_' + $fname + '_' + $frange );
|
1514 |
+
if ( typeof query_value !== 'undefined' ) {
|
1515 |
+
$picker.set( 'select', query_value*1000 );
|
1516 |
+
}
|
1517 |
+
|
1518 |
+
});
|
1519 |
+
|
1520 |
+
|
1521 |
+
//timepicker filter
|
1522 |
+
directory.find('.um-timepicker-filter').each( function() {
|
1523 |
+
var elem = jQuery(this);
|
1524 |
+
var elemID = elem.attr('id');
|
1525 |
+
var elem_filter_name = elem.data('filter_name');
|
1526 |
+
|
1527 |
+
//using arrays formatted as [HOUR,MINUTE]
|
1528 |
+
var min = elem.attr('data-min');
|
1529 |
+
var max = elem.attr('data-max');
|
1530 |
+
|
1531 |
+
var picker_min = min.split(':');
|
1532 |
+
var picker_max = max.split(':');
|
1533 |
+
|
1534 |
+
var $input = elem.pickatime({
|
1535 |
+
format: elem.data('format'),
|
1536 |
+
interval: parseInt( elem.data('intervals') ),
|
1537 |
+
min: [picker_min[0],picker_min[1]],
|
1538 |
+
max: [picker_max[0],picker_max[1]],
|
1539 |
+
formatSubmit: 'HH:i',
|
1540 |
+
hiddenName: true,
|
1541 |
+
onOpen: function() { elem.blur(); },
|
1542 |
+
onClose: function() { elem.blur(); },
|
1543 |
+
onSet: function( context ) {
|
1544 |
+
|
1545 |
+
if ( ! context.select ) {
|
1546 |
+
return;
|
1547 |
+
}
|
1548 |
+
|
1549 |
+
var directory = elem.parents('.um-directory');
|
1550 |
+
|
1551 |
+
if ( um_is_directory_busy( directory ) ) {
|
1552 |
+
return;
|
1553 |
+
}
|
1554 |
+
|
1555 |
+
um_members_show_preloader( directory );
|
1556 |
+
|
1557 |
+
var filter_name = elem.data( 'filter_name' );
|
1558 |
+
var range = elem.data( 'range' );
|
1559 |
+
|
1560 |
+
var current_value_from = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
1561 |
+
var current_value_to = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
1562 |
+
if ( typeof current_value_from === "undefined" ) {
|
1563 |
+
current_value_from = min;
|
1564 |
+
}
|
1565 |
+
if ( typeof current_value_to === "undefined" ) {
|
1566 |
+
current_value_to = max;
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
if ( typeof context.select !== 'undefined' ) {
|
1570 |
+
var select_val = um_time_convert( context.select, range );
|
1571 |
+
|
1572 |
+
//var select_val = context.select / 60;
|
1573 |
+
|
1574 |
+
if ( range === 'from' ) {
|
1575 |
+
current_value_from = select_val;
|
1576 |
+
} else if ( range === 'to' ) {
|
1577 |
+
current_value_to = select_val;
|
1578 |
+
}
|
1579 |
+
} else {
|
1580 |
+
if ( range === 'from' ) {
|
1581 |
+
current_value_from = min;
|
1582 |
+
} else if ( range === 'to' ) {
|
1583 |
+
current_value_to = max;
|
1584 |
+
}
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
var time = jQuery( '#' + elemID ).val();
|
1588 |
+
|
1589 |
+
if ( elem.data('range') === 'from' ) {
|
1590 |
+
jQuery( '#' + elem_filter_name + '_to' ).pickatime('picker').set('min', time);
|
1591 |
+
} else {
|
1592 |
+
jQuery( '#' + elem_filter_name + '_from').pickatime('picker').set('max', time);
|
1593 |
+
}
|
1594 |
+
|
1595 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_from', current_value_from );
|
1596 |
+
um_set_url_from_data( directory, 'filter_' + filter_name + '_to', current_value_to );
|
1597 |
+
|
1598 |
+
//set 1st page after filtration
|
1599 |
+
directory.data( 'page', 1 );
|
1600 |
+
um_set_url_from_data( directory, 'page', '' );
|
1601 |
+
|
1602 |
+
um_ajax_get_members( directory );
|
1603 |
+
|
1604 |
+
um_change_tag( directory );
|
1605 |
+
|
1606 |
+
directory.data( 'searched', 1 );
|
1607 |
+
directory.find( '.um-member-directory-sorting-options' ).prop( 'disabled', false );
|
1608 |
+
directory.find( '.um-member-directory-view-type' ).removeClass( 'um-disabled' );
|
1609 |
+
|
1610 |
+
}
|
1611 |
+
});
|
1612 |
+
|
1613 |
+
// first loading timepicker select
|
1614 |
+
var $picker = $input.pickatime('picker');
|
1615 |
+
var $fname = elem.data('filter_name');
|
1616 |
+
var $frange = elem.data('range');
|
1617 |
+
var $directory = elem.parents('.um-directory');
|
1618 |
+
|
1619 |
+
var query_value = um_get_data_for_directory( $directory, 'filter_' + $fname + '_' + $frange );
|
1620 |
+
if ( typeof query_value !== 'undefined' ) {
|
1621 |
+
var arr = query_value.split(':');
|
1622 |
+
$picker.set( 'select', arr[0]*60 + arr[1]*1 );
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
});
|
1626 |
+
|
1627 |
+
wp.hooks.doAction( 'um_member_directory_on_init', directory, hash );
|
1628 |
+
|
1629 |
+
var ignore_after_search = false;
|
1630 |
+
ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
|
1631 |
+
|
1632 |
+
if ( ! ignore_after_search ) {
|
1633 |
+
var show_after_search = directory.data('must-search');
|
1634 |
+
if ( show_after_search === 1 ) {
|
1635 |
+
var search = um_get_search( directory );
|
1636 |
+
var filters_data = um_get_filters_data( directory );
|
1637 |
+
if ( ! filters_data.length && ! search ) {
|
1638 |
+
return;
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
}
|
1642 |
+
|
1643 |
+
var prevent_default = wp.hooks.applyFilters( 'um_member_directory_prevent_default_first_loading', false, directory, hash );
|
1644 |
+
|
1645 |
+
if ( ! prevent_default ) {
|
1646 |
+
um_members_show_preloader( directory );
|
1647 |
+
um_ajax_get_members( directory, {first_load:true} );
|
1648 |
+
um_change_tag( directory );
|
1649 |
+
}
|
1650 |
+
});
|
1651 |
+
|
1652 |
+
|
1653 |
+
//history events when back/forward and change window.location.hash
|
1654 |
+
window.addEventListener( "popstate", function(e) {
|
1655 |
+
jQuery( '.um-directory' ).each( function() {
|
1656 |
+
var directory = jQuery(this);
|
1657 |
+
var hash = um_members_get_hash( directory );
|
1658 |
+
um_member_directories.push( hash );
|
1659 |
+
|
1660 |
+
um_members_show_preloader( directory );
|
1661 |
+
|
1662 |
+
// clear layout and header
|
1663 |
+
directory.find('.um-members-grid, .um-members-list, .um-members-intro').remove();
|
1664 |
+
|
1665 |
+
// set search from history
|
1666 |
+
if ( directory.find( '.um-member-directory-search-line' ).length ) {
|
1667 |
+
var search = um_get_data_for_directory( directory, 'search' );
|
1668 |
+
if ( typeof search == 'undefined' ) {
|
1669 |
+
search = '';
|
1670 |
+
}
|
1671 |
+
directory.data( 'general_search', search );
|
1672 |
+
directory.find('.um-search-line').val( search );
|
1673 |
+
}
|
1674 |
+
|
1675 |
+
var page = um_get_data_for_directory( directory, 'page' );
|
1676 |
+
if ( typeof page == 'undefined' ) {
|
1677 |
+
page = 1;
|
1678 |
+
} else if ( page > directory.data( 'total_pages' ) ) {
|
1679 |
+
page = directory.data( 'total_pages' );
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
directory.data( 'page', page ).attr( 'data-page', page );
|
1683 |
+
|
1684 |
+
//sorting from history
|
1685 |
+
if ( directory.find( '.um-member-directory-sorting' ).length ) {
|
1686 |
+
var sort = um_get_data_for_directory( directory, 'sort' );
|
1687 |
+
if ( typeof sort == 'undefined' ) {
|
1688 |
+
sort = directory.find( '.um-new-dropdown[data-element=".um-member-directory-sorting-a"]' ).find('a[data-default="1"]').data('value');
|
1689 |
+
}
|
1690 |
+
directory.data( 'sorting', sort );
|
1691 |
+
|
1692 |
+
var sort_dropdown = directory.find( '.um-new-dropdown[data-element=".um-member-directory-sorting-a"]' );
|
1693 |
+
sort_dropdown.find('a').data('selected', 0).prop('data-selected', 0).attr('data-selected', 0);
|
1694 |
+
sort_dropdown.find('a[data-value="' + sort + '"]').data('selected', 1).prop('data-selected', 1).attr('data-selected', 1);
|
1695 |
+
directory.find('.um-member-directory-sorting-a').find('> a').html( sort_dropdown.find('a[data-value="' + sort + '"]').html() );
|
1696 |
+
}
|
1697 |
+
|
1698 |
+
//view type from history
|
1699 |
+
if ( directory.find( '.um-member-directory-view-type' ).length ) {
|
1700 |
+
var layout = um_get_data_for_directory( directory, 'view_type' );
|
1701 |
+
if ( typeof layout == 'undefined' ) {
|
1702 |
+
layout = directory.find( '.um-member-directory-view-type-a[data-default="1"]' ).data('type');
|
1703 |
+
}
|
1704 |
+
directory.data( 'view_type', layout );
|
1705 |
+
|
1706 |
+
directory.find('.um-member-directory-view-type .um-member-directory-view-type-a').hide();
|
1707 |
+
directory.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="' + layout + '"]').show();
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
//datepicker filter
|
1711 |
+
directory.find('.um-datepicker-filter').each( function() {
|
1712 |
+
var elem = jQuery(this);
|
1713 |
+
|
1714 |
+
var $picker = elem.pickadate('picker');
|
1715 |
+
var $fname = elem.data('filter_name');
|
1716 |
+
var $frange = elem.data('range');
|
1717 |
+
|
1718 |
+
var query_value = um_get_data_for_directory( directory, 'filter_' + $fname + '_' + $frange );
|
1719 |
+
if ( typeof query_value !== 'undefined' ) {
|
1720 |
+
$picker.set( 'select', query_value*1000 );
|
1721 |
+
} else {
|
1722 |
+
$picker.clear();
|
1723 |
+
}
|
1724 |
+
});
|
1725 |
+
|
1726 |
+
directory.find('.um-slider').each( function() {
|
1727 |
+
var slider = jQuery( this );
|
1728 |
+
var filter_name = slider.data('field_name');
|
1729 |
+
|
1730 |
+
var min_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_from' );
|
1731 |
+
var max_default_value = um_get_data_for_directory( directory, 'filter_' + filter_name + '_to' );
|
1732 |
+
if ( typeof min_default_value == 'undefined' ) {
|
1733 |
+
min_default_value = slider.data('min');
|
1734 |
+
}
|
1735 |
+
min_default_value = parseInt( min_default_value );
|
1736 |
+
|
1737 |
+
if ( typeof max_default_value == 'undefined' ) {
|
1738 |
+
max_default_value = slider.data('max');
|
1739 |
+
}
|
1740 |
+
max_default_value = parseInt( max_default_value );
|
1741 |
+
|
1742 |
+
slider.slider( 'values', [min_default_value, max_default_value] );
|
1743 |
+
um_set_range_label( slider );
|
1744 |
+
});
|
1745 |
+
|
1746 |
+
//timepicker filter
|
1747 |
+
directory.find('.um-timepicker-filter').each( function() {
|
1748 |
+
var elem = jQuery(this);
|
1749 |
+
|
1750 |
+
var $picker = elem.pickatime('picker');
|
1751 |
+
var $fname = elem.data('filter_name');
|
1752 |
+
var $frange = elem.data('range');
|
1753 |
+
|
1754 |
+
var query_value = um_get_data_for_directory( directory, 'filter_' + $fname + '_' + $frange );
|
1755 |
+
if ( typeof query_value !== 'undefined' ) {
|
1756 |
+
var arr = query_value.split(':');
|
1757 |
+
$picker.set( 'select', arr[0]*60 );
|
1758 |
+
} else {
|
1759 |
+
$picker.clear();
|
1760 |
+
}
|
1761 |
+
});
|
1762 |
+
|
1763 |
+
var ignore_after_search = false;
|
1764 |
+
ignore_after_search = wp.hooks.applyFilters( 'um_member_directory_ignore_after_search', ignore_after_search, directory );
|
1765 |
+
|
1766 |
+
if ( ! ignore_after_search ) {
|
1767 |
+
var show_after_search = directory.data('must-search');
|
1768 |
+
if ( show_after_search === 1 ) {
|
1769 |
+
var search = um_get_search( directory );
|
1770 |
+
var filters_data = um_get_filters_data( directory );
|
1771 |
+
if ( ! filters_data.length && ! search ) {
|
1772 |
+
directory.data( 'searched', 0 );
|
1773 |
+
um_members_hide_preloader( directory );
|
1774 |
+
return;
|
1775 |
+
} else {
|
1776 |
+
directory.data( 'searched', 1 );
|
1777 |
+
}
|
1778 |
+
}
|
1779 |
+
}
|
1780 |
+
|
1781 |
+
var prevent_default = wp.hooks.applyFilters( 'um_member_directory_prevent_default_first_loading', false, directory, hash );
|
1782 |
+
|
1783 |
+
if ( ! prevent_default ) {
|
1784 |
+
um_ajax_get_members( directory );
|
1785 |
+
um_change_tag( directory );
|
1786 |
+
}
|
1787 |
+
});
|
1788 |
+
});
|
1789 |
+
|
1790 |
+
});
|
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))&&(s=um_unsanitize_value(s),_[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))&&(s=um_unsanitize_value(s),_[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=um_unsanitize_value(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=jQuery(this).val(),r=um_sanitize_value(e);if(""!==r){var t=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(t)){um_members_show_preloader(t);var a=jQuery(this).prop("name"),i=um_get_data_for_directory(t,"filter_"+a);i=void 0===i?[]:i.split("||"),-1===jQuery.inArray(r,i)&&(i.push(r),um_set_url_from_data(t,"filter_"+a,i=i.join("||")),t.data("page",1),um_set_url_from_data(t,"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 m=jQuery(this);m.select2("destroy").select2({dropdownParent:m.parent()}),m.val("").trigger("change"),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")}}}),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=um_unsanitize_value(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,i="",m=e.siblings(".um-slider-range").data("placeholder-s"),d=e.siblings(".um-slider-range").data("placeholder-p");a=r?(i=r.values[0]===r.values[1]?m.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):d.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=r.values[0],r.values[1]):(i=e.slider("values",0)===e.slider("values",1)?m.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):d.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=e.slider("values",0),e.slider("values",1)),e.siblings(".um-slider-range").html(i),e.siblings(".um_range_min").val(t),e.siblings(".um_range_max").val(a)}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))&&(s=um_unsanitize_value(s),_[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))&&(s=um_unsanitize_value(s),_[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=um_unsanitize_value(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=jQuery(this).val(),r=um_sanitize_value(e);if(""!==r){var t=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(t)){um_members_show_preloader(t);var a=jQuery(this).prop("name"),i=um_get_data_for_directory(t,"filter_"+a);i=void 0===i?[]:i.split("||"),-1===jQuery.inArray(r,i)&&(i.push(r),um_set_url_from_data(t,"filter_"+a,i=i.join("||")),t.data("page",1),um_set_url_from_data(t,"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 m=jQuery(this);m.select2("destroy").select2({dropdownParent:m.parent()}),m.val("").trigger("change"),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")}}}),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=um_unsanitize_value(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))})})});
|
includes/admin/assets/js/um-admin-forms.js
CHANGED
@@ -483,10 +483,10 @@ jQuery(document).ready( function() {
|
|
483 |
});
|
484 |
|
485 |
function um_set_range_label( slider, ui ) {
|
486 |
-
console.log( slider );
|
487 |
var placeholder = '';
|
488 |
var placeholder_s = slider.siblings( '.um-slider-range' ).data( 'placeholder-s' );
|
489 |
var placeholder_p = slider.siblings( '.um-slider-range' ).data( 'placeholder-p' );
|
|
|
490 |
|
491 |
if ( ui ) {
|
492 |
if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
|
@@ -499,6 +499,8 @@ jQuery(document).ready( function() {
|
|
499 |
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
500 |
.data('label') );
|
501 |
}
|
|
|
|
|
502 |
} else {
|
503 |
if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
|
504 |
placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
|
@@ -510,11 +512,13 @@ jQuery(document).ready( function() {
|
|
510 |
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
511 |
.data('label') );
|
512 |
}
|
|
|
|
|
513 |
}
|
514 |
slider.siblings( '.um-slider-range' ).html( placeholder );
|
515 |
|
516 |
-
slider.siblings( ".um_range_min" ).val(
|
517 |
-
slider.siblings( ".um_range_max" ).val(
|
518 |
}
|
519 |
|
520 |
|
483 |
});
|
484 |
|
485 |
function um_set_range_label( slider, ui ) {
|
|
|
486 |
var placeholder = '';
|
487 |
var placeholder_s = slider.siblings( '.um-slider-range' ).data( 'placeholder-s' );
|
488 |
var placeholder_p = slider.siblings( '.um-slider-range' ).data( 'placeholder-p' );
|
489 |
+
var um_range_min, um_range_max;
|
490 |
|
491 |
if ( ui ) {
|
492 |
if ( ui.values[ 0 ] === ui.values[ 1 ] ) {
|
499 |
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
500 |
.data('label') );
|
501 |
}
|
502 |
+
um_range_min = ui.values[0];
|
503 |
+
um_range_max = ui.values[1];
|
504 |
} else {
|
505 |
if ( slider.slider( "values", 0 ) === slider.slider( "values", 1 ) ) {
|
506 |
placeholder = placeholder_s.replace( '\{value\}', slider.slider( "values", 0 ) )
|
512 |
.replace( '\{field_label\}', slider.siblings( '.um-slider-range' )
|
513 |
.data('label') );
|
514 |
}
|
515 |
+
um_range_min = slider.slider( "values", 0 );
|
516 |
+
um_range_max = slider.slider( "values", 1 );
|
517 |
}
|
518 |
slider.siblings( '.um-slider-range' ).html( placeholder );
|
519 |
|
520 |
+
slider.siblings( ".um_range_min" ).val( um_range_min );
|
521 |
+
slider.siblings( ".um_range_max" ).val( um_range_max );
|
522 |
}
|
523 |
|
524 |
|
includes/admin/class-admin.php
CHANGED
@@ -767,10 +767,10 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
|
767 |
'sanitize' => 'absint',
|
768 |
),
|
769 |
'_min' => array(
|
770 |
-
'sanitize' => '
|
771 |
),
|
772 |
'_max' => array(
|
773 |
-
'sanitize' => '
|
774 |
),
|
775 |
'_min_chars' => array(
|
776 |
'sanitize' => 'absint',
|
@@ -1360,6 +1360,9 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
|
1360 |
case 'int':
|
1361 |
$sanitized[ $k ] = (int) $v;
|
1362 |
break;
|
|
|
|
|
|
|
1363 |
case 'bool':
|
1364 |
$sanitized[ $k ] = (bool) $v;
|
1365 |
break;
|
@@ -1393,6 +1396,13 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
|
1393 |
$sanitized[ $k ] = absint( $v );
|
1394 |
}
|
1395 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1396 |
}
|
1397 |
}
|
1398 |
|
767 |
'sanitize' => 'absint',
|
768 |
),
|
769 |
'_min' => array(
|
770 |
+
'sanitize' => 'empty_int',
|
771 |
),
|
772 |
'_max' => array(
|
773 |
+
'sanitize' => 'empty_int',
|
774 |
),
|
775 |
'_min_chars' => array(
|
776 |
'sanitize' => 'absint',
|
1360 |
case 'int':
|
1361 |
$sanitized[ $k ] = (int) $v;
|
1362 |
break;
|
1363 |
+
case 'empty_int':
|
1364 |
+
$sanitized[ $k ] = ( '' !== $v ) ? (int) $v : '';
|
1365 |
+
break;
|
1366 |
case 'bool':
|
1367 |
$sanitized[ $k ] = (bool) $v;
|
1368 |
break;
|
1396 |
$sanitized[ $k ] = absint( $v );
|
1397 |
}
|
1398 |
break;
|
1399 |
+
case 'empty_absint':
|
1400 |
+
if ( is_array( $v ) ) {
|
1401 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1402 |
+
} else {
|
1403 |
+
$sanitized[ $k ] = ( '' !== $v ) ? absint( $v ) : '';
|
1404 |
+
}
|
1405 |
+
break;
|
1406 |
}
|
1407 |
}
|
1408 |
|
includes/admin/core/class-admin-metabox.php
CHANGED
@@ -431,7 +431,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
|
431 |
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
432 |
'1' => __( 'Redirect user', 'ultimate-member' ),
|
433 |
),
|
434 |
-
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ),
|
435 |
),
|
436 |
array(
|
437 |
'id' => '_um_restrict_by_custom_message',
|
@@ -583,7 +583,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
|
583 |
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
584 |
'1' => __( 'Redirect user', 'ultimate-member' ),
|
585 |
),
|
586 |
-
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ),
|
587 |
),
|
588 |
array(
|
589 |
'id' => '_um_restrict_by_custom_message',
|
431 |
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
432 |
'1' => __( 'Redirect user', 'ultimate-member' ),
|
433 |
),
|
434 |
+
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
435 |
),
|
436 |
array(
|
437 |
'id' => '_um_restrict_by_custom_message',
|
583 |
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
584 |
'1' => __( 'Redirect user', 'ultimate-member' ),
|
585 |
),
|
586 |
+
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
587 |
),
|
588 |
array(
|
589 |
'id' => '_um_restrict_by_custom_message',
|
includes/admin/core/class-admin-settings.php
CHANGED
@@ -1,3455 +1,3475 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
exit;
|
6 |
-
}
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Settings
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Settings {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var array
|
20 |
-
*/
|
21 |
-
public $settings_map;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var array
|
26 |
-
*/
|
27 |
-
public $settings_structure;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var
|
32 |
-
*/
|
33 |
-
private $previous_licenses;
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var
|
38 |
-
*/
|
39 |
-
private $need_change_permalinks;
|
40 |
-
|
41 |
-
|
42 |
-
private $gravatar_changed = false;
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Admin_Settings constructor.
|
47 |
-
*/
|
48 |
-
public function __construct() {
|
49 |
-
//init settings structure
|
50 |
-
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
-
|
52 |
-
//admin menu
|
53 |
-
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
-
|
55 |
-
//settings structure handlers
|
56 |
-
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
-
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
-
|
59 |
-
//enqueue wp_media for profiles tab
|
60 |
-
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
-
|
62 |
-
//custom content for licenses tab
|
63 |
-
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
-
|
65 |
-
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
-
|
67 |
-
|
68 |
-
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
-
|
70 |
-
|
71 |
-
//save handlers
|
72 |
-
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
-
|
74 |
-
//save pages options
|
75 |
-
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
-
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
-
|
78 |
-
|
79 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
-
|
81 |
-
|
82 |
-
//save licenses options
|
83 |
-
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
-
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
-
|
86 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
-
|
89 |
-
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
public function same_page_update_ajax() {
|
95 |
-
UM()->admin()->check_ajax_nonce();
|
96 |
-
|
97 |
-
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
-
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
-
}
|
100 |
-
|
101 |
-
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
-
|
103 |
-
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
-
//first install metatable
|
105 |
-
global $wpdb;
|
106 |
-
|
107 |
-
$metakeys = array();
|
108 |
-
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
-
$metakeys[] = $all_user_field['metakey'];
|
110 |
-
}
|
111 |
-
|
112 |
-
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
-
|
114 |
-
if ( is_multisite() ) {
|
115 |
-
|
116 |
-
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
-
foreach ( $sites as $blog_id ) {
|
118 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
-
}
|
120 |
-
} else {
|
121 |
-
$blog_id = get_current_blog_id();
|
122 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
-
}
|
124 |
-
|
125 |
-
//member directory data
|
126 |
-
$metakeys[] = 'um_member_directory_data';
|
127 |
-
$metakeys[] = '_um_verified';
|
128 |
-
$metakeys[] = '_money_spent';
|
129 |
-
$metakeys[] = '_completed';
|
130 |
-
$metakeys[] = '_reviews_avg';
|
131 |
-
|
132 |
-
//myCred meta
|
133 |
-
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
-
$mycred_types = mycred_get_types();
|
135 |
-
if ( ! empty( $mycred_types ) ) {
|
136 |
-
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
-
$metakeys[] = $point_type;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
-
if ( empty( $sortby_custom_keys ) ) {
|
144 |
-
$sortby_custom_keys = array();
|
145 |
-
}
|
146 |
-
|
147 |
-
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
-
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
-
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
-
$custom_val = maybe_unserialize( $custom_val );
|
151 |
-
|
152 |
-
foreach ( $custom_val as $sort_value ) {
|
153 |
-
if ( is_array( $sort_value ) ) {
|
154 |
-
$field_keys = array_keys( $sort_value );
|
155 |
-
$sortby_custom_keys[] = $field_keys[0];
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
-
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
-
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
-
}
|
165 |
-
|
166 |
-
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
-
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
-
|
169 |
-
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
-
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
-
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
-
|
173 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
-
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
-
}
|
176 |
-
|
177 |
-
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
-
|
179 |
-
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
-
|
181 |
-
update_option( 'um_member_directory_update_meta', time() );
|
182 |
-
|
183 |
-
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
-
|
185 |
-
wp_send_json_success();
|
186 |
-
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
-
global $wpdb;
|
188 |
-
|
189 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
-
|
191 |
-
$count = $wpdb->get_var(
|
192 |
-
"SELECT COUNT(*)
|
193 |
-
FROM {$wpdb->usermeta}
|
194 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
-
);
|
196 |
-
|
197 |
-
wp_send_json_success( array( 'count' => $count ) );
|
198 |
-
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
-
|
200 |
-
if ( empty( $_POST['page'] ) ) {
|
201 |
-
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
-
}
|
203 |
-
|
204 |
-
$per_page = 500;
|
205 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
-
|
207 |
-
global $wpdb;
|
208 |
-
$metadata = $wpdb->get_results(
|
209 |
-
$wpdb->prepare(
|
210 |
-
"SELECT *
|
211 |
-
FROM {$wpdb->usermeta}
|
212 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
-
LIMIT %d, %d",
|
214 |
-
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
-
$per_page
|
216 |
-
),
|
217 |
-
ARRAY_A
|
218 |
-
);
|
219 |
-
|
220 |
-
$values = array();
|
221 |
-
foreach ( $metadata as $metarow ) {
|
222 |
-
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( ! empty( $values ) ) {
|
226 |
-
$wpdb->query(
|
227 |
-
"INSERT INTO
|
228 |
-
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
-
VALUES " . implode( ',', $values )
|
230 |
-
);
|
231 |
-
}
|
232 |
-
|
233 |
-
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
-
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
-
|
236 |
-
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
*
|
243 |
-
*/
|
244 |
-
public function init_variables() {
|
245 |
-
|
246 |
-
$settings_map = array();
|
247 |
-
|
248 |
-
$general_pages_fields = array(
|
249 |
-
array(
|
250 |
-
'id' => 'pages_settings',
|
251 |
-
'type' => 'hidden',
|
252 |
-
'value' => true,
|
253 |
-
'is_option' => false,
|
254 |
-
),
|
255 |
-
);
|
256 |
-
|
257 |
-
$core_pages = UM()->config()->core_pages;
|
258 |
-
|
259 |
-
foreach ( $core_pages as $page_s => $page ) {
|
260 |
-
$have_pages = UM()->query()->wp_pages();
|
261 |
-
$page_id = UM()->options()->get_core_page_id( $page_s );
|
262 |
-
|
263 |
-
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
264 |
-
|
265 |
-
if ( 'reached_maximum_limit' === $have_pages ) {
|
266 |
-
$general_pages_fields[] = array(
|
267 |
-
'id' => $page_id,
|
268 |
-
'type' => 'text',
|
269 |
-
// translators: %s: Page title
|
270 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
271 |
-
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
272 |
-
'compiler' => true,
|
273 |
-
'size' => 'small',
|
274 |
-
);
|
275 |
-
} else {
|
276 |
-
$general_pages_fields[] = array(
|
277 |
-
'id' => $page_id,
|
278 |
-
'type' => 'select',
|
279 |
-
// translators: %s: Page title
|
280 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
281 |
-
'options' => UM()->query()->wp_pages(),
|
282 |
-
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
283 |
-
'compiler' => true,
|
284 |
-
'size' => 'small',
|
285 |
-
);
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
$settings_map[ $page_id ] = array(
|
290 |
-
'sanitize' => 'absint',
|
291 |
-
);
|
292 |
-
}
|
293 |
-
|
294 |
-
$appearances_profile_menu_fields = array(
|
295 |
-
array(
|
296 |
-
'id' => 'profile_menu',
|
297 |
-
'type' => 'checkbox',
|
298 |
-
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
299 |
-
),
|
300 |
-
);
|
301 |
-
|
302 |
-
$settings_map['profile_menu'] = array(
|
303 |
-
'sanitize' => 'bool',
|
304 |
-
);
|
305 |
-
|
306 |
-
$tabs = UM()->profile()->tabs();
|
307 |
-
|
308 |
-
$tabs_options = array();
|
309 |
-
$tabs_condition = array();
|
310 |
-
foreach ( $tabs as $id => $tab ) {
|
311 |
-
|
312 |
-
if ( ! empty( $tab['hidden'] ) ) {
|
313 |
-
continue;
|
314 |
-
}
|
315 |
-
|
316 |
-
if ( isset( $tab['name'] ) ) {
|
317 |
-
$tabs_options[ $id ] = $tab['name'];
|
318 |
-
$tabs_condition[] = 'profile_tab_' . $id;
|
319 |
-
}
|
320 |
-
|
321 |
-
if ( isset( $tab['default_privacy'] ) ) {
|
322 |
-
$fields = array(
|
323 |
-
array(
|
324 |
-
'id' => 'profile_tab_' . $id,
|
325 |
-
'type' => 'checkbox',
|
326 |
-
// translators: %s: Tab title
|
327 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
328 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
329 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
330 |
-
),
|
331 |
-
);
|
332 |
-
|
333 |
-
$settings_map[ 'profile_tab_' . $id ] = array(
|
334 |
-
'sanitize' => 'bool',
|
335 |
-
);
|
336 |
-
} else {
|
337 |
-
|
338 |
-
$fields = array(
|
339 |
-
array(
|
340 |
-
'id' => 'profile_tab_' . $id,
|
341 |
-
'type' => 'checkbox',
|
342 |
-
// translators: %s: Tab title
|
343 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
344 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
345 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
346 |
-
),
|
347 |
-
array(
|
348 |
-
'id' => 'profile_tab_' . $id . '_privacy',
|
349 |
-
'type' => 'select',
|
350 |
-
// translators: %s: Tab title
|
351 |
-
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
352 |
-
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
353 |
-
'options' => UM()->profile()->tabs_privacy(),
|
354 |
-
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
355 |
-
'size' => 'small',
|
356 |
-
),
|
357 |
-
array(
|
358 |
-
'id' => 'profile_tab_' . $id . '_roles',
|
359 |
-
'type' => 'select',
|
360 |
-
'multi' => true,
|
361 |
-
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
362 |
-
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
363 |
-
'options' => UM()->roles()->get_roles(),
|
364 |
-
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
365 |
-
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
366 |
-
'size' => 'small',
|
367 |
-
),
|
368 |
-
);
|
369 |
-
|
370 |
-
$settings_map = array_merge(
|
371 |
-
$settings_map,
|
372 |
-
array(
|
373 |
-
"profile_tab_{$id}" => array(
|
374 |
-
'sanitize' => 'bool',
|
375 |
-
),
|
376 |
-
"profile_tab_{$id}_privacy" => array(
|
377 |
-
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
378 |
-
),
|
379 |
-
"profile_tab_{$id}_roles" => array(
|
380 |
-
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
381 |
-
),
|
382 |
-
)
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
387 |
-
}
|
388 |
-
|
389 |
-
$appearances_profile_menu_fields[] = array(
|
390 |
-
'id' => 'profile_menu_default_tab',
|
391 |
-
'type' => 'select',
|
392 |
-
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
393 |
-
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
394 |
-
'options' => $tabs_options,
|
395 |
-
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
396 |
-
'size' => 'small',
|
397 |
-
);
|
398 |
-
|
399 |
-
$settings_map['profile_menu_default_tab'] = array(
|
400 |
-
'sanitize' => 'key',
|
401 |
-
);
|
402 |
-
|
403 |
-
$appearances_profile_menu_fields = array_merge(
|
404 |
-
$appearances_profile_menu_fields,
|
405 |
-
array(
|
406 |
-
array(
|
407 |
-
'id' => 'profile_menu_icons',
|
408 |
-
'type' => 'checkbox',
|
409 |
-
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
410 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
411 |
-
),
|
412 |
-
)
|
413 |
-
);
|
414 |
-
|
415 |
-
$settings_map['profile_menu_icons'] = array(
|
416 |
-
'sanitize' => 'bool',
|
417 |
-
);
|
418 |
-
|
419 |
-
$post_types_options = array();
|
420 |
-
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
421 |
-
foreach ( $all_post_types as $key => $post_type_data ) {
|
422 |
-
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
423 |
-
}
|
424 |
-
|
425 |
-
$duplicates = array();
|
426 |
-
$taxonomies_options = array();
|
427 |
-
$exclude_taxonomies = UM()->excluded_taxonomies();
|
428 |
-
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
429 |
-
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
430 |
-
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
431 |
-
continue;
|
432 |
-
}
|
433 |
-
|
434 |
-
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
435 |
-
$duplicates[] = $taxonomy->labels->singular_name;
|
436 |
-
$label = $taxonomy->labels->singular_name;
|
437 |
-
} else {
|
438 |
-
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
439 |
-
}
|
440 |
-
|
441 |
-
$taxonomies_options[ $key ] = $label;
|
442 |
-
}
|
443 |
-
|
444 |
-
$restricted_access_post_metabox_value = array();
|
445 |
-
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
446 |
-
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
447 |
-
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
448 |
-
if ( $value ) {
|
449 |
-
$restricted_access_post_metabox_value[] = $key;
|
450 |
-
}
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
|
455 |
-
$restricted_access_taxonomy_metabox_value = array();
|
456 |
-
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
457 |
-
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
458 |
-
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
459 |
-
if ( $value ) {
|
460 |
-
$restricted_access_taxonomy_metabox_value[] = $key;
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
$access_fields = array(
|
466 |
-
array(
|
467 |
-
'id' => 'accessible',
|
468 |
-
'type' => 'select',
|
469 |
-
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
470 |
-
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
471 |
-
'options' => array(
|
472 |
-
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
473 |
-
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
474 |
-
),
|
475 |
-
'size' => 'medium',
|
476 |
-
),
|
477 |
-
array(
|
478 |
-
'id' => 'access_redirect',
|
479 |
-
'type' => 'text',
|
480 |
-
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
481 |
-
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
482 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
483 |
-
),
|
484 |
-
array(
|
485 |
-
'id' => 'access_exclude_uris',
|
486 |
-
'type' => 'multi_text',
|
487 |
-
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
488 |
-
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
489 |
-
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
490 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
491 |
-
'show_default_number' => 0,
|
492 |
-
),
|
493 |
-
array(
|
494 |
-
'id' => 'home_page_accessible',
|
495 |
-
'type' => 'checkbox',
|
496 |
-
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
497 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
498 |
-
),
|
499 |
-
array(
|
500 |
-
'id' => 'category_page_accessible',
|
501 |
-
'type' => 'checkbox',
|
502 |
-
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
503 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
504 |
-
),
|
505 |
-
array(
|
506 |
-
'id' => 'restricted_post_title_replace',
|
507 |
-
'type' => 'checkbox',
|
508 |
-
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
509 |
-
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
510 |
-
),
|
511 |
-
array(
|
512 |
-
'id' => 'restricted_access_post_title',
|
513 |
-
'type' => 'text',
|
514 |
-
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
515 |
-
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
516 |
-
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
517 |
-
),
|
518 |
-
array(
|
519 |
-
'id' => 'restricted_access_message',
|
520 |
-
'type' => 'wp_editor',
|
521 |
-
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
522 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
523 |
-
),
|
524 |
-
);
|
525 |
-
|
526 |
-
$settings_map = array_merge(
|
527 |
-
$settings_map,
|
528 |
-
array(
|
529 |
-
'accessible' => array(
|
530 |
-
'sanitize' => 'int',
|
531 |
-
),
|
532 |
-
'access_redirect' => array(
|
533 |
-
'sanitize' => 'url',
|
534 |
-
),
|
535 |
-
'access_exclude_uris' => array(
|
536 |
-
'sanitize' => 'url',
|
537 |
-
),
|
538 |
-
'home_page_accessible' => array(
|
539 |
-
'sanitize' => 'bool',
|
540 |
-
),
|
541 |
-
'category_page_accessible' => array(
|
542 |
-
'sanitize' => 'bool',
|
543 |
-
),
|
544 |
-
'restricted_post_title_replace' => array(
|
545 |
-
'sanitize' => 'bool',
|
546 |
-
),
|
547 |
-
'restricted_access_post_title' => array(
|
548 |
-
'sanitize' => 'text',
|
549 |
-
),
|
550 |
-
'restricted_access_message' => array(
|
551 |
-
'sanitize' => 'wp_kses',
|
552 |
-
),
|
553 |
-
)
|
554 |
-
);
|
555 |
-
|
556 |
-
global $wp_version;
|
557 |
-
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
558 |
-
$access_fields = array_merge(
|
559 |
-
$access_fields,
|
560 |
-
array(
|
561 |
-
array(
|
562 |
-
'id' => 'restricted_blocks',
|
563 |
-
'type' => 'checkbox',
|
564 |
-
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
565 |
-
),
|
566 |
-
array(
|
567 |
-
'id' => 'restricted_block_message',
|
568 |
-
'type' => 'textarea',
|
569 |
-
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
570 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
571 |
-
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
572 |
-
),
|
573 |
-
)
|
574 |
-
);
|
575 |
-
|
576 |
-
$settings_map['restricted_blocks'] = array(
|
577 |
-
'sanitize' => 'bool',
|
578 |
-
);
|
579 |
-
$settings_map['restricted_block_message'] = array(
|
580 |
-
'sanitize' => 'textarea',
|
581 |
-
);
|
582 |
-
}
|
583 |
-
|
584 |
-
$access_fields = array_merge(
|
585 |
-
$access_fields,
|
586 |
-
array(
|
587 |
-
array(
|
588 |
-
'id' => 'restricted_access_post_metabox',
|
589 |
-
'type' => 'hidden',
|
590 |
-
'value' => '',
|
591 |
-
),
|
592 |
-
array(
|
593 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
594 |
-
'type' => 'hidden',
|
595 |
-
'value' => '',
|
596 |
-
),
|
597 |
-
array(
|
598 |
-
'id' => 'restricted_access_post_metabox',
|
599 |
-
'type' => 'multi_checkbox',
|
600 |
-
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
601 |
-
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
602 |
-
'options' => $post_types_options,
|
603 |
-
'columns' => 3,
|
604 |
-
'value' => $restricted_access_post_metabox_value,
|
605 |
-
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
606 |
-
),
|
607 |
-
array(
|
608 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
609 |
-
'type' => 'multi_checkbox',
|
610 |
-
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
611 |
-
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
612 |
-
'options' => $taxonomies_options,
|
613 |
-
'columns' => 3,
|
614 |
-
'value' => $restricted_access_taxonomy_metabox_value,
|
615 |
-
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
616 |
-
),
|
617 |
-
)
|
618 |
-
);
|
619 |
-
|
620 |
-
$settings_map = array_merge(
|
621 |
-
$settings_map,
|
622 |
-
array(
|
623 |
-
'restricted_access_post_metabox' => array(
|
624 |
-
'sanitize' => 'key',
|
625 |
-
),
|
626 |
-
'restricted_access_taxonomy_metabox' => array(
|
627 |
-
'sanitize' => 'key',
|
628 |
-
),
|
629 |
-
)
|
630 |
-
);
|
631 |
-
|
632 |
-
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
633 |
-
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
634 |
-
|
635 |
-
$same_page_update = array(
|
636 |
-
'id' => 'member_directory_own_table',
|
637 |
-
'type' => 'same_page_update',
|
638 |
-
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
639 |
-
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
640 |
-
);
|
641 |
-
|
642 |
-
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
643 |
-
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
644 |
-
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
645 |
-
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
646 |
-
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
647 |
-
}
|
648 |
-
|
649 |
-
$settings_map = array_merge(
|
650 |
-
$settings_map,
|
651 |
-
array(
|
652 |
-
'permalink_base' => array(
|
653 |
-
'sanitize' => 'key',
|
654 |
-
),
|
655 |
-
'display_name' => array(
|
656 |
-
'sanitize' => 'key',
|
657 |
-
),
|
658 |
-
'display_name_field' => array(
|
659 |
-
'sanitize' => 'text',
|
660 |
-
),
|
661 |
-
'author_redirect' => array(
|
662 |
-
'sanitize' => 'bool',
|
663 |
-
),
|
664 |
-
'members_page' => array(
|
665 |
-
'sanitize' => 'bool',
|
666 |
-
),
|
667 |
-
'use_gravatars' => array(
|
668 |
-
'sanitize' => 'bool',
|
669 |
-
),
|
670 |
-
'use_um_gravatar_default_builtin_image' => array(
|
671 |
-
'sanitize' => 'key',
|
672 |
-
),
|
673 |
-
'use_um_gravatar_default_image' => array(
|
674 |
-
'sanitize' => 'bool',
|
675 |
-
),
|
676 |
-
'reset_require_strongpass' => array(
|
677 |
-
'sanitize' => 'bool',
|
678 |
-
),
|
679 |
-
'
|
680 |
-
'sanitize' => '
|
681 |
-
),
|
682 |
-
'
|
683 |
-
'sanitize' => 'absint',
|
684 |
-
),
|
685 |
-
'
|
686 |
-
'sanitize' => 'bool',
|
687 |
-
),
|
688 |
-
'
|
689 |
-
'sanitize' => '
|
690 |
-
),
|
691 |
-
'
|
692 |
-
'sanitize' => 'bool',
|
693 |
-
),
|
694 |
-
'
|
695 |
-
'sanitize' => 'bool',
|
696 |
-
),
|
697 |
-
'
|
698 |
-
'sanitize' => '
|
699 |
-
),
|
700 |
-
'
|
701 |
-
'sanitize' => '
|
702 |
-
),
|
703 |
-
'
|
704 |
-
'sanitize' => '
|
705 |
-
),
|
706 |
-
'
|
707 |
-
'sanitize' => '
|
708 |
-
),
|
709 |
-
'
|
710 |
-
'sanitize' => 'bool',
|
711 |
-
),
|
712 |
-
'
|
713 |
-
'sanitize' => 'bool',
|
714 |
-
),
|
715 |
-
'
|
716 |
-
'sanitize' => 'bool',
|
717 |
-
),
|
718 |
-
'
|
719 |
-
'sanitize' => 'bool',
|
720 |
-
),
|
721 |
-
'
|
722 |
-
'sanitize' => 'bool',
|
723 |
-
),
|
724 |
-
'
|
725 |
-
'sanitize' => '
|
726 |
-
),
|
727 |
-
'
|
728 |
-
'sanitize' => '
|
729 |
-
),
|
730 |
-
'
|
731 |
-
'sanitize' => '
|
732 |
-
),
|
733 |
-
'
|
734 |
-
'sanitize' => 'absint',
|
735 |
-
),
|
736 |
-
'
|
737 |
-
'sanitize' => 'absint',
|
738 |
-
),
|
739 |
-
'
|
740 |
-
'sanitize' => '
|
741 |
-
),
|
742 |
-
'
|
743 |
-
'sanitize' => 'absint',
|
744 |
-
),
|
745 |
-
'
|
746 |
-
'sanitize' => '
|
747 |
-
),
|
748 |
-
'
|
749 |
-
'sanitize' => 'absint',
|
750 |
-
),
|
751 |
-
'
|
752 |
-
'sanitize' => '
|
753 |
-
),
|
754 |
-
'
|
755 |
-
'sanitize' => 'absint',
|
756 |
-
),
|
757 |
-
'
|
758 |
-
'sanitize' => '
|
759 |
-
),
|
760 |
-
'
|
761 |
-
'sanitize' => '
|
762 |
-
),
|
763 |
-
'
|
764 |
-
'sanitize' => '
|
765 |
-
),
|
766 |
-
'
|
767 |
-
'sanitize' => '
|
768 |
-
),
|
769 |
-
'
|
770 |
-
'sanitize' => 'text',
|
771 |
-
),
|
772 |
-
'
|
773 |
-
'sanitize' => '
|
774 |
-
),
|
775 |
-
'
|
776 |
-
'sanitize' => 'text',
|
777 |
-
),
|
778 |
-
'
|
779 |
-
'sanitize' => '
|
780 |
-
),
|
781 |
-
'
|
782 |
-
'sanitize' => 'text',
|
783 |
-
),
|
784 |
-
'
|
785 |
-
'sanitize' => '
|
786 |
-
),
|
787 |
-
'
|
788 |
-
'sanitize' => 'text',
|
789 |
-
),
|
790 |
-
'
|
791 |
-
'sanitize' => '
|
792 |
-
),
|
793 |
-
'
|
794 |
-
'sanitize' => 'text',
|
795 |
-
),
|
796 |
-
'
|
797 |
-
'sanitize' => '
|
798 |
-
),
|
799 |
-
'
|
800 |
-
'sanitize' => '
|
801 |
-
),
|
802 |
-
'
|
803 |
-
'sanitize' => '
|
804 |
-
),
|
805 |
-
'
|
806 |
-
'sanitize' =>
|
807 |
-
),
|
808 |
-
'
|
809 |
-
'sanitize' => 'bool',
|
810 |
-
),
|
811 |
-
'
|
812 |
-
'sanitize' => array( UM()->admin(), '
|
813 |
-
),
|
814 |
-
'
|
815 |
-
'sanitize' => '
|
816 |
-
),
|
817 |
-
'
|
818 |
-
'sanitize' => '
|
819 |
-
),
|
820 |
-
'
|
821 |
-
'sanitize' => '
|
822 |
-
),
|
823 |
-
'
|
824 |
-
'sanitize' => 'bool',
|
825 |
-
),
|
826 |
-
'
|
827 |
-
'sanitize' => 'bool',
|
828 |
-
),
|
829 |
-
'
|
830 |
-
'sanitize' => 'bool',
|
831 |
-
),
|
832 |
-
'
|
833 |
-
'sanitize' => '
|
834 |
-
),
|
835 |
-
'
|
836 |
-
'sanitize' => '
|
837 |
-
),
|
838 |
-
'
|
839 |
-
'sanitize' => '
|
840 |
-
),
|
841 |
-
'
|
842 |
-
'sanitize' => '
|
843 |
-
),
|
844 |
-
'
|
845 |
-
'sanitize' => '
|
846 |
-
),
|
847 |
-
'
|
848 |
-
'sanitize' => '
|
849 |
-
),
|
850 |
-
'
|
851 |
-
'sanitize' => '
|
852 |
-
),
|
853 |
-
'
|
854 |
-
'sanitize' => '
|
855 |
-
),
|
856 |
-
'
|
857 |
-
'sanitize' => '
|
858 |
-
),
|
859 |
-
'
|
860 |
-
'sanitize' => '
|
861 |
-
),
|
862 |
-
'
|
863 |
-
'sanitize' => 'text',
|
864 |
-
),
|
865 |
-
'
|
866 |
-
'sanitize' => '
|
867 |
-
),
|
868 |
-
'
|
869 |
-
'sanitize' => '
|
870 |
-
),
|
871 |
-
'
|
872 |
-
'sanitize' => '
|
873 |
-
),
|
874 |
-
'
|
875 |
-
'sanitize' => '
|
876 |
-
),
|
877 |
-
'
|
878 |
-
'sanitize' => '
|
879 |
-
),
|
880 |
-
'
|
881 |
-
'sanitize' => '
|
882 |
-
),
|
883 |
-
'
|
884 |
-
'sanitize' => '
|
885 |
-
),
|
886 |
-
'
|
887 |
-
'sanitize' => '
|
888 |
-
),
|
889 |
-
'
|
890 |
-
'sanitize' => 'text',
|
891 |
-
),
|
892 |
-
'
|
893 |
-
'sanitize' => '
|
894 |
-
),
|
895 |
-
'
|
896 |
-
'sanitize' => '
|
897 |
-
),
|
898 |
-
'
|
899 |
-
'sanitize' => '
|
900 |
-
),
|
901 |
-
'
|
902 |
-
'sanitize' => 'bool',
|
903 |
-
),
|
904 |
-
'
|
905 |
-
'sanitize' => '
|
906 |
-
),
|
907 |
-
'
|
908 |
-
'sanitize' => '
|
909 |
-
),
|
910 |
-
'
|
911 |
-
'sanitize' => '
|
912 |
-
),
|
913 |
-
'
|
914 |
-
'sanitize' => '
|
915 |
-
),
|
916 |
-
'
|
917 |
-
'sanitize' => '
|
918 |
-
),
|
919 |
-
'
|
920 |
-
'sanitize' => 'bool',
|
921 |
-
),
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
*
|
935 |
-
*
|
936 |
-
*
|
937 |
-
* @
|
938 |
-
* @
|
939 |
-
*
|
940 |
-
*
|
941 |
-
*
|
942 |
-
*
|
943 |
-
*
|
944 |
-
*
|
945 |
-
*
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
'
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
'
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
'
|
990 |
-
'
|
991 |
-
'
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
'
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
'
|
1004 |
-
'
|
1005 |
-
'
|
1006 |
-
'
|
1007 |
-
),
|
1008 |
-
array(
|
1009 |
-
'id' => '
|
1010 |
-
'type' => 'checkbox',
|
1011 |
-
'label' => __( '
|
1012 |
-
'tooltip' => __( '
|
1013 |
-
),
|
1014 |
-
array(
|
1015 |
-
'id' => '
|
1016 |
-
'type' => 'checkbox',
|
1017 |
-
'label' => __( '
|
1018 |
-
'tooltip' => __( '
|
1019 |
-
),
|
1020 |
-
array(
|
1021 |
-
'id'
|
1022 |
-
'type'
|
1023 |
-
'label'
|
1024 |
-
'tooltip'
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
'
|
1033 |
-
'
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
'
|
1042 |
-
'
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
'
|
1047 |
-
'
|
1048 |
-
'
|
1049 |
-
'
|
1050 |
-
),
|
1051 |
-
array(
|
1052 |
-
'id' => '
|
1053 |
-
'type' => '
|
1054 |
-
'
|
1055 |
-
'
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
),
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
'
|
1066 |
-
'
|
1067 |
-
'
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
'
|
1076 |
-
'
|
1077 |
-
'
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
'
|
1084 |
-
'
|
1085 |
-
|
1086 |
-
|
1087 |
-
'
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
'
|
1096 |
-
'
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
'
|
1102 |
-
'
|
1103 |
-
'
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
'
|
1109 |
-
'
|
1110 |
-
'
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
'
|
1120 |
-
'
|
1121 |
-
|
1122 |
-
|
1123 |
-
'
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
'
|
1131 |
-
'
|
1132 |
-
'
|
1133 |
-
|
1134 |
-
|
1135 |
-
),
|
1136 |
-
array(
|
1137 |
-
'id' => '
|
1138 |
-
'type' => 'checkbox',
|
1139 |
-
'label' => __( '
|
1140 |
-
'tooltip' => __( 'Whether to
|
1141 |
-
),
|
1142 |
-
array(
|
1143 |
-
'id'
|
1144 |
-
'type'
|
1145 |
-
'label'
|
1146 |
-
'tooltip'
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
'
|
1151 |
-
'
|
1152 |
-
'
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
'
|
1158 |
-
'
|
1159 |
-
'
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
'
|
1164 |
-
'
|
1165 |
-
'
|
1166 |
-
'
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
'
|
1171 |
-
'
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
'
|
1180 |
-
|
1181 |
-
|
1182 |
-
'
|
1183 |
-
'
|
1184 |
-
|
1185 |
-
|
1186 |
-
'
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
'
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
'
|
1200 |
-
'
|
1201 |
-
|
1202 |
-
|
1203 |
-
'
|
1204 |
-
|
1205 |
-
|
1206 |
-
'
|
1207 |
-
'
|
1208 |
-
'
|
1209 |
-
'
|
1210 |
-
'
|
1211 |
-
),
|
1212 |
-
array(
|
1213 |
-
'id'
|
1214 |
-
'type'
|
1215 |
-
'
|
1216 |
-
'
|
1217 |
-
|
1218 |
-
|
1219 |
-
'
|
1220 |
-
'
|
1221 |
-
|
1222 |
-
|
1223 |
-
'
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
'
|
1228 |
-
'
|
1229 |
-
'
|
1230 |
-
'
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
'
|
1236 |
-
'
|
1237 |
-
|
1238 |
-
|
1239 |
-
'
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
'
|
1257 |
-
'
|
1258 |
-
'label'
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
array(
|
1276 |
-
'id'
|
1277 |
-
'type'
|
1278 |
-
'label'
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
'
|
1310 |
-
'
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
'
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
'
|
1342 |
-
'
|
1343 |
-
'
|
1344 |
-
|
1345 |
-
|
1346 |
-
'
|
1347 |
-
'
|
1348 |
-
|
1349 |
-
|
1350 |
-
'
|
1351 |
-
'
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
'
|
1360 |
-
'
|
1361 |
-
'
|
1362 |
-
'
|
1363 |
-
'
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
'
|
1368 |
-
'
|
1369 |
-
'
|
1370 |
-
'default' => um_get_metadefault( '
|
1371 |
-
'
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
'
|
1377 |
-
|
1378 |
-
|
1379 |
-
'
|
1380 |
-
'
|
1381 |
-
|
1382 |
-
|
1383 |
-
'
|
1384 |
-
'
|
1385 |
-
|
1386 |
-
|
1387 |
-
'
|
1388 |
-
'
|
1389 |
-
|
1390 |
-
),
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
'
|
1395 |
-
'
|
1396 |
-
'
|
1397 |
-
'
|
1398 |
-
'tooltip'
|
1399 |
-
'
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
'
|
1404 |
-
'
|
1405 |
-
'
|
1406 |
-
'
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
'
|
1414 |
-
'
|
1415 |
-
'
|
1416 |
-
|
1417 |
-
|
1418 |
-
'
|
1419 |
-
'
|
1420 |
-
|
1421 |
-
|
1422 |
-
'
|
1423 |
-
|
1424 |
-
|
1425 |
-
'
|
1426 |
-
'
|
1427 |
-
|
1428 |
-
|
1429 |
-
'
|
1430 |
-
'
|
1431 |
-
'
|
1432 |
-
'
|
1433 |
-
|
1434 |
-
|
1435 |
-
'
|
1436 |
-
|
1437 |
-
|
1438 |
-
'
|
1439 |
-
'
|
1440 |
-
'
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
'
|
1447 |
-
'
|
1448 |
-
|
1449 |
-
|
1450 |
-
'
|
1451 |
-
'
|
1452 |
-
'
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
'
|
1458 |
-
'
|
1459 |
-
'
|
1460 |
-
'
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
'
|
1467 |
-
'
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
'
|
1472 |
-
'
|
1473 |
-
'
|
1474 |
-
'
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
'
|
1479 |
-
'
|
1480 |
-
'
|
1481 |
-
'tooltip' => __( 'Switch on/off
|
1482 |
-
),
|
1483 |
-
array(
|
1484 |
-
'id'
|
1485 |
-
'type'
|
1486 |
-
'label'
|
1487 |
-
'default'
|
1488 |
-
'tooltip'
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
'
|
1494 |
-
'
|
1495 |
-
'
|
1496 |
-
|
1497 |
-
|
1498 |
-
'
|
1499 |
-
|
1500 |
-
|
1501 |
-
),
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
'
|
1506 |
-
'
|
1507 |
-
'
|
1508 |
-
'
|
1509 |
-
'
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
'
|
1514 |
-
'
|
1515 |
-
'
|
1516 |
-
'
|
1517 |
-
'
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
'
|
1530 |
-
|
1531 |
-
|
1532 |
-
'
|
1533 |
-
'
|
1534 |
-
'
|
1535 |
-
'
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
'
|
1550 |
-
'
|
1551 |
-
'
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
'
|
1560 |
-
'
|
1561 |
-
'
|
1562 |
-
'tooltip' => __( '
|
1563 |
-
'
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
),
|
1569 |
-
'
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
'
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
'
|
1581 |
-
'
|
1582 |
-
'
|
1583 |
-
'default' =>
|
1584 |
-
'
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
'
|
1590 |
-
|
1591 |
-
|
1592 |
-
'
|
1593 |
-
'
|
1594 |
-
|
1595 |
-
|
1596 |
-
'
|
1597 |
-
'
|
1598 |
-
|
1599 |
-
|
1600 |
-
'
|
1601 |
-
'
|
1602 |
-
'
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
'
|
1608 |
-
'
|
1609 |
-
'
|
1610 |
-
'
|
1611 |
-
'
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
'
|
1620 |
-
'
|
1621 |
-
'
|
1622 |
-
'
|
1623 |
-
|
1624 |
-
|
1625 |
-
'
|
1626 |
-
|
1627 |
-
|
1628 |
-
'
|
1629 |
-
'
|
1630 |
-
'
|
1631 |
-
'
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
'
|
1640 |
-
'
|
1641 |
-
'
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
'
|
1650 |
-
'
|
1651 |
-
'
|
1652 |
-
'tooltip' => __( '
|
1653 |
-
'
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
),
|
1659 |
-
'
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
'
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
'
|
1671 |
-
'
|
1672 |
-
'
|
1673 |
-
'default' =>
|
1674 |
-
'
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
'
|
1680 |
-
|
1681 |
-
|
1682 |
-
'
|
1683 |
-
'
|
1684 |
-
|
1685 |
-
|
1686 |
-
'
|
1687 |
-
'
|
1688 |
-
|
1689 |
-
|
1690 |
-
'
|
1691 |
-
'
|
1692 |
-
'
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
'
|
1698 |
-
'
|
1699 |
-
'
|
1700 |
-
|
1701 |
-
|
1702 |
-
'
|
1703 |
-
'
|
1704 |
-
|
1705 |
-
|
1706 |
-
'
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
'
|
1744 |
-
'
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
'
|
1750 |
-
'
|
1751 |
-
'
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
'
|
1756 |
-
'
|
1757 |
-
'
|
1758 |
-
'
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
'
|
1770 |
-
'
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
'
|
1776 |
-
'
|
1777 |
-
'
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
*
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
*
|
1949 |
-
*
|
1950 |
-
* @
|
1951 |
-
* @
|
1952 |
-
*
|
1953 |
-
* @
|
1954 |
-
* @
|
1955 |
-
*
|
1956 |
-
* {
|
1957 |
-
*
|
1958 |
-
*
|
1959 |
-
*
|
1960 |
-
*
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
*
|
2004 |
-
*
|
2005 |
-
* @
|
2006 |
-
* @
|
2007 |
-
*
|
2008 |
-
* @
|
2009 |
-
*
|
2010 |
-
*
|
2011 |
-
*
|
2012 |
-
*
|
2013 |
-
*
|
2014 |
-
*
|
2015 |
-
*
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
*
|
2173 |
-
*
|
2174 |
-
* @
|
2175 |
-
* @
|
2176 |
-
* @
|
2177 |
-
*
|
2178 |
-
*
|
2179 |
-
*
|
2180 |
-
* @
|
2181 |
-
*
|
2182 |
-
*
|
2183 |
-
*
|
2184 |
-
*
|
2185 |
-
*
|
2186 |
-
*
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
*
|
2200 |
-
*
|
2201 |
-
* @
|
2202 |
-
*
|
2203 |
-
*
|
2204 |
-
*
|
2205 |
-
*
|
2206 |
-
*
|
2207 |
-
*
|
2208 |
-
*
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
$
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
}
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
}
|
2367 |
-
}
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
}
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
$
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
}
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
);
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
$
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
}
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
$
|
2506 |
-
$
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
$
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
$
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
'
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
'
|
2635 |
-
'
|
2636 |
-
'
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
$
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
$
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
$
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
$
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
$
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
$
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
$
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
$
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
$
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
$
|
2875 |
-
$
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
$
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
<?php
|
3046 |
-
<?php
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
<?php
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
<?php
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
);
|
3064 |
-
|
3065 |
-
$
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
$
|
3071 |
-
|
3072 |
-
?>
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
*
|
3126 |
-
*
|
3127 |
-
* @
|
3128 |
-
*
|
3129 |
-
*
|
3130 |
-
*
|
3131 |
-
*
|
3132 |
-
*
|
3133 |
-
*
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
<?php
|
3168 |
-
|
3169 |
-
<?php
|
3170 |
-
|
3171 |
-
<?php
|
3172 |
-
|
3173 |
-
<?php
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
<?php
|
3181 |
-
|
3182 |
-
<?php
|
3183 |
-
<?php
|
3184 |
-
|
3185 |
-
<?php } ?>
|
3186 |
-
<?php $
|
3187 |
-
|
3188 |
-
<?php } ?>
|
3189 |
-
<?php
|
3190 |
-
|
3191 |
-
<?php
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
*
|
3386 |
-
*/
|
3387 |
-
function
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
*
|
3402 |
-
* @param
|
3403 |
-
* @param string $
|
3404 |
-
*
|
3405 |
-
*
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
* @param
|
3425 |
-
*
|
3426 |
-
* @return
|
3427 |
-
*/
|
3428 |
-
function
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
$
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
|
3451 |
-
|
3452 |
-
|
3453 |
-
|
3454 |
-
|
3455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Settings
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Settings {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
public $settings_map;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
public $settings_structure;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var
|
32 |
+
*/
|
33 |
+
private $previous_licenses;
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var
|
38 |
+
*/
|
39 |
+
private $need_change_permalinks;
|
40 |
+
|
41 |
+
|
42 |
+
private $gravatar_changed = false;
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Admin_Settings constructor.
|
47 |
+
*/
|
48 |
+
public function __construct() {
|
49 |
+
//init settings structure
|
50 |
+
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
+
|
52 |
+
//admin menu
|
53 |
+
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
+
|
55 |
+
//settings structure handlers
|
56 |
+
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
+
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
+
|
59 |
+
//enqueue wp_media for profiles tab
|
60 |
+
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
+
|
62 |
+
//custom content for licenses tab
|
63 |
+
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
+
|
65 |
+
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
+
|
67 |
+
|
68 |
+
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
+
|
70 |
+
|
71 |
+
//save handlers
|
72 |
+
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
+
|
74 |
+
//save pages options
|
75 |
+
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
+
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
+
|
78 |
+
|
79 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
+
|
81 |
+
|
82 |
+
//save licenses options
|
83 |
+
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
+
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
+
|
86 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
+
|
89 |
+
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
public function same_page_update_ajax() {
|
95 |
+
UM()->admin()->check_ajax_nonce();
|
96 |
+
|
97 |
+
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
+
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
+
}
|
100 |
+
|
101 |
+
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
+
|
103 |
+
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
+
//first install metatable
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
$metakeys = array();
|
108 |
+
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
+
$metakeys[] = $all_user_field['metakey'];
|
110 |
+
}
|
111 |
+
|
112 |
+
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
+
|
114 |
+
if ( is_multisite() ) {
|
115 |
+
|
116 |
+
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
+
foreach ( $sites as $blog_id ) {
|
118 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
$blog_id = get_current_blog_id();
|
122 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
+
}
|
124 |
+
|
125 |
+
//member directory data
|
126 |
+
$metakeys[] = 'um_member_directory_data';
|
127 |
+
$metakeys[] = '_um_verified';
|
128 |
+
$metakeys[] = '_money_spent';
|
129 |
+
$metakeys[] = '_completed';
|
130 |
+
$metakeys[] = '_reviews_avg';
|
131 |
+
|
132 |
+
//myCred meta
|
133 |
+
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
+
$mycred_types = mycred_get_types();
|
135 |
+
if ( ! empty( $mycred_types ) ) {
|
136 |
+
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
+
$metakeys[] = $point_type;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
+
if ( empty( $sortby_custom_keys ) ) {
|
144 |
+
$sortby_custom_keys = array();
|
145 |
+
}
|
146 |
+
|
147 |
+
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
+
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
+
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
+
$custom_val = maybe_unserialize( $custom_val );
|
151 |
+
|
152 |
+
foreach ( $custom_val as $sort_value ) {
|
153 |
+
if ( is_array( $sort_value ) ) {
|
154 |
+
$field_keys = array_keys( $sort_value );
|
155 |
+
$sortby_custom_keys[] = $field_keys[0];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
+
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
+
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
+
}
|
165 |
+
|
166 |
+
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
+
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
+
|
169 |
+
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
+
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
+
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
+
|
173 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
+
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
+
}
|
176 |
+
|
177 |
+
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
+
|
179 |
+
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
+
|
181 |
+
update_option( 'um_member_directory_update_meta', time() );
|
182 |
+
|
183 |
+
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
+
|
185 |
+
wp_send_json_success();
|
186 |
+
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
+
global $wpdb;
|
188 |
+
|
189 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
+
|
191 |
+
$count = $wpdb->get_var(
|
192 |
+
"SELECT COUNT(*)
|
193 |
+
FROM {$wpdb->usermeta}
|
194 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
+
);
|
196 |
+
|
197 |
+
wp_send_json_success( array( 'count' => $count ) );
|
198 |
+
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
+
|
200 |
+
if ( empty( $_POST['page'] ) ) {
|
201 |
+
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
+
}
|
203 |
+
|
204 |
+
$per_page = 500;
|
205 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
$metadata = $wpdb->get_results(
|
209 |
+
$wpdb->prepare(
|
210 |
+
"SELECT *
|
211 |
+
FROM {$wpdb->usermeta}
|
212 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
+
LIMIT %d, %d",
|
214 |
+
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
+
$per_page
|
216 |
+
),
|
217 |
+
ARRAY_A
|
218 |
+
);
|
219 |
+
|
220 |
+
$values = array();
|
221 |
+
foreach ( $metadata as $metarow ) {
|
222 |
+
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
+
}
|
224 |
+
|
225 |
+
if ( ! empty( $values ) ) {
|
226 |
+
$wpdb->query(
|
227 |
+
"INSERT INTO
|
228 |
+
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
+
VALUES " . implode( ',', $values )
|
230 |
+
);
|
231 |
+
}
|
232 |
+
|
233 |
+
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
+
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
+
|
236 |
+
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
*
|
243 |
+
*/
|
244 |
+
public function init_variables() {
|
245 |
+
|
246 |
+
$settings_map = array();
|
247 |
+
|
248 |
+
$general_pages_fields = array(
|
249 |
+
array(
|
250 |
+
'id' => 'pages_settings',
|
251 |
+
'type' => 'hidden',
|
252 |
+
'value' => true,
|
253 |
+
'is_option' => false,
|
254 |
+
),
|
255 |
+
);
|
256 |
+
|
257 |
+
$core_pages = UM()->config()->core_pages;
|
258 |
+
|
259 |
+
foreach ( $core_pages as $page_s => $page ) {
|
260 |
+
$have_pages = UM()->query()->wp_pages();
|
261 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
262 |
+
|
263 |
+
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
264 |
+
|
265 |
+
if ( 'reached_maximum_limit' === $have_pages ) {
|
266 |
+
$general_pages_fields[] = array(
|
267 |
+
'id' => $page_id,
|
268 |
+
'type' => 'text',
|
269 |
+
// translators: %s: Page title
|
270 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
271 |
+
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
272 |
+
'compiler' => true,
|
273 |
+
'size' => 'small',
|
274 |
+
);
|
275 |
+
} else {
|
276 |
+
$general_pages_fields[] = array(
|
277 |
+
'id' => $page_id,
|
278 |
+
'type' => 'select',
|
279 |
+
// translators: %s: Page title
|
280 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
281 |
+
'options' => UM()->query()->wp_pages(),
|
282 |
+
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
283 |
+
'compiler' => true,
|
284 |
+
'size' => 'small',
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
$settings_map[ $page_id ] = array(
|
290 |
+
'sanitize' => 'absint',
|
291 |
+
);
|
292 |
+
}
|
293 |
+
|
294 |
+
$appearances_profile_menu_fields = array(
|
295 |
+
array(
|
296 |
+
'id' => 'profile_menu',
|
297 |
+
'type' => 'checkbox',
|
298 |
+
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
299 |
+
),
|
300 |
+
);
|
301 |
+
|
302 |
+
$settings_map['profile_menu'] = array(
|
303 |
+
'sanitize' => 'bool',
|
304 |
+
);
|
305 |
+
|
306 |
+
$tabs = UM()->profile()->tabs();
|
307 |
+
|
308 |
+
$tabs_options = array();
|
309 |
+
$tabs_condition = array();
|
310 |
+
foreach ( $tabs as $id => $tab ) {
|
311 |
+
|
312 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
313 |
+
continue;
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( isset( $tab['name'] ) ) {
|
317 |
+
$tabs_options[ $id ] = $tab['name'];
|
318 |
+
$tabs_condition[] = 'profile_tab_' . $id;
|
319 |
+
}
|
320 |
+
|
321 |
+
if ( isset( $tab['default_privacy'] ) ) {
|
322 |
+
$fields = array(
|
323 |
+
array(
|
324 |
+
'id' => 'profile_tab_' . $id,
|
325 |
+
'type' => 'checkbox',
|
326 |
+
// translators: %s: Tab title
|
327 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
328 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
329 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
330 |
+
),
|
331 |
+
);
|
332 |
+
|
333 |
+
$settings_map[ 'profile_tab_' . $id ] = array(
|
334 |
+
'sanitize' => 'bool',
|
335 |
+
);
|
336 |
+
} else {
|
337 |
+
|
338 |
+
$fields = array(
|
339 |
+
array(
|
340 |
+
'id' => 'profile_tab_' . $id,
|
341 |
+
'type' => 'checkbox',
|
342 |
+
// translators: %s: Tab title
|
343 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
344 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
345 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'id' => 'profile_tab_' . $id . '_privacy',
|
349 |
+
'type' => 'select',
|
350 |
+
// translators: %s: Tab title
|
351 |
+
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
352 |
+
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
353 |
+
'options' => UM()->profile()->tabs_privacy(),
|
354 |
+
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
355 |
+
'size' => 'small',
|
356 |
+
),
|
357 |
+
array(
|
358 |
+
'id' => 'profile_tab_' . $id . '_roles',
|
359 |
+
'type' => 'select',
|
360 |
+
'multi' => true,
|
361 |
+
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
362 |
+
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
363 |
+
'options' => UM()->roles()->get_roles(),
|
364 |
+
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
365 |
+
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
366 |
+
'size' => 'small',
|
367 |
+
),
|
368 |
+
);
|
369 |
+
|
370 |
+
$settings_map = array_merge(
|
371 |
+
$settings_map,
|
372 |
+
array(
|
373 |
+
"profile_tab_{$id}" => array(
|
374 |
+
'sanitize' => 'bool',
|
375 |
+
),
|
376 |
+
"profile_tab_{$id}_privacy" => array(
|
377 |
+
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
378 |
+
),
|
379 |
+
"profile_tab_{$id}_roles" => array(
|
380 |
+
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
381 |
+
),
|
382 |
+
)
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
387 |
+
}
|
388 |
+
|
389 |
+
$appearances_profile_menu_fields[] = array(
|
390 |
+
'id' => 'profile_menu_default_tab',
|
391 |
+
'type' => 'select',
|
392 |
+
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
393 |
+
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
394 |
+
'options' => $tabs_options,
|
395 |
+
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
396 |
+
'size' => 'small',
|
397 |
+
);
|
398 |
+
|
399 |
+
$settings_map['profile_menu_default_tab'] = array(
|
400 |
+
'sanitize' => 'key',
|
401 |
+
);
|
402 |
+
|
403 |
+
$appearances_profile_menu_fields = array_merge(
|
404 |
+
$appearances_profile_menu_fields,
|
405 |
+
array(
|
406 |
+
array(
|
407 |
+
'id' => 'profile_menu_icons',
|
408 |
+
'type' => 'checkbox',
|
409 |
+
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
410 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
411 |
+
),
|
412 |
+
)
|
413 |
+
);
|
414 |
+
|
415 |
+
$settings_map['profile_menu_icons'] = array(
|
416 |
+
'sanitize' => 'bool',
|
417 |
+
);
|
418 |
+
|
419 |
+
$post_types_options = array();
|
420 |
+
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
421 |
+
foreach ( $all_post_types as $key => $post_type_data ) {
|
422 |
+
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
423 |
+
}
|
424 |
+
|
425 |
+
$duplicates = array();
|
426 |
+
$taxonomies_options = array();
|
427 |
+
$exclude_taxonomies = UM()->excluded_taxonomies();
|
428 |
+
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
429 |
+
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
430 |
+
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
431 |
+
continue;
|
432 |
+
}
|
433 |
+
|
434 |
+
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
435 |
+
$duplicates[] = $taxonomy->labels->singular_name;
|
436 |
+
$label = $taxonomy->labels->singular_name;
|
437 |
+
} else {
|
438 |
+
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
439 |
+
}
|
440 |
+
|
441 |
+
$taxonomies_options[ $key ] = $label;
|
442 |
+
}
|
443 |
+
|
444 |
+
$restricted_access_post_metabox_value = array();
|
445 |
+
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
446 |
+
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
447 |
+
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
448 |
+
if ( $value ) {
|
449 |
+
$restricted_access_post_metabox_value[] = $key;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
|
455 |
+
$restricted_access_taxonomy_metabox_value = array();
|
456 |
+
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
457 |
+
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
458 |
+
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
459 |
+
if ( $value ) {
|
460 |
+
$restricted_access_taxonomy_metabox_value[] = $key;
|
461 |
+
}
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
$access_fields = array(
|
466 |
+
array(
|
467 |
+
'id' => 'accessible',
|
468 |
+
'type' => 'select',
|
469 |
+
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
470 |
+
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
471 |
+
'options' => array(
|
472 |
+
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
473 |
+
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
474 |
+
),
|
475 |
+
'size' => 'medium',
|
476 |
+
),
|
477 |
+
array(
|
478 |
+
'id' => 'access_redirect',
|
479 |
+
'type' => 'text',
|
480 |
+
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
481 |
+
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
482 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
483 |
+
),
|
484 |
+
array(
|
485 |
+
'id' => 'access_exclude_uris',
|
486 |
+
'type' => 'multi_text',
|
487 |
+
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
488 |
+
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
489 |
+
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
490 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
491 |
+
'show_default_number' => 0,
|
492 |
+
),
|
493 |
+
array(
|
494 |
+
'id' => 'home_page_accessible',
|
495 |
+
'type' => 'checkbox',
|
496 |
+
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
497 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
498 |
+
),
|
499 |
+
array(
|
500 |
+
'id' => 'category_page_accessible',
|
501 |
+
'type' => 'checkbox',
|
502 |
+
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
503 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
504 |
+
),
|
505 |
+
array(
|
506 |
+
'id' => 'restricted_post_title_replace',
|
507 |
+
'type' => 'checkbox',
|
508 |
+
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
509 |
+
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
510 |
+
),
|
511 |
+
array(
|
512 |
+
'id' => 'restricted_access_post_title',
|
513 |
+
'type' => 'text',
|
514 |
+
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
515 |
+
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
516 |
+
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
517 |
+
),
|
518 |
+
array(
|
519 |
+
'id' => 'restricted_access_message',
|
520 |
+
'type' => 'wp_editor',
|
521 |
+
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
522 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
523 |
+
),
|
524 |
+
);
|
525 |
+
|
526 |
+
$settings_map = array_merge(
|
527 |
+
$settings_map,
|
528 |
+
array(
|
529 |
+
'accessible' => array(
|
530 |
+
'sanitize' => 'int',
|
531 |
+
),
|
532 |
+
'access_redirect' => array(
|
533 |
+
'sanitize' => 'url',
|
534 |
+
),
|
535 |
+
'access_exclude_uris' => array(
|
536 |
+
'sanitize' => 'url',
|
537 |
+
),
|
538 |
+
'home_page_accessible' => array(
|
539 |
+
'sanitize' => 'bool',
|
540 |
+
),
|
541 |
+
'category_page_accessible' => array(
|
542 |
+
'sanitize' => 'bool',
|
543 |
+
),
|
544 |
+
'restricted_post_title_replace' => array(
|
545 |
+
'sanitize' => 'bool',
|
546 |
+
),
|
547 |
+
'restricted_access_post_title' => array(
|
548 |
+
'sanitize' => 'text',
|
549 |
+
),
|
550 |
+
'restricted_access_message' => array(
|
551 |
+
'sanitize' => 'wp_kses',
|
552 |
+
),
|
553 |
+
)
|
554 |
+
);
|
555 |
+
|
556 |
+
global $wp_version;
|
557 |
+
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
558 |
+
$access_fields = array_merge(
|
559 |
+
$access_fields,
|
560 |
+
array(
|
561 |
+
array(
|
562 |
+
'id' => 'restricted_blocks',
|
563 |
+
'type' => 'checkbox',
|
564 |
+
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
565 |
+
),
|
566 |
+
array(
|
567 |
+
'id' => 'restricted_block_message',
|
568 |
+
'type' => 'textarea',
|
569 |
+
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
570 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
571 |
+
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
572 |
+
),
|
573 |
+
)
|
574 |
+
);
|
575 |
+
|
576 |
+
$settings_map['restricted_blocks'] = array(
|
577 |
+
'sanitize' => 'bool',
|
578 |
+
);
|
579 |
+
$settings_map['restricted_block_message'] = array(
|
580 |
+
'sanitize' => 'textarea',
|
581 |
+
);
|
582 |
+
}
|
583 |
+
|
584 |
+
$access_fields = array_merge(
|
585 |
+
$access_fields,
|
586 |
+
array(
|
587 |
+
array(
|
588 |
+
'id' => 'restricted_access_post_metabox',
|
589 |
+
'type' => 'hidden',
|
590 |
+
'value' => '',
|
591 |
+
),
|
592 |
+
array(
|
593 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
594 |
+
'type' => 'hidden',
|
595 |
+
'value' => '',
|
596 |
+
),
|
597 |
+
array(
|
598 |
+
'id' => 'restricted_access_post_metabox',
|
599 |
+
'type' => 'multi_checkbox',
|
600 |
+
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
601 |
+
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
602 |
+
'options' => $post_types_options,
|
603 |
+
'columns' => 3,
|
604 |
+
'value' => $restricted_access_post_metabox_value,
|
605 |
+
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
606 |
+
),
|
607 |
+
array(
|
608 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
609 |
+
'type' => 'multi_checkbox',
|
610 |
+
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
611 |
+
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
612 |
+
'options' => $taxonomies_options,
|
613 |
+
'columns' => 3,
|
614 |
+
'value' => $restricted_access_taxonomy_metabox_value,
|
615 |
+
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
616 |
+
),
|
617 |
+
)
|
618 |
+
);
|
619 |
+
|
620 |
+
$settings_map = array_merge(
|
621 |
+
$settings_map,
|
622 |
+
array(
|
623 |
+
'restricted_access_post_metabox' => array(
|
624 |
+
'sanitize' => 'key',
|
625 |
+
),
|
626 |
+
'restricted_access_taxonomy_metabox' => array(
|
627 |
+
'sanitize' => 'key',
|
628 |
+
),
|
629 |
+
)
|
630 |
+
);
|
631 |
+
|
632 |
+
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
633 |
+
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
634 |
+
|
635 |
+
$same_page_update = array(
|
636 |
+
'id' => 'member_directory_own_table',
|
637 |
+
'type' => 'same_page_update',
|
638 |
+
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
639 |
+
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
640 |
+
);
|
641 |
+
|
642 |
+
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
643 |
+
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
644 |
+
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
645 |
+
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
646 |
+
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
647 |
+
}
|
648 |
+
|
649 |
+
$settings_map = array_merge(
|
650 |
+
$settings_map,
|
651 |
+
array(
|
652 |
+
'permalink_base' => array(
|
653 |
+
'sanitize' => 'key',
|
654 |
+
),
|
655 |
+
'display_name' => array(
|
656 |
+
'sanitize' => 'key',
|
657 |
+
),
|
658 |
+
'display_name_field' => array(
|
659 |
+
'sanitize' => 'text',
|
660 |
+
),
|
661 |
+
'author_redirect' => array(
|
662 |
+
'sanitize' => 'bool',
|
663 |
+
),
|
664 |
+
'members_page' => array(
|
665 |
+
'sanitize' => 'bool',
|
666 |
+
),
|
667 |
+
'use_gravatars' => array(
|
668 |
+
'sanitize' => 'bool',
|
669 |
+
),
|
670 |
+
'use_um_gravatar_default_builtin_image' => array(
|
671 |
+
'sanitize' => 'key',
|
672 |
+
),
|
673 |
+
'use_um_gravatar_default_image' => array(
|
674 |
+
'sanitize' => 'bool',
|
675 |
+
),
|
676 |
+
'reset_require_strongpass' => array(
|
677 |
+
'sanitize' => 'bool',
|
678 |
+
),
|
679 |
+
'password_min_chars' => array(
|
680 |
+
'sanitize' => 'absint',
|
681 |
+
),
|
682 |
+
'password_max_chars' => array(
|
683 |
+
'sanitize' => 'absint',
|
684 |
+
),
|
685 |
+
'profile_noindex' => array(
|
686 |
+
'sanitize' => 'bool',
|
687 |
+
),
|
688 |
+
'activation_link_expiry_time' => array(
|
689 |
+
'sanitize' => 'absint',
|
690 |
+
),
|
691 |
+
'account_tab_password' => array(
|
692 |
+
'sanitize' => 'bool',
|
693 |
+
),
|
694 |
+
'account_tab_privacy' => array(
|
695 |
+
'sanitize' => 'bool',
|
696 |
+
),
|
697 |
+
'account_tab_notifications' => array(
|
698 |
+
'sanitize' => 'bool',
|
699 |
+
),
|
700 |
+
'account_tab_delete' => array(
|
701 |
+
'sanitize' => 'bool',
|
702 |
+
),
|
703 |
+
'delete_account_text' => array(
|
704 |
+
'sanitize' => 'textarea',
|
705 |
+
),
|
706 |
+
'delete_account_no_pass_required_text' => array(
|
707 |
+
'sanitize' => 'textarea',
|
708 |
+
),
|
709 |
+
'account_name' => array(
|
710 |
+
'sanitize' => 'bool',
|
711 |
+
),
|
712 |
+
'account_name_disable' => array(
|
713 |
+
'sanitize' => 'bool',
|
714 |
+
),
|
715 |
+
'account_name_require' => array(
|
716 |
+
'sanitize' => 'bool',
|
717 |
+
),
|
718 |
+
'account_email' => array(
|
719 |
+
'sanitize' => 'bool',
|
720 |
+
),
|
721 |
+
'account_general_password' => array(
|
722 |
+
'sanitize' => 'bool',
|
723 |
+
),
|
724 |
+
'account_require_strongpass' => array(
|
725 |
+
'sanitize' => 'bool',
|
726 |
+
),
|
727 |
+
'account_hide_in_directory' => array(
|
728 |
+
'sanitize' => 'bool',
|
729 |
+
),
|
730 |
+
'account_hide_in_directory_default' => array(
|
731 |
+
'sanitize' => 'text',
|
732 |
+
),
|
733 |
+
'profile_photo_max_size' => array(
|
734 |
+
'sanitize' => 'absint',
|
735 |
+
),
|
736 |
+
'cover_photo_max_size' => array(
|
737 |
+
'sanitize' => 'absint',
|
738 |
+
),
|
739 |
+
'photo_thumb_sizes' => array(
|
740 |
+
'sanitize' => 'absint',
|
741 |
+
),
|
742 |
+
'cover_thumb_sizes' => array(
|
743 |
+
'sanitize' => 'absint',
|
744 |
+
),
|
745 |
+
'image_orientation_by_exif' => array(
|
746 |
+
'sanitize' => 'bool',
|
747 |
+
),
|
748 |
+
'image_compression' => array(
|
749 |
+
'sanitize' => 'absint',
|
750 |
+
),
|
751 |
+
'image_max_width' => array(
|
752 |
+
'sanitize' => 'absint',
|
753 |
+
),
|
754 |
+
'cover_min_width' => array(
|
755 |
+
'sanitize' => 'absint',
|
756 |
+
),
|
757 |
+
'enable_reset_password_limit' => array(
|
758 |
+
'sanitize' => 'bool',
|
759 |
+
),
|
760 |
+
'reset_password_limit_number' => array(
|
761 |
+
'sanitize' => 'absint',
|
762 |
+
),
|
763 |
+
'blocked_emails' => array(
|
764 |
+
'sanitize' => 'textarea',
|
765 |
+
),
|
766 |
+
'blocked_words' => array(
|
767 |
+
'sanitize' => 'textarea',
|
768 |
+
),
|
769 |
+
'admin_email' => array(
|
770 |
+
'sanitize' => 'text',
|
771 |
+
),
|
772 |
+
'mail_from' => array(
|
773 |
+
'sanitize' => 'text',
|
774 |
+
),
|
775 |
+
'mail_from_addr' => array(
|
776 |
+
'sanitize' => 'text',
|
777 |
+
),
|
778 |
+
'email_html' => array(
|
779 |
+
'sanitize' => 'bool',
|
780 |
+
),
|
781 |
+
'profile_template' => array(
|
782 |
+
'sanitize' => 'text',
|
783 |
+
),
|
784 |
+
'profile_max_width' => array(
|
785 |
+
'sanitize' => 'text',
|
786 |
+
),
|
787 |
+
'profile_area_max_width' => array(
|
788 |
+
'sanitize' => 'text',
|
789 |
+
),
|
790 |
+
'profile_icons' => array(
|
791 |
+
'sanitize' => 'key',
|
792 |
+
),
|
793 |
+
'profile_primary_btn_word' => array(
|
794 |
+
'sanitize' => 'text',
|
795 |
+
),
|
796 |
+
'profile_secondary_btn' => array(
|
797 |
+
'sanitize' => 'bool',
|
798 |
+
),
|
799 |
+
'profile_secondary_btn_word' => array(
|
800 |
+
'sanitize' => 'text',
|
801 |
+
),
|
802 |
+
'default_avatar' => array(
|
803 |
+
'sanitize' => 'url',
|
804 |
+
),
|
805 |
+
'default_cover' => array(
|
806 |
+
'sanitize' => 'url',
|
807 |
+
),
|
808 |
+
'disable_profile_photo_upload' => array(
|
809 |
+
'sanitize' => 'bool',
|
810 |
+
),
|
811 |
+
'profile_photosize' => array(
|
812 |
+
'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
|
813 |
+
),
|
814 |
+
'profile_cover_enabled' => array(
|
815 |
+
'sanitize' => 'bool',
|
816 |
+
),
|
817 |
+
'profile_coversize' => array(
|
818 |
+
'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
|
819 |
+
),
|
820 |
+
'profile_cover_ratio' => array(
|
821 |
+
'sanitize' => 'text',
|
822 |
+
),
|
823 |
+
'profile_show_metaicon' => array(
|
824 |
+
'sanitize' => 'bool',
|
825 |
+
),
|
826 |
+
'profile_show_name' => array(
|
827 |
+
'sanitize' => 'bool',
|
828 |
+
),
|
829 |
+
'profile_show_social_links' => array(
|
830 |
+
'sanitize' => 'bool',
|
831 |
+
),
|
832 |
+
'profile_show_bio' => array(
|
833 |
+
'sanitize' => 'bool',
|
834 |
+
),
|
835 |
+
'profile_show_html_bio' => array(
|
836 |
+
'sanitize' => 'bool',
|
837 |
+
),
|
838 |
+
'profile_bio_maxchars' => array(
|
839 |
+
'sanitize' => 'absint',
|
840 |
+
),
|
841 |
+
'profile_header_menu' => array(
|
842 |
+
'sanitize' => 'key',
|
843 |
+
),
|
844 |
+
'profile_empty_text' => array(
|
845 |
+
'sanitize' => 'bool',
|
846 |
+
),
|
847 |
+
'profile_empty_text_emo' => array(
|
848 |
+
'sanitize' => 'bool',
|
849 |
+
),
|
850 |
+
'register_template' => array(
|
851 |
+
'sanitize' => 'text',
|
852 |
+
),
|
853 |
+
'register_max_width' => array(
|
854 |
+
'sanitize' => 'text',
|
855 |
+
),
|
856 |
+
'register_align' => array(
|
857 |
+
'sanitize' => 'key',
|
858 |
+
),
|
859 |
+
'register_icons' => array(
|
860 |
+
'sanitize' => 'key',
|
861 |
+
),
|
862 |
+
'register_primary_btn_word' => array(
|
863 |
+
'sanitize' => 'text',
|
864 |
+
),
|
865 |
+
'register_secondary_btn' => array(
|
866 |
+
'sanitize' => 'bool',
|
867 |
+
),
|
868 |
+
'register_secondary_btn_word' => array(
|
869 |
+
'sanitize' => 'text',
|
870 |
+
),
|
871 |
+
'register_secondary_btn_url' => array(
|
872 |
+
'sanitize' => 'url',
|
873 |
+
),
|
874 |
+
'register_role' => array(
|
875 |
+
'sanitize' => 'key',
|
876 |
+
),
|
877 |
+
'login_template' => array(
|
878 |
+
'sanitize' => 'text',
|
879 |
+
),
|
880 |
+
'login_max_width' => array(
|
881 |
+
'sanitize' => 'text',
|
882 |
+
),
|
883 |
+
'login_align' => array(
|
884 |
+
'sanitize' => 'key',
|
885 |
+
),
|
886 |
+
'login_icons' => array(
|
887 |
+
'sanitize' => 'key',
|
888 |
+
),
|
889 |
+
'login_primary_btn_word' => array(
|
890 |
+
'sanitize' => 'text',
|
891 |
+
),
|
892 |
+
'login_secondary_btn' => array(
|
893 |
+
'sanitize' => 'bool',
|
894 |
+
),
|
895 |
+
'login_secondary_btn_word' => array(
|
896 |
+
'sanitize' => 'text',
|
897 |
+
),
|
898 |
+
'login_secondary_btn_url' => array(
|
899 |
+
'sanitize' => 'url',
|
900 |
+
),
|
901 |
+
'login_forgot_pass_link' => array(
|
902 |
+
'sanitize' => 'bool',
|
903 |
+
),
|
904 |
+
'login_show_rememberme' => array(
|
905 |
+
'sanitize' => 'bool',
|
906 |
+
),
|
907 |
+
'form_asterisk' => array(
|
908 |
+
'sanitize' => 'bool',
|
909 |
+
),
|
910 |
+
'profile_title' => array(
|
911 |
+
'sanitize' => 'text',
|
912 |
+
),
|
913 |
+
'profile_desc' => array(
|
914 |
+
'sanitize' => 'textarea',
|
915 |
+
),
|
916 |
+
'um_profile_object_cache_stop' => array(
|
917 |
+
'sanitize' => 'bool',
|
918 |
+
),
|
919 |
+
'enable_blocks' => array(
|
920 |
+
'sanitize' => 'bool',
|
921 |
+
),
|
922 |
+
'rest_api_version' => array(
|
923 |
+
'sanitize' => 'text',
|
924 |
+
),
|
925 |
+
'uninstall_on_delete' => array(
|
926 |
+
'sanitize' => 'bool',
|
927 |
+
),
|
928 |
+
)
|
929 |
+
);
|
930 |
+
|
931 |
+
$this->settings_map = apply_filters( 'um_settings_map', $settings_map );
|
932 |
+
|
933 |
+
/**
|
934 |
+
* UM hook
|
935 |
+
*
|
936 |
+
* @type filter
|
937 |
+
* @title um_settings_structure
|
938 |
+
* @description Extend UM Settings
|
939 |
+
* @input_vars
|
940 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings"}]
|
941 |
+
* @change_log
|
942 |
+
* ["Since: 2.0"]
|
943 |
+
* @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
|
944 |
+
* @example
|
945 |
+
* <?php
|
946 |
+
* add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
|
947 |
+
* function my_settings_structure( $settings ) {
|
948 |
+
* // your code here
|
949 |
+
* return $settings;
|
950 |
+
* }
|
951 |
+
* ?>
|
952 |
+
*/
|
953 |
+
$this->settings_structure = apply_filters(
|
954 |
+
'um_settings_structure',
|
955 |
+
array(
|
956 |
+
'' => array(
|
957 |
+
'title' => __( 'General', 'ultimate-member' ),
|
958 |
+
'sections' => array(
|
959 |
+
'' => array(
|
960 |
+
'title' => __( 'Pages', 'ultimate-member' ),
|
961 |
+
'fields' => $general_pages_fields,
|
962 |
+
),
|
963 |
+
'users' => array(
|
964 |
+
'title' => __( 'Users', 'ultimate-member' ),
|
965 |
+
'fields' => array(
|
966 |
+
array(
|
967 |
+
'id' => 'permalink_base',
|
968 |
+
'type' => 'select',
|
969 |
+
'size' => 'small',
|
970 |
+
'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
|
971 |
+
// translators: %s: Profile page URL
|
972 |
+
'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' ) ) ),
|
973 |
+
'options' => array(
|
974 |
+
'user_login' => __( 'Username', 'ultimate-member' ),
|
975 |
+
'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
|
976 |
+
'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
|
977 |
+
'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
|
978 |
+
'user_id' => __( 'User ID', 'ultimate-member' ),
|
979 |
+
),
|
980 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
981 |
+
),
|
982 |
+
array(
|
983 |
+
'id' => 'display_name',
|
984 |
+
'type' => 'select',
|
985 |
+
'size' => 'medium',
|
986 |
+
'label' => __( 'User Display Name', 'ultimate-member' ),
|
987 |
+
'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' ),
|
988 |
+
'options' => array(
|
989 |
+
'default' => __( 'Default WP Display Name', 'ultimate-member' ),
|
990 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
991 |
+
'username' => __( 'Username', 'ultimate-member' ),
|
992 |
+
'full_name' => __( 'First name & last name', 'ultimate-member' ),
|
993 |
+
'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
|
994 |
+
'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
|
995 |
+
'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
|
996 |
+
'first_name' => __( 'First name only', 'ultimate-member' ),
|
997 |
+
'field' => __( 'Custom field(s)', 'ultimate-member' ),
|
998 |
+
),
|
999 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
1000 |
+
),
|
1001 |
+
array(
|
1002 |
+
'id' => 'display_name_field',
|
1003 |
+
'type' => 'text',
|
1004 |
+
'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
|
1005 |
+
'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' ),
|
1006 |
+
'conditional' => array( 'display_name', '=', 'field' ),
|
1007 |
+
),
|
1008 |
+
array(
|
1009 |
+
'id' => 'author_redirect',
|
1010 |
+
'type' => 'checkbox',
|
1011 |
+
'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
|
1012 |
+
'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
|
1013 |
+
),
|
1014 |
+
array(
|
1015 |
+
'id' => 'members_page',
|
1016 |
+
'type' => 'checkbox',
|
1017 |
+
'label' => __( 'Enable Members Directory', 'ultimate-member' ),
|
1018 |
+
'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
|
1019 |
+
),
|
1020 |
+
array(
|
1021 |
+
'id' => 'use_gravatars',
|
1022 |
+
'type' => 'checkbox',
|
1023 |
+
'label' => __( 'Use Gravatars?', 'ultimate-member' ),
|
1024 |
+
'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' ),
|
1025 |
+
),
|
1026 |
+
array(
|
1027 |
+
'id' => 'use_um_gravatar_default_builtin_image',
|
1028 |
+
'type' => 'select',
|
1029 |
+
'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
|
1030 |
+
'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
|
1031 |
+
'options' => array(
|
1032 |
+
'default' => __( 'Default', 'ultimate-member' ),
|
1033 |
+
'404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
|
1034 |
+
'mm' => __( 'Mystery Man', 'ultimate-member' ),
|
1035 |
+
'identicon' => __( 'Identicon', 'ultimate-member' ),
|
1036 |
+
'monsterid' => __( 'Monsterid', 'ultimate-member' ),
|
1037 |
+
'wavatar' => __( 'Wavatar', 'ultimate-member' ),
|
1038 |
+
'retro' => __( 'Retro', 'ultimate-member' ),
|
1039 |
+
'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
|
1040 |
+
),
|
1041 |
+
'conditional' => array( 'use_gravatars', '=', 1 ),
|
1042 |
+
'size' => 'medium',
|
1043 |
+
),
|
1044 |
+
array(
|
1045 |
+
'id' => 'use_um_gravatar_default_image',
|
1046 |
+
'type' => 'checkbox',
|
1047 |
+
'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
|
1048 |
+
'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' ),
|
1049 |
+
'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
|
1050 |
+
),
|
1051 |
+
array(
|
1052 |
+
'id' => 'reset_require_strongpass',
|
1053 |
+
'type' => 'checkbox',
|
1054 |
+
'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
|
1055 |
+
'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
|
1056 |
+
),
|
1057 |
+
array(
|
1058 |
+
'id' => 'password_min_chars',
|
1059 |
+
'type' => 'number',
|
1060 |
+
'label' => __( 'Password minimum length', 'ultimate-member' ),
|
1061 |
+
'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ),
|
1062 |
+
'size' => 'small',
|
1063 |
+
),
|
1064 |
+
array(
|
1065 |
+
'id' => 'password_max_chars',
|
1066 |
+
'type' => 'number',
|
1067 |
+
'label' => __( 'Password maximum length', 'ultimate-member' ),
|
1068 |
+
'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ),
|
1069 |
+
'size' => 'small',
|
1070 |
+
),
|
1071 |
+
array(
|
1072 |
+
'id' => 'profile_noindex',
|
1073 |
+
'type' => 'select',
|
1074 |
+
'size' => 'small',
|
1075 |
+
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
1076 |
+
'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
|
1077 |
+
'options' => array(
|
1078 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1079 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1080 |
+
),
|
1081 |
+
),
|
1082 |
+
array(
|
1083 |
+
'id' => 'activation_link_expiry_time',
|
1084 |
+
'type' => 'number',
|
1085 |
+
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
1086 |
+
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
|
1087 |
+
'size' => 'small',
|
1088 |
+
),
|
1089 |
+
),
|
1090 |
+
),
|
1091 |
+
'account' => array(
|
1092 |
+
'title' => __( 'Account', 'ultimate-member' ),
|
1093 |
+
'fields' => array(
|
1094 |
+
array(
|
1095 |
+
'id' => 'account_tab_password',
|
1096 |
+
'type' => 'checkbox',
|
1097 |
+
'label' => __( 'Password Account Tab', 'ultimate-member' ),
|
1098 |
+
'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
|
1099 |
+
),
|
1100 |
+
array(
|
1101 |
+
'id' => 'account_tab_privacy',
|
1102 |
+
'type' => 'checkbox',
|
1103 |
+
'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
|
1104 |
+
'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
|
1105 |
+
),
|
1106 |
+
array(
|
1107 |
+
'id' => 'account_tab_notifications',
|
1108 |
+
'type' => 'checkbox',
|
1109 |
+
'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
|
1110 |
+
'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
|
1111 |
+
),
|
1112 |
+
array(
|
1113 |
+
'id' => 'account_tab_delete',
|
1114 |
+
'type' => 'checkbox',
|
1115 |
+
'label' => __( 'Delete Account Tab', 'ultimate-member' ),
|
1116 |
+
'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
|
1117 |
+
),
|
1118 |
+
array(
|
1119 |
+
'id' => 'delete_account_text',
|
1120 |
+
'type' => 'textarea', // bug with wp 4.4? should be editor
|
1121 |
+
'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
|
1122 |
+
'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' ),
|
1123 |
+
'args' => array(
|
1124 |
+
'textarea_rows' => 6,
|
1125 |
+
),
|
1126 |
+
),
|
1127 |
+
array(
|
1128 |
+
'id' => 'delete_account_no_pass_required_text',
|
1129 |
+
'type' => 'textarea',
|
1130 |
+
'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
|
1131 |
+
'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' ),
|
1132 |
+
'args' => array(
|
1133 |
+
'textarea_rows' => 6,
|
1134 |
+
),
|
1135 |
+
),
|
1136 |
+
array(
|
1137 |
+
'id' => 'account_name',
|
1138 |
+
'type' => 'checkbox',
|
1139 |
+
'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
|
1140 |
+
'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
|
1141 |
+
),
|
1142 |
+
array(
|
1143 |
+
'id' => 'account_name_disable',
|
1144 |
+
'type' => 'checkbox',
|
1145 |
+
'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
|
1146 |
+
'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
|
1147 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1148 |
+
),
|
1149 |
+
array(
|
1150 |
+
'id' => 'account_name_require',
|
1151 |
+
'type' => 'checkbox',
|
1152 |
+
'label' => __( 'Require First & Last Name', 'ultimate-member' ),
|
1153 |
+
'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
|
1154 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1155 |
+
),
|
1156 |
+
array(
|
1157 |
+
'id' => 'account_email',
|
1158 |
+
'type' => 'checkbox',
|
1159 |
+
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
|
1160 |
+
'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
|
1161 |
+
),
|
1162 |
+
array(
|
1163 |
+
'id' => 'account_general_password',
|
1164 |
+
'type' => 'checkbox',
|
1165 |
+
'label' => __( 'Password is required?', 'ultimate-member' ),
|
1166 |
+
'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
|
1167 |
+
),
|
1168 |
+
array(
|
1169 |
+
'id' => 'account_require_strongpass',
|
1170 |
+
'type' => 'checkbox',
|
1171 |
+
'label' => __( 'Require a strong password?', 'ultimate-member' ),
|
1172 |
+
'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
|
1173 |
+
),
|
1174 |
+
array(
|
1175 |
+
'id' => 'account_hide_in_directory',
|
1176 |
+
'type' => 'checkbox',
|
1177 |
+
'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
|
1178 |
+
'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
|
1179 |
+
'conditional' => array( 'account_tab_privacy', '=', '1' ),
|
1180 |
+
),
|
1181 |
+
array(
|
1182 |
+
'id' => 'account_hide_in_directory_default',
|
1183 |
+
'type' => 'select',
|
1184 |
+
'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
|
1185 |
+
'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
|
1186 |
+
'options' => array(
|
1187 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1188 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1189 |
+
),
|
1190 |
+
'size' => 'small',
|
1191 |
+
'conditional' => array( 'account_hide_in_directory', '=', '1' ),
|
1192 |
+
),
|
1193 |
+
),
|
1194 |
+
),
|
1195 |
+
'uploads' => array(
|
1196 |
+
'title' => __( 'Uploads', 'ultimate-member' ),
|
1197 |
+
'fields' => array(
|
1198 |
+
array(
|
1199 |
+
'id' => 'profile_photo_max_size',
|
1200 |
+
'type' => 'text',
|
1201 |
+
'size' => 'small',
|
1202 |
+
'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1203 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
|
1204 |
+
),
|
1205 |
+
array(
|
1206 |
+
'id' => 'cover_photo_max_size',
|
1207 |
+
'type' => 'text',
|
1208 |
+
'size' => 'small',
|
1209 |
+
'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1210 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
|
1211 |
+
),
|
1212 |
+
array(
|
1213 |
+
'id' => 'photo_thumb_sizes',
|
1214 |
+
'type' => 'multi_text',
|
1215 |
+
'size' => 'small',
|
1216 |
+
'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1217 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
|
1218 |
+
'validate' => 'numeric',
|
1219 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1220 |
+
'show_default_number' => 1,
|
1221 |
+
),
|
1222 |
+
array(
|
1223 |
+
'id' => 'cover_thumb_sizes',
|
1224 |
+
'type' => 'multi_text',
|
1225 |
+
'size' => 'small',
|
1226 |
+
'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1227 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
|
1228 |
+
'validate' => 'numeric',
|
1229 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1230 |
+
'show_default_number' => 1,
|
1231 |
+
),
|
1232 |
+
array(
|
1233 |
+
'id' => 'image_orientation_by_exif',
|
1234 |
+
'type' => 'checkbox',
|
1235 |
+
'label' => __( 'Change image orientation', 'ultimate-member' ),
|
1236 |
+
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
|
1237 |
+
),
|
1238 |
+
array(
|
1239 |
+
'id' => 'image_compression',
|
1240 |
+
'type' => 'text',
|
1241 |
+
'size' => 'small',
|
1242 |
+
'label' => __( 'Image Quality', 'ultimate-member' ),
|
1243 |
+
'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' ),
|
1244 |
+
),
|
1245 |
+
|
1246 |
+
array(
|
1247 |
+
'id' => 'image_max_width',
|
1248 |
+
'type' => 'text',
|
1249 |
+
'size' => 'small',
|
1250 |
+
'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
|
1251 |
+
'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
|
1252 |
+
),
|
1253 |
+
|
1254 |
+
array(
|
1255 |
+
'id' => 'cover_min_width',
|
1256 |
+
'type' => 'text',
|
1257 |
+
'size' => 'small',
|
1258 |
+
'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
|
1259 |
+
'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
|
1260 |
+
),
|
1261 |
+
),
|
1262 |
+
),
|
1263 |
+
),
|
1264 |
+
),
|
1265 |
+
'access' => array(
|
1266 |
+
'title' => __( 'Access', 'ultimate-member' ),
|
1267 |
+
'sections' => array(
|
1268 |
+
'' => array(
|
1269 |
+
'title' => __( 'Restriction Content', 'ultimate-member' ),
|
1270 |
+
'fields' => $access_fields,
|
1271 |
+
),
|
1272 |
+
'other' => array(
|
1273 |
+
'title' => __( 'Other', 'ultimate-member' ),
|
1274 |
+
'fields' => array(
|
1275 |
+
array(
|
1276 |
+
'id' => 'enable_reset_password_limit',
|
1277 |
+
'type' => 'checkbox',
|
1278 |
+
'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
|
1279 |
+
),
|
1280 |
+
array(
|
1281 |
+
'id' => 'reset_password_limit_number',
|
1282 |
+
'type' => 'text',
|
1283 |
+
'label' => __( 'Reset Password Limit', 'ultimate-member' ),
|
1284 |
+
'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
|
1285 |
+
'validate' => 'numeric',
|
1286 |
+
'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
|
1287 |
+
'size' => 'small',
|
1288 |
+
),
|
1289 |
+
array(
|
1290 |
+
'id' => 'blocked_emails',
|
1291 |
+
'type' => 'textarea',
|
1292 |
+
'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
|
1293 |
+
'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' ),
|
1294 |
+
),
|
1295 |
+
array(
|
1296 |
+
'id' => 'blocked_words',
|
1297 |
+
'type' => 'textarea',
|
1298 |
+
'label' => __( 'Blacklist Words', 'ultimate-member' ),
|
1299 |
+
'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
|
1300 |
+
),
|
1301 |
+
),
|
1302 |
+
),
|
1303 |
+
),
|
1304 |
+
),
|
1305 |
+
'email' => array(
|
1306 |
+
'title' => __( 'Email', 'ultimate-member' ),
|
1307 |
+
'fields' => array(
|
1308 |
+
array(
|
1309 |
+
'id' => 'admin_email',
|
1310 |
+
'type' => 'text',
|
1311 |
+
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
|
1312 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1313 |
+
),
|
1314 |
+
array(
|
1315 |
+
'id' => 'mail_from',
|
1316 |
+
'type' => 'text',
|
1317 |
+
'label' => __( 'Mail appears from', 'ultimate-member' ),
|
1318 |
+
'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
|
1319 |
+
),
|
1320 |
+
array(
|
1321 |
+
'id' => 'mail_from_addr',
|
1322 |
+
'type' => 'text',
|
1323 |
+
'label' => __( 'Mail appears from address', 'ultimate-member' ),
|
1324 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1325 |
+
),
|
1326 |
+
array(
|
1327 |
+
'id' => 'email_html',
|
1328 |
+
'type' => 'checkbox',
|
1329 |
+
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
|
1330 |
+
'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' ),
|
1331 |
+
),
|
1332 |
+
),
|
1333 |
+
),
|
1334 |
+
'appearance' => array(
|
1335 |
+
'title' => __( 'Appearance', 'ultimate-member' ),
|
1336 |
+
'sections' => array(
|
1337 |
+
'' => array(
|
1338 |
+
'title' => __( 'Profile', 'ultimate-member' ),
|
1339 |
+
'fields' => array(
|
1340 |
+
array(
|
1341 |
+
'id' => 'profile_template',
|
1342 |
+
'type' => 'select',
|
1343 |
+
'label' => __( 'Profile Default Template', 'ultimate-member' ),
|
1344 |
+
'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
|
1345 |
+
'default' => um_get_metadefault( 'profile_template' ),
|
1346 |
+
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
1347 |
+
'size' => 'small',
|
1348 |
+
),
|
1349 |
+
array(
|
1350 |
+
'id' => 'profile_max_width',
|
1351 |
+
'type' => 'text',
|
1352 |
+
'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
|
1353 |
+
'default' => um_get_metadefault( 'profile_max_width' ),
|
1354 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1355 |
+
'size' => 'small',
|
1356 |
+
),
|
1357 |
+
array(
|
1358 |
+
'id' => 'profile_area_max_width',
|
1359 |
+
'type' => 'text',
|
1360 |
+
'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
|
1361 |
+
'default' => um_get_metadefault( 'profile_area_max_width' ),
|
1362 |
+
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
1363 |
+
'size' => 'small',
|
1364 |
+
),
|
1365 |
+
array(
|
1366 |
+
'id' => 'profile_icons',
|
1367 |
+
'type' => 'select',
|
1368 |
+
'label' => __( 'Profile Field Icons', 'ultimate-member' ),
|
1369 |
+
'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
|
1370 |
+
'default' => um_get_metadefault( 'profile_icons' ),
|
1371 |
+
'options' => array(
|
1372 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1373 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1374 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1375 |
+
),
|
1376 |
+
'size' => 'small',
|
1377 |
+
),
|
1378 |
+
array(
|
1379 |
+
'id' => 'profile_primary_btn_word',
|
1380 |
+
'type' => 'text',
|
1381 |
+
'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
|
1382 |
+
'default' => um_get_metadefault( 'profile_primary_btn_word' ),
|
1383 |
+
'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
|
1384 |
+
'size' => 'medium',
|
1385 |
+
),
|
1386 |
+
array(
|
1387 |
+
'id' => 'profile_secondary_btn',
|
1388 |
+
'type' => 'checkbox',
|
1389 |
+
'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
|
1390 |
+
'default' => um_get_metadefault( 'profile_secondary_btn' ),
|
1391 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1392 |
+
),
|
1393 |
+
array(
|
1394 |
+
'id' => 'profile_secondary_btn_word',
|
1395 |
+
'type' => 'text',
|
1396 |
+
'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
|
1397 |
+
'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
|
1398 |
+
'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
|
1399 |
+
'conditional' => array( 'profile_secondary_btn', '=', 1 ),
|
1400 |
+
'size' => 'medium',
|
1401 |
+
),
|
1402 |
+
array(
|
1403 |
+
'id' => 'default_avatar',
|
1404 |
+
'type' => 'media',
|
1405 |
+
'label' => __( 'Default Profile Photo', 'ultimate-member' ),
|
1406 |
+
'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
|
1407 |
+
'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
|
1408 |
+
'default' => array(
|
1409 |
+
'url' => um_url . 'assets/img/default_avatar.jpg',
|
1410 |
+
),
|
1411 |
+
),
|
1412 |
+
array(
|
1413 |
+
'id' => 'default_cover',
|
1414 |
+
'type' => 'media',
|
1415 |
+
'url' => true,
|
1416 |
+
'preview' => false,
|
1417 |
+
'label' => __( 'Default Cover Photo', 'ultimate-member' ),
|
1418 |
+
'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' ),
|
1419 |
+
'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
|
1420 |
+
),
|
1421 |
+
array(
|
1422 |
+
'id' => 'disable_profile_photo_upload',
|
1423 |
+
'type' => 'checkbox',
|
1424 |
+
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
1425 |
+
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
1426 |
+
'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
|
1427 |
+
),
|
1428 |
+
array(
|
1429 |
+
'id' => 'profile_photosize',
|
1430 |
+
'type' => 'select',
|
1431 |
+
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
1432 |
+
'default' => um_get_metadefault( 'profile_photosize' ),
|
1433 |
+
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
1434 |
+
'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1435 |
+
'size' => 'small',
|
1436 |
+
),
|
1437 |
+
array(
|
1438 |
+
'id' => 'profile_cover_enabled',
|
1439 |
+
'type' => 'checkbox',
|
1440 |
+
'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
|
1441 |
+
'default' => um_get_metadefault( 'profile_cover_enabled' ),
|
1442 |
+
'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
|
1443 |
+
),
|
1444 |
+
array(
|
1445 |
+
'id' => 'profile_coversize',
|
1446 |
+
'type' => 'select',
|
1447 |
+
'label' => __( 'Profile Cover Size', 'ultimate-member' ),
|
1448 |
+
'default' => um_get_metadefault( 'profile_coversize' ),
|
1449 |
+
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
1450 |
+
'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1451 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1452 |
+
'size' => 'small',
|
1453 |
+
),
|
1454 |
+
array(
|
1455 |
+
'id' => 'profile_cover_ratio',
|
1456 |
+
'type' => 'select',
|
1457 |
+
'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
|
1458 |
+
'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
|
1459 |
+
'default' => um_get_metadefault( 'profile_cover_ratio' ),
|
1460 |
+
'options' => array(
|
1461 |
+
'1.6:1' => '1.6:1',
|
1462 |
+
'2.7:1' => '2.7:1',
|
1463 |
+
'2.2:1' => '2.2:1',
|
1464 |
+
'3.2:1' => '3.2:1',
|
1465 |
+
),
|
1466 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1467 |
+
'size' => 'small',
|
1468 |
+
),
|
1469 |
+
array(
|
1470 |
+
'id' => 'profile_show_metaicon',
|
1471 |
+
'type' => 'checkbox',
|
1472 |
+
'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
|
1473 |
+
'default' => 0,
|
1474 |
+
'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
|
1475 |
+
),
|
1476 |
+
array(
|
1477 |
+
'id' => 'profile_show_name',
|
1478 |
+
'type' => 'checkbox',
|
1479 |
+
'label' => __( 'Show display name in profile header', 'ultimate-member' ),
|
1480 |
+
'default' => um_get_metadefault( 'profile_show_name' ),
|
1481 |
+
'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
|
1482 |
+
),
|
1483 |
+
array(
|
1484 |
+
'id' => 'profile_show_social_links',
|
1485 |
+
'type' => 'checkbox',
|
1486 |
+
'label' => __( 'Show social links in profile header', 'ultimate-member' ),
|
1487 |
+
'default' => um_get_metadefault( 'profile_show_social_links' ),
|
1488 |
+
'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
|
1489 |
+
),
|
1490 |
+
array(
|
1491 |
+
'id' => 'profile_show_bio',
|
1492 |
+
'type' => 'checkbox',
|
1493 |
+
'label' => __( 'Show user description in header', 'ultimate-member' ),
|
1494 |
+
'default' => um_get_metadefault( 'profile_show_bio' ),
|
1495 |
+
'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
|
1496 |
+
),
|
1497 |
+
array(
|
1498 |
+
'id' => 'profile_show_html_bio',
|
1499 |
+
'type' => 'checkbox',
|
1500 |
+
'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
|
1501 |
+
'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
|
1502 |
+
),
|
1503 |
+
array(
|
1504 |
+
'id' => 'profile_bio_maxchars',
|
1505 |
+
'type' => 'text',
|
1506 |
+
'label' => __( 'User description maximum chars', 'ultimate-member' ),
|
1507 |
+
'default' => um_get_metadefault( 'profile_bio_maxchars' ),
|
1508 |
+
'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
|
1509 |
+
'conditional' => array( 'profile_show_bio', '=', 1 ),
|
1510 |
+
'size' => 'small',
|
1511 |
+
),
|
1512 |
+
array(
|
1513 |
+
'id' => 'profile_header_menu',
|
1514 |
+
'type' => 'select',
|
1515 |
+
'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
|
1516 |
+
'default' => um_get_metadefault( 'profile_header_menu' ),
|
1517 |
+
'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
|
1518 |
+
'options' => array(
|
1519 |
+
'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
|
1520 |
+
'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
|
1521 |
+
),
|
1522 |
+
'size' => 'small',
|
1523 |
+
),
|
1524 |
+
array(
|
1525 |
+
'id' => 'profile_empty_text',
|
1526 |
+
'type' => 'checkbox',
|
1527 |
+
'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
|
1528 |
+
'default' => um_get_metadefault( 'profile_empty_text' ),
|
1529 |
+
'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
|
1530 |
+
),
|
1531 |
+
array(
|
1532 |
+
'id' => 'profile_empty_text_emo',
|
1533 |
+
'type' => 'checkbox',
|
1534 |
+
'label' => __( 'Show the emoticon', 'ultimate-member' ),
|
1535 |
+
'default' => um_get_metadefault( 'profile_empty_text_emo' ),
|
1536 |
+
'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
|
1537 |
+
'conditional' => array( 'profile_empty_text', '=', 1 ),
|
1538 |
+
),
|
1539 |
+
),
|
1540 |
+
),
|
1541 |
+
'profile_menu' => array(
|
1542 |
+
'title' => __( 'Profile Menu', 'ultimate-member' ),
|
1543 |
+
'fields' => $appearances_profile_menu_fields,
|
1544 |
+
),
|
1545 |
+
'registration_form' => array(
|
1546 |
+
'title' => __( 'Registration Form', 'ultimate-member' ),
|
1547 |
+
'fields' => array(
|
1548 |
+
array(
|
1549 |
+
'id' => 'register_template',
|
1550 |
+
'type' => 'select',
|
1551 |
+
'label' => __( 'Registration Default Template', 'ultimate-member' ),
|
1552 |
+
'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
|
1553 |
+
'default' => um_get_metadefault( 'register_template' ),
|
1554 |
+
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
1555 |
+
'size' => 'small',
|
1556 |
+
),
|
1557 |
+
array(
|
1558 |
+
'id' => 'register_max_width',
|
1559 |
+
'type' => 'text',
|
1560 |
+
'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
|
1561 |
+
'default' => um_get_metadefault( 'register_max_width' ),
|
1562 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1563 |
+
'size' => 'small',
|
1564 |
+
),
|
1565 |
+
array(
|
1566 |
+
'id' => 'register_align',
|
1567 |
+
'type' => 'select',
|
1568 |
+
'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
|
1569 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1570 |
+
'default' => um_get_metadefault( 'register_align' ),
|
1571 |
+
'options' => array(
|
1572 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1573 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1574 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1575 |
+
),
|
1576 |
+
'size' => 'small',
|
1577 |
+
),
|
1578 |
+
array(
|
1579 |
+
'id' => 'register_icons',
|
1580 |
+
'type' => 'select',
|
1581 |
+
'label' => __( 'Registration Field Icons', 'ultimate-member' ),
|
1582 |
+
'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
|
1583 |
+
'default' => um_get_metadefault( 'register_icons' ),
|
1584 |
+
'options' => array(
|
1585 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1586 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1587 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1588 |
+
),
|
1589 |
+
'size' => 'small',
|
1590 |
+
),
|
1591 |
+
array(
|
1592 |
+
'id' => 'register_primary_btn_word',
|
1593 |
+
'type' => 'text',
|
1594 |
+
'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
|
1595 |
+
'default' => um_get_metadefault( 'register_primary_btn_word' ),
|
1596 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1597 |
+
'size' => 'medium',
|
1598 |
+
),
|
1599 |
+
array(
|
1600 |
+
'id' => 'register_secondary_btn',
|
1601 |
+
'type' => 'checkbox',
|
1602 |
+
'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
|
1603 |
+
'default' => 1,
|
1604 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1605 |
+
),
|
1606 |
+
array(
|
1607 |
+
'id' => 'register_secondary_btn_word',
|
1608 |
+
'type' => 'text',
|
1609 |
+
'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
|
1610 |
+
'default' => um_get_metadefault( 'register_secondary_btn_word' ),
|
1611 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1612 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1613 |
+
'size' => 'medium',
|
1614 |
+
),
|
1615 |
+
array(
|
1616 |
+
'id' => 'register_secondary_btn_url',
|
1617 |
+
'type' => 'text',
|
1618 |
+
'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
|
1619 |
+
'default' => um_get_metadefault( 'register_secondary_btn_url' ),
|
1620 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1621 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1622 |
+
'size' => 'medium',
|
1623 |
+
),
|
1624 |
+
array(
|
1625 |
+
'id' => 'register_role',
|
1626 |
+
'type' => 'select',
|
1627 |
+
'label' => __( 'Registration Default Role', 'ultimate-member' ),
|
1628 |
+
'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
|
1629 |
+
'default' => um_get_metadefault( 'register_role' ),
|
1630 |
+
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
1631 |
+
'size' => 'small',
|
1632 |
+
),
|
1633 |
+
),
|
1634 |
+
),
|
1635 |
+
'login_form' => array(
|
1636 |
+
'title' => __( 'Login Form', 'ultimate-member' ),
|
1637 |
+
'fields' => array(
|
1638 |
+
array(
|
1639 |
+
'id' => 'login_template',
|
1640 |
+
'type' => 'select',
|
1641 |
+
'label' => __( 'Login Default Template', 'ultimate-member' ),
|
1642 |
+
'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
|
1643 |
+
'default' => um_get_metadefault( 'login_template' ),
|
1644 |
+
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
1645 |
+
'size' => 'small',
|
1646 |
+
),
|
1647 |
+
array(
|
1648 |
+
'id' => 'login_max_width',
|
1649 |
+
'type' => 'text',
|
1650 |
+
'label' => __( 'Login Maximum Width', 'ultimate-member' ),
|
1651 |
+
'default' => um_get_metadefault( 'login_max_width' ),
|
1652 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1653 |
+
'size' => 'small',
|
1654 |
+
),
|
1655 |
+
array(
|
1656 |
+
'id' => 'login_align',
|
1657 |
+
'type' => 'select',
|
1658 |
+
'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
|
1659 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1660 |
+
'default' => um_get_metadefault( 'login_align' ),
|
1661 |
+
'options' => array(
|
1662 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1663 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1664 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1665 |
+
),
|
1666 |
+
'size' => 'small',
|
1667 |
+
),
|
1668 |
+
array(
|
1669 |
+
'id' => 'login_icons',
|
1670 |
+
'type' => 'select',
|
1671 |
+
'label' => __( 'Login Field Icons', 'ultimate-member' ),
|
1672 |
+
'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
|
1673 |
+
'default' => um_get_metadefault( 'login_icons' ),
|
1674 |
+
'options' => array(
|
1675 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1676 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1677 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1678 |
+
),
|
1679 |
+
'size' => 'small',
|
1680 |
+
),
|
1681 |
+
array(
|
1682 |
+
'id' => 'login_primary_btn_word',
|
1683 |
+
'type' => 'text',
|
1684 |
+
'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
|
1685 |
+
'default' => um_get_metadefault( 'login_primary_btn_word' ),
|
1686 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1687 |
+
'size' => 'medium',
|
1688 |
+
),
|
1689 |
+
array(
|
1690 |
+
'id' => 'login_secondary_btn',
|
1691 |
+
'type' => 'checkbox',
|
1692 |
+
'label' => __( 'Login Secondary Button', 'ultimate-member' ),
|
1693 |
+
'default' => 1,
|
1694 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1695 |
+
),
|
1696 |
+
array(
|
1697 |
+
'id' => 'login_secondary_btn_word',
|
1698 |
+
'type' => 'text',
|
1699 |
+
'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
|
1700 |
+
'default' => um_get_metadefault( 'login_secondary_btn_word' ),
|
1701 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1702 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1703 |
+
'size' => 'medium',
|
1704 |
+
),
|
1705 |
+
array(
|
1706 |
+
'id' => 'login_secondary_btn_url',
|
1707 |
+
'type' => 'text',
|
1708 |
+
'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
|
1709 |
+
'default' => um_get_metadefault( 'login_secondary_btn_url' ),
|
1710 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1711 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1712 |
+
'size' => 'medium',
|
1713 |
+
),
|
1714 |
+
array(
|
1715 |
+
'id' => 'login_forgot_pass_link',
|
1716 |
+
'type' => 'checkbox',
|
1717 |
+
'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
|
1718 |
+
'default' => 1,
|
1719 |
+
'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
|
1720 |
+
),
|
1721 |
+
array(
|
1722 |
+
'id' => 'login_show_rememberme',
|
1723 |
+
'type' => 'checkbox',
|
1724 |
+
'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
|
1725 |
+
'default' => 1,
|
1726 |
+
'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' ),
|
1727 |
+
),
|
1728 |
+
),
|
1729 |
+
),
|
1730 |
+
),
|
1731 |
+
),
|
1732 |
+
'extensions' => array(
|
1733 |
+
'title' => __( 'Extensions', 'ultimate-member' ),
|
1734 |
+
),
|
1735 |
+
'licenses' => array(
|
1736 |
+
'title' => __( 'Licenses', 'ultimate-member' ),
|
1737 |
+
),
|
1738 |
+
'misc' => array(
|
1739 |
+
'title' => __( 'Misc', 'ultimate-member' ),
|
1740 |
+
'fields' => array(
|
1741 |
+
array(
|
1742 |
+
'id' => 'form_asterisk',
|
1743 |
+
'type' => 'checkbox',
|
1744 |
+
'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
|
1745 |
+
),
|
1746 |
+
array(
|
1747 |
+
'id' => 'profile_title',
|
1748 |
+
'type' => 'text',
|
1749 |
+
'label' => __( 'User Profile Title', 'ultimate-member' ),
|
1750 |
+
'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
|
1751 |
+
'size' => 'medium',
|
1752 |
+
),
|
1753 |
+
array(
|
1754 |
+
'id' => 'profile_desc',
|
1755 |
+
'type' => 'textarea',
|
1756 |
+
'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
|
1757 |
+
'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
|
1758 |
+
'args' => array(
|
1759 |
+
'textarea_rows' => 6,
|
1760 |
+
),
|
1761 |
+
),
|
1762 |
+
array(
|
1763 |
+
'id' => 'um_profile_object_cache_stop',
|
1764 |
+
'type' => 'checkbox',
|
1765 |
+
'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
|
1766 |
+
'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
|
1767 |
+
),
|
1768 |
+
array(
|
1769 |
+
'id' => 'enable_blocks',
|
1770 |
+
'type' => 'checkbox',
|
1771 |
+
'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
|
1772 |
+
'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' ),
|
1773 |
+
),
|
1774 |
+
array(
|
1775 |
+
'id' => 'rest_api_version',
|
1776 |
+
'type' => 'select',
|
1777 |
+
'label' => __( 'REST API version', 'ultimate-member' ),
|
1778 |
+
'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
|
1779 |
+
'options' => array(
|
1780 |
+
'1.0' => __( '1.0 version', 'ultimate-member' ),
|
1781 |
+
'2.0' => __( '2.0 version', 'ultimate-member' ),
|
1782 |
+
),
|
1783 |
+
),
|
1784 |
+
// backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
|
1785 |
+
// otherwise we filtering only results and restricted posts/terms can be visible
|
1786 |
+
array(
|
1787 |
+
'id' => 'disable_restriction_pre_queries',
|
1788 |
+
'type' => 'checkbox',
|
1789 |
+
'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
|
1790 |
+
'tooltip' => __( 'Please enable this option only in the cases when you have big or unnecessary queries on your site with active restriction logic. If you want to exclude posts only from the results queries instead of pre_get_posts and fully-hidden post logic also please enable this option. It activates the restriction content logic until 2.2.x version without latest security enhancements', 'ultimate-member' ),
|
1791 |
+
),
|
1792 |
+
$same_page_update,
|
1793 |
+
array(
|
1794 |
+
'id' => 'uninstall_on_delete',
|
1795 |
+
'type' => 'checkbox',
|
1796 |
+
'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
|
1797 |
+
'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' ),
|
1798 |
+
),
|
1799 |
+
),
|
1800 |
+
),
|
1801 |
+
'install_info' => array(
|
1802 |
+
'title' => __( 'Install Info', 'ultimate-member' ),
|
1803 |
+
'fields' => array(
|
1804 |
+
array(
|
1805 |
+
'type' => 'install_info',
|
1806 |
+
),
|
1807 |
+
),
|
1808 |
+
),
|
1809 |
+
)
|
1810 |
+
);
|
1811 |
+
|
1812 |
+
}
|
1813 |
+
|
1814 |
+
|
1815 |
+
/**
|
1816 |
+
* @param array $settings
|
1817 |
+
*
|
1818 |
+
* @return array
|
1819 |
+
*/
|
1820 |
+
public function sorting_licenses_options( $settings ) {
|
1821 |
+
//sorting licenses
|
1822 |
+
if ( empty( $settings['licenses']['fields'] ) ) {
|
1823 |
+
return $settings;
|
1824 |
+
}
|
1825 |
+
|
1826 |
+
$licenses = $settings['licenses']['fields'];
|
1827 |
+
@uasort( $licenses, function( $a, $b ) {
|
1828 |
+
return strnatcasecmp( $a['label'], $b['label'] );
|
1829 |
+
} );
|
1830 |
+
$settings['licenses']['fields'] = $licenses;
|
1831 |
+
|
1832 |
+
//sorting extensions
|
1833 |
+
if ( empty( $settings['extensions']['sections'] ) ) {
|
1834 |
+
return $settings;
|
1835 |
+
}
|
1836 |
+
|
1837 |
+
$extensions = $settings['extensions']['sections'];
|
1838 |
+
@uasort( $extensions, function( $a, $b ) {
|
1839 |
+
return strnatcasecmp( $a['title'], $b['title'] );
|
1840 |
+
} );
|
1841 |
+
|
1842 |
+
$keys = array_keys( $extensions );
|
1843 |
+
if ( $keys[0] !== '' ) {
|
1844 |
+
$new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
|
1845 |
+
$temp = $extensions[''];
|
1846 |
+
$extensions[ $new_key ] = $temp;
|
1847 |
+
$extensions[''] = $extensions[ $keys[0] ];
|
1848 |
+
unset( $extensions[ $keys[0] ] );
|
1849 |
+
@uasort( $extensions, function( $a, $b ) {
|
1850 |
+
return strnatcasecmp( $a['title'], $b['title'] );
|
1851 |
+
} );
|
1852 |
+
}
|
1853 |
+
|
1854 |
+
$settings['extensions']['sections'] = $extensions;
|
1855 |
+
|
1856 |
+
return $settings;
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
|
1860 |
+
/**
|
1861 |
+
* @param $tab
|
1862 |
+
* @param $section
|
1863 |
+
*
|
1864 |
+
* @return array
|
1865 |
+
*/
|
1866 |
+
function get_section_fields( $tab, $section ) {
|
1867 |
+
|
1868 |
+
if ( empty( $this->settings_structure[ $tab ] ) ) {
|
1869 |
+
return array();
|
1870 |
+
}
|
1871 |
+
|
1872 |
+
if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
1873 |
+
return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
1874 |
+
} elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
|
1875 |
+
return $this->settings_structure[ $tab ]['fields'];
|
1876 |
+
}
|
1877 |
+
|
1878 |
+
return array();
|
1879 |
+
}
|
1880 |
+
|
1881 |
+
|
1882 |
+
/**
|
1883 |
+
* Setup admin menu
|
1884 |
+
*/
|
1885 |
+
function primary_admin_menu() {
|
1886 |
+
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
|
1887 |
+
}
|
1888 |
+
|
1889 |
+
|
1890 |
+
/**
|
1891 |
+
* Settings page callback
|
1892 |
+
*/
|
1893 |
+
function settings_page() {
|
1894 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
1895 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
1896 |
+
|
1897 |
+
$settings_struct = $this->settings_structure[ $current_tab ];
|
1898 |
+
|
1899 |
+
//remove not option hidden fields
|
1900 |
+
if ( ! empty( $settings_struct['fields'] ) ) {
|
1901 |
+
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
|
1902 |
+
|
1903 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
1904 |
+
unset( $settings_struct['fields'][ $field_key ] );
|
1905 |
+
}
|
1906 |
+
|
1907 |
+
}
|
1908 |
+
}
|
1909 |
+
|
1910 |
+
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
|
1911 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
if ( ! empty( $settings_struct['sections'] ) ) {
|
1915 |
+
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
|
1916 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
|
1917 |
+
}
|
1918 |
+
}
|
1919 |
+
|
1920 |
+
echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
|
1921 |
+
|
1922 |
+
echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
|
1923 |
+
|
1924 |
+
/**
|
1925 |
+
* UM hook
|
1926 |
+
*
|
1927 |
+
* @type action
|
1928 |
+
* @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
|
1929 |
+
* @description Show some content before settings page content
|
1930 |
+
* @change_log
|
1931 |
+
* ["Since: 2.0"]
|
1932 |
+
* @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
|
1933 |
+
* @example
|
1934 |
+
* <?php
|
1935 |
+
* add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
|
1936 |
+
* function my_settings_page_before() {
|
1937 |
+
* // your code here
|
1938 |
+
* }
|
1939 |
+
* ?>
|
1940 |
+
*/
|
1941 |
+
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
1942 |
+
|
1943 |
+
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 ) ) ) {
|
1944 |
+
|
1945 |
+
/**
|
1946 |
+
* UM hook
|
1947 |
+
*
|
1948 |
+
* @type action
|
1949 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1950 |
+
* @description Show some content before section content at settings page
|
1951 |
+
* @change_log
|
1952 |
+
* ["Since: 2.0"]
|
1953 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1954 |
+
* @example
|
1955 |
+
* <?php
|
1956 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1957 |
+
* function my_settings_page_before_section() {
|
1958 |
+
* // your code here
|
1959 |
+
* }
|
1960 |
+
* ?>
|
1961 |
+
*/
|
1962 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
1963 |
+
|
1964 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
1965 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
1966 |
+
|
1967 |
+
/**
|
1968 |
+
* UM hook
|
1969 |
+
*
|
1970 |
+
* @type filter
|
1971 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
1972 |
+
*
|
1973 |
+
* @description Render settings section
|
1974 |
+
* @input_vars
|
1975 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
1976 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
1977 |
+
* @change_log
|
1978 |
+
* ["Since: 2.0"]
|
1979 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
1980 |
+
* @example
|
1981 |
+
* <?php
|
1982 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
1983 |
+
* function my_settings_section( $content ) {
|
1984 |
+
* // your code here
|
1985 |
+
* return $content;
|
1986 |
+
* }
|
1987 |
+
* ?>
|
1988 |
+
*/
|
1989 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
1990 |
+
$settings_section,
|
1991 |
+
$section_fields
|
1992 |
+
);
|
1993 |
+
|
1994 |
+
} else { ?>
|
1995 |
+
|
1996 |
+
<form method="post" action="" name="um-settings-form" id="um-settings-form">
|
1997 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
1998 |
+
|
1999 |
+
<?php
|
2000 |
+
/**
|
2001 |
+
* UM hook
|
2002 |
+
*
|
2003 |
+
* @type action
|
2004 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
2005 |
+
* @description Show some content before section content at settings page
|
2006 |
+
* @change_log
|
2007 |
+
* ["Since: 2.0"]
|
2008 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
2009 |
+
* @example
|
2010 |
+
* <?php
|
2011 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
2012 |
+
* function my_settings_page_before_section() {
|
2013 |
+
* // your code here
|
2014 |
+
* }
|
2015 |
+
* ?>
|
2016 |
+
*/
|
2017 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
2018 |
+
|
2019 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
2020 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
2021 |
+
|
2022 |
+
/**
|
2023 |
+
* UM hook
|
2024 |
+
*
|
2025 |
+
* @type filter
|
2026 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
2027 |
+
* @description Render settings section
|
2028 |
+
* @input_vars
|
2029 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
2030 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
2031 |
+
* @change_log
|
2032 |
+
* ["Since: 2.0"]
|
2033 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
2034 |
+
* @example
|
2035 |
+
* <?php
|
2036 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
2037 |
+
* function my_settings_section( $content ) {
|
2038 |
+
* // your code here
|
2039 |
+
* return $content;
|
2040 |
+
* }
|
2041 |
+
* ?>
|
2042 |
+
*/
|
2043 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
2044 |
+
$settings_section,
|
2045 |
+
$section_fields
|
2046 |
+
); ?>
|
2047 |
+
|
2048 |
+
|
2049 |
+
<p class="submit">
|
2050 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
|
2051 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2052 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2053 |
+
</p>
|
2054 |
+
</form>
|
2055 |
+
|
2056 |
+
<?php }
|
2057 |
+
}
|
2058 |
+
|
2059 |
+
|
2060 |
+
/**
|
2061 |
+
* Generate pages tabs
|
2062 |
+
*
|
2063 |
+
* @param string $page
|
2064 |
+
* @return string
|
2065 |
+
*/
|
2066 |
+
function generate_tabs_menu( $page = 'settings' ) {
|
2067 |
+
|
2068 |
+
$tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
|
2069 |
+
|
2070 |
+
switch( $page ) {
|
2071 |
+
case 'settings':
|
2072 |
+
$menu_tabs = array();
|
2073 |
+
foreach ( $this->settings_structure as $slug => $tab ) {
|
2074 |
+
if ( ! empty( $tab['fields'] ) ) {
|
2075 |
+
foreach ( $tab['fields'] as $field_key => $field_options ) {
|
2076 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
2077 |
+
unset( $tab['fields'][ $field_key ] );
|
2078 |
+
}
|
2079 |
+
}
|
2080 |
+
}
|
2081 |
+
|
2082 |
+
if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
|
2083 |
+
$menu_tabs[ $slug ] = $tab['title'];
|
2084 |
+
}
|
2085 |
+
}
|
2086 |
+
|
2087 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2088 |
+
foreach ( $menu_tabs as $name => $label ) {
|
2089 |
+
$active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
|
2090 |
+
$tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
|
2091 |
+
$label .
|
2092 |
+
'</a>';
|
2093 |
+
}
|
2094 |
+
|
2095 |
+
break;
|
2096 |
+
default:
|
2097 |
+
/**
|
2098 |
+
* UM hook
|
2099 |
+
*
|
2100 |
+
* @type filter
|
2101 |
+
* @title um_generate_tabs_menu_{$page}
|
2102 |
+
* @description Generate tabs menu
|
2103 |
+
* @input_vars
|
2104 |
+
* [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
|
2105 |
+
* @change_log
|
2106 |
+
* ["Since: 2.0"]
|
2107 |
+
* @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
|
2108 |
+
* @example
|
2109 |
+
* <?php
|
2110 |
+
* add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
|
2111 |
+
* function my_tabs_menu( $tabs ) {
|
2112 |
+
* // your code here
|
2113 |
+
* return $tabs;
|
2114 |
+
* }
|
2115 |
+
* ?>
|
2116 |
+
*/
|
2117 |
+
$tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
|
2118 |
+
break;
|
2119 |
+
}
|
2120 |
+
|
2121 |
+
return $tabs . '</h2>';
|
2122 |
+
}
|
2123 |
+
|
2124 |
+
|
2125 |
+
/**
|
2126 |
+
* @param string $tab
|
2127 |
+
*
|
2128 |
+
* @return string
|
2129 |
+
*/
|
2130 |
+
function generate_subtabs_menu( $tab = '' ) {
|
2131 |
+
if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
|
2132 |
+
return '';
|
2133 |
+
}
|
2134 |
+
|
2135 |
+
$menu_subtabs = array();
|
2136 |
+
foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
|
2137 |
+
$menu_subtabs[ $slug ] = $subtab['title'];
|
2138 |
+
}
|
2139 |
+
|
2140 |
+
$subtabs = '<div><ul class="subsubsub">';
|
2141 |
+
|
2142 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2143 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
2144 |
+
foreach ( $menu_subtabs as $name => $label ) {
|
2145 |
+
$active = ( $current_subtab == $name ) ? 'current' : '';
|
2146 |
+
$subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '§ion=' . $name ) ) ) . '" class="' . $active . '">'
|
2147 |
+
. $label .
|
2148 |
+
'</a> | ';
|
2149 |
+
}
|
2150 |
+
|
2151 |
+
return substr( $subtabs, 0, -3 ) . '</ul></div>';
|
2152 |
+
}
|
2153 |
+
|
2154 |
+
|
2155 |
+
/**
|
2156 |
+
* Handler for settings forms
|
2157 |
+
* when "Save Settings" button click
|
2158 |
+
*
|
2159 |
+
*/
|
2160 |
+
function save_settings_handler() {
|
2161 |
+
|
2162 |
+
if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
|
2163 |
+
|
2164 |
+
$nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
|
2165 |
+
|
2166 |
+
if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
|
2167 |
+
// This nonce is not valid.
|
2168 |
+
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
2169 |
+
}
|
2170 |
+
|
2171 |
+
/**
|
2172 |
+
* UM hook
|
2173 |
+
*
|
2174 |
+
* @type action
|
2175 |
+
* @title um_settings_before_save
|
2176 |
+
* @description Before settings save action
|
2177 |
+
* @change_log
|
2178 |
+
* ["Since: 2.0"]
|
2179 |
+
* @usage add_action( 'um_settings_before_save', 'function_name', 10 );
|
2180 |
+
* @example
|
2181 |
+
* <?php
|
2182 |
+
* add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
|
2183 |
+
* function my_settings_before_save() {
|
2184 |
+
* // your code here
|
2185 |
+
* }
|
2186 |
+
* ?>
|
2187 |
+
*/
|
2188 |
+
do_action( "um_settings_before_save" );
|
2189 |
+
|
2190 |
+
/**
|
2191 |
+
* UM hook
|
2192 |
+
*
|
2193 |
+
* @type filter
|
2194 |
+
* @title um_change_settings_before_save
|
2195 |
+
* @description Change settings before save
|
2196 |
+
* @input_vars
|
2197 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
|
2198 |
+
* @change_log
|
2199 |
+
* ["Since: 2.0"]
|
2200 |
+
* @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
|
2201 |
+
* @example
|
2202 |
+
* <?php
|
2203 |
+
* add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
|
2204 |
+
* function my_change_settings_before_save( $settings ) {
|
2205 |
+
* // your code here
|
2206 |
+
* return $settings;
|
2207 |
+
* }
|
2208 |
+
* ?>
|
2209 |
+
*/
|
2210 |
+
$settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
|
2211 |
+
|
2212 |
+
$settings = UM()->admin()->sanitize_options( $settings );
|
2213 |
+
|
2214 |
+
foreach ( $settings as $key => $value ) {
|
2215 |
+
UM()->options()->update( $key, $value );
|
2216 |
+
}
|
2217 |
+
|
2218 |
+
/**
|
2219 |
+
* UM hook
|
2220 |
+
*
|
2221 |
+
* @type action
|
2222 |
+
* @title um_settings_save
|
2223 |
+
* @description After settings save action
|
2224 |
+
* @change_log
|
2225 |
+
* ["Since: 2.0"]
|
2226 |
+
* @usage add_action( 'um_settings_save', 'function_name', 10 );
|
2227 |
+
* @example
|
2228 |
+
* <?php
|
2229 |
+
* add_action( 'um_settings_save', 'my_settings_save', 10 );
|
2230 |
+
* function my_settings_save() {
|
2231 |
+
* // your code here
|
2232 |
+
* }
|
2233 |
+
* ?>
|
2234 |
+
*/
|
2235 |
+
do_action( 'um_settings_save' );
|
2236 |
+
|
2237 |
+
//redirect after save settings
|
2238 |
+
$arg = array(
|
2239 |
+
'page' => 'um_options',
|
2240 |
+
);
|
2241 |
+
|
2242 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2243 |
+
$arg['tab'] = sanitize_key( $_GET['tab'] );
|
2244 |
+
}
|
2245 |
+
|
2246 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2247 |
+
$arg['section'] = sanitize_key( $_GET['section'] );
|
2248 |
+
}
|
2249 |
+
|
2250 |
+
um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
|
2251 |
+
}
|
2252 |
+
}
|
2253 |
+
|
2254 |
+
|
2255 |
+
function set_default_if_empty( $settings ) {
|
2256 |
+
$tab = '';
|
2257 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2258 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2259 |
+
}
|
2260 |
+
|
2261 |
+
$section = '';
|
2262 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2263 |
+
$section = sanitize_key( $_GET['section'] );
|
2264 |
+
}
|
2265 |
+
|
2266 |
+
|
2267 |
+
if ( 'access' === $tab && empty( $section ) ) {
|
2268 |
+
if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
|
2269 |
+
$settings['access_exclude_uris'] = array();
|
2270 |
+
}
|
2271 |
+
}
|
2272 |
+
|
2273 |
+
return $settings;
|
2274 |
+
}
|
2275 |
+
|
2276 |
+
|
2277 |
+
/**
|
2278 |
+
* Remove empty values from multi text fields
|
2279 |
+
*
|
2280 |
+
* @param $settings
|
2281 |
+
* @return array
|
2282 |
+
*/
|
2283 |
+
function remove_empty_values( $settings ) {
|
2284 |
+
$tab = '';
|
2285 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2286 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2287 |
+
}
|
2288 |
+
|
2289 |
+
$section = '';
|
2290 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2291 |
+
$section = sanitize_key( $_GET['section'] );
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
2295 |
+
$fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
2296 |
+
} else {
|
2297 |
+
$fields = $this->settings_structure[ $tab ]['fields'];
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
if ( empty( $fields ) ) {
|
2301 |
+
return $settings;
|
2302 |
+
}
|
2303 |
+
|
2304 |
+
|
2305 |
+
$filtered_settings = array();
|
2306 |
+
foreach ( $settings as $key => $value ) {
|
2307 |
+
|
2308 |
+
$filtered_settings[ $key ] = $value;
|
2309 |
+
|
2310 |
+
foreach ( $fields as $field ) {
|
2311 |
+
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
|
2312 |
+
$filtered_settings[ $key ] = array_filter( $settings[ $key ] );
|
2313 |
+
}
|
2314 |
+
}
|
2315 |
+
}
|
2316 |
+
|
2317 |
+
return $filtered_settings;
|
2318 |
+
}
|
2319 |
+
|
2320 |
+
|
2321 |
+
/**
|
2322 |
+
*
|
2323 |
+
*/
|
2324 |
+
function check_permalinks_changes() {
|
2325 |
+
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2326 |
+
if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
|
2327 |
+
$this->need_change_permalinks = true;
|
2328 |
+
}
|
2329 |
+
}
|
2330 |
+
|
2331 |
+
// set variable if gravatar settings were changed
|
2332 |
+
// update for um_member_directory_data metakey
|
2333 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2334 |
+
$use_gravatar = UM()->options()->get( 'use_gravatars' );
|
2335 |
+
if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
|
2336 |
+
$this->gravatar_changed = true;
|
2337 |
+
}
|
2338 |
+
}
|
2339 |
+
}
|
2340 |
+
|
2341 |
+
|
2342 |
+
/**
|
2343 |
+
*
|
2344 |
+
*/
|
2345 |
+
function on_settings_save() {
|
2346 |
+
if ( ! empty( $_POST['um_options'] ) ) {
|
2347 |
+
|
2348 |
+
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
2349 |
+
$post_ids = new \WP_Query( array(
|
2350 |
+
'post_type' => 'page',
|
2351 |
+
'meta_query' => array(
|
2352 |
+
array(
|
2353 |
+
'key' => '_um_core',
|
2354 |
+
'compare' => 'EXISTS'
|
2355 |
+
)
|
2356 |
+
),
|
2357 |
+
'posts_per_page' => -1,
|
2358 |
+
'fields' => 'ids'
|
2359 |
+
) );
|
2360 |
+
|
2361 |
+
$post_ids = $post_ids->get_posts();
|
2362 |
+
|
2363 |
+
if ( ! empty( $post_ids ) ) {
|
2364 |
+
foreach ( $post_ids as $post_id ) {
|
2365 |
+
delete_post_meta( $post_id, '_um_core' );
|
2366 |
+
}
|
2367 |
+
}
|
2368 |
+
|
2369 |
+
foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
|
2370 |
+
$slug = str_replace( 'core_', '', $option_slug );
|
2371 |
+
update_post_meta( $post_id, '_um_core', $slug );
|
2372 |
+
}
|
2373 |
+
|
2374 |
+
// reset rewrite rules after re-save pages
|
2375 |
+
UM()->rewrite()->reset_rules();
|
2376 |
+
|
2377 |
+
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2378 |
+
if ( ! empty( $this->need_change_permalinks ) ) {
|
2379 |
+
$users = get_users( array(
|
2380 |
+
'fields' => 'ids',
|
2381 |
+
) );
|
2382 |
+
if ( ! empty( $users ) ) {
|
2383 |
+
foreach ( $users as $user_id ) {
|
2384 |
+
UM()->user()->generate_profile_slug( $user_id );
|
2385 |
+
}
|
2386 |
+
}
|
2387 |
+
}
|
2388 |
+
|
2389 |
+
|
2390 |
+
// update for um_member_directory_data metakey
|
2391 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2392 |
+
if ( $this->gravatar_changed ) {
|
2393 |
+
global $wpdb;
|
2394 |
+
|
2395 |
+
if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
|
2396 |
+
|
2397 |
+
$results = $wpdb->get_col(
|
2398 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2399 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
|
2400 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2401 |
+
WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
|
2402 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
|
2403 |
+
);
|
2404 |
+
|
2405 |
+
} else {
|
2406 |
+
|
2407 |
+
$results = $wpdb->get_col(
|
2408 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2409 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
|
2410 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2411 |
+
WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
|
2412 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
|
2413 |
+
);
|
2414 |
+
|
2415 |
+
}
|
2416 |
+
|
2417 |
+
if ( ! empty( $results ) ) {
|
2418 |
+
foreach ( $results as $user_id ) {
|
2419 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2420 |
+
if ( ! empty( $md_data ) ) {
|
2421 |
+
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
2422 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2423 |
+
}
|
2424 |
+
}
|
2425 |
+
}
|
2426 |
+
}
|
2427 |
+
}
|
2428 |
+
|
2429 |
+
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2430 |
+
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2431 |
+
global $wpdb;
|
2432 |
+
|
2433 |
+
$results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
|
2434 |
+
|
2435 |
+
if ( ! empty( $results ) ) {
|
2436 |
+
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
|
2437 |
+
}
|
2438 |
+
|
2439 |
+
update_option( 'um_member_directory_truncated', time() );
|
2440 |
+
}
|
2441 |
+
} elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
|
2442 |
+
|
2443 |
+
global $wpdb;
|
2444 |
+
|
2445 |
+
if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
|
2446 |
+
|
2447 |
+
$results = $wpdb->get_col(
|
2448 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2449 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2450 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2451 |
+
WHERE um.meta_value IS NULL AND
|
2452 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
|
2453 |
+
);
|
2454 |
+
|
2455 |
+
} else {
|
2456 |
+
|
2457 |
+
$results = $wpdb->get_col(
|
2458 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2459 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2460 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2461 |
+
WHERE um.meta_value IS NULL AND
|
2462 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
|
2463 |
+
);
|
2464 |
+
|
2465 |
+
}
|
2466 |
+
|
2467 |
+
if ( ! empty( $results ) ) {
|
2468 |
+
foreach ( $results as $user_id ) {
|
2469 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2470 |
+
if ( ! empty( $md_data ) ) {
|
2471 |
+
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
2472 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2473 |
+
}
|
2474 |
+
}
|
2475 |
+
}
|
2476 |
+
|
2477 |
+
}
|
2478 |
+
}
|
2479 |
+
}
|
2480 |
+
|
2481 |
+
|
2482 |
+
/**
|
2483 |
+
*
|
2484 |
+
*/
|
2485 |
+
function before_licenses_save() {
|
2486 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2487 |
+
return;
|
2488 |
+
}
|
2489 |
+
|
2490 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2491 |
+
$this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
|
2492 |
+
}
|
2493 |
+
}
|
2494 |
+
|
2495 |
+
|
2496 |
+
/**
|
2497 |
+
*
|
2498 |
+
*/
|
2499 |
+
function licenses_save() {
|
2500 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2501 |
+
return;
|
2502 |
+
}
|
2503 |
+
|
2504 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2505 |
+
$key = sanitize_key( $key );
|
2506 |
+
$value = sanitize_text_field( $value );
|
2507 |
+
|
2508 |
+
$edd_action = '';
|
2509 |
+
$license_key = '';
|
2510 |
+
if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
|
2511 |
+
$edd_action = 'activate_license';
|
2512 |
+
$license_key = $value;
|
2513 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
|
2514 |
+
$edd_action = 'deactivate_license';
|
2515 |
+
$license_key = $this->previous_licenses[ $key ];
|
2516 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
|
2517 |
+
$edd_action = 'check_license';
|
2518 |
+
$license_key = $value;
|
2519 |
+
}
|
2520 |
+
|
2521 |
+
if ( empty( $edd_action ) ) {
|
2522 |
+
continue;
|
2523 |
+
}
|
2524 |
+
|
2525 |
+
$item_name = false;
|
2526 |
+
$version = false;
|
2527 |
+
$author = false;
|
2528 |
+
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
2529 |
+
if ( $field_data['id'] == $key ) {
|
2530 |
+
$item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
|
2531 |
+
$version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
|
2532 |
+
$author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
|
2533 |
+
}
|
2534 |
+
}
|
2535 |
+
|
2536 |
+
$api_params = array(
|
2537 |
+
'edd_action' => $edd_action,
|
2538 |
+
'license' => $license_key,
|
2539 |
+
'item_name' => $item_name,
|
2540 |
+
'version' => $version,
|
2541 |
+
'author' => $author,
|
2542 |
+
'url' => home_url(),
|
2543 |
+
);
|
2544 |
+
|
2545 |
+
$request = wp_remote_post(
|
2546 |
+
UM()->store_url,
|
2547 |
+
array(
|
2548 |
+
'timeout' => UM()->request_timeout,
|
2549 |
+
'sslverify' => false,
|
2550 |
+
'body' => $api_params
|
2551 |
+
)
|
2552 |
+
);
|
2553 |
+
|
2554 |
+
if ( ! is_wp_error( $request ) ) {
|
2555 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2556 |
+
} else {
|
2557 |
+
$request = wp_remote_post(
|
2558 |
+
UM()->store_url,
|
2559 |
+
array(
|
2560 |
+
'timeout' => UM()->request_timeout,
|
2561 |
+
'sslverify' => true,
|
2562 |
+
'body' => $api_params
|
2563 |
+
)
|
2564 |
+
);
|
2565 |
+
|
2566 |
+
if ( ! is_wp_error( $request ) ) {
|
2567 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2568 |
+
}
|
2569 |
+
}
|
2570 |
+
|
2571 |
+
$request = ( $request ) ? maybe_unserialize( $request ) : false;
|
2572 |
+
|
2573 |
+
if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
|
2574 |
+
update_option( "{$key}_edd_answer", $request );
|
2575 |
+
} else {
|
2576 |
+
delete_option( "{$key}_edd_answer" );
|
2577 |
+
}
|
2578 |
+
|
2579 |
+
}
|
2580 |
+
}
|
2581 |
+
|
2582 |
+
|
2583 |
+
/**
|
2584 |
+
*
|
2585 |
+
*/
|
2586 |
+
function settings_before_email_tab() {
|
2587 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2588 |
+
$emails = UM()->config()->email_notifications;
|
2589 |
+
|
2590 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2591 |
+
include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
|
2592 |
+
}
|
2593 |
+
}
|
2594 |
+
|
2595 |
+
|
2596 |
+
/**
|
2597 |
+
* @param $section
|
2598 |
+
*
|
2599 |
+
* @return string
|
2600 |
+
*/
|
2601 |
+
function settings_email_tab( $section ) {
|
2602 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2603 |
+
$emails = UM()->config()->email_notifications;
|
2604 |
+
|
2605 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2606 |
+
return $section;
|
2607 |
+
}
|
2608 |
+
|
2609 |
+
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
2610 |
+
|
2611 |
+
/**
|
2612 |
+
* UM hook
|
2613 |
+
*
|
2614 |
+
* @type filter
|
2615 |
+
* @title um_admin_settings_email_section_fields
|
2616 |
+
* @description Extend UM Email Settings
|
2617 |
+
* @input_vars
|
2618 |
+
* [{"var":"$settings","type":"array","desc":"UM Email Settings"},
|
2619 |
+
* {"var":"$email_key","type":"string","desc":"Email Key"}]
|
2620 |
+
* @change_log
|
2621 |
+
* ["Since: 2.0"]
|
2622 |
+
* @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
|
2623 |
+
* @example
|
2624 |
+
* <?php
|
2625 |
+
* add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
|
2626 |
+
* function my_admin_settings_email_section( $settings, $email_key ) {
|
2627 |
+
* // your code here
|
2628 |
+
* return $settings;
|
2629 |
+
* }
|
2630 |
+
* ?>
|
2631 |
+
*/
|
2632 |
+
$section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
|
2633 |
+
array(
|
2634 |
+
'id' => 'um_email_template',
|
2635 |
+
'type' => 'hidden',
|
2636 |
+
'value' => $email_key,
|
2637 |
+
),
|
2638 |
+
array(
|
2639 |
+
'id' => $email_key . '_on',
|
2640 |
+
'type' => 'checkbox',
|
2641 |
+
'label' => $emails[ $email_key ]['title'],
|
2642 |
+
'tooltip' => $emails[ $email_key ]['description'],
|
2643 |
+
),
|
2644 |
+
array(
|
2645 |
+
'id' => $email_key . '_sub',
|
2646 |
+
'type' => 'text',
|
2647 |
+
'label' => __( 'Subject Line', 'ultimate-member' ),
|
2648 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2649 |
+
'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
|
2650 |
+
),
|
2651 |
+
array(
|
2652 |
+
'id' => $email_key,
|
2653 |
+
'type' => 'email_template',
|
2654 |
+
'label' => __( 'Message Body', 'ultimate-member' ),
|
2655 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2656 |
+
'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
|
2657 |
+
'value' => UM()->mail()->get_email_template( $email_key ),
|
2658 |
+
'in_theme' => $in_theme
|
2659 |
+
),
|
2660 |
+
), $email_key );
|
2661 |
+
|
2662 |
+
return $this->render_settings_section( $section_fields, 'email', $email_key );
|
2663 |
+
}
|
2664 |
+
|
2665 |
+
|
2666 |
+
/**
|
2667 |
+
*
|
2668 |
+
*/
|
2669 |
+
function settings_appearance_profile_tab() {
|
2670 |
+
wp_enqueue_media();
|
2671 |
+
}
|
2672 |
+
|
2673 |
+
|
2674 |
+
/**
|
2675 |
+
* @param $html
|
2676 |
+
* @param $section_fields
|
2677 |
+
*
|
2678 |
+
* @return string
|
2679 |
+
*/
|
2680 |
+
function settings_licenses_tab( $html, $section_fields ) {
|
2681 |
+
ob_start(); ?>
|
2682 |
+
|
2683 |
+
<div class="wrap-licenses">
|
2684 |
+
<input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
|
2685 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2686 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2687 |
+
<table class="form-table um-settings-section">
|
2688 |
+
<tbody>
|
2689 |
+
<?php foreach ( $section_fields as $field_data ) {
|
2690 |
+
$option_value = UM()->options()->get( $field_data['id'] );
|
2691 |
+
$value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
|
2692 |
+
|
2693 |
+
$license = get_option( "{$field_data['id']}_edd_answer" );
|
2694 |
+
|
2695 |
+
if ( is_object( $license ) && ! empty( $value ) ) {
|
2696 |
+
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
2697 |
+
if ( empty( $license->success ) ) {
|
2698 |
+
|
2699 |
+
if ( ! empty( $license->error ) ) {
|
2700 |
+
switch ( $license->error ) {
|
2701 |
+
|
2702 |
+
case 'expired' :
|
2703 |
+
|
2704 |
+
$class = 'expired';
|
2705 |
+
$messages[] = sprintf(
|
2706 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2707 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2708 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2709 |
+
);
|
2710 |
+
|
2711 |
+
$license_status = 'license-' . $class . '-notice';
|
2712 |
+
|
2713 |
+
break;
|
2714 |
+
|
2715 |
+
case 'revoked' :
|
2716 |
+
|
2717 |
+
$class = 'error';
|
2718 |
+
$messages[] = sprintf(
|
2719 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2720 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2721 |
+
);
|
2722 |
+
|
2723 |
+
$license_status = 'license-' . $class . '-notice';
|
2724 |
+
|
2725 |
+
break;
|
2726 |
+
|
2727 |
+
case 'missing' :
|
2728 |
+
|
2729 |
+
$class = 'error';
|
2730 |
+
$messages[] = sprintf(
|
2731 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2732 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2733 |
+
);
|
2734 |
+
|
2735 |
+
$license_status = 'license-' . $class . '-notice';
|
2736 |
+
|
2737 |
+
break;
|
2738 |
+
|
2739 |
+
case 'invalid' :
|
2740 |
+
case 'site_inactive' :
|
2741 |
+
|
2742 |
+
$class = 'error';
|
2743 |
+
$messages[] = sprintf(
|
2744 |
+
__( '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' ),
|
2745 |
+
$field_data['item_name'],
|
2746 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2747 |
+
);
|
2748 |
+
|
2749 |
+
$license_status = 'license-' . $class . '-notice';
|
2750 |
+
|
2751 |
+
break;
|
2752 |
+
|
2753 |
+
case 'item_name_mismatch' :
|
2754 |
+
|
2755 |
+
$class = 'error';
|
2756 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2757 |
+
|
2758 |
+
$license_status = 'license-' . $class . '-notice';
|
2759 |
+
|
2760 |
+
break;
|
2761 |
+
|
2762 |
+
case 'no_activations_left':
|
2763 |
+
|
2764 |
+
$class = 'error';
|
2765 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2766 |
+
|
2767 |
+
$license_status = 'license-' . $class . '-notice';
|
2768 |
+
|
2769 |
+
break;
|
2770 |
+
|
2771 |
+
case 'license_not_activable':
|
2772 |
+
|
2773 |
+
$class = 'error';
|
2774 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2775 |
+
|
2776 |
+
$license_status = 'license-' . $class . '-notice';
|
2777 |
+
break;
|
2778 |
+
|
2779 |
+
default :
|
2780 |
+
|
2781 |
+
$class = 'error';
|
2782 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2783 |
+
$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' );
|
2784 |
+
|
2785 |
+
$license_status = 'license-' . $class . '-notice';
|
2786 |
+
break;
|
2787 |
+
}
|
2788 |
+
} else {
|
2789 |
+
$class = 'error';
|
2790 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2791 |
+
$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' );
|
2792 |
+
|
2793 |
+
$license_status = 'license-' . $class . '-notice';
|
2794 |
+
}
|
2795 |
+
|
2796 |
+
} elseif ( ! empty( $license->errors ) ) {
|
2797 |
+
|
2798 |
+
$errors = array_keys( $license->errors );
|
2799 |
+
$errors_data = array_values( $license->errors );
|
2800 |
+
|
2801 |
+
$class = 'error';
|
2802 |
+
$error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
|
2803 |
+
$errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
|
2804 |
+
$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' );
|
2805 |
+
|
2806 |
+
$license_status = 'license-' . $class . '-notice';
|
2807 |
+
|
2808 |
+
} else {
|
2809 |
+
|
2810 |
+
switch( $license->license ) {
|
2811 |
+
|
2812 |
+
case 'expired' :
|
2813 |
+
|
2814 |
+
$class = 'expired';
|
2815 |
+
$messages[] = sprintf(
|
2816 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2817 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2818 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2819 |
+
);
|
2820 |
+
|
2821 |
+
$license_status = 'license-' . $class . '-notice';
|
2822 |
+
|
2823 |
+
break;
|
2824 |
+
|
2825 |
+
case 'revoked' :
|
2826 |
+
|
2827 |
+
$class = 'error';
|
2828 |
+
$messages[] = sprintf(
|
2829 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2830 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2831 |
+
);
|
2832 |
+
|
2833 |
+
$license_status = 'license-' . $class . '-notice';
|
2834 |
+
|
2835 |
+
break;
|
2836 |
+
|
2837 |
+
case 'missing' :
|
2838 |
+
|
2839 |
+
$class = 'error';
|
2840 |
+
$messages[] = sprintf(
|
2841 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2842 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2843 |
+
);
|
2844 |
+
|
2845 |
+
$license_status = 'license-' . $class . '-notice';
|
2846 |
+
|
2847 |
+
break;
|
2848 |
+
|
2849 |
+
case 'invalid' :
|
2850 |
+
case 'site_inactive' :
|
2851 |
+
|
2852 |
+
$class = 'error';
|
2853 |
+
$messages[] = sprintf(
|
2854 |
+
__( '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' ),
|
2855 |
+
$field_data['item_name'],
|
2856 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2857 |
+
);
|
2858 |
+
|
2859 |
+
$license_status = 'license-' . $class . '-notice';
|
2860 |
+
|
2861 |
+
break;
|
2862 |
+
|
2863 |
+
case 'item_name_mismatch' :
|
2864 |
+
|
2865 |
+
$class = 'error';
|
2866 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2867 |
+
|
2868 |
+
$license_status = 'license-' . $class . '-notice';
|
2869 |
+
|
2870 |
+
break;
|
2871 |
+
|
2872 |
+
case 'no_activations_left':
|
2873 |
+
|
2874 |
+
$class = 'error';
|
2875 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2876 |
+
|
2877 |
+
$license_status = 'license-' . $class . '-notice';
|
2878 |
+
|
2879 |
+
break;
|
2880 |
+
|
2881 |
+
case 'license_not_activable':
|
2882 |
+
|
2883 |
+
$class = 'error';
|
2884 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2885 |
+
|
2886 |
+
$license_status = 'license-' . $class . '-notice';
|
2887 |
+
break;
|
2888 |
+
|
2889 |
+
case 'valid' :
|
2890 |
+
default:
|
2891 |
+
|
2892 |
+
$class = 'valid';
|
2893 |
+
|
2894 |
+
$now = current_time( 'timestamp' );
|
2895 |
+
$expiration = strtotime( $license->expires, $now );
|
2896 |
+
|
2897 |
+
if( 'lifetime' === $license->expires ) {
|
2898 |
+
|
2899 |
+
$messages[] = __( 'License key never expires.', 'ultimate-member' );
|
2900 |
+
|
2901 |
+
$license_status = 'license-lifetime-notice';
|
2902 |
+
|
2903 |
+
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
2904 |
+
|
2905 |
+
$messages[] = sprintf(
|
2906 |
+
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
|
2907 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2908 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
|
2909 |
+
);
|
2910 |
+
|
2911 |
+
$license_status = 'license-expires-soon-notice';
|
2912 |
+
|
2913 |
+
} else {
|
2914 |
+
|
2915 |
+
$messages[] = sprintf(
|
2916 |
+
__( 'Your license key expires on %s.', 'ultimate-member' ),
|
2917 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
2918 |
+
);
|
2919 |
+
|
2920 |
+
$license_status = 'license-expiration-date-notice';
|
2921 |
+
|
2922 |
+
}
|
2923 |
+
|
2924 |
+
break;
|
2925 |
+
|
2926 |
+
}
|
2927 |
+
|
2928 |
+
}
|
2929 |
+
|
2930 |
+
} else {
|
2931 |
+
$class = 'empty';
|
2932 |
+
|
2933 |
+
$messages[] = sprintf(
|
2934 |
+
__( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
|
2935 |
+
$field_data['item_name']
|
2936 |
+
);
|
2937 |
+
|
2938 |
+
$license_status = null;
|
2939 |
+
|
2940 |
+
} ?>
|
2941 |
+
|
2942 |
+
<tr class="um-settings-line">
|
2943 |
+
<th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
|
2944 |
+
<td>
|
2945 |
+
<form method="post" action="" name="um-settings-form" class="um-settings-form">
|
2946 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
2947 |
+
<input type="hidden" name="licenses_settings" value="1" />
|
2948 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2949 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2950 |
+
<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'] ) ?>" />
|
2951 |
+
<?php if ( ! empty( $field_data['description'] ) ) { ?>
|
2952 |
+
<div class="description"><?php echo $field_data['description'] ?></div>
|
2953 |
+
<?php } ?>
|
2954 |
+
|
2955 |
+
<?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
|
2956 |
+
<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' ) ?>"/>
|
2957 |
+
<?php } elseif ( empty( $value ) ) { ?>
|
2958 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
|
2959 |
+
<?php } else { ?>
|
2960 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
|
2961 |
+
<?php }
|
2962 |
+
|
2963 |
+
if ( ! empty( $messages ) ) {
|
2964 |
+
foreach ( $messages as $message ) { ?>
|
2965 |
+
<div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
|
2966 |
+
<p><?php echo $message ?></p>
|
2967 |
+
</div>
|
2968 |
+
<?php }
|
2969 |
+
} ?>
|
2970 |
+
</form>
|
2971 |
+
</td>
|
2972 |
+
</tr>
|
2973 |
+
<?php } ?>
|
2974 |
+
</tbody>
|
2975 |
+
</table>
|
2976 |
+
</div>
|
2977 |
+
<?php $section = ob_get_clean();
|
2978 |
+
|
2979 |
+
return $section;
|
2980 |
+
}
|
2981 |
+
|
2982 |
+
|
2983 |
+
/**
|
2984 |
+
* @param $html
|
2985 |
+
* @param $section_fields
|
2986 |
+
*/
|
2987 |
+
function settings_install_info_tab( $html, $section_fields ) {
|
2988 |
+
global $wpdb;
|
2989 |
+
|
2990 |
+
if ( ! class_exists( '\Browser' ) )
|
2991 |
+
require_once um_path . 'includes/lib/browser.php';
|
2992 |
+
|
2993 |
+
// Detect browser
|
2994 |
+
$browser = new \Browser();
|
2995 |
+
|
2996 |
+
// Get theme info
|
2997 |
+
$theme_data = wp_get_theme();
|
2998 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
2999 |
+
|
3000 |
+
// Identify Hosting Provider
|
3001 |
+
$host = um_get_host();
|
3002 |
+
|
3003 |
+
um_fetch_user( get_current_user_id() );
|
3004 |
+
|
3005 |
+
if ( isset( $this->content ) ) {
|
3006 |
+
echo $this->content;
|
3007 |
+
} else { ?>
|
3008 |
+
|
3009 |
+
<h3>Install Info</h3>
|
3010 |
+
|
3011 |
+
<form action="" method="post" dir="ltr">
|
3012 |
+
<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' ); ?>">
|
3013 |
+
### Begin Install Info ###
|
3014 |
+
|
3015 |
+
## Please include this information when posting support requests ##
|
3016 |
+
|
3017 |
+
<?php
|
3018 |
+
/**
|
3019 |
+
* UM hook
|
3020 |
+
*
|
3021 |
+
* @type action
|
3022 |
+
* @title um_install_info_before
|
3023 |
+
* @description Before install info settings
|
3024 |
+
* @change_log
|
3025 |
+
* ["Since: 2.0"]
|
3026 |
+
* @usage add_action( 'um_install_info_before', 'function_name', 10 );
|
3027 |
+
* @example
|
3028 |
+
* <?php
|
3029 |
+
* add_action( 'um_install_info_before', 'my_install_info_before', 10 );
|
3030 |
+
* function my_install_info_before() {
|
3031 |
+
* // your code here
|
3032 |
+
* }
|
3033 |
+
* ?>
|
3034 |
+
*/
|
3035 |
+
do_action( 'um_install_info_before' ); ?>
|
3036 |
+
|
3037 |
+
--- Site Info ---
|
3038 |
+
|
3039 |
+
Site URL: <?php echo site_url() . "\n"; ?>
|
3040 |
+
Home URL: <?php echo home_url() . "\n"; ?>
|
3041 |
+
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
3042 |
+
|
3043 |
+
--- Hosting Provider ---
|
3044 |
+
|
3045 |
+
<?php if( $host ) : ?>
|
3046 |
+
Host: <?php echo $host . "\n"; ?>
|
3047 |
+
<?php endif; ?>
|
3048 |
+
|
3049 |
+
--- User Browser ---
|
3050 |
+
|
3051 |
+
<?php echo $browser ; ?>
|
3052 |
+
|
3053 |
+
---- Current User Details --
|
3054 |
+
|
3055 |
+
<?php $user = wp_get_current_user(); ?>
|
3056 |
+
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
3057 |
+
|
3058 |
+
|
3059 |
+
--- WordPress Configurations ---
|
3060 |
+
|
3061 |
+
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
3062 |
+
Language: <?php echo get_locale()."\n"; ?>
|
3063 |
+
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
3064 |
+
Active Theme: <?php echo $theme . "\n"; ?>
|
3065 |
+
<?php $show_on_front = get_option( 'show_on_front' ); ?>
|
3066 |
+
<?php if( $show_on_front == "posts" ): ?>
|
3067 |
+
Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
|
3068 |
+
<?php elseif( $show_on_front == "page" ): ?>
|
3069 |
+
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3070 |
+
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3071 |
+
<?php endif; ?>
|
3072 |
+
ABSPATH: <?php echo ABSPATH."\n"; ?>
|
3073 |
+
<?php $wp_count_posts = wp_count_posts(); ?>
|
3074 |
+
All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
|
3075 |
+
<?php
|
3076 |
+
$request['cmd'] = '_notify-validate';
|
3077 |
+
|
3078 |
+
$params = array(
|
3079 |
+
'sslverify' => false,
|
3080 |
+
'timeout' => 60,
|
3081 |
+
'user-agent' => 'UltimateMember/' . ultimatemember_version,
|
3082 |
+
'body' => $request
|
3083 |
+
);
|
3084 |
+
|
3085 |
+
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
3086 |
+
|
3087 |
+
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
3088 |
+
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
|
3089 |
+
} else {
|
3090 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
|
3091 |
+
}
|
3092 |
+
?>
|
3093 |
+
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
|
3094 |
+
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
3095 |
+
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"; ?>
|
3096 |
+
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
3097 |
+
|
3098 |
+
|
3099 |
+
--- UM Configurations ---
|
3100 |
+
|
3101 |
+
Version: <?php echo ultimatemember_version . "\n"; ?>
|
3102 |
+
Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
|
3103 |
+
Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
|
3104 |
+
Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3105 |
+
Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3106 |
+
Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3107 |
+
JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3108 |
+
<?php if( is_multisite() ): ?>
|
3109 |
+
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
3110 |
+
<?php endif; ?>
|
3111 |
+
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3112 |
+
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3113 |
+
|
3114 |
+
|
3115 |
+
--- UM Pages Configuration ---
|
3116 |
+
|
3117 |
+
<?php
|
3118 |
+
/**
|
3119 |
+
* UM hook
|
3120 |
+
*
|
3121 |
+
* @type action
|
3122 |
+
* @title um_install_info_before_page_config
|
3123 |
+
* @description Before page config install info
|
3124 |
+
* @change_log
|
3125 |
+
* ["Since: 2.0"]
|
3126 |
+
* @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
|
3127 |
+
* @example
|
3128 |
+
* <?php
|
3129 |
+
* add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
|
3130 |
+
* function my_install_info_before_page_config() {
|
3131 |
+
* // your code here
|
3132 |
+
* }
|
3133 |
+
* ?>
|
3134 |
+
*/
|
3135 |
+
do_action( "um_install_info_before_page_config" ); ?>
|
3136 |
+
User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
|
3137 |
+
Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
|
3138 |
+
Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
|
3139 |
+
Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
|
3140 |
+
Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
|
3141 |
+
Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
|
3142 |
+
Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
|
3143 |
+
<?php
|
3144 |
+
/**
|
3145 |
+
* UM hook
|
3146 |
+
*
|
3147 |
+
* @type action
|
3148 |
+
* @title um_install_info_after_page_config
|
3149 |
+
* @description After page config install info
|
3150 |
+
* @change_log
|
3151 |
+
* ["Since: 2.0"]
|
3152 |
+
* @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
|
3153 |
+
* @example
|
3154 |
+
* <?php
|
3155 |
+
* add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
|
3156 |
+
* function my_install_info_after_page_config() {
|
3157 |
+
* // your code here
|
3158 |
+
* }
|
3159 |
+
* ?>
|
3160 |
+
*/
|
3161 |
+
do_action( "um_install_info_after_page_config" ); ?>
|
3162 |
+
|
3163 |
+
|
3164 |
+
--- UM Users Configuration ---
|
3165 |
+
|
3166 |
+
Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
|
3167 |
+
Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
|
3168 |
+
User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
|
3169 |
+
Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
|
3170 |
+
Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
|
3171 |
+
Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
|
3172 |
+
Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
|
3173 |
+
<?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
|
3174 |
+
UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
|
3175 |
+
Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
|
3176 |
+
|
3177 |
+
|
3178 |
+
--- UM Access Configuration ---
|
3179 |
+
|
3180 |
+
Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
|
3181 |
+
Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
|
3182 |
+
<?php if( UM()->options()->get('accessible') == 2 ) { ?>
|
3183 |
+
Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
|
3184 |
+
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";?>
|
3185 |
+
<?php } ?>
|
3186 |
+
Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
|
3187 |
+
<?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
|
3188 |
+
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"; }?>
|
3189 |
+
<?php } ?>
|
3190 |
+
Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
|
3191 |
+
<?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
|
3192 |
+
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"; }?>
|
3193 |
+
<?php } ?>
|
3194 |
+
Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
|
3195 |
+
Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
|
3196 |
+
<?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
|
3197 |
+
Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
|
3198 |
+
Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
|
3199 |
+
<?php } ?>
|
3200 |
+
<?php $wpadmin_allow_ips = UM()->options()->get( 'wpadmin_allow_ips' ); if( ! empty( $wpadmin_allow_ips ) ) { ?>
|
3201 |
+
Whitelisted Backend IPs: <?php echo count( explode("\n",trim(UM()->options()->get('wpadmin_allow_ips') ) ) )."\n"; ?>
|
3202 |
+
<?php } ?>
|
3203 |
+
<?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
|
3204 |
+
Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
|
3205 |
+
<?php } ?>
|
3206 |
+
<?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
|
3207 |
+
Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
|
3208 |
+
<?php } ?>
|
3209 |
+
<?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
|
3210 |
+
Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
|
3211 |
+
<?php } ?>
|
3212 |
+
|
3213 |
+
|
3214 |
+
--- UM Email Configurations ---
|
3215 |
+
|
3216 |
+
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";?>
|
3217 |
+
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";?>
|
3218 |
+
Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
|
3219 |
+
Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
|
3220 |
+
Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
|
3221 |
+
Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
|
3222 |
+
Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
|
3223 |
+
Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
|
3224 |
+
Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
|
3225 |
+
Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
|
3226 |
+
Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
|
3227 |
+
Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
|
3228 |
+
|
3229 |
+
|
3230 |
+
--- UM Total Users ---
|
3231 |
+
|
3232 |
+
<?php $result = count_users();
|
3233 |
+
echo 'All Users('.$result['total_users'].")\n";
|
3234 |
+
foreach( $result['avail_roles'] as $role => $count ) {
|
3235 |
+
echo $role."(".$count.")\n";
|
3236 |
+
} ?>
|
3237 |
+
|
3238 |
+
|
3239 |
+
--- UM Roles ---
|
3240 |
+
|
3241 |
+
<?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
|
3242 |
+
echo $role." ({$role_id})\n";
|
3243 |
+
} ?>
|
3244 |
+
|
3245 |
+
|
3246 |
+
--- UM Custom Templates ---
|
3247 |
+
|
3248 |
+
<?php // Show templates that have been copied to the theme's edd_templates dir
|
3249 |
+
$dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
|
3250 |
+
if ( ! empty( $dir ) ) {
|
3251 |
+
$found = glob( $dir );
|
3252 |
+
if ( ! empty( $found ) ) {
|
3253 |
+
foreach ( glob( $dir ) as $file ) {
|
3254 |
+
echo "File: " . $file . "\n";
|
3255 |
+
}
|
3256 |
+
} else {
|
3257 |
+
echo 'N/A'."\n";
|
3258 |
+
}
|
3259 |
+
} ?>
|
3260 |
+
|
3261 |
+
|
3262 |
+
--- UM Email HTML Templates ---
|
3263 |
+
|
3264 |
+
<?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
|
3265 |
+
|
3266 |
+
if ( ! empty( $dir ) ) {
|
3267 |
+
$found = glob( $dir );
|
3268 |
+
if ( ! empty( $found ) ){
|
3269 |
+
foreach ( glob( $dir ) as $file ) {
|
3270 |
+
echo "File: ". $file . "\n";
|
3271 |
+
}
|
3272 |
+
} else {
|
3273 |
+
echo 'N/A'."\n";
|
3274 |
+
}
|
3275 |
+
} ?>
|
3276 |
+
|
3277 |
+
|
3278 |
+
--- Web Server Configurations ---
|
3279 |
+
|
3280 |
+
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
|
3281 |
+
MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
|
3282 |
+
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
|
3283 |
+
|
3284 |
+
|
3285 |
+
--- PHP Configurations ---
|
3286 |
+
|
3287 |
+
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
|
3288 |
+
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3289 |
+
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
|
3290 |
+
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3291 |
+
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
|
3292 |
+
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
|
3293 |
+
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
|
3294 |
+
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
|
3295 |
+
|
3296 |
+
|
3297 |
+
--- Web Server Extensions/Modules ---
|
3298 |
+
|
3299 |
+
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
|
3300 |
+
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
|
3301 |
+
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
|
3302 |
+
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"; ?>
|
3303 |
+
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
|
3304 |
+
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"; ?>
|
3305 |
+
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"; ?>
|
3306 |
+
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"; ?>
|
3307 |
+
|
3308 |
+
|
3309 |
+
--- Session Configurations ---
|
3310 |
+
|
3311 |
+
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
|
3312 |
+
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
|
3313 |
+
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
|
3314 |
+
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
|
3315 |
+
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3316 |
+
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3317 |
+
|
3318 |
+
|
3319 |
+
--- WordPress Active Plugins ---
|
3320 |
+
|
3321 |
+
<?php $plugins = get_plugins();
|
3322 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
3323 |
+
|
3324 |
+
foreach ( $plugins as $plugin_path => $plugin ) {
|
3325 |
+
// If the plugin isn't active, don't show it.
|
3326 |
+
if ( ! in_array( $plugin_path, $active_plugins ) )
|
3327 |
+
continue;
|
3328 |
+
|
3329 |
+
echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
|
3330 |
+
}
|
3331 |
+
|
3332 |
+
if ( is_multisite() ) { ?>
|
3333 |
+
|
3334 |
+
--- WordPress Network Active Plugins ---
|
3335 |
+
|
3336 |
+
<?php $plugins = wp_get_active_network_plugins();
|
3337 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
3338 |
+
|
3339 |
+
foreach ( $plugins as $plugin_path ) {
|
3340 |
+
$plugin_base = plugin_basename( $plugin_path );
|
3341 |
+
|
3342 |
+
// If the plugin isn't active, don't show it.
|
3343 |
+
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
|
3344 |
+
continue;
|
3345 |
+
|
3346 |
+
$plugin = get_plugin_data( $plugin_path );
|
3347 |
+
|
3348 |
+
echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
|
3349 |
+
}
|
3350 |
+
|
3351 |
+
}
|
3352 |
+
|
3353 |
+
/**
|
3354 |
+
* UM hook
|
3355 |
+
*
|
3356 |
+
* @type action
|
3357 |
+
* @title um_install_info_after
|
3358 |
+
* @description After install info
|
3359 |
+
* @change_log
|
3360 |
+
* ["Since: 2.0"]
|
3361 |
+
* @usage add_action( 'um_install_info_after', 'function_name', 10 );
|
3362 |
+
* @example
|
3363 |
+
* <?php
|
3364 |
+
* add_action( 'um_install_info_after', 'my_install_info_after', 10 );
|
3365 |
+
* function my_install_info_after() {
|
3366 |
+
* // your code here
|
3367 |
+
* }
|
3368 |
+
* ?>
|
3369 |
+
*/
|
3370 |
+
do_action( 'um_install_info_after' ); ?>
|
3371 |
+
|
3372 |
+
### End Install Info ###
|
3373 |
+
</textarea>
|
3374 |
+
<p class="submit">
|
3375 |
+
<input type="hidden" name="um-addon-hook" value="download_install_info" />
|
3376 |
+
<?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
|
3377 |
+
</p>
|
3378 |
+
</form>
|
3379 |
+
|
3380 |
+
<?php }
|
3381 |
+
}
|
3382 |
+
|
3383 |
+
|
3384 |
+
/**
|
3385 |
+
*
|
3386 |
+
*/
|
3387 |
+
function um_download_install_info() {
|
3388 |
+
if ( ! empty( $_POST['download_install_info'] ) ) {
|
3389 |
+
nocache_headers();
|
3390 |
+
|
3391 |
+
header( "Content-type: text/plain" );
|
3392 |
+
header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
|
3393 |
+
|
3394 |
+
echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
|
3395 |
+
exit;
|
3396 |
+
}
|
3397 |
+
}
|
3398 |
+
|
3399 |
+
|
3400 |
+
/**
|
3401 |
+
* @param string $raw_value
|
3402 |
+
* @param string $type
|
3403 |
+
* @param string $default
|
3404 |
+
*
|
3405 |
+
* @return string
|
3406 |
+
*/
|
3407 |
+
function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
|
3408 |
+
|
3409 |
+
if ( $type == 'yesno' ) {
|
3410 |
+
$raw_value = ( $default == $raw_value ) ? "Yes" : "No";
|
3411 |
+
} elseif( $type == 'onoff' ) {
|
3412 |
+
$raw_value = ( $default == $raw_value ) ? "On" : "Off";
|
3413 |
+
}
|
3414 |
+
|
3415 |
+
return $raw_value."\n";
|
3416 |
+
}
|
3417 |
+
|
3418 |
+
|
3419 |
+
/**
|
3420 |
+
* Render settings section
|
3421 |
+
*
|
3422 |
+
* @param array $section_fields
|
3423 |
+
* @param string $current_tab
|
3424 |
+
* @param string $current_subtab
|
3425 |
+
*
|
3426 |
+
* @return string
|
3427 |
+
*/
|
3428 |
+
function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
|
3429 |
+
ob_start();
|
3430 |
+
|
3431 |
+
UM()->admin_forms_settings( array(
|
3432 |
+
'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
|
3433 |
+
'prefix_id' => 'um_options',
|
3434 |
+
'fields' => $section_fields
|
3435 |
+
) )->render_form(); ?>
|
3436 |
+
|
3437 |
+
<?php $section = ob_get_clean();
|
3438 |
+
|
3439 |
+
return $section;
|
3440 |
+
}
|
3441 |
+
|
3442 |
+
|
3443 |
+
/**
|
3444 |
+
* @param array $settings
|
3445 |
+
*
|
3446 |
+
* @return array
|
3447 |
+
*/
|
3448 |
+
function save_email_templates( $settings ) {
|
3449 |
+
|
3450 |
+
if ( empty( $settings['um_email_template'] ) ) {
|
3451 |
+
return $settings;
|
3452 |
+
}
|
3453 |
+
|
3454 |
+
$template = $settings['um_email_template'];
|
3455 |
+
$content = wp_kses_post( stripslashes( $settings[ $template ] ) );
|
3456 |
+
|
3457 |
+
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
|
3458 |
+
|
3459 |
+
if ( ! file_exists( $theme_template_path ) ) {
|
3460 |
+
UM()->mail()->copy_email_template( $template );
|
3461 |
+
}
|
3462 |
+
|
3463 |
+
$fp = fopen( $theme_template_path, "w" );
|
3464 |
+
$result = fputs( $fp, $content );
|
3465 |
+
fclose( $fp );
|
3466 |
+
|
3467 |
+
if ( $result !== false ) {
|
3468 |
+
unset( $settings['um_email_template'] );
|
3469 |
+
unset( $settings[ $template ] );
|
3470 |
+
}
|
3471 |
+
|
3472 |
+
return $settings;
|
3473 |
+
}
|
3474 |
+
}
|
3475 |
+
}
|
includes/admin/core/list-tables/roles-list-table.php
CHANGED
@@ -16,13 +16,15 @@ if ( isset( $_GET['action'] ) ) {
|
|
16 |
switch ( sanitize_key( $_GET['action'] ) ) {
|
17 |
/* delete action */
|
18 |
case 'delete': {
|
|
|
|
|
19 |
$role_keys = array();
|
20 |
if ( isset( $_REQUEST['id'] ) ) {
|
21 |
-
check_admin_referer( 'um_role_delete' .
|
22 |
-
$role_keys = (array)
|
23 |
} elseif ( isset( $_REQUEST['item'] ) ) {
|
24 |
check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
|
25 |
-
$role_keys = array_map( '
|
26 |
}
|
27 |
|
28 |
if ( ! count( $role_keys ) ) {
|
@@ -88,13 +90,15 @@ if ( isset( $_GET['action'] ) ) {
|
|
88 |
break;
|
89 |
}
|
90 |
case 'reset': {
|
|
|
|
|
91 |
$role_keys = array();
|
92 |
if ( isset( $_REQUEST['id'] ) ) {
|
93 |
-
check_admin_referer( 'um_role_reset' .
|
94 |
-
$role_keys = (array)
|
95 |
} elseif ( isset( $_REQUEST['item'] ) ) {
|
96 |
check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
|
97 |
-
$role_keys = array_map( '
|
98 |
}
|
99 |
|
100 |
if ( ! count( $role_keys ) ) {
|
@@ -342,22 +346,23 @@ class UM_Roles_List_Table extends WP_List_Table {
|
|
342 |
*/
|
343 |
function column_title( $item ) {
|
344 |
$actions = array();
|
|
|
|
|
|
|
345 |
|
346 |
-
$actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $
|
347 |
|
348 |
if ( ! empty( $item['_um_is_custom'] ) ) {
|
349 |
-
$actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . esc_attr( $
|
350 |
} else {
|
351 |
$role_meta = get_option( "um_role_{$item['key']}_meta" );
|
352 |
|
353 |
if ( ! empty( $role_meta ) ) {
|
354 |
-
$actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . esc_attr( $
|
355 |
}
|
356 |
}
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
|
361 |
}
|
362 |
|
363 |
|
16 |
switch ( sanitize_key( $_GET['action'] ) ) {
|
17 |
/* delete action */
|
18 |
case 'delete': {
|
19 |
+
// uses sanitize_title instead of sanitize_key for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906)
|
20 |
+
// roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID
|
21 |
$role_keys = array();
|
22 |
if ( isset( $_REQUEST['id'] ) ) {
|
23 |
+
check_admin_referer( 'um_role_delete' . sanitize_title( $_REQUEST['id'] ) . get_current_user_id() );
|
24 |
+
$role_keys = (array) sanitize_title( $_REQUEST['id'] );
|
25 |
} elseif ( isset( $_REQUEST['item'] ) ) {
|
26 |
check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
|
27 |
+
$role_keys = array_map( 'sanitize_title', $_REQUEST['item'] );
|
28 |
}
|
29 |
|
30 |
if ( ! count( $role_keys ) ) {
|
90 |
break;
|
91 |
}
|
92 |
case 'reset': {
|
93 |
+
// uses sanitize_title instead of sanitize_key for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906)
|
94 |
+
// roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID
|
95 |
$role_keys = array();
|
96 |
if ( isset( $_REQUEST['id'] ) ) {
|
97 |
+
check_admin_referer( 'um_role_reset' . sanitize_title( $_REQUEST['id'] ) . get_current_user_id() );
|
98 |
+
$role_keys = (array) sanitize_title( $_REQUEST['id'] );
|
99 |
} elseif ( isset( $_REQUEST['item'] ) ) {
|
100 |
check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
|
101 |
+
$role_keys = array_map( 'sanitize_title', $_REQUEST['item'] );
|
102 |
}
|
103 |
|
104 |
if ( ! count( $role_keys ) ) {
|
346 |
*/
|
347 |
function column_title( $item ) {
|
348 |
$actions = array();
|
349 |
+
// for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906)
|
350 |
+
// roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID
|
351 |
+
$id = urlencode( $item['key'] );
|
352 |
|
353 |
+
$actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $id ) . '">' . __( 'Edit', 'ultimate-member' ) . '</a>';
|
354 |
|
355 |
if ( ! empty( $item['_um_is_custom'] ) ) {
|
356 |
+
$actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . esc_attr( $id ) . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ) . '</a>';
|
357 |
} else {
|
358 |
$role_meta = get_option( "um_role_{$item['key']}_meta" );
|
359 |
|
360 |
if ( ! empty( $role_meta ) ) {
|
361 |
+
$actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . esc_attr( $id ) . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ) . '</a>';
|
362 |
}
|
363 |
}
|
364 |
|
365 |
+
return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $id ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
|
|
|
|
|
366 |
}
|
367 |
|
368 |
|
includes/admin/templates/access/restrict_content.php
CHANGED
@@ -96,7 +96,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
96 |
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
97 |
'1' => __( 'Redirect user', 'ultimate-member' ),
|
98 |
),
|
99 |
-
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ),
|
100 |
),
|
101 |
array(
|
102 |
'id' => '_um_restrict_by_custom_message',
|
96 |
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
97 |
'1' => __( 'Redirect user', 'ultimate-member' ),
|
98 |
),
|
99 |
+
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
100 |
),
|
101 |
array(
|
102 |
'id' => '_um_restrict_by_custom_message',
|
includes/admin/templates/role/role-edit.php
CHANGED
@@ -50,7 +50,9 @@ global $wp_roles;
|
|
50 |
|
51 |
if ( ! empty( $_GET['id'] ) ) {
|
52 |
|
53 |
-
|
|
|
|
|
54 |
|
55 |
$data = get_option( "um_role_{$role_id}_meta" );
|
56 |
|
@@ -88,7 +90,9 @@ if ( ! empty( $_POST['role'] ) ) {
|
|
88 |
$error .= __( 'Title is empty!', 'ultimate-member' ) . '<br />';
|
89 |
}
|
90 |
|
91 |
-
if ( preg_match( "
|
|
|
|
|
92 |
$id = sanitize_title( $data['name'] );
|
93 |
} else {
|
94 |
$auto_increment = UM()->options()->get( 'custom_roles_increment' );
|
@@ -96,9 +100,11 @@ if ( ! empty( $_POST['role'] ) ) {
|
|
96 |
$id = 'custom_role_' . $auto_increment;
|
97 |
}
|
98 |
|
99 |
-
$redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'
|
100 |
} elseif ( 'edit' === sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) {
|
101 |
-
|
|
|
|
|
102 |
|
103 |
$pre_role_meta = get_option( "um_role_{$id}_meta", array() );
|
104 |
if ( isset( $pre_role_meta['name'] ) ) {
|
50 |
|
51 |
if ( ! empty( $_GET['id'] ) ) {
|
52 |
|
53 |
+
// uses sanitize_title instead of sanitize_key for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906)
|
54 |
+
// roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID
|
55 |
+
$role_id = sanitize_title( $_GET['id'] );
|
56 |
|
57 |
$data = get_option( "um_role_{$role_id}_meta" );
|
58 |
|
90 |
$error .= __( 'Title is empty!', 'ultimate-member' ) . '<br />';
|
91 |
}
|
92 |
|
93 |
+
if ( preg_match( "/^[\p{Latin}\d\-_ ]+$/i", $data['name'] ) ) {
|
94 |
+
// uses sanitize_title instead of sanitize_key for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906)
|
95 |
+
// roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID
|
96 |
$id = sanitize_title( $data['name'] );
|
97 |
} else {
|
98 |
$auto_increment = UM()->options()->get( 'custom_roles_increment' );
|
100 |
$id = 'custom_role_' . $auto_increment;
|
101 |
}
|
102 |
|
103 |
+
$redirect = add_query_arg( array( 'page' => 'um_roles', 'tab' => 'edit', 'id' => $id, 'msg' => 'a' ), admin_url( 'admin.php' ) );
|
104 |
} elseif ( 'edit' === sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) {
|
105 |
+
// uses sanitize_title instead of sanitize_key for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906)
|
106 |
+
// roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID
|
107 |
+
$id = sanitize_title( $_GET['id'] );
|
108 |
|
109 |
$pre_role_meta = get_option( "um_role_{$id}_meta", array() );
|
110 |
if ( isset( $pre_role_meta['name'] ) ) {
|
includes/class-config.php
CHANGED
@@ -1,807 +1,809 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\Config' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Config
|
13 |
-
*
|
14 |
-
* Class with global variables for UM
|
15 |
-
*
|
16 |
-
* @package um
|
17 |
-
*/
|
18 |
-
class Config {
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @var array
|
23 |
-
*/
|
24 |
-
var $core_forms;
|
25 |
-
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
var $core_directories;
|
31 |
-
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @var mixed|void
|
35 |
-
*/
|
36 |
-
var $core_pages;
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @var array
|
41 |
-
*/
|
42 |
-
var $core_directory_meta = array();
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @var array
|
47 |
-
*/
|
48 |
-
var $core_global_meta_all;
|
49 |
-
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @var mixed|void
|
53 |
-
*/
|
54 |
-
var $core_form_meta_all;
|
55 |
-
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @var array
|
59 |
-
*/
|
60 |
-
var $core_form_meta = array();
|
61 |
-
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @var
|
65 |
-
*/
|
66 |
-
var $perms;
|
67 |
-
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @var
|
71 |
-
*/
|
72 |
-
var $nonadmin_perms;
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @var mixed|void
|
77 |
-
*/
|
78 |
-
var $email_notifications;
|
79 |
-
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @var mixed|void
|
83 |
-
*/
|
84 |
-
var $settings_defaults;
|
85 |
-
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @var array
|
89 |
-
*/
|
90 |
-
var $permalinks;
|
91 |
-
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Config constructor.
|
95 |
-
*/
|
96 |
-
function __construct() {
|
97 |
-
$this->core_forms = array(
|
98 |
-
'register',
|
99 |
-
'login',
|
100 |
-
'profile',
|
101 |
-
);
|
102 |
-
|
103 |
-
$this->core_directories = array(
|
104 |
-
'members',
|
105 |
-
);
|
106 |
-
|
107 |
-
|
108 |
-
/**
|
109 |
-
* UM hook
|
110 |
-
*
|
111 |
-
* @type filter
|
112 |
-
* @title um_core_pages
|
113 |
-
* @description Extend UM core pages
|
114 |
-
* @input_vars
|
115 |
-
* [{"var":"$pages","type":"array","desc":"UM core pages"}]
|
116 |
-
* @change_log
|
117 |
-
* ["Since: 2.0"]
|
118 |
-
* @usage
|
119 |
-
* <?php add_filter( 'um_core_pages', 'function_name', 10, 1 ); ?>
|
120 |
-
* @example
|
121 |
-
* <?php
|
122 |
-
* add_filter( 'um_core_pages', 'my_core_pages', 10, 1 );
|
123 |
-
* function my_core_pages( $pages ) {
|
124 |
-
* // your code here
|
125 |
-
* $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) );
|
126 |
-
* return $pages;
|
127 |
-
* }
|
128 |
-
* ?>
|
129 |
-
*/
|
130 |
-
$this->core_pages = apply_filters( 'um_core_pages', array(
|
131 |
-
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
132 |
-
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
133 |
-
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
134 |
-
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
135 |
-
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
136 |
-
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
137 |
-
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
138 |
-
) );
|
139 |
-
|
140 |
-
$this->core_directory_meta['members'] = array(
|
141 |
-
'_um_core' => 'members',
|
142 |
-
'_um_template' => 'members',
|
143 |
-
'_um_mode' => 'directory',
|
144 |
-
'_um_view_types' => array( 'grid' ),
|
145 |
-
'_um_default_view' => 'grid',
|
146 |
-
'_um_roles' => array(),
|
147 |
-
'_um_has_profile_photo' => 0,
|
148 |
-
'_um_has_cover_photo' => 0,
|
149 |
-
'_um_show_these_users' => '',
|
150 |
-
'_um_exclude_these_users' => '',
|
151 |
-
|
152 |
-
'_um_sortby' => 'user_registered_desc',
|
153 |
-
'_um_sortby_custom' => '',
|
154 |
-
'_um_sortby_custom_label' => '',
|
155 |
-
'_um_enable_sorting' => 0,
|
156 |
-
'_um_sorting_fields' => array(),
|
157 |
-
|
158 |
-
'_um_profile_photo' => '1',
|
159 |
-
'_um_cover_photos' => '1',
|
160 |
-
'_um_show_name' => '1',
|
161 |
-
'_um_show_tagline' => 0,
|
162 |
-
'_um_tagline_fields' => array(),
|
163 |
-
'_um_show_userinfo' => 0,
|
164 |
-
'_um_reveal_fields' => array(),
|
165 |
-
'_um_show_social' => 0,
|
166 |
-
'_um_userinfo_animate' => '1',
|
167 |
-
|
168 |
-
'_um_search' => 0,
|
169 |
-
'_um_roles_can_search' => array(),
|
170 |
-
'_um_filters' => 0,
|
171 |
-
'_um_roles_can_filter' => array(),
|
172 |
-
'_um_search_fields' => array(),
|
173 |
-
'_um_filters_expanded' => 0,
|
174 |
-
'_um_filters_is_collapsible' => 1,
|
175 |
-
'_um_search_filters' => array(),
|
176 |
-
|
177 |
-
'_um_must_search' => 0,
|
178 |
-
'_um_max_users' => '',
|
179 |
-
'_um_profiles_per_page' => 12,
|
180 |
-
'_um_profiles_per_page_mobile' => 6,
|
181 |
-
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
182 |
-
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
183 |
-
'_um_directory_no_users' => __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ),
|
184 |
-
);
|
185 |
-
|
186 |
-
$this->core_global_meta_all = array(
|
187 |
-
'_um_primary_btn_color',
|
188 |
-
'_um_primary_btn_hover',
|
189 |
-
'_um_primary_btn_text',
|
190 |
-
'_um_secondary_btn_color',
|
191 |
-
'_um_secondary_btn_hover',
|
192 |
-
'_um_secondary_btn_text',
|
193 |
-
'_um_form_border',
|
194 |
-
'_um_form_border_hover',
|
195 |
-
'_um_form_bg_color',
|
196 |
-
'_um_form_bg_color_focus',
|
197 |
-
'_um_form_placeholder',
|
198 |
-
'_um_form_icon_color',
|
199 |
-
'_um_form_asterisk_color',
|
200 |
-
'_um_form_field_label',
|
201 |
-
'_um_form_text_color',
|
202 |
-
'_um_active_color',
|
203 |
-
'_um_help_tip_color',
|
204 |
-
'_um_secondary_color',
|
205 |
-
);
|
206 |
-
|
207 |
-
|
208 |
-
/**
|
209 |
-
* UM hook
|
210 |
-
*
|
211 |
-
* @type filter
|
212 |
-
* @title um_core_form_meta_all
|
213 |
-
* @description Extend UM forms meta keys
|
214 |
-
* @input_vars
|
215 |
-
* [{"var":"$meta","type":"array","desc":"UM forms meta"}]
|
216 |
-
* @change_log
|
217 |
-
* ["Since: 2.0"]
|
218 |
-
* @usage
|
219 |
-
* <?php add_filter( 'um_core_form_meta_all', 'function_name', 10, 1 ); ?>
|
220 |
-
* @example
|
221 |
-
* <?php
|
222 |
-
* add_filter( 'um_core_form_meta_all', 'my_core_form_meta', 10, 1 );
|
223 |
-
* function my_core_form_meta( $meta ) {
|
224 |
-
* // your code here
|
225 |
-
* $meta['my_meta_key'] = 'my_meta_value';
|
226 |
-
* return $meta;
|
227 |
-
* }
|
228 |
-
* ?>
|
229 |
-
*/
|
230 |
-
$this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', array(
|
231 |
-
/*Profile Form*/
|
232 |
-
'_um_profile_show_name' => 1,
|
233 |
-
'_um_profile_show_social_links' => 0,
|
234 |
-
'_um_profile_show_bio' => 1,
|
235 |
-
'_um_profile_bio_maxchars' => 180,
|
236 |
-
'_um_profile_header_menu' => 'bc',
|
237 |
-
'_um_profile_empty_text' => 1,
|
238 |
-
'_um_profile_empty_text_emo' => 1,
|
239 |
-
'_um_profile_role' => array(),
|
240 |
-
'_um_profile_template' => 'profile',
|
241 |
-
'_um_profile_max_width' => '1000px',
|
242 |
-
'_um_profile_area_max_width' => '600px',
|
243 |
-
'_um_profile_align' => 'center',
|
244 |
-
'_um_profile_icons' => 'label',
|
245 |
-
'_um_profile_disable_photo_upload' => 0,
|
246 |
-
'_um_profile_photosize' => '190',
|
247 |
-
'_um_profile_cover_enabled' => 1,
|
248 |
-
'_um_profile_coversize' => 'original',
|
249 |
-
'_um_profile_cover_ratio' => '2.7:1',
|
250 |
-
'_um_profile_photocorner' => '1',
|
251 |
-
'_um_profile_header_bg' => '',
|
252 |
-
'_um_profile_primary_btn_word' => __( 'Update Profile', 'ultimate-member' ),
|
253 |
-
'_um_profile_secondary_btn' => '1',
|
254 |
-
'_um_profile_secondary_btn_word' => __( 'Cancel', 'ultimate-member' ),
|
255 |
-
|
256 |
-
/*Registration Form*/
|
257 |
-
'_um_register_role' => '0',
|
258 |
-
'_um_register_template' => 'register',
|
259 |
-
'_um_register_max_width' => '450px',
|
260 |
-
'_um_register_align' => 'center',
|
261 |
-
'_um_register_icons' => 'label',
|
262 |
-
'_um_register_primary_btn_word' => __( 'Register', 'ultimate-member' ),
|
263 |
-
'_um_register_secondary_btn' => 1,
|
264 |
-
'_um_register_secondary_btn_word' => __( 'Login', 'ultimate-member' ),
|
265 |
-
'_um_register_secondary_btn_url' => '',
|
266 |
-
|
267 |
-
/*Login Form*/
|
268 |
-
'_um_login_template' => 'login',
|
269 |
-
'_um_login_max_width' => '450px',
|
270 |
-
'_um_login_align' => 'center',
|
271 |
-
'_um_login_icons' => 'label',
|
272 |
-
'_um_login_primary_btn_word' => __( 'Login', 'ultimate-member' ),
|
273 |
-
'_um_login_forgot_pass_link' => 1,
|
274 |
-
'_um_login_show_rememberme' => 1,
|
275 |
-
'_um_login_secondary_btn' => 1,
|
276 |
-
'_um_login_secondary_btn_word' => __( 'Register', 'ultimate-member' ),
|
277 |
-
'_um_login_secondary_btn_url' => '',
|
278 |
-
|
279 |
-
/*Member Directory*/
|
280 |
-
'_um_directory_template' => 'members',
|
281 |
-
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
282 |
-
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
283 |
-
) );
|
284 |
-
|
285 |
-
$this->core_form_meta['register'] = array(
|
286 |
-
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"E-mail Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
287 |
-
'_um_mode' => 'register',
|
288 |
-
'_um_core' => 'register',
|
289 |
-
'_um_register_use_custom_settings' => 0,
|
290 |
-
);
|
291 |
-
|
292 |
-
$this->core_form_meta['login'] = array(
|
293 |
-
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or E-mail";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
294 |
-
'_um_mode' => 'login',
|
295 |
-
'_um_core' => 'login',
|
296 |
-
'_um_login_use_custom_settings' => 0,
|
297 |
-
);
|
298 |
-
|
299 |
-
$this->core_form_meta['profile'] = array(
|
300 |
-
'_um_custom_fields' => 'a:1:{s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
301 |
-
'_um_mode' => 'profile',
|
302 |
-
'_um_core' => 'profile',
|
303 |
-
'_um_profile_use_custom_settings' => 0,
|
304 |
-
);
|
305 |
-
|
306 |
-
|
307 |
-
/**
|
308 |
-
* UM hook
|
309 |
-
*
|
310 |
-
* @type filter
|
311 |
-
* @title um_email_notifications
|
312 |
-
* @description Extend UM email notifications
|
313 |
-
* @input_vars
|
314 |
-
* [{"var":"$emails","type":"array","desc":"UM email notifications"}]
|
315 |
-
* @change_log
|
316 |
-
* ["Since: 2.0"]
|
317 |
-
* @usage
|
318 |
-
* <?php add_filter( 'um_email_notifications', 'function_name', 10, 1 ); ?>
|
319 |
-
* @example
|
320 |
-
* <?php
|
321 |
-
* add_filter( 'um_email_notifications', 'my_email_notifications', 10, 1 );
|
322 |
-
* function my_email_notifications( $emails ) {
|
323 |
-
* // your code here
|
324 |
-
* $emails['my_email'] = array(
|
325 |
-
* 'key' => 'my_email',
|
326 |
-
* 'title' => __( 'my_email_title','ultimate-member' ),
|
327 |
-
* 'subject' => 'my_email_subject',
|
328 |
-
* 'body' => 'my_email_body',
|
329 |
-
* 'description' => 'my_email_description',
|
330 |
-
* 'recipient' => 'user', // set 'admin' for make administrator as recipient
|
331 |
-
* 'default_active' => true // can be false for make disabled by default
|
332 |
-
* );
|
333 |
-
*
|
334 |
-
* return $emails;
|
335 |
-
* }
|
336 |
-
* ?>
|
337 |
-
*/
|
338 |
-
$this->email_notifications = apply_filters( 'um_email_notifications', array(
|
339 |
-
'welcome_email' => array(
|
340 |
-
'key' => 'welcome_email',
|
341 |
-
'title' => __( 'Account Welcome Email','ultimate-member' ),
|
342 |
-
'subject' => 'Welcome to {site_name}!',
|
343 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
344 |
-
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
|
345 |
-
'To login please visit the following url:<br /><br />' .
|
346 |
-
'{login_url} <br /><br />' .
|
347 |
-
'Your account e-mail: {email} <br />' .
|
348 |
-
'Your account username: {username} <br /><br />' .
|
349 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
350 |
-
'Thanks,<br />' .
|
351 |
-
'{site_name}',
|
352 |
-
'description' => __('Whether to send the user an email when his account is automatically approved','ultimate-member'),
|
353 |
-
'recipient' => 'user',
|
354 |
-
'default_active' => true
|
355 |
-
),
|
356 |
-
'checkmail_email' => array(
|
357 |
-
'key' => 'checkmail_email',
|
358 |
-
'title' => __( 'Account Activation Email','ultimate-member' ),
|
359 |
-
'subject' => 'Please activate your account',
|
360 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
361 |
-
'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:<br /><br />' .
|
362 |
-
'{account_activation_link} <br /><br />' .
|
363 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
364 |
-
'Thanks, <br />' .
|
365 |
-
'{site_name}',
|
366 |
-
'description' => __('Whether to send the user an email when his account needs e-mail activation','ultimate-member'),
|
367 |
-
'recipient' => 'user'
|
368 |
-
),
|
369 |
-
'pending_email' => array(
|
370 |
-
'key' => 'pending_email',
|
371 |
-
'title' => __( 'Your account is pending review','ultimate-member' ),
|
372 |
-
'subject' => '[{site_name}] New user account',
|
373 |
-
'body' => 'Hi {display_name}, <br /><br />' .
|
374 |
-
'Thank you for signing up with {site_name}! Your account is currently being reviewed by a member of our team.<br /><br />' .
|
375 |
-
'Please allow us some time to process your request.<br /><br />' .
|
376 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
377 |
-
'Thanks,<br />' .
|
378 |
-
'{site_name}',
|
379 |
-
'description' => __('Whether to send the user an email when his account needs admin review','ultimate-member'),
|
380 |
-
'recipient' => 'user'
|
381 |
-
),
|
382 |
-
'approved_email' => array(
|
383 |
-
'key' => 'approved_email',
|
384 |
-
'title' => __( 'Account Approved Email','ultimate-member' ),
|
385 |
-
'subject' => 'Your account at {site_name} is now active',
|
386 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
387 |
-
'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
|
388 |
-
'To login please visit the following url:<br /><br />' .
|
389 |
-
'{login_url}<br /><br />' .
|
390 |
-
'Your account e-mail: {email}<br />' .
|
391 |
-
'Your account username: {username}<br />' .
|
392 |
-
'Set your account password: {password_reset_link}<br /><br />' .
|
393 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
394 |
-
'Thanks,<br />' .
|
395 |
-
'{site_name}',
|
396 |
-
'description' => __('Whether to send the user an email when his account is approved','ultimate-member'),
|
397 |
-
'recipient' => 'user'
|
398 |
-
),
|
399 |
-
'rejected_email' => array(
|
400 |
-
'key' => 'rejected_email',
|
401 |
-
'title' => __( 'Account Rejected Email','ultimate-member' ),
|
402 |
-
'subject' => 'Your account has been rejected',
|
403 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
404 |
-
'Thank you for applying for membership to {site_name}! We have reviewed your information and unfortunately we are unable to accept you as a member at this moment.<br /><br />' .
|
405 |
-
'Please feel free to apply again at a future date.<br /><br />' .
|
406 |
-
'Thanks,<br />' .
|
407 |
-
'{site_name}',
|
408 |
-
'description' => __('Whether to send the user an email when his account is rejected','ultimate-member'),
|
409 |
-
'recipient' => 'user'
|
410 |
-
),
|
411 |
-
'inactive_email' => array(
|
412 |
-
'key' => 'inactive_email',
|
413 |
-
'title' => __( 'Account Deactivated Email','ultimate-member' ),
|
414 |
-
'subject' => 'Your account has been deactivated',
|
415 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
416 |
-
'This is an automated email to let you know your {site_name} account has been deactivated.<br /><br />' .
|
417 |
-
'If you would like your account to be reactivated please contact us at {admin_email}<br /><br />' .
|
418 |
-
'Thanks,<br />' .
|
419 |
-
'{site_name}',
|
420 |
-
'description' => __('Whether to send the user an email when his account is deactivated','ultimate-member'),
|
421 |
-
'recipient' => 'user',
|
422 |
-
'default_active' => true
|
423 |
-
),
|
424 |
-
'deletion_email' => array(
|
425 |
-
'key' => 'deletion_email',
|
426 |
-
'title' => __( 'Account Deleted Email','ultimate-member' ),
|
427 |
-
'subject' => 'Your account has been deleted',
|
428 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
429 |
-
'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.<br /><br />' .
|
430 |
-
'If your account has been deleted by accident please contact us at {admin_email} <br />' .
|
431 |
-
'Thanks,<br />' .
|
432 |
-
'{site_name}',
|
433 |
-
'description' => __('Whether to send the user an email when his account is deleted','ultimate-member'),
|
434 |
-
'recipient' => 'user',
|
435 |
-
'default_active' => true
|
436 |
-
),
|
437 |
-
'resetpw_email' => array(
|
438 |
-
'key' => 'resetpw_email',
|
439 |
-
'title' => __( 'Password Reset Email','ultimate-member' ),
|
440 |
-
'subject' => 'Reset your password',
|
441 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
442 |
-
'We received a request to reset the password for your account. If you made this request, click the link below to change your password:<br /><br />' .
|
443 |
-
'{password_reset_link}<br /><br />' .
|
444 |
-
'If you didn\'t make this request, you can ignore this email <br /><br />' .
|
445 |
-
'Thanks,<br />' .
|
446 |
-
'{site_name}',
|
447 |
-
'description' => __('Whether to send an email when users changed their password (Recommended, please keep on)','ultimate-member'),
|
448 |
-
'recipient' => 'user',
|
449 |
-
'default_active' => true
|
450 |
-
),
|
451 |
-
'changedpw_email' => array(
|
452 |
-
'key' => 'changedpw_email',
|
453 |
-
'title' => __( 'Password Changed Email','ultimate-member' ),
|
454 |
-
'subject' => 'Your {site_name} password has been changed',
|
455 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
456 |
-
'You recently changed the password associated with your {site_name} account.<br /><br />' .
|
457 |
-
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
458 |
-
'Thanks,<br />' .
|
459 |
-
'{site_name}',
|
460 |
-
'description' => __('Whether to send the user an email when he request to reset password (Recommended, please keep on)','ultimate-member'),
|
461 |
-
'recipient' => 'user',
|
462 |
-
'default_active' => true
|
463 |
-
),
|
464 |
-
'changedaccount_email' => array(
|
465 |
-
'key' => 'changedaccount_email',
|
466 |
-
'title' => __( 'Account Updated Email','ultimate-member' ),
|
467 |
-
'subject' => 'Your account at {site_name} was updated',
|
468 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
469 |
-
'You recently updated your {site_name} account.<br /><br />' .
|
470 |
-
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
471 |
-
'Thanks,<br />' .
|
472 |
-
'{site_name}',
|
473 |
-
'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
|
474 |
-
'recipient' => 'user',
|
475 |
-
'default_active'=> true
|
476 |
-
),
|
477 |
-
'notification_new_user' => array(
|
478 |
-
'key' => 'notification_new_user',
|
479 |
-
'title' => __( 'New User Notification','ultimate-member' ),
|
480 |
-
'subject' => '[{site_name}] New user account',
|
481 |
-
'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:<br /><br />' .
|
482 |
-
'{user_profile_link}<br /><br />' .
|
483 |
-
'Here is the submitted registration form:<br /><br />' .
|
484 |
-
'{submitted_registration}',
|
485 |
-
'description' => __('Whether to receive notification when a new user account is approved','ultimate-member'),
|
486 |
-
'recipient' => 'admin',
|
487 |
-
'default_active' => true
|
488 |
-
),
|
489 |
-
'notification_review' => array(
|
490 |
-
'key' => 'notification_review',
|
491 |
-
'title' => __( 'Account Needs Review Notification','ultimate-member' ),
|
492 |
-
'subject' => '[{site_name}] New user awaiting review',
|
493 |
-
'body' => '{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.<br /><br />' .
|
494 |
-
'To review this member please click the following link:<br /><br />' .
|
495 |
-
'{user_profile_link}<br /><br />' .
|
496 |
-
'Here is the submitted registration form:<br /><br />' .
|
497 |
-
'{submitted_registration}',
|
498 |
-
'description' => __('Whether to receive notification when an account needs admin review','ultimate-member'),
|
499 |
-
'recipient' => 'admin'
|
500 |
-
),
|
501 |
-
'notification_deletion' => array(
|
502 |
-
'key' => 'notification_deletion',
|
503 |
-
'title' => __( 'Account Deletion Notification','ultimate-member' ),
|
504 |
-
'subject' => '[{site_name}] Account deleted',
|
505 |
-
'body' => '{display_name} has just deleted their {site_name} account.',
|
506 |
-
'description' => __('Whether to receive notification when an account is deleted','ultimate-member'),
|
507 |
-
'recipient' => 'admin'
|
508 |
-
)
|
509 |
-
) );
|
510 |
-
|
511 |
-
|
512 |
-
//settings defaults
|
513 |
-
$this->settings_defaults = array(
|
514 |
-
'restricted_access_post_metabox' => array( 'post' => 1, 'page' => 1 ),
|
515 |
-
'disable_restriction_pre_queries' => 0,
|
516 |
-
'uninstall_on_delete' => 0,
|
517 |
-
'permalink_base' => 'user_login',
|
518 |
-
'display_name' => 'full_name',
|
519 |
-
'display_name_field' => '',
|
520 |
-
'author_redirect' => 1,
|
521 |
-
'members_page' => 1,
|
522 |
-
'use_gravatars' => 0,
|
523 |
-
'use_um_gravatar_default_builtin_image' => 'default',
|
524 |
-
'use_um_gravatar_default_image' => 0,
|
525 |
-
'reset_require_strongpass' => 0,
|
526 |
-
'
|
527 |
-
'
|
528 |
-
'
|
529 |
-
'
|
530 |
-
'
|
531 |
-
'
|
532 |
-
'
|
533 |
-
'
|
534 |
-
'
|
535 |
-
'
|
536 |
-
'
|
537 |
-
'
|
538 |
-
'
|
539 |
-
'
|
540 |
-
'
|
541 |
-
'
|
542 |
-
'
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
'
|
547 |
-
'
|
548 |
-
'
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
'
|
554 |
-
'
|
555 |
-
'
|
556 |
-
'
|
557 |
-
'
|
558 |
-
'
|
559 |
-
'
|
560 |
-
'
|
561 |
-
'
|
562 |
-
'
|
563 |
-
'
|
564 |
-
'
|
565 |
-
'
|
566 |
-
'
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
'
|
571 |
-
'
|
572 |
-
'
|
573 |
-
'
|
574 |
-
'
|
575 |
-
'
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
'
|
583 |
-
'
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
$this->settings_defaults[ $key ] = $notification['
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
*
|
624 |
-
*
|
625 |
-
* @
|
626 |
-
* @
|
627 |
-
*
|
628 |
-
* @
|
629 |
-
* ["
|
630 |
-
* @
|
631 |
-
*
|
632 |
-
* @
|
633 |
-
* <?php
|
634 |
-
*
|
635 |
-
*
|
636 |
-
*
|
637 |
-
*
|
638 |
-
*
|
639 |
-
*
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
$this->
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
*
|
652 |
-
|
653 |
-
|
654 |
-
'
|
655 |
-
'
|
656 |
-
'
|
657 |
-
'
|
658 |
-
'
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
662 |
-
'
|
663 |
-
'
|
664 |
-
'
|
665 |
-
'
|
666 |
-
'
|
667 |
-
'
|
668 |
-
'
|
669 |
-
'
|
670 |
-
'
|
671 |
-
'
|
672 |
-
'
|
673 |
-
'
|
674 |
-
'
|
675 |
-
'
|
676 |
-
'
|
677 |
-
'
|
678 |
-
'
|
679 |
-
'
|
680 |
-
'
|
681 |
-
'
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
'
|
690 |
-
'
|
691 |
-
'
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
'
|
696 |
-
'
|
697 |
-
'
|
698 |
-
'
|
699 |
-
'
|
700 |
-
'
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
'
|
706 |
-
'
|
707 |
-
'
|
708 |
-
'
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
'
|
713 |
-
'
|
714 |
-
'
|
715 |
-
'
|
716 |
-
'
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
'
|
722 |
-
'
|
723 |
-
'
|
724 |
-
'
|
725 |
-
'
|
726 |
-
'
|
727 |
-
'
|
728 |
-
'
|
729 |
-
'
|
730 |
-
'
|
731 |
-
'
|
732 |
-
'
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
'
|
738 |
-
'
|
739 |
-
'
|
740 |
-
'
|
741 |
-
'
|
742 |
-
'
|
743 |
-
'
|
744 |
-
'
|
745 |
-
'
|
746 |
-
'
|
747 |
-
'
|
748 |
-
'
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
'
|
754 |
-
'
|
755 |
-
'
|
756 |
-
'
|
757 |
-
'
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
'
|
762 |
-
'
|
763 |
-
'
|
764 |
-
'
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
*
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
'
|
799 |
-
'
|
800 |
-
'
|
801 |
-
'
|
802 |
-
'
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\Config' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Config
|
13 |
+
*
|
14 |
+
* Class with global variables for UM
|
15 |
+
*
|
16 |
+
* @package um
|
17 |
+
*/
|
18 |
+
class Config {
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
var $core_forms;
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
var $core_directories;
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var mixed|void
|
35 |
+
*/
|
36 |
+
var $core_pages;
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
var $core_directory_meta = array();
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
var $core_global_meta_all;
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var mixed|void
|
53 |
+
*/
|
54 |
+
var $core_form_meta_all;
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
var $core_form_meta = array();
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @var
|
65 |
+
*/
|
66 |
+
var $perms;
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @var
|
71 |
+
*/
|
72 |
+
var $nonadmin_perms;
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @var mixed|void
|
77 |
+
*/
|
78 |
+
var $email_notifications;
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @var mixed|void
|
83 |
+
*/
|
84 |
+
var $settings_defaults;
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @var array
|
89 |
+
*/
|
90 |
+
var $permalinks;
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Config constructor.
|
95 |
+
*/
|
96 |
+
function __construct() {
|
97 |
+
$this->core_forms = array(
|
98 |
+
'register',
|
99 |
+
'login',
|
100 |
+
'profile',
|
101 |
+
);
|
102 |
+
|
103 |
+
$this->core_directories = array(
|
104 |
+
'members',
|
105 |
+
);
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* UM hook
|
110 |
+
*
|
111 |
+
* @type filter
|
112 |
+
* @title um_core_pages
|
113 |
+
* @description Extend UM core pages
|
114 |
+
* @input_vars
|
115 |
+
* [{"var":"$pages","type":"array","desc":"UM core pages"}]
|
116 |
+
* @change_log
|
117 |
+
* ["Since: 2.0"]
|
118 |
+
* @usage
|
119 |
+
* <?php add_filter( 'um_core_pages', 'function_name', 10, 1 ); ?>
|
120 |
+
* @example
|
121 |
+
* <?php
|
122 |
+
* add_filter( 'um_core_pages', 'my_core_pages', 10, 1 );
|
123 |
+
* function my_core_pages( $pages ) {
|
124 |
+
* // your code here
|
125 |
+
* $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) );
|
126 |
+
* return $pages;
|
127 |
+
* }
|
128 |
+
* ?>
|
129 |
+
*/
|
130 |
+
$this->core_pages = apply_filters( 'um_core_pages', array(
|
131 |
+
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
132 |
+
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
133 |
+
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
134 |
+
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
135 |
+
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
136 |
+
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
137 |
+
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
138 |
+
) );
|
139 |
+
|
140 |
+
$this->core_directory_meta['members'] = array(
|
141 |
+
'_um_core' => 'members',
|
142 |
+
'_um_template' => 'members',
|
143 |
+
'_um_mode' => 'directory',
|
144 |
+
'_um_view_types' => array( 'grid' ),
|
145 |
+
'_um_default_view' => 'grid',
|
146 |
+
'_um_roles' => array(),
|
147 |
+
'_um_has_profile_photo' => 0,
|
148 |
+
'_um_has_cover_photo' => 0,
|
149 |
+
'_um_show_these_users' => '',
|
150 |
+
'_um_exclude_these_users' => '',
|
151 |
+
|
152 |
+
'_um_sortby' => 'user_registered_desc',
|
153 |
+
'_um_sortby_custom' => '',
|
154 |
+
'_um_sortby_custom_label' => '',
|
155 |
+
'_um_enable_sorting' => 0,
|
156 |
+
'_um_sorting_fields' => array(),
|
157 |
+
|
158 |
+
'_um_profile_photo' => '1',
|
159 |
+
'_um_cover_photos' => '1',
|
160 |
+
'_um_show_name' => '1',
|
161 |
+
'_um_show_tagline' => 0,
|
162 |
+
'_um_tagline_fields' => array(),
|
163 |
+
'_um_show_userinfo' => 0,
|
164 |
+
'_um_reveal_fields' => array(),
|
165 |
+
'_um_show_social' => 0,
|
166 |
+
'_um_userinfo_animate' => '1',
|
167 |
+
|
168 |
+
'_um_search' => 0,
|
169 |
+
'_um_roles_can_search' => array(),
|
170 |
+
'_um_filters' => 0,
|
171 |
+
'_um_roles_can_filter' => array(),
|
172 |
+
'_um_search_fields' => array(),
|
173 |
+
'_um_filters_expanded' => 0,
|
174 |
+
'_um_filters_is_collapsible' => 1,
|
175 |
+
'_um_search_filters' => array(),
|
176 |
+
|
177 |
+
'_um_must_search' => 0,
|
178 |
+
'_um_max_users' => '',
|
179 |
+
'_um_profiles_per_page' => 12,
|
180 |
+
'_um_profiles_per_page_mobile' => 6,
|
181 |
+
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
182 |
+
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
183 |
+
'_um_directory_no_users' => __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ),
|
184 |
+
);
|
185 |
+
|
186 |
+
$this->core_global_meta_all = array(
|
187 |
+
'_um_primary_btn_color',
|
188 |
+
'_um_primary_btn_hover',
|
189 |
+
'_um_primary_btn_text',
|
190 |
+
'_um_secondary_btn_color',
|
191 |
+
'_um_secondary_btn_hover',
|
192 |
+
'_um_secondary_btn_text',
|
193 |
+
'_um_form_border',
|
194 |
+
'_um_form_border_hover',
|
195 |
+
'_um_form_bg_color',
|
196 |
+
'_um_form_bg_color_focus',
|
197 |
+
'_um_form_placeholder',
|
198 |
+
'_um_form_icon_color',
|
199 |
+
'_um_form_asterisk_color',
|
200 |
+
'_um_form_field_label',
|
201 |
+
'_um_form_text_color',
|
202 |
+
'_um_active_color',
|
203 |
+
'_um_help_tip_color',
|
204 |
+
'_um_secondary_color',
|
205 |
+
);
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* UM hook
|
210 |
+
*
|
211 |
+
* @type filter
|
212 |
+
* @title um_core_form_meta_all
|
213 |
+
* @description Extend UM forms meta keys
|
214 |
+
* @input_vars
|
215 |
+
* [{"var":"$meta","type":"array","desc":"UM forms meta"}]
|
216 |
+
* @change_log
|
217 |
+
* ["Since: 2.0"]
|
218 |
+
* @usage
|
219 |
+
* <?php add_filter( 'um_core_form_meta_all', 'function_name', 10, 1 ); ?>
|
220 |
+
* @example
|
221 |
+
* <?php
|
222 |
+
* add_filter( 'um_core_form_meta_all', 'my_core_form_meta', 10, 1 );
|
223 |
+
* function my_core_form_meta( $meta ) {
|
224 |
+
* // your code here
|
225 |
+
* $meta['my_meta_key'] = 'my_meta_value';
|
226 |
+
* return $meta;
|
227 |
+
* }
|
228 |
+
* ?>
|
229 |
+
*/
|
230 |
+
$this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', array(
|
231 |
+
/*Profile Form*/
|
232 |
+
'_um_profile_show_name' => 1,
|
233 |
+
'_um_profile_show_social_links' => 0,
|
234 |
+
'_um_profile_show_bio' => 1,
|
235 |
+
'_um_profile_bio_maxchars' => 180,
|
236 |
+
'_um_profile_header_menu' => 'bc',
|
237 |
+
'_um_profile_empty_text' => 1,
|
238 |
+
'_um_profile_empty_text_emo' => 1,
|
239 |
+
'_um_profile_role' => array(),
|
240 |
+
'_um_profile_template' => 'profile',
|
241 |
+
'_um_profile_max_width' => '1000px',
|
242 |
+
'_um_profile_area_max_width' => '600px',
|
243 |
+
'_um_profile_align' => 'center',
|
244 |
+
'_um_profile_icons' => 'label',
|
245 |
+
'_um_profile_disable_photo_upload' => 0,
|
246 |
+
'_um_profile_photosize' => '190',
|
247 |
+
'_um_profile_cover_enabled' => 1,
|
248 |
+
'_um_profile_coversize' => 'original',
|
249 |
+
'_um_profile_cover_ratio' => '2.7:1',
|
250 |
+
'_um_profile_photocorner' => '1',
|
251 |
+
'_um_profile_header_bg' => '',
|
252 |
+
'_um_profile_primary_btn_word' => __( 'Update Profile', 'ultimate-member' ),
|
253 |
+
'_um_profile_secondary_btn' => '1',
|
254 |
+
'_um_profile_secondary_btn_word' => __( 'Cancel', 'ultimate-member' ),
|
255 |
+
|
256 |
+
/*Registration Form*/
|
257 |
+
'_um_register_role' => '0',
|
258 |
+
'_um_register_template' => 'register',
|
259 |
+
'_um_register_max_width' => '450px',
|
260 |
+
'_um_register_align' => 'center',
|
261 |
+
'_um_register_icons' => 'label',
|
262 |
+
'_um_register_primary_btn_word' => __( 'Register', 'ultimate-member' ),
|
263 |
+
'_um_register_secondary_btn' => 1,
|
264 |
+
'_um_register_secondary_btn_word' => __( 'Login', 'ultimate-member' ),
|
265 |
+
'_um_register_secondary_btn_url' => '',
|
266 |
+
|
267 |
+
/*Login Form*/
|
268 |
+
'_um_login_template' => 'login',
|
269 |
+
'_um_login_max_width' => '450px',
|
270 |
+
'_um_login_align' => 'center',
|
271 |
+
'_um_login_icons' => 'label',
|
272 |
+
'_um_login_primary_btn_word' => __( 'Login', 'ultimate-member' ),
|
273 |
+
'_um_login_forgot_pass_link' => 1,
|
274 |
+
'_um_login_show_rememberme' => 1,
|
275 |
+
'_um_login_secondary_btn' => 1,
|
276 |
+
'_um_login_secondary_btn_word' => __( 'Register', 'ultimate-member' ),
|
277 |
+
'_um_login_secondary_btn_url' => '',
|
278 |
+
|
279 |
+
/*Member Directory*/
|
280 |
+
'_um_directory_template' => 'members',
|
281 |
+
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
282 |
+
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
283 |
+
) );
|
284 |
+
|
285 |
+
$this->core_form_meta['register'] = array(
|
286 |
+
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"E-mail Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
287 |
+
'_um_mode' => 'register',
|
288 |
+
'_um_core' => 'register',
|
289 |
+
'_um_register_use_custom_settings' => 0,
|
290 |
+
);
|
291 |
+
|
292 |
+
$this->core_form_meta['login'] = array(
|
293 |
+
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or E-mail";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
294 |
+
'_um_mode' => 'login',
|
295 |
+
'_um_core' => 'login',
|
296 |
+
'_um_login_use_custom_settings' => 0,
|
297 |
+
);
|
298 |
+
|
299 |
+
$this->core_form_meta['profile'] = array(
|
300 |
+
'_um_custom_fields' => 'a:1:{s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
301 |
+
'_um_mode' => 'profile',
|
302 |
+
'_um_core' => 'profile',
|
303 |
+
'_um_profile_use_custom_settings' => 0,
|
304 |
+
);
|
305 |
+
|
306 |
+
|
307 |
+
/**
|
308 |
+
* UM hook
|
309 |
+
*
|
310 |
+
* @type filter
|
311 |
+
* @title um_email_notifications
|
312 |
+
* @description Extend UM email notifications
|
313 |
+
* @input_vars
|
314 |
+
* [{"var":"$emails","type":"array","desc":"UM email notifications"}]
|
315 |
+
* @change_log
|
316 |
+
* ["Since: 2.0"]
|
317 |
+
* @usage
|
318 |
+
* <?php add_filter( 'um_email_notifications', 'function_name', 10, 1 ); ?>
|
319 |
+
* @example
|
320 |
+
* <?php
|
321 |
+
* add_filter( 'um_email_notifications', 'my_email_notifications', 10, 1 );
|
322 |
+
* function my_email_notifications( $emails ) {
|
323 |
+
* // your code here
|
324 |
+
* $emails['my_email'] = array(
|
325 |
+
* 'key' => 'my_email',
|
326 |
+
* 'title' => __( 'my_email_title','ultimate-member' ),
|
327 |
+
* 'subject' => 'my_email_subject',
|
328 |
+
* 'body' => 'my_email_body',
|
329 |
+
* 'description' => 'my_email_description',
|
330 |
+
* 'recipient' => 'user', // set 'admin' for make administrator as recipient
|
331 |
+
* 'default_active' => true // can be false for make disabled by default
|
332 |
+
* );
|
333 |
+
*
|
334 |
+
* return $emails;
|
335 |
+
* }
|
336 |
+
* ?>
|
337 |
+
*/
|
338 |
+
$this->email_notifications = apply_filters( 'um_email_notifications', array(
|
339 |
+
'welcome_email' => array(
|
340 |
+
'key' => 'welcome_email',
|
341 |
+
'title' => __( 'Account Welcome Email','ultimate-member' ),
|
342 |
+
'subject' => 'Welcome to {site_name}!',
|
343 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
344 |
+
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
|
345 |
+
'To login please visit the following url:<br /><br />' .
|
346 |
+
'{login_url} <br /><br />' .
|
347 |
+
'Your account e-mail: {email} <br />' .
|
348 |
+
'Your account username: {username} <br /><br />' .
|
349 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
350 |
+
'Thanks,<br />' .
|
351 |
+
'{site_name}',
|
352 |
+
'description' => __('Whether to send the user an email when his account is automatically approved','ultimate-member'),
|
353 |
+
'recipient' => 'user',
|
354 |
+
'default_active' => true
|
355 |
+
),
|
356 |
+
'checkmail_email' => array(
|
357 |
+
'key' => 'checkmail_email',
|
358 |
+
'title' => __( 'Account Activation Email','ultimate-member' ),
|
359 |
+
'subject' => 'Please activate your account',
|
360 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
361 |
+
'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:<br /><br />' .
|
362 |
+
'{account_activation_link} <br /><br />' .
|
363 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
364 |
+
'Thanks, <br />' .
|
365 |
+
'{site_name}',
|
366 |
+
'description' => __('Whether to send the user an email when his account needs e-mail activation','ultimate-member'),
|
367 |
+
'recipient' => 'user'
|
368 |
+
),
|
369 |
+
'pending_email' => array(
|
370 |
+
'key' => 'pending_email',
|
371 |
+
'title' => __( 'Your account is pending review','ultimate-member' ),
|
372 |
+
'subject' => '[{site_name}] New user account',
|
373 |
+
'body' => 'Hi {display_name}, <br /><br />' .
|
374 |
+
'Thank you for signing up with {site_name}! Your account is currently being reviewed by a member of our team.<br /><br />' .
|
375 |
+
'Please allow us some time to process your request.<br /><br />' .
|
376 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
377 |
+
'Thanks,<br />' .
|
378 |
+
'{site_name}',
|
379 |
+
'description' => __('Whether to send the user an email when his account needs admin review','ultimate-member'),
|
380 |
+
'recipient' => 'user'
|
381 |
+
),
|
382 |
+
'approved_email' => array(
|
383 |
+
'key' => 'approved_email',
|
384 |
+
'title' => __( 'Account Approved Email','ultimate-member' ),
|
385 |
+
'subject' => 'Your account at {site_name} is now active',
|
386 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
387 |
+
'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
|
388 |
+
'To login please visit the following url:<br /><br />' .
|
389 |
+
'{login_url}<br /><br />' .
|
390 |
+
'Your account e-mail: {email}<br />' .
|
391 |
+
'Your account username: {username}<br />' .
|
392 |
+
'Set your account password: {password_reset_link}<br /><br />' .
|
393 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
394 |
+
'Thanks,<br />' .
|
395 |
+
'{site_name}',
|
396 |
+
'description' => __('Whether to send the user an email when his account is approved','ultimate-member'),
|
397 |
+
'recipient' => 'user'
|
398 |
+
),
|
399 |
+
'rejected_email' => array(
|
400 |
+
'key' => 'rejected_email',
|
401 |
+
'title' => __( 'Account Rejected Email','ultimate-member' ),
|
402 |
+
'subject' => 'Your account has been rejected',
|
403 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
404 |
+
'Thank you for applying for membership to {site_name}! We have reviewed your information and unfortunately we are unable to accept you as a member at this moment.<br /><br />' .
|
405 |
+
'Please feel free to apply again at a future date.<br /><br />' .
|
406 |
+
'Thanks,<br />' .
|
407 |
+
'{site_name}',
|
408 |
+
'description' => __('Whether to send the user an email when his account is rejected','ultimate-member'),
|
409 |
+
'recipient' => 'user'
|
410 |
+
),
|
411 |
+
'inactive_email' => array(
|
412 |
+
'key' => 'inactive_email',
|
413 |
+
'title' => __( 'Account Deactivated Email','ultimate-member' ),
|
414 |
+
'subject' => 'Your account has been deactivated',
|
415 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
416 |
+
'This is an automated email to let you know your {site_name} account has been deactivated.<br /><br />' .
|
417 |
+
'If you would like your account to be reactivated please contact us at {admin_email}<br /><br />' .
|
418 |
+
'Thanks,<br />' .
|
419 |
+
'{site_name}',
|
420 |
+
'description' => __('Whether to send the user an email when his account is deactivated','ultimate-member'),
|
421 |
+
'recipient' => 'user',
|
422 |
+
'default_active' => true
|
423 |
+
),
|
424 |
+
'deletion_email' => array(
|
425 |
+
'key' => 'deletion_email',
|
426 |
+
'title' => __( 'Account Deleted Email','ultimate-member' ),
|
427 |
+
'subject' => 'Your account has been deleted',
|
428 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
429 |
+
'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.<br /><br />' .
|
430 |
+
'If your account has been deleted by accident please contact us at {admin_email} <br />' .
|
431 |
+
'Thanks,<br />' .
|
432 |
+
'{site_name}',
|
433 |
+
'description' => __('Whether to send the user an email when his account is deleted','ultimate-member'),
|
434 |
+
'recipient' => 'user',
|
435 |
+
'default_active' => true
|
436 |
+
),
|
437 |
+
'resetpw_email' => array(
|
438 |
+
'key' => 'resetpw_email',
|
439 |
+
'title' => __( 'Password Reset Email','ultimate-member' ),
|
440 |
+
'subject' => 'Reset your password',
|
441 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
442 |
+
'We received a request to reset the password for your account. If you made this request, click the link below to change your password:<br /><br />' .
|
443 |
+
'{password_reset_link}<br /><br />' .
|
444 |
+
'If you didn\'t make this request, you can ignore this email <br /><br />' .
|
445 |
+
'Thanks,<br />' .
|
446 |
+
'{site_name}',
|
447 |
+
'description' => __('Whether to send an email when users changed their password (Recommended, please keep on)','ultimate-member'),
|
448 |
+
'recipient' => 'user',
|
449 |
+
'default_active' => true
|
450 |
+
),
|
451 |
+
'changedpw_email' => array(
|
452 |
+
'key' => 'changedpw_email',
|
453 |
+
'title' => __( 'Password Changed Email','ultimate-member' ),
|
454 |
+
'subject' => 'Your {site_name} password has been changed',
|
455 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
456 |
+
'You recently changed the password associated with your {site_name} account.<br /><br />' .
|
457 |
+
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
458 |
+
'Thanks,<br />' .
|
459 |
+
'{site_name}',
|
460 |
+
'description' => __('Whether to send the user an email when he request to reset password (Recommended, please keep on)','ultimate-member'),
|
461 |
+
'recipient' => 'user',
|
462 |
+
'default_active' => true
|
463 |
+
),
|
464 |
+
'changedaccount_email' => array(
|
465 |
+
'key' => 'changedaccount_email',
|
466 |
+
'title' => __( 'Account Updated Email','ultimate-member' ),
|
467 |
+
'subject' => 'Your account at {site_name} was updated',
|
468 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
469 |
+
'You recently updated your {site_name} account.<br /><br />' .
|
470 |
+
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
471 |
+
'Thanks,<br />' .
|
472 |
+
'{site_name}',
|
473 |
+
'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
|
474 |
+
'recipient' => 'user',
|
475 |
+
'default_active'=> true
|
476 |
+
),
|
477 |
+
'notification_new_user' => array(
|
478 |
+
'key' => 'notification_new_user',
|
479 |
+
'title' => __( 'New User Notification','ultimate-member' ),
|
480 |
+
'subject' => '[{site_name}] New user account',
|
481 |
+
'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:<br /><br />' .
|
482 |
+
'{user_profile_link}<br /><br />' .
|
483 |
+
'Here is the submitted registration form:<br /><br />' .
|
484 |
+
'{submitted_registration}',
|
485 |
+
'description' => __('Whether to receive notification when a new user account is approved','ultimate-member'),
|
486 |
+
'recipient' => 'admin',
|
487 |
+
'default_active' => true
|
488 |
+
),
|
489 |
+
'notification_review' => array(
|
490 |
+
'key' => 'notification_review',
|
491 |
+
'title' => __( 'Account Needs Review Notification','ultimate-member' ),
|
492 |
+
'subject' => '[{site_name}] New user awaiting review',
|
493 |
+
'body' => '{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.<br /><br />' .
|
494 |
+
'To review this member please click the following link:<br /><br />' .
|
495 |
+
'{user_profile_link}<br /><br />' .
|
496 |
+
'Here is the submitted registration form:<br /><br />' .
|
497 |
+
'{submitted_registration}',
|
498 |
+
'description' => __('Whether to receive notification when an account needs admin review','ultimate-member'),
|
499 |
+
'recipient' => 'admin'
|
500 |
+
),
|
501 |
+
'notification_deletion' => array(
|
502 |
+
'key' => 'notification_deletion',
|
503 |
+
'title' => __( 'Account Deletion Notification','ultimate-member' ),
|
504 |
+
'subject' => '[{site_name}] Account deleted',
|
505 |
+
'body' => '{display_name} has just deleted their {site_name} account.',
|
506 |
+
'description' => __('Whether to receive notification when an account is deleted','ultimate-member'),
|
507 |
+
'recipient' => 'admin'
|
508 |
+
)
|
509 |
+
) );
|
510 |
+
|
511 |
+
|
512 |
+
//settings defaults
|
513 |
+
$this->settings_defaults = array(
|
514 |
+
'restricted_access_post_metabox' => array( 'post' => 1, 'page' => 1 ),
|
515 |
+
'disable_restriction_pre_queries' => 0,
|
516 |
+
'uninstall_on_delete' => 0,
|
517 |
+
'permalink_base' => 'user_login',
|
518 |
+
'display_name' => 'full_name',
|
519 |
+
'display_name_field' => '',
|
520 |
+
'author_redirect' => 1,
|
521 |
+
'members_page' => 1,
|
522 |
+
'use_gravatars' => 0,
|
523 |
+
'use_um_gravatar_default_builtin_image' => 'default',
|
524 |
+
'use_um_gravatar_default_image' => 0,
|
525 |
+
'reset_require_strongpass' => 0,
|
526 |
+
'password_min_chars' => 8,
|
527 |
+
'password_max_chars' => 30,
|
528 |
+
'account_tab_password' => 1,
|
529 |
+
'account_tab_privacy' => 1,
|
530 |
+
'account_tab_notifications' => 1,
|
531 |
+
'account_tab_delete' => 1,
|
532 |
+
'delete_account_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account enter your password below.', 'ultimate-member' ),
|
533 |
+
'delete_account_no_pass_required_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account, click on the button below.', 'ultimate-member' ),
|
534 |
+
'account_name' => 1,
|
535 |
+
'account_name_disable' => 0,
|
536 |
+
'account_name_require' => 1,
|
537 |
+
'account_email' => 1,
|
538 |
+
'account_general_password' => 0,
|
539 |
+
'account_hide_in_directory' => 1,
|
540 |
+
'account_hide_in_directory_default' => 'No',
|
541 |
+
'account_require_strongpass' => 0,
|
542 |
+
'photo_thumb_sizes' => array( 40, 80, 190 ),
|
543 |
+
'cover_thumb_sizes' => array( 300, 600 ),
|
544 |
+
'accessible' => 0,
|
545 |
+
'access_redirect' => '',
|
546 |
+
'access_exclude_uris' => array(),
|
547 |
+
'home_page_accessible' => 1,
|
548 |
+
'category_page_accessible' => 1,
|
549 |
+
'restricted_post_title_replace' => 1,
|
550 |
+
'restricted_access_post_title' => __( 'Restricted content', 'ultimate-member' ),
|
551 |
+
'restricted_access_message' => '',
|
552 |
+
'restricted_blocks' => 0,
|
553 |
+
'enable_blocks' => 0,
|
554 |
+
'restricted_block_message' => '',
|
555 |
+
'enable_reset_password_limit' => 1,
|
556 |
+
'reset_password_limit_number' => 3,
|
557 |
+
'blocked_emails' => '',
|
558 |
+
'blocked_words' => 'admin' . "\r\n" . 'administrator' . "\r\n" . 'webmaster' . "\r\n" . 'support' . "\r\n" . 'staff',
|
559 |
+
'default_avatar' => '',
|
560 |
+
'default_cover' => '',
|
561 |
+
'disable_profile_photo_upload' => 0,
|
562 |
+
'profile_show_metaicon' => 0,
|
563 |
+
'profile_menu' => 1,
|
564 |
+
'profile_menu_default_tab' => 'main',
|
565 |
+
'profile_menu_icons' => 1,
|
566 |
+
'form_asterisk' => 0,
|
567 |
+
'profile_title' => '{display_name} | {site_name}',
|
568 |
+
'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile',
|
569 |
+
'admin_email' => get_bloginfo('admin_email'),
|
570 |
+
'mail_from' => get_bloginfo('name'),
|
571 |
+
'mail_from_addr' => get_bloginfo('admin_email'),
|
572 |
+
'email_html' => 1,
|
573 |
+
'image_orientation_by_exif' => 0,
|
574 |
+
'image_compression' => 60,
|
575 |
+
'image_max_width' => 1000,
|
576 |
+
'cover_min_width' => 1000,
|
577 |
+
'profile_photo_max_size' => 999999999,
|
578 |
+
'cover_photo_max_size' => 999999999,
|
579 |
+
'custom_roles_increment' => 1,
|
580 |
+
'um_profile_object_cache_stop' => 0,
|
581 |
+
'rest_api_version' => '2.0',
|
582 |
+
'member_directory_own_table' => 0,
|
583 |
+
'profile_show_html_bio' => 0,
|
584 |
+
'profile_noindex' => 0,
|
585 |
+
'activation_link_expiry_time' => '',
|
586 |
+
);
|
587 |
+
|
588 |
+
add_filter( 'um_get_tabs_from_config', '__return_true' );
|
589 |
+
|
590 |
+
$tabs = UM()->profile()->tabs();
|
591 |
+
|
592 |
+
foreach ( $tabs as $id => $tab ) {
|
593 |
+
|
594 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
595 |
+
continue;
|
596 |
+
}
|
597 |
+
|
598 |
+
$this->settings_defaults[ 'profile_tab_' . $id ] = 1;
|
599 |
+
|
600 |
+
if ( ! isset( $tab['default_privacy'] ) ) {
|
601 |
+
$this->settings_defaults[ 'profile_tab_' . $id . '_privacy' ] = 0;
|
602 |
+
$this->settings_defaults[ 'profile_tab_' . $id . '_roles' ] = '';
|
603 |
+
}
|
604 |
+
}
|
605 |
+
|
606 |
+
foreach ( $this->email_notifications as $key => $notification ) {
|
607 |
+
$this->settings_defaults[ $key . '_on' ] = ! empty( $notification['default_active'] );
|
608 |
+
$this->settings_defaults[ $key . '_sub' ] = $notification['subject'];
|
609 |
+
$this->settings_defaults[ $key ] = $notification['body'];
|
610 |
+
}
|
611 |
+
|
612 |
+
foreach ( $this->core_pages as $page_s => $page ) {
|
613 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
614 |
+
$this->settings_defaults[ $page_id ] = '';
|
615 |
+
}
|
616 |
+
|
617 |
+
foreach( $this->core_form_meta_all as $key => $value ) {
|
618 |
+
$this->settings_defaults[ str_replace( '_um_', '', $key ) ] = $value;
|
619 |
+
}
|
620 |
+
|
621 |
+
|
622 |
+
/**
|
623 |
+
* UM hook
|
624 |
+
*
|
625 |
+
* @type filter
|
626 |
+
* @title um_default_settings_values
|
627 |
+
* @description Extend UM default settings
|
628 |
+
* @input_vars
|
629 |
+
* [{"var":"$settings","type":"array","desc":"UM default settings"}]
|
630 |
+
* @change_log
|
631 |
+
* ["Since: 2.0"]
|
632 |
+
* @usage
|
633 |
+
* <?php add_filter( 'um_default_settings_values', 'function_name', 10, 1 ); ?>
|
634 |
+
* @example
|
635 |
+
* <?php
|
636 |
+
* add_filter( 'um_default_settings_values', 'my_default_settings_values', 10, 1 );
|
637 |
+
* function my_default_settings_values( $settings ) {
|
638 |
+
* // your code here
|
639 |
+
* return $settings;
|
640 |
+
* }
|
641 |
+
* ?>
|
642 |
+
*/
|
643 |
+
$this->settings_defaults = apply_filters( 'um_default_settings_values', $this->settings_defaults );
|
644 |
+
|
645 |
+
$this->permalinks = $this->get_core_pages();
|
646 |
+
|
647 |
+
|
648 |
+
|
649 |
+
$this->default_roles_metadata = array(
|
650 |
+
/*
|
651 |
+
* All caps map
|
652 |
+
*
|
653 |
+
* '_um_can_access_wpadmin' => 1,
|
654 |
+
'_um_can_not_see_adminbar' => 0,
|
655 |
+
'_um_can_edit_everyone' => 1,
|
656 |
+
'_um_can_edit_roles' => '',
|
657 |
+
'_um_can_delete_everyone' => 1,
|
658 |
+
'_um_can_delete_roles' => '',
|
659 |
+
'_um_after_delete' => '',
|
660 |
+
'_um_delete_redirect_url' => '',
|
661 |
+
'_um_can_edit_profile' => 1,
|
662 |
+
'_um_can_delete_profile' => 1,
|
663 |
+
'_um_default_homepage' => 1,
|
664 |
+
'_um_redirect_homepage' => '',
|
665 |
+
'_um_after_login' => 'redirect_admin',
|
666 |
+
'_um_login_redirect_url' => '',
|
667 |
+
'_um_after_logout' => 'redirect_home',
|
668 |
+
'_um_logout_redirect_url' => '',
|
669 |
+
'_um_can_view_all' => 1,
|
670 |
+
'_um_can_view_roles' => '',
|
671 |
+
'_um_can_make_private_profile' => 1,
|
672 |
+
'_um_can_access_private_profile' => 1,
|
673 |
+
'_um_status' => 'approved',
|
674 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
675 |
+
'_um_auto_approve_url' => '',
|
676 |
+
'_um_login_email_activate' => '',
|
677 |
+
'_um_checkmail_action' => '',
|
678 |
+
'_um_checkmail_message' => '',
|
679 |
+
'_um_checkmail_url' => '',
|
680 |
+
'_um_url_email_activate' => '',
|
681 |
+
'_um_pending_action' => '',
|
682 |
+
'_um_pending_message' => '',
|
683 |
+
'_um_pending_url' => '',
|
684 |
+
*
|
685 |
+
* */
|
686 |
+
|
687 |
+
|
688 |
+
'subscriber' => array(
|
689 |
+
'_um_can_access_wpadmin' => 0,
|
690 |
+
'_um_can_not_see_adminbar' => 1,
|
691 |
+
'_um_can_edit_everyone' => 0,
|
692 |
+
'_um_can_delete_everyone' => 0,
|
693 |
+
'_um_can_edit_profile' => 1,
|
694 |
+
'_um_can_delete_profile' => 1,
|
695 |
+
'_um_after_login' => 'redirect_profile',
|
696 |
+
'_um_after_logout' => 'redirect_home',
|
697 |
+
'_um_default_homepage' => 1,
|
698 |
+
'_um_can_view_all' => 1,
|
699 |
+
'_um_can_make_private_profile' => 0,
|
700 |
+
'_um_can_access_private_profile' => 0,
|
701 |
+
'_um_status' => 'approved',
|
702 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
703 |
+
),
|
704 |
+
'author' => array(
|
705 |
+
'_um_can_access_wpadmin' => 0,
|
706 |
+
'_um_can_not_see_adminbar' => 1,
|
707 |
+
'_um_can_edit_everyone' => 0,
|
708 |
+
'_um_can_delete_everyone' => 0,
|
709 |
+
'_um_can_edit_profile' => 1,
|
710 |
+
'_um_can_delete_profile' => 1,
|
711 |
+
'_um_after_login' => 'redirect_profile',
|
712 |
+
'_um_after_logout' => 'redirect_home',
|
713 |
+
'_um_default_homepage' => 1,
|
714 |
+
'_um_can_view_all' => 1,
|
715 |
+
'_um_can_make_private_profile' => 0,
|
716 |
+
'_um_can_access_private_profile' => 0,
|
717 |
+
'_um_status' => 'approved',
|
718 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
719 |
+
),
|
720 |
+
'contributor' => array(
|
721 |
+
'_um_can_access_wpadmin' => 0,
|
722 |
+
'_um_can_not_see_adminbar' => 1,
|
723 |
+
'_um_can_edit_everyone' => 0,
|
724 |
+
'_um_can_delete_everyone' => 0,
|
725 |
+
'_um_can_edit_profile' => 1,
|
726 |
+
'_um_can_delete_profile' => 1,
|
727 |
+
'_um_after_login' => 'redirect_profile',
|
728 |
+
'_um_after_logout' => 'redirect_home',
|
729 |
+
'_um_default_homepage' => 1,
|
730 |
+
'_um_can_view_all' => 1,
|
731 |
+
'_um_can_make_private_profile' => 0,
|
732 |
+
'_um_can_access_private_profile' => 0,
|
733 |
+
'_um_status' => 'approved',
|
734 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
735 |
+
),
|
736 |
+
'editor' => array(
|
737 |
+
'_um_can_access_wpadmin' => 0,
|
738 |
+
'_um_can_not_see_adminbar' => 1,
|
739 |
+
'_um_can_edit_everyone' => 0,
|
740 |
+
'_um_can_delete_everyone' => 0,
|
741 |
+
'_um_can_edit_profile' => 1,
|
742 |
+
'_um_can_delete_profile' => 1,
|
743 |
+
'_um_after_login' => 'redirect_profile',
|
744 |
+
'_um_after_logout' => 'redirect_home',
|
745 |
+
'_um_default_homepage' => 1,
|
746 |
+
'_um_can_view_all' => 1,
|
747 |
+
'_um_can_make_private_profile' => 0,
|
748 |
+
'_um_can_access_private_profile' => 0,
|
749 |
+
'_um_status' => 'approved',
|
750 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
751 |
+
),
|
752 |
+
'administrator' => array(
|
753 |
+
'_um_can_access_wpadmin' => 1,
|
754 |
+
'_um_can_not_see_adminbar' => 0,
|
755 |
+
'_um_can_edit_everyone' => 1,
|
756 |
+
'_um_can_delete_everyone' => 1,
|
757 |
+
'_um_can_edit_profile' => 1,
|
758 |
+
'_um_can_delete_profile' => 1,
|
759 |
+
'_um_default_homepage' => 1,
|
760 |
+
'_um_after_login' => 'redirect_admin',
|
761 |
+
'_um_after_logout' => 'redirect_home',
|
762 |
+
'_um_can_view_all' => 1,
|
763 |
+
'_um_can_make_private_profile' => 1,
|
764 |
+
'_um_can_access_private_profile' => 1,
|
765 |
+
'_um_status' => 'approved',
|
766 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
767 |
+
),
|
768 |
+
);
|
769 |
+
}
|
770 |
+
|
771 |
+
|
772 |
+
/**
|
773 |
+
* Get UM Pages
|
774 |
+
*
|
775 |
+
* @return array
|
776 |
+
*/
|
777 |
+
function get_core_pages() {
|
778 |
+
$permalink = array();
|
779 |
+
$core_pages = array_keys( $this->core_pages );
|
780 |
+
if ( empty( $core_pages ) ) {
|
781 |
+
return $permalink;
|
782 |
+
}
|
783 |
+
|
784 |
+
foreach ( $core_pages as $page_key ) {
|
785 |
+
$page_option_key = UM()->options()->get_core_page_id( $page_key );
|
786 |
+
$permalink[ $page_key ] = UM()->options()->get( $page_option_key );
|
787 |
+
}
|
788 |
+
|
789 |
+
return $permalink;
|
790 |
+
}
|
791 |
+
|
792 |
+
|
793 |
+
/**
|
794 |
+
* @todo make config class not cycled
|
795 |
+
*/
|
796 |
+
function set_core_page() {
|
797 |
+
$this->core_pages = apply_filters( 'um_core_pages', array(
|
798 |
+
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
799 |
+
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
800 |
+
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
801 |
+
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
802 |
+
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
803 |
+
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
804 |
+
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
805 |
+
) );
|
806 |
+
}
|
807 |
+
//end class
|
808 |
+
}
|
809 |
+
}
|
includes/class-functions.php
CHANGED
@@ -1,395 +1,410 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
-
|
3 |
-
|
4 |
-
if ( ! class_exists( 'UM_Functions' ) ) {
|
5 |
-
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class UM_Functions
|
9 |
-
*/
|
10 |
-
class UM_Functions {
|
11 |
-
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Store URL
|
15 |
-
*
|
16 |
-
* @var string
|
17 |
-
*/
|
18 |
-
var $store_url = 'https://ultimatemember.com/';
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* WP remote Post timeout
|
23 |
-
* @var int
|
24 |
-
*/
|
25 |
-
var $request_timeout = 60;
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* UM_Functions constructor.
|
30 |
-
*/
|
31 |
-
function __construct() {
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Check if AJAX now
|
37 |
-
*
|
38 |
-
* @return bool
|
39 |
-
*/
|
40 |
-
function is_ajax() {
|
41 |
-
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Check frontend nonce
|
47 |
-
*
|
48 |
-
* @param bool $action
|
49 |
-
*/
|
50 |
-
function check_ajax_nonce( $action = false ) {
|
51 |
-
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
|
52 |
-
$action = empty( $action ) ? 'um-frontend-nonce' : $action;
|
53 |
-
|
54 |
-
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
55 |
-
wp_send_json_error( esc_js( __( 'Wrong Nonce', 'ultimate-member' ) ) );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
/**
|
61 |
-
* What type of request is this?
|
62 |
-
*
|
63 |
-
* @param string $type String containing name of request type (ajax, frontend, cron or admin)
|
64 |
-
*
|
65 |
-
* @return bool
|
66 |
-
*/
|
67 |
-
public function is_request( $type ) {
|
68 |
-
switch ( $type ) {
|
69 |
-
case 'admin' :
|
70 |
-
return is_admin();
|
71 |
-
case 'ajax' :
|
72 |
-
return defined( 'DOING_AJAX' );
|
73 |
-
case 'cron' :
|
74 |
-
return defined( 'DOING_CRON' );
|
75 |
-
case 'frontend' :
|
76 |
-
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
|
77 |
-
}
|
78 |
-
|
79 |
-
return false;
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Help Tip displaying
|
85 |
-
*
|
86 |
-
* Function for render/displaying UltimateMember help tip
|
87 |
-
*
|
88 |
-
* @since 2.0.0
|
89 |
-
*
|
90 |
-
* @param string $tip Help tip text
|
91 |
-
* @param bool $allow_html Allow sanitized HTML if true or escape
|
92 |
-
* @param bool $echo Return HTML or echo
|
93 |
-
* @return string
|
94 |
-
*/
|
95 |
-
function tooltip( $tip, $allow_html = false, $echo = true ) {
|
96 |
-
if ( $allow_html ) {
|
97 |
-
|
98 |
-
$tip = htmlspecialchars( wp_kses( html_entity_decode( $tip ), array(
|
99 |
-
'br' => array(),
|
100 |
-
'em' => array(),
|
101 |
-
'strong' => array(),
|
102 |
-
'small' => array(),
|
103 |
-
'span' => array(),
|
104 |
-
'ul' => array(),
|
105 |
-
'li' => array(),
|
106 |
-
'ol' => array(),
|
107 |
-
'p' => array(),
|
108 |
-
) ) );
|
109 |
-
|
110 |
-
} else {
|
111 |
-
$tip = esc_attr( $tip );
|
112 |
-
}
|
113 |
-
|
114 |
-
ob_start(); ?>
|
115 |
-
|
116 |
-
<span class="um_tooltip dashicons dashicons-editor-help" title="<?php echo $tip ?>"></span>
|
117 |
-
|
118 |
-
<?php if ( $echo ) {
|
119 |
-
ob_get_flush();
|
120 |
-
return '';
|
121 |
-
} else {
|
122 |
-
return ob_get_clean();
|
123 |
-
}
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
|
128 |
-
/**
|
129 |
-
* @return mixed|void
|
130 |
-
*/
|
131 |
-
function excluded_taxonomies() {
|
132 |
-
$taxes = array(
|
133 |
-
'nav_menu',
|
134 |
-
'link_category',
|
135 |
-
'post_format',
|
136 |
-
);
|
137 |
-
|
138 |
-
/**
|
139 |
-
* UM hook
|
140 |
-
*
|
141 |
-
* @type filter
|
142 |
-
* @title um_excluded_taxonomies
|
143 |
-
* @description Exclude taxonomies for UM
|
144 |
-
* @input_vars
|
145 |
-
* [{"var":"$taxes","type":"array","desc":"Taxonomies keys"}]
|
146 |
-
* @change_log
|
147 |
-
* ["Since: 2.0"]
|
148 |
-
* @usage
|
149 |
-
* <?php add_filter( 'um_excluded_taxonomies', 'function_name', 10, 1 ); ?>
|
150 |
-
* @example
|
151 |
-
* <?php
|
152 |
-
* add_filter( 'um_excluded_taxonomies', 'my_excluded_taxonomies', 10, 1 );
|
153 |
-
* function my_excluded_taxonomies( $taxes ) {
|
154 |
-
* // your code here
|
155 |
-
* return $taxes;
|
156 |
-
* }
|
157 |
-
* ?>
|
158 |
-
*/
|
159 |
-
return apply_filters( 'um_excluded_taxonomies', $taxes );
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Output templates
|
165 |
-
*
|
166 |
-
* @access public
|
167 |
-
* @param string $template_name
|
168 |
-
* @param string $basename (default: '')
|
169 |
-
* @param array $t_args (default: array())
|
170 |
-
* @param bool $echo
|
171 |
-
*
|
172 |
-
* @return string|void
|
173 |
-
*/
|
174 |
-
function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
|
175 |
-
if ( ! empty( $t_args ) && is_array( $t_args ) ) {
|
176 |
-
extract( $t_args );
|
177 |
-
}
|
178 |
-
|
179 |
-
$path = '';
|
180 |
-
if ( $basename ) {
|
181 |
-
// use '/' instead of "DIRECTORY_SEPARATOR", because wp_normalize_path makes the correct replace
|
182 |
-
$array = explode( '/', wp_normalize_path( trim( $basename ) ) );
|
183 |
-
$path = $array[0];
|
184 |
-
}
|
185 |
-
|
186 |
-
$located = $this->locate_template( $template_name, $path );
|
187 |
-
if ( ! file_exists( $located ) ) {
|
188 |
-
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
|
189 |
-
return;
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/**
|
194 |
-
* UM hook
|
195 |
-
*
|
196 |
-
* @type filter
|
197 |
-
* @title um_get_template
|
198 |
-
* @description Change template location
|
199 |
-
* @input_vars
|
200 |
-
* [{"var":"$located","type":"string","desc":"template Located"},
|
201 |
-
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
202 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
203 |
-
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
204 |
-
* @change_log
|
205 |
-
* ["Since: 2.0"]
|
206 |
-
* @usage add_filter( 'um_get_template', 'function_name', 10, 4 );
|
207 |
-
* @example
|
208 |
-
* <?php
|
209 |
-
* add_filter( 'um_get_template', 'my_get_template', 10, 4 );
|
210 |
-
* function my_get_template( $located, $template_name, $path, $t_args ) {
|
211 |
-
* // your code here
|
212 |
-
* return $located;
|
213 |
-
* }
|
214 |
-
* ?>
|
215 |
-
*/
|
216 |
-
$located = apply_filters( 'um_get_template', $located, $template_name, $path, $t_args );
|
217 |
-
|
218 |
-
ob_start();
|
219 |
-
|
220 |
-
/**
|
221 |
-
* UM hook
|
222 |
-
*
|
223 |
-
* @type action
|
224 |
-
* @title um_before_template_part
|
225 |
-
* @description Make some action before include template file
|
226 |
-
* @input_vars
|
227 |
-
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
228 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
229 |
-
* {"var":"$located","type":"string","desc":"template Located"},
|
230 |
-
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
231 |
-
* @change_log
|
232 |
-
* ["Since: 2.0"]
|
233 |
-
* @usage add_action( 'um_before_template_part', 'function_name', 10, 4 );
|
234 |
-
* @example
|
235 |
-
* <?php
|
236 |
-
* add_action( 'um_before_template_part', 'my_before_template_part', 10, 4 );
|
237 |
-
* function my_before_template_part( $template_name, $path, $located, $t_args ) {
|
238 |
-
* // your code here
|
239 |
-
* }
|
240 |
-
* ?>
|
241 |
-
*/
|
242 |
-
do_action( 'um_before_template_part', $template_name, $path, $located, $t_args );
|
243 |
-
include( $located );
|
244 |
-
|
245 |
-
/**
|
246 |
-
* UM hook
|
247 |
-
*
|
248 |
-
* @type action
|
249 |
-
* @title um_after_template_part
|
250 |
-
* @description Make some action after include template file
|
251 |
-
* @input_vars
|
252 |
-
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
253 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
254 |
-
* {"var":"$located","type":"string","desc":"template Located"},
|
255 |
-
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
256 |
-
* @change_log
|
257 |
-
* ["Since: 2.0"]
|
258 |
-
* @usage add_action( 'um_after_template_part', 'function_name', 10, 4 );
|
259 |
-
* @example
|
260 |
-
* <?php
|
261 |
-
* add_action( 'um_after_template_part', 'my_after_template_part', 10, 4 );
|
262 |
-
* function my_after_template_part( $template_name, $path, $located, $t_args ) {
|
263 |
-
* // your code here
|
264 |
-
* }
|
265 |
-
* ?>
|
266 |
-
*/
|
267 |
-
do_action( 'um_after_template_part', $template_name, $path, $located, $t_args );
|
268 |
-
$html = ob_get_clean();
|
269 |
-
|
270 |
-
if ( ! $echo ) {
|
271 |
-
return $html;
|
272 |
-
} else {
|
273 |
-
echo $html;
|
274 |
-
return;
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Locate a template and return the path for inclusion.
|
281 |
-
*
|
282 |
-
* @access public
|
283 |
-
* @param string $template_name
|
284 |
-
* @param string $path (default: '')
|
285 |
-
* @return string
|
286 |
-
*/
|
287 |
-
function locate_template( $template_name, $path = '' ) {
|
288 |
-
// check if there is template at theme folder
|
289 |
-
$template = locate_template( array(
|
290 |
-
trailingslashit( 'ultimate-member' . DIRECTORY_SEPARATOR . $path ) . $template_name
|
291 |
-
) );
|
292 |
-
|
293 |
-
if ( ! $template ) {
|
294 |
-
if ( $path ) {
|
295 |
-
$template = trailingslashit( trailingslashit( WP_PLUGIN_DIR ) . $path );
|
296 |
-
} else {
|
297 |
-
$template = trailingslashit( um_path );
|
298 |
-
}
|
299 |
-
$template .= 'templates' . DIRECTORY_SEPARATOR . $template_name;
|
300 |
-
}
|
301 |
-
|
302 |
-
|
303 |
-
/**
|
304 |
-
* UM hook
|
305 |
-
*
|
306 |
-
* @type filter
|
307 |
-
* @title um_locate_template
|
308 |
-
* @description Change template locate
|
309 |
-
* @input_vars
|
310 |
-
* [{"var":"$template","type":"string","desc":"Template locate"},
|
311 |
-
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
312 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"}]
|
313 |
-
* @change_log
|
314 |
-
* ["Since: 2.0"]
|
315 |
-
* @usage add_filter( 'um_locate_template', 'function_name', 10, 3 );
|
316 |
-
* @example
|
317 |
-
* <?php
|
318 |
-
* add_filter( 'um_locate_template', 'my_locate_template', 10, 3 );
|
319 |
-
* function my_locate_template( $template, $template_name, $path ) {
|
320 |
-
* // your code here
|
321 |
-
* return $template;
|
322 |
-
* }
|
323 |
-
* ?>
|
324 |
-
*/
|
325 |
-
return apply_filters( 'um_locate_template', $template, $template_name, $path );
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
/**
|
330 |
-
* @return mixed|void
|
331 |
-
*/
|
332 |
-
function cpt_list() {
|
333 |
-
/**
|
334 |
-
* UM hook
|
335 |
-
*
|
336 |
-
* @type filter
|
337 |
-
* @title um_cpt_list
|
338 |
-
* @description Extend UM Custom Post Types
|
339 |
-
* @input_vars
|
340 |
-
* [{"var":"$list","type":"array","desc":"Custom Post Types list"}]
|
341 |
-
* @change_log
|
342 |
-
* ["Since: 2.0"]
|
343 |
-
* @usage
|
344 |
-
* <?php add_filter( 'um_cpt_list', 'function_name', 10, 1 ); ?>
|
345 |
-
* @example
|
346 |
-
* <?php
|
347 |
-
* add_filter( 'um_cpt_list', 'my_cpt_list', 10, 1 );
|
348 |
-
* function my_admin_pending_queue( $list ) {
|
349 |
-
* // your code here
|
350 |
-
* return $list;
|
351 |
-
* }
|
352 |
-
* ?>
|
353 |
-
*/
|
354 |
-
$cpt = apply_filters( 'um_cpt_list', array( 'um_form', 'um_directory' ) );
|
355 |
-
return $cpt;
|
356 |
-
}
|
357 |
-
|
358 |
-
|
359 |
-
/**
|
360 |
-
* @param array $array
|
361 |
-
* @param string $key
|
362 |
-
* @param array $insert_array
|
363 |
-
*
|
364 |
-
* @return array
|
365 |
-
*/
|
366 |
-
function array_insert_before( $array, $key, $insert_array ) {
|
367 |
-
$index = array_search( $key, array_keys( $array ) );
|
368 |
-
if ( $index === false ) {
|
369 |
-
return $array;
|
370 |
-
}
|
371 |
-
|
372 |
-
$array = array_slice( $array, 0, $index, true ) +
|
373 |
-
$insert_array +
|
374 |
-
array_slice( $array, $index, count( $array ) - 1, true );
|
375 |
-
|
376 |
-
return $array;
|
377 |
-
}
|
378 |
-
|
379 |
-
|
380 |
-
/**
|
381 |
-
* @since 2.1.0
|
382 |
-
*
|
383 |
-
* @param $var
|
384 |
-
* @return array|string
|
385 |
-
*/
|
386 |
-
function clean_array( $var ) {
|
387 |
-
if ( is_array( $var ) ) {
|
388 |
-
return array_map( array( $this, 'clean_array' ), $var );
|
389 |
-
} else {
|
390 |
-
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
|
395 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
if ( ! class_exists( 'UM_Functions' ) ) {
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class UM_Functions
|
9 |
+
*/
|
10 |
+
class UM_Functions {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Store URL
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
var $store_url = 'https://ultimatemember.com/';
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* WP remote Post timeout
|
23 |
+
* @var int
|
24 |
+
*/
|
25 |
+
var $request_timeout = 60;
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* UM_Functions constructor.
|
30 |
+
*/
|
31 |
+
function __construct() {
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Check if AJAX now
|
37 |
+
*
|
38 |
+
* @return bool
|
39 |
+
*/
|
40 |
+
function is_ajax() {
|
41 |
+
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Check frontend nonce
|
47 |
+
*
|
48 |
+
* @param bool $action
|
49 |
+
*/
|
50 |
+
function check_ajax_nonce( $action = false ) {
|
51 |
+
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
|
52 |
+
$action = empty( $action ) ? 'um-frontend-nonce' : $action;
|
53 |
+
|
54 |
+
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
55 |
+
wp_send_json_error( esc_js( __( 'Wrong Nonce', 'ultimate-member' ) ) );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* What type of request is this?
|
62 |
+
*
|
63 |
+
* @param string $type String containing name of request type (ajax, frontend, cron or admin)
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function is_request( $type ) {
|
68 |
+
switch ( $type ) {
|
69 |
+
case 'admin' :
|
70 |
+
return is_admin();
|
71 |
+
case 'ajax' :
|
72 |
+
return defined( 'DOING_AJAX' );
|
73 |
+
case 'cron' :
|
74 |
+
return defined( 'DOING_CRON' );
|
75 |
+
case 'frontend' :
|
76 |
+
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
|
77 |
+
}
|
78 |
+
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Help Tip displaying
|
85 |
+
*
|
86 |
+
* Function for render/displaying UltimateMember help tip
|
87 |
+
*
|
88 |
+
* @since 2.0.0
|
89 |
+
*
|
90 |
+
* @param string $tip Help tip text
|
91 |
+
* @param bool $allow_html Allow sanitized HTML if true or escape
|
92 |
+
* @param bool $echo Return HTML or echo
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
function tooltip( $tip, $allow_html = false, $echo = true ) {
|
96 |
+
if ( $allow_html ) {
|
97 |
+
|
98 |
+
$tip = htmlspecialchars( wp_kses( html_entity_decode( $tip ), array(
|
99 |
+
'br' => array(),
|
100 |
+
'em' => array(),
|
101 |
+
'strong' => array(),
|
102 |
+
'small' => array(),
|
103 |
+
'span' => array(),
|
104 |
+
'ul' => array(),
|
105 |
+
'li' => array(),
|
106 |
+
'ol' => array(),
|
107 |
+
'p' => array(),
|
108 |
+
) ) );
|
109 |
+
|
110 |
+
} else {
|
111 |
+
$tip = esc_attr( $tip );
|
112 |
+
}
|
113 |
+
|
114 |
+
ob_start(); ?>
|
115 |
+
|
116 |
+
<span class="um_tooltip dashicons dashicons-editor-help" title="<?php echo $tip ?>"></span>
|
117 |
+
|
118 |
+
<?php if ( $echo ) {
|
119 |
+
ob_get_flush();
|
120 |
+
return '';
|
121 |
+
} else {
|
122 |
+
return ob_get_clean();
|
123 |
+
}
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @return mixed|void
|
130 |
+
*/
|
131 |
+
function excluded_taxonomies() {
|
132 |
+
$taxes = array(
|
133 |
+
'nav_menu',
|
134 |
+
'link_category',
|
135 |
+
'post_format',
|
136 |
+
);
|
137 |
+
|
138 |
+
/**
|
139 |
+
* UM hook
|
140 |
+
*
|
141 |
+
* @type filter
|
142 |
+
* @title um_excluded_taxonomies
|
143 |
+
* @description Exclude taxonomies for UM
|
144 |
+
* @input_vars
|
145 |
+
* [{"var":"$taxes","type":"array","desc":"Taxonomies keys"}]
|
146 |
+
* @change_log
|
147 |
+
* ["Since: 2.0"]
|
148 |
+
* @usage
|
149 |
+
* <?php add_filter( 'um_excluded_taxonomies', 'function_name', 10, 1 ); ?>
|
150 |
+
* @example
|
151 |
+
* <?php
|
152 |
+
* add_filter( 'um_excluded_taxonomies', 'my_excluded_taxonomies', 10, 1 );
|
153 |
+
* function my_excluded_taxonomies( $taxes ) {
|
154 |
+
* // your code here
|
155 |
+
* return $taxes;
|
156 |
+
* }
|
157 |
+
* ?>
|
158 |
+
*/
|
159 |
+
return apply_filters( 'um_excluded_taxonomies', $taxes );
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Output templates
|
165 |
+
*
|
166 |
+
* @access public
|
167 |
+
* @param string $template_name
|
168 |
+
* @param string $basename (default: '')
|
169 |
+
* @param array $t_args (default: array())
|
170 |
+
* @param bool $echo
|
171 |
+
*
|
172 |
+
* @return string|void
|
173 |
+
*/
|
174 |
+
function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
|
175 |
+
if ( ! empty( $t_args ) && is_array( $t_args ) ) {
|
176 |
+
extract( $t_args );
|
177 |
+
}
|
178 |
+
|
179 |
+
$path = '';
|
180 |
+
if ( $basename ) {
|
181 |
+
// use '/' instead of "DIRECTORY_SEPARATOR", because wp_normalize_path makes the correct replace
|
182 |
+
$array = explode( '/', wp_normalize_path( trim( $basename ) ) );
|
183 |
+
$path = $array[0];
|
184 |
+
}
|
185 |
+
|
186 |
+
$located = $this->locate_template( $template_name, $path );
|
187 |
+
if ( ! file_exists( $located ) ) {
|
188 |
+
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
|
189 |
+
return;
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/**
|
194 |
+
* UM hook
|
195 |
+
*
|
196 |
+
* @type filter
|
197 |
+
* @title um_get_template
|
198 |
+
* @description Change template location
|
199 |
+
* @input_vars
|
200 |
+
* [{"var":"$located","type":"string","desc":"template Located"},
|
201 |
+
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
202 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
203 |
+
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
204 |
+
* @change_log
|
205 |
+
* ["Since: 2.0"]
|
206 |
+
* @usage add_filter( 'um_get_template', 'function_name', 10, 4 );
|
207 |
+
* @example
|
208 |
+
* <?php
|
209 |
+
* add_filter( 'um_get_template', 'my_get_template', 10, 4 );
|
210 |
+
* function my_get_template( $located, $template_name, $path, $t_args ) {
|
211 |
+
* // your code here
|
212 |
+
* return $located;
|
213 |
+
* }
|
214 |
+
* ?>
|
215 |
+
*/
|
216 |
+
$located = apply_filters( 'um_get_template', $located, $template_name, $path, $t_args );
|
217 |
+
|
218 |
+
ob_start();
|
219 |
+
|
220 |
+
/**
|
221 |
+
* UM hook
|
222 |
+
*
|
223 |
+
* @type action
|
224 |
+
* @title um_before_template_part
|
225 |
+
* @description Make some action before include template file
|
226 |
+
* @input_vars
|
227 |
+
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
228 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
229 |
+
* {"var":"$located","type":"string","desc":"template Located"},
|
230 |
+
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
231 |
+
* @change_log
|
232 |
+
* ["Since: 2.0"]
|
233 |
+
* @usage add_action( 'um_before_template_part', 'function_name', 10, 4 );
|
234 |
+
* @example
|
235 |
+
* <?php
|
236 |
+
* add_action( 'um_before_template_part', 'my_before_template_part', 10, 4 );
|
237 |
+
* function my_before_template_part( $template_name, $path, $located, $t_args ) {
|
238 |
+
* // your code here
|
239 |
+
* }
|
240 |
+
* ?>
|
241 |
+
*/
|
242 |
+
do_action( 'um_before_template_part', $template_name, $path, $located, $t_args );
|
243 |
+
include( $located );
|
244 |
+
|
245 |
+
/**
|
246 |
+
* UM hook
|
247 |
+
*
|
248 |
+
* @type action
|
249 |
+
* @title um_after_template_part
|
250 |
+
* @description Make some action after include template file
|
251 |
+
* @input_vars
|
252 |
+
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
253 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
254 |
+
* {"var":"$located","type":"string","desc":"template Located"},
|
255 |
+
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
256 |
+
* @change_log
|
257 |
+
* ["Since: 2.0"]
|
258 |
+
* @usage add_action( 'um_after_template_part', 'function_name', 10, 4 );
|
259 |
+
* @example
|
260 |
+
* <?php
|
261 |
+
* add_action( 'um_after_template_part', 'my_after_template_part', 10, 4 );
|
262 |
+
* function my_after_template_part( $template_name, $path, $located, $t_args ) {
|
263 |
+
* // your code here
|
264 |
+
* }
|
265 |
+
* ?>
|
266 |
+
*/
|
267 |
+
do_action( 'um_after_template_part', $template_name, $path, $located, $t_args );
|
268 |
+
$html = ob_get_clean();
|
269 |
+
|
270 |
+
if ( ! $echo ) {
|
271 |
+
return $html;
|
272 |
+
} else {
|
273 |
+
echo $html;
|
274 |
+
return;
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Locate a template and return the path for inclusion.
|
281 |
+
*
|
282 |
+
* @access public
|
283 |
+
* @param string $template_name
|
284 |
+
* @param string $path (default: '')
|
285 |
+
* @return string
|
286 |
+
*/
|
287 |
+
function locate_template( $template_name, $path = '' ) {
|
288 |
+
// check if there is template at theme folder
|
289 |
+
$template = locate_template( array(
|
290 |
+
trailingslashit( 'ultimate-member' . DIRECTORY_SEPARATOR . $path ) . $template_name
|
291 |
+
) );
|
292 |
+
|
293 |
+
if ( ! $template ) {
|
294 |
+
if ( $path ) {
|
295 |
+
$template = trailingslashit( trailingslashit( WP_PLUGIN_DIR ) . $path );
|
296 |
+
} else {
|
297 |
+
$template = trailingslashit( um_path );
|
298 |
+
}
|
299 |
+
$template .= 'templates' . DIRECTORY_SEPARATOR . $template_name;
|
300 |
+
}
|
301 |
+
|
302 |
+
|
303 |
+
/**
|
304 |
+
* UM hook
|
305 |
+
*
|
306 |
+
* @type filter
|
307 |
+
* @title um_locate_template
|
308 |
+
* @description Change template locate
|
309 |
+
* @input_vars
|
310 |
+
* [{"var":"$template","type":"string","desc":"Template locate"},
|
311 |
+
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
312 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"}]
|
313 |
+
* @change_log
|
314 |
+
* ["Since: 2.0"]
|
315 |
+
* @usage add_filter( 'um_locate_template', 'function_name', 10, 3 );
|
316 |
+
* @example
|
317 |
+
* <?php
|
318 |
+
* add_filter( 'um_locate_template', 'my_locate_template', 10, 3 );
|
319 |
+
* function my_locate_template( $template, $template_name, $path ) {
|
320 |
+
* // your code here
|
321 |
+
* return $template;
|
322 |
+
* }
|
323 |
+
* ?>
|
324 |
+
*/
|
325 |
+
return apply_filters( 'um_locate_template', $template, $template_name, $path );
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
/**
|
330 |
+
* @return mixed|void
|
331 |
+
*/
|
332 |
+
function cpt_list() {
|
333 |
+
/**
|
334 |
+
* UM hook
|
335 |
+
*
|
336 |
+
* @type filter
|
337 |
+
* @title um_cpt_list
|
338 |
+
* @description Extend UM Custom Post Types
|
339 |
+
* @input_vars
|
340 |
+
* [{"var":"$list","type":"array","desc":"Custom Post Types list"}]
|
341 |
+
* @change_log
|
342 |
+
* ["Since: 2.0"]
|
343 |
+
* @usage
|
344 |
+
* <?php add_filter( 'um_cpt_list', 'function_name', 10, 1 ); ?>
|
345 |
+
* @example
|
346 |
+
* <?php
|
347 |
+
* add_filter( 'um_cpt_list', 'my_cpt_list', 10, 1 );
|
348 |
+
* function my_admin_pending_queue( $list ) {
|
349 |
+
* // your code here
|
350 |
+
* return $list;
|
351 |
+
* }
|
352 |
+
* ?>
|
353 |
+
*/
|
354 |
+
$cpt = apply_filters( 'um_cpt_list', array( 'um_form', 'um_directory' ) );
|
355 |
+
return $cpt;
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
/**
|
360 |
+
* @param array $array
|
361 |
+
* @param string $key
|
362 |
+
* @param array $insert_array
|
363 |
+
*
|
364 |
+
* @return array
|
365 |
+
*/
|
366 |
+
function array_insert_before( $array, $key, $insert_array ) {
|
367 |
+
$index = array_search( $key, array_keys( $array ) );
|
368 |
+
if ( $index === false ) {
|
369 |
+
return $array;
|
370 |
+
}
|
371 |
+
|
372 |
+
$array = array_slice( $array, 0, $index, true ) +
|
373 |
+
$insert_array +
|
374 |
+
array_slice( $array, $index, count( $array ) - 1, true );
|
375 |
+
|
376 |
+
return $array;
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* @since 2.1.0
|
382 |
+
*
|
383 |
+
* @param $var
|
384 |
+
* @return array|string
|
385 |
+
*/
|
386 |
+
function clean_array( $var ) {
|
387 |
+
if ( is_array( $var ) ) {
|
388 |
+
return array_map( array( $this, 'clean_array' ), $var );
|
389 |
+
} else {
|
390 |
+
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Replace the first match in the string, alternative for the `str_replace()` function
|
397 |
+
*
|
398 |
+
* @param string $search
|
399 |
+
* @param string $replace
|
400 |
+
* @param string $subject
|
401 |
+
*
|
402 |
+
* @return string
|
403 |
+
*/
|
404 |
+
function str_replace_first( $search, $replace, $subject ) {
|
405 |
+
$search = '/' . preg_quote( $search, '/' ) . '/';
|
406 |
+
return preg_replace( $search, $replace, $subject, 1 );
|
407 |
+
}
|
408 |
+
|
409 |
+
}
|
410 |
+
}
|
includes/core/class-access.php
CHANGED
@@ -127,7 +127,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
127 |
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
|
128 |
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
|
129 |
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
|
130 |
-
remove_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10 );
|
131 |
}
|
132 |
|
133 |
|
@@ -1131,8 +1130,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1131 |
continue;
|
1132 |
} else {
|
1133 |
$restriction_settings = $this->get_post_privacy_settings( $menu_item->object_id );
|
1134 |
-
if ( UM()->options()->get( 'disable_restriction_pre_queries' )
|
1135 |
-
$filtered_items[] = $menu_item;
|
1136 |
continue;
|
1137 |
}
|
1138 |
}
|
@@ -1270,6 +1269,36 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1270 |
}
|
1271 |
|
1272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1273 |
/**
|
1274 |
* Protect Post Types in query
|
1275 |
* Restrict content new logic
|
@@ -1379,7 +1408,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1379 |
}
|
1380 |
}
|
1381 |
} else {
|
1382 |
-
if ( UM()->options()->get( 'disable_restriction_pre_queries' )
|
1383 |
$filtered_posts[] = $this->maybe_replace_title( $post );
|
1384 |
continue;
|
1385 |
}
|
127 |
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
|
128 |
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
|
129 |
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
|
|
|
130 |
}
|
131 |
|
132 |
|
1130 |
continue;
|
1131 |
} else {
|
1132 |
$restriction_settings = $this->get_post_privacy_settings( $menu_item->object_id );
|
1133 |
+
if ( empty( $restriction_settings['_um_access_hide_from_queries'] ) || ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
1134 |
+
$filtered_items[] = $this->maybe_replace_nav_menu_title( $menu_item );
|
1135 |
continue;
|
1136 |
}
|
1137 |
}
|
1269 |
}
|
1270 |
|
1271 |
|
1272 |
+
/**
|
1273 |
+
* @param \WP_Post $nav_item
|
1274 |
+
*
|
1275 |
+
* @return \WP_Post
|
1276 |
+
*/
|
1277 |
+
function maybe_replace_nav_menu_title( $nav_item ) {
|
1278 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
1279 |
+
return $nav_item;
|
1280 |
+
}
|
1281 |
+
|
1282 |
+
if ( current_user_can( 'administrator' ) ) {
|
1283 |
+
return $nav_item;
|
1284 |
+
}
|
1285 |
+
|
1286 |
+
if ( ! is_a( $nav_item, '\WP_Post' ) ) {
|
1287 |
+
return $nav_item;
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $nav_item->ID );
|
1291 |
+
if ( $ignore ) {
|
1292 |
+
return $nav_item;
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
1296 |
+
$nav_item->title = stripslashes( $restricted_global_title );
|
1297 |
+
|
1298 |
+
return $nav_item;
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
|
1302 |
/**
|
1303 |
* Protect Post Types in query
|
1304 |
* Restrict content new logic
|
1408 |
}
|
1409 |
}
|
1410 |
} else {
|
1411 |
+
if ( empty( $restriction['_um_access_hide_from_queries'] ) || ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
1412 |
$filtered_posts[] = $this->maybe_replace_title( $post );
|
1413 |
continue;
|
1414 |
}
|
includes/core/class-builtin.php
CHANGED
@@ -1,1917 +1,1917 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Builtin' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Builtin
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Builtin {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var array
|
19 |
-
*/
|
20 |
-
public $predefined_fields = array();
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var array
|
25 |
-
*/
|
26 |
-
var $all_user_fields = array();
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var array
|
31 |
-
*/
|
32 |
-
var $core_fields = array();
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Builtin constructor.
|
37 |
-
*/
|
38 |
-
function __construct() {
|
39 |
-
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
40 |
-
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
41 |
-
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
42 |
-
$this->saved_fields = get_option( 'um_fields' );
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @return array
|
48 |
-
*/
|
49 |
-
function get_all_user_fields() {
|
50 |
-
return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Regular or multi-select/options
|
56 |
-
*
|
57 |
-
* @param $field
|
58 |
-
* @param $attrs
|
59 |
-
*
|
60 |
-
* @return bool
|
61 |
-
*/
|
62 |
-
function is_dropdown_field( $field, $attrs ) {
|
63 |
-
|
64 |
-
if ( isset( $attrs['options'] ) ) {
|
65 |
-
return true;
|
66 |
-
}
|
67 |
-
|
68 |
-
$fields = $this->all_user_fields;
|
69 |
-
|
70 |
-
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
|
71 |
-
return true;
|
72 |
-
}
|
73 |
-
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Get a field
|
80 |
-
*
|
81 |
-
* @param $field
|
82 |
-
*
|
83 |
-
* @return mixed|string
|
84 |
-
*/
|
85 |
-
function get_a_field( $field ) {
|
86 |
-
$fields = $this->all_user_fields;
|
87 |
-
if ( isset( $fields[ $field ] ) ) {
|
88 |
-
return $fields[ $field ];
|
89 |
-
}
|
90 |
-
return '';
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get specific fields
|
96 |
-
*
|
97 |
-
* @param $fields
|
98 |
-
*
|
99 |
-
* @return array
|
100 |
-
*/
|
101 |
-
function get_specific_fields( $fields ) {
|
102 |
-
$fields = explode( ',', $fields );
|
103 |
-
$array = array();
|
104 |
-
foreach ( $fields as $field ) {
|
105 |
-
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
106 |
-
$array[ $field ] = $this->predefined_fields[ $field ];
|
107 |
-
}
|
108 |
-
}
|
109 |
-
return $array;
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Get specific field
|
115 |
-
*
|
116 |
-
* @param $fields
|
117 |
-
*
|
118 |
-
* @return array|mixed
|
119 |
-
*/
|
120 |
-
function get_specific_field( $fields ) {
|
121 |
-
$fields = explode( ',', $fields );
|
122 |
-
$array = array();
|
123 |
-
foreach ( $fields as $field ) {
|
124 |
-
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
125 |
-
$array = $this->predefined_fields[ $field ];
|
126 |
-
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
|
127 |
-
$array = $this->saved_fields[ $field ];
|
128 |
-
}
|
129 |
-
}
|
130 |
-
return $array;
|
131 |
-
}
|
132 |
-
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Checks for a unique field error
|
136 |
-
*
|
137 |
-
* @param $key
|
138 |
-
*
|
139 |
-
* @return int|string
|
140 |
-
*/
|
141 |
-
function unique_field_err( $key ) {
|
142 |
-
if ( empty( $key ) ) {
|
143 |
-
return __( 'Please provide a meta key', 'ultimate-member' );
|
144 |
-
}
|
145 |
-
if ( isset( $this->core_fields[ $key ] ) ) {
|
146 |
-
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
147 |
-
}
|
148 |
-
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
149 |
-
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
150 |
-
}
|
151 |
-
if ( isset( $this->saved_fields[ $key ] ) ) {
|
152 |
-
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
153 |
-
}
|
154 |
-
if ( ! UM()->validation()->safe_string( $key ) ) {
|
155 |
-
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
156 |
-
}
|
157 |
-
|
158 |
-
return 0;
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Check date range errors (start date)
|
164 |
-
*
|
165 |
-
* @param $date
|
166 |
-
*
|
167 |
-
* @return int|string
|
168 |
-
*/
|
169 |
-
function date_range_start_err( $date ) {
|
170 |
-
if ( empty( $date ) ) {
|
171 |
-
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
172 |
-
}
|
173 |
-
if ( ! UM()->validation()->validate_date( $date ) ) {
|
174 |
-
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
175 |
-
}
|
176 |
-
|
177 |
-
return 0;
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Check date range errors (end date)
|
183 |
-
*
|
184 |
-
* @param $date
|
185 |
-
* @param $start_date
|
186 |
-
*
|
187 |
-
* @return int|string
|
188 |
-
*/
|
189 |
-
function date_range_end_err( $date, $start_date ) {
|
190 |
-
if ( empty( $date ) ) {
|
191 |
-
return __( 'Please provide a date range end', 'ultimate-member' );
|
192 |
-
}
|
193 |
-
if ( ! UM()->validation()->validate_date( $date ) ) {
|
194 |
-
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
195 |
-
}
|
196 |
-
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
197 |
-
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
198 |
-
}
|
199 |
-
return 0;
|
200 |
-
}
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Get a core field attrs
|
205 |
-
*
|
206 |
-
* @param $type
|
207 |
-
*
|
208 |
-
* @return array|mixed
|
209 |
-
*/
|
210 |
-
function get_core_field_attrs( $type ) {
|
211 |
-
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Core Fields
|
217 |
-
*/
|
218 |
-
function set_core_fields() {
|
219 |
-
|
220 |
-
$this->core_fields = array(
|
221 |
-
|
222 |
-
'row' => array(
|
223 |
-
'name' => 'Row',
|
224 |
-
'in_fields' => false,
|
225 |
-
'form_only' => true,
|
226 |
-
'conditional_support' => 0,
|
227 |
-
'icon' => 'um-faicon-pencil',
|
228 |
-
'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
|
229 |
-
'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
|
230 |
-
),
|
231 |
-
|
232 |
-
'text' => array(
|
233 |
-
'name' => 'Text Box',
|
234 |
-
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
235 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
236 |
-
'col3' => array('_required','_editable','_icon'),
|
237 |
-
'validate' => array(
|
238 |
-
'_title' => array(
|
239 |
-
'mode' => 'required',
|
240 |
-
'error' => __('You must provide a title','ultimate-member')
|
241 |
-
),
|
242 |
-
'_metakey' => array(
|
243 |
-
'mode' => 'unique',
|
244 |
-
),
|
245 |
-
)
|
246 |
-
),
|
247 |
-
|
248 |
-
'number' => array(
|
249 |
-
'name' => __('Number','ultimate-member'),
|
250 |
-
'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
|
251 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
|
252 |
-
'col3' => array('_required','_editable','_icon'),
|
253 |
-
'validate' => array(
|
254 |
-
'_title' => array(
|
255 |
-
'mode' => 'required',
|
256 |
-
'error' => __('You must provide a title','ultimate-member')
|
257 |
-
),
|
258 |
-
'_metakey' => array(
|
259 |
-
'mode' => 'unique',
|
260 |
-
),
|
261 |
-
)
|
262 |
-
),
|
263 |
-
|
264 |
-
'textarea' => array(
|
265 |
-
'name' => 'Textarea',
|
266 |
-
'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
|
267 |
-
'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
|
268 |
-
'col3' => array('_required','_editable','_icon'),
|
269 |
-
'validate' => array(
|
270 |
-
'_title' => array(
|
271 |
-
'mode' => 'required',
|
272 |
-
'error' => __('You must provide a title','ultimate-member')
|
273 |
-
),
|
274 |
-
'_metakey' => array(
|
275 |
-
'mode' => 'unique',
|
276 |
-
),
|
277 |
-
)
|
278 |
-
),
|
279 |
-
|
280 |
-
'select' => array(
|
281 |
-
'name' => 'Dropdown',
|
282 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
283 |
-
'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
|
284 |
-
'col3' => array('_required','_editable','_icon'),
|
285 |
-
'validate' => array(
|
286 |
-
'_title' => array(
|
287 |
-
'mode' => 'required',
|
288 |
-
'error' => __('You must provide a title','ultimate-member')
|
289 |
-
),
|
290 |
-
'_metakey' => array(
|
291 |
-
'mode' => 'unique',
|
292 |
-
),
|
293 |
-
'_options' => array(
|
294 |
-
'mode' => 'required',
|
295 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
296 |
-
),
|
297 |
-
)
|
298 |
-
),
|
299 |
-
|
300 |
-
'multiselect' => array(
|
301 |
-
'name' => 'Multi-Select',
|
302 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
303 |
-
'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
|
304 |
-
'col3' => array('_required','_editable','_icon'),
|
305 |
-
'validate' => array(
|
306 |
-
'_title' => array(
|
307 |
-
'mode' => 'required',
|
308 |
-
'error' => __('You must provide a title','ultimate-member')
|
309 |
-
),
|
310 |
-
'_metakey' => array(
|
311 |
-
'mode' => 'unique',
|
312 |
-
),
|
313 |
-
'_options' => array(
|
314 |
-
'mode' => 'required',
|
315 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
316 |
-
),
|
317 |
-
)
|
318 |
-
),
|
319 |
-
|
320 |
-
'radio' => array(
|
321 |
-
'name' => 'Radio',
|
322 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
323 |
-
'col2' => array('_label','_public','_roles'),
|
324 |
-
'col3' => array('_required','_editable','_icon'),
|
325 |
-
'validate' => array(
|
326 |
-
'_title' => array(
|
327 |
-
'mode' => 'required',
|
328 |
-
'error' => __('You must provide a title','ultimate-member')
|
329 |
-
),
|
330 |
-
'_metakey' => array(
|
331 |
-
'mode' => 'unique',
|
332 |
-
),
|
333 |
-
'_options' => array(
|
334 |
-
'mode' => 'required',
|
335 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
336 |
-
),
|
337 |
-
)
|
338 |
-
),
|
339 |
-
|
340 |
-
'checkbox' => array(
|
341 |
-
'name' => 'Checkbox',
|
342 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
343 |
-
'col2' => array('_label','_public','_roles','_max_selections'),
|
344 |
-
'col3' => array('_required','_editable','_icon'),
|
345 |
-
'validate' => array(
|
346 |
-
'_title' => array(
|
347 |
-
'mode' => 'required',
|
348 |
-
'error' => __('You must provide a title','ultimate-member')
|
349 |
-
),
|
350 |
-
'_metakey' => array(
|
351 |
-
'mode' => 'unique',
|
352 |
-
),
|
353 |
-
'_options' => array(
|
354 |
-
'mode' => 'required',
|
355 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
356 |
-
),
|
357 |
-
)
|
358 |
-
),
|
359 |
-
|
360 |
-
'url' => array(
|
361 |
-
'name' => 'URL',
|
362 |
-
'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
|
363 |
-
'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
|
364 |
-
'col3' => array('_required','_editable','_icon'),
|
365 |
-
'validate' => array(
|
366 |
-
'_title' => array(
|
367 |
-
'mode' => 'required',
|
368 |
-
'error' => __('You must provide a title','ultimate-member')
|
369 |
-
),
|
370 |
-
'_metakey' => array(
|
371 |
-
'mode' => 'unique',
|
372 |
-
),
|
373 |
-
)
|
374 |
-
),
|
375 |
-
|
376 |
-
'password' => array(
|
377 |
-
'name' => 'Password',
|
378 |
-
'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
|
379 |
-
'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
|
380 |
-
'col3' => array('_required','_editable','_icon'),
|
381 |
-
'validate' => array(
|
382 |
-
'_title' => array(
|
383 |
-
'mode' => 'required',
|
384 |
-
'error' => __('You must provide a title','ultimate-member')
|
385 |
-
),
|
386 |
-
'_metakey' => array(
|
387 |
-
'mode' => 'unique',
|
388 |
-
),
|
389 |
-
)
|
390 |
-
),
|
391 |
-
|
392 |
-
'image' => array(
|
393 |
-
'name' => 'Image Upload',
|
394 |
-
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
|
395 |
-
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
396 |
-
'col3' => array('_required','_editable','_icon'),
|
397 |
-
'validate' => array(
|
398 |
-
'_title' => array(
|
399 |
-
'mode' => 'required',
|
400 |
-
'error' => __('You must provide a title','ultimate-member')
|
401 |
-
),
|
402 |
-
'_metakey' => array(
|
403 |
-
'mode' => 'unique',
|
404 |
-
),
|
405 |
-
'_max_size' => array(
|
406 |
-
'mode' => 'numeric',
|
407 |
-
'error' => __('Please enter a valid size','ultimate-member')
|
408 |
-
),
|
409 |
-
)
|
410 |
-
),
|
411 |
-
|
412 |
-
'file' => array(
|
413 |
-
'name' => 'File Upload',
|
414 |
-
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
|
415 |
-
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
416 |
-
'col3' => array('_required','_editable','_icon'),
|
417 |
-
'validate' => array(
|
418 |
-
'_title' => array(
|
419 |
-
'mode' => 'required',
|
420 |
-
'error' => __('You must provide a title','ultimate-member')
|
421 |
-
),
|
422 |
-
'_metakey' => array(
|
423 |
-
'mode' => 'unique',
|
424 |
-
),
|
425 |
-
'_max_size' => array(
|
426 |
-
'mode' => 'numeric',
|
427 |
-
'error' => __( 'Please enter a valid size', 'ultimate-member' )
|
428 |
-
),
|
429 |
-
)
|
430 |
-
),
|
431 |
-
|
432 |
-
'date' => array(
|
433 |
-
'name' => 'Date Picker',
|
434 |
-
'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
|
435 |
-
'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
|
436 |
-
'col3' => array( '_required', '_editable', '_icon' ),
|
437 |
-
'validate' => array(
|
438 |
-
'_title' => array(
|
439 |
-
'mode' => 'required',
|
440 |
-
'error' => __( 'You must provide a title', 'ultimate-member' )
|
441 |
-
),
|
442 |
-
'_metakey' => array(
|
443 |
-
'mode' => 'unique',
|
444 |
-
),
|
445 |
-
'_years' => array(
|
446 |
-
'mode' => 'numeric',
|
447 |
-
'error' => __( 'Number of years is not valid', 'ultimate-member' )
|
448 |
-
),
|
449 |
-
'_range_start' => array(
|
450 |
-
'mode' => 'range-start',
|
451 |
-
),
|
452 |
-
'_range_end' => array(
|
453 |
-
'mode' => 'range-end',
|
454 |
-
),
|
455 |
-
)
|
456 |
-
),
|
457 |
-
|
458 |
-
'time' => array(
|
459 |
-
'name' => 'Time Picker',
|
460 |
-
'col1' => array('_title','_metakey','_help','_format','_visibility'),
|
461 |
-
'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
|
462 |
-
'col3' => array('_required','_editable','_icon'),
|
463 |
-
'validate' => array(
|
464 |
-
'_title' => array(
|
465 |
-
'mode' => 'required',
|
466 |
-
'error' => __( 'You must provide a title', 'ultimate-member' )
|
467 |
-
),
|
468 |
-
'_metakey' => array(
|
469 |
-
'mode' => 'unique',
|
470 |
-
),
|
471 |
-
)
|
472 |
-
),
|
473 |
-
|
474 |
-
'rating' => array(
|
475 |
-
'name' => 'Rating',
|
476 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
477 |
-
'col2' => array('_label','_public','_roles','_number','_default'),
|
478 |
-
'col3' => array('_required','_editable','_icon'),
|
479 |
-
'validate' => array(
|
480 |
-
'_title' => array(
|
481 |
-
'mode' => 'required',
|
482 |
-
'error' => __('You must provide a title','ultimate-member')
|
483 |
-
),
|
484 |
-
'_metakey' => array(
|
485 |
-
'mode' => 'unique',
|
486 |
-
),
|
487 |
-
)
|
488 |
-
),
|
489 |
-
|
490 |
-
'block' => array(
|
491 |
-
'name' => 'Content Block',
|
492 |
-
'col1' => array('_title','_visibility'),
|
493 |
-
'col2' => array('_public','_roles'),
|
494 |
-
'col_full' => array('_content'),
|
495 |
-
'mce_content' => true,
|
496 |
-
'validate' => array(
|
497 |
-
'_title' => array(
|
498 |
-
'mode' => 'required',
|
499 |
-
'error' => __('You must provide a title','ultimate-member')
|
500 |
-
),
|
501 |
-
)
|
502 |
-
),
|
503 |
-
|
504 |
-
'shortcode' => array(
|
505 |
-
'name' => 'Shortcode',
|
506 |
-
'col1' => array('_title','_visibility'),
|
507 |
-
'col2' => array('_public','_roles'),
|
508 |
-
'col_full' => array('_content'),
|
509 |
-
'validate' => array(
|
510 |
-
'_title' => array(
|
511 |
-
'mode' => 'required',
|
512 |
-
'error' => __('You must provide a title','ultimate-member')
|
513 |
-
),
|
514 |
-
'_content' => array(
|
515 |
-
'mode' => 'required',
|
516 |
-
'error' => __('You must add a shortcode to the content area','ultimate-member')
|
517 |
-
),
|
518 |
-
)
|
519 |
-
),
|
520 |
-
|
521 |
-
'spacing' => array(
|
522 |
-
'name' => 'Spacing',
|
523 |
-
'col1' => array('_title','_visibility'),
|
524 |
-
'col2' => array('_spacing'),
|
525 |
-
'form_only' => true,
|
526 |
-
'validate' => array(
|
527 |
-
'_title' => array(
|
528 |
-
'mode' => 'required',
|
529 |
-
'error' => __('You must provide a title','ultimate-member')
|
530 |
-
),
|
531 |
-
)
|
532 |
-
),
|
533 |
-
|
534 |
-
'divider' => array(
|
535 |
-
'name' => 'Divider',
|
536 |
-
'col1' => array('_title','_width','_divider_text','_visibility'),
|
537 |
-
'col2' => array('_style','_color','_public','_roles'),
|
538 |
-
'form_only' => true,
|
539 |
-
'validate' => array(
|
540 |
-
'_title' => array(
|
541 |
-
'mode' => 'required',
|
542 |
-
'error' => __('You must provide a title','ultimate-member')
|
543 |
-
),
|
544 |
-
)
|
545 |
-
),
|
546 |
-
|
547 |
-
'googlemap' => array(
|
548 |
-
'name' => 'Google Map',
|
549 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
550 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
551 |
-
'col3' => array('_required','_editable','_icon'),
|
552 |
-
'validate' => array(
|
553 |
-
'_title' => array(
|
554 |
-
'mode' => 'required',
|
555 |
-
'error' => __('You must provide a title','ultimate-member')
|
556 |
-
),
|
557 |
-
'_metakey' => array(
|
558 |
-
'mode' => 'unique',
|
559 |
-
),
|
560 |
-
)
|
561 |
-
),
|
562 |
-
|
563 |
-
'youtube_video' => array(
|
564 |
-
'name' => 'YouTube Video',
|
565 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
566 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
567 |
-
'col3' => array('_required','_editable','_icon'),
|
568 |
-
'validate' => array(
|
569 |
-
'_title' => array(
|
570 |
-
'mode' => 'required',
|
571 |
-
'error' => __('You must provide a title','ultimate-member')
|
572 |
-
),
|
573 |
-
'_metakey' => array(
|
574 |
-
'mode' => 'unique',
|
575 |
-
),
|
576 |
-
)
|
577 |
-
),
|
578 |
-
|
579 |
-
'vimeo_video' => array(
|
580 |
-
'name' => 'Vimeo Video',
|
581 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
582 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
583 |
-
'col3' => array('_required','_editable','_icon'),
|
584 |
-
'validate' => array(
|
585 |
-
'_title' => array(
|
586 |
-
'mode' => 'required',
|
587 |
-
'error' => __('You must provide a title','ultimate-member')
|
588 |
-
),
|
589 |
-
'_metakey' => array(
|
590 |
-
'mode' => 'unique',
|
591 |
-
),
|
592 |
-
)
|
593 |
-
),
|
594 |
-
|
595 |
-
'soundcloud_track' => array(
|
596 |
-
'name' => 'SoundCloud Track',
|
597 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
598 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
599 |
-
'col3' => array('_required','_editable','_icon'),
|
600 |
-
'validate' => array(
|
601 |
-
'_title' => array(
|
602 |
-
'mode' => 'required',
|
603 |
-
'error' => __('You must provide a title','ultimate-member')
|
604 |
-
),
|
605 |
-
'_metakey' => array(
|
606 |
-
'mode' => 'unique',
|
607 |
-
),
|
608 |
-
)
|
609 |
-
),
|
610 |
-
|
611 |
-
/*'group' => array(
|
612 |
-
'name' => 'Field Group',
|
613 |
-
'col1' => array('_title','_max_entries'),
|
614 |
-
'col2' => array('_label','_public','_roles'),
|
615 |
-
'form_only' => true,
|
616 |
-
'validate' => array(
|
617 |
-
'_title' => array(
|
618 |
-
'mode' => 'required',
|
619 |
-
'error' => 'You must provide a title'
|
620 |
-
),
|
621 |
-
'_label' => array(
|
622 |
-
'mode' => 'required',
|
623 |
-
'error' => 'You must provide a label'
|
624 |
-
),
|
625 |
-
)
|
626 |
-
),*/
|
627 |
-
|
628 |
-
);
|
629 |
-
|
630 |
-
/**
|
631 |
-
* UM hook
|
632 |
-
*
|
633 |
-
* @type filter
|
634 |
-
* @title um_core_fields_hook
|
635 |
-
* @description UM Core Fields
|
636 |
-
* @input_vars
|
637 |
-
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
638 |
-
* @change_log
|
639 |
-
* ["Since: 2.0"]
|
640 |
-
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
641 |
-
* @example
|
642 |
-
* <?php
|
643 |
-
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
644 |
-
* function my_core_fields( $core_fields ) {
|
645 |
-
* // your code here
|
646 |
-
* return $core_fields;
|
647 |
-
* }
|
648 |
-
* ?>
|
649 |
-
*/
|
650 |
-
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
651 |
-
}
|
652 |
-
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Predefined Fields
|
656 |
-
*/
|
657 |
-
function set_predefined_fields() {
|
658 |
-
global $wp_roles;
|
659 |
-
|
660 |
-
$um_roles = array();
|
661 |
-
if ( ! empty( $wp_roles->roles ) ) {
|
662 |
-
$role_keys = get_option( 'um_roles', array() );
|
663 |
-
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
|
664 |
-
$role_keys = array_map( function( $item ) {
|
665 |
-
return 'um_' . $item;
|
666 |
-
}, $role_keys );
|
667 |
-
} else {
|
668 |
-
$role_keys = array();
|
669 |
-
}
|
670 |
-
|
671 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
672 |
-
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
673 |
-
}
|
674 |
-
|
675 |
-
/**
|
676 |
-
* UM hook
|
677 |
-
*
|
678 |
-
* @type filter
|
679 |
-
* @title um_profile_privacy_options
|
680 |
-
* @description Profile Privacy Options
|
681 |
-
* @input_vars
|
682 |
-
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
683 |
-
* @change_log
|
684 |
-
* ["Since: 2.0"]
|
685 |
-
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
686 |
-
* @example
|
687 |
-
* <?php
|
688 |
-
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
689 |
-
* function my_profile_privacy_options( $privacy_options ) {
|
690 |
-
* // your code here
|
691 |
-
* return $privacy_options;
|
692 |
-
* }
|
693 |
-
* ?>
|
694 |
-
*/
|
695 |
-
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
696 |
-
'Everyone' => __( 'Everyone', 'ultimate-member' ),
|
697 |
-
'Only me' => __( 'Only me', 'ultimate-member' )
|
698 |
-
) );
|
699 |
-
|
700 |
-
/*
|
701 |
-
* it's important create key for array equals value of 'metakey'.
|
702 |
-
*
|
703 |
-
*/
|
704 |
-
|
705 |
-
$this->predefined_fields = array(
|
706 |
-
|
707 |
-
'user_login' => array(
|
708 |
-
'title' => __('Username','ultimate-member'),
|
709 |
-
'metakey' => 'user_login',
|
710 |
-
'type' => 'text',
|
711 |
-
'label' => __('Username','ultimate-member'),
|
712 |
-
'required' => 1,
|
713 |
-
'public' => 1,
|
714 |
-
'editable' => 0,
|
715 |
-
'validate' => 'unique_username',
|
716 |
-
'min_chars' => 3,
|
717 |
-
'max_chars' => 24
|
718 |
-
),
|
719 |
-
|
720 |
-
'username' => array(
|
721 |
-
'title' => __('Username or E-mail','ultimate-member'),
|
722 |
-
'metakey' => 'username',
|
723 |
-
'type' => 'text',
|
724 |
-
'label' => __('Username or E-mail','ultimate-member'),
|
725 |
-
'required' => 1,
|
726 |
-
'public' => 1,
|
727 |
-
'editable' => 0,
|
728 |
-
'validate' => 'unique_username_or_email',
|
729 |
-
),
|
730 |
-
|
731 |
-
'user_password' => array(
|
732 |
-
'title' => __('Password','ultimate-member'),
|
733 |
-
'metakey' => 'user_password',
|
734 |
-
'type' => 'password',
|
735 |
-
'label' => __('Password','ultimate-member'),
|
736 |
-
'required' => 1,
|
737 |
-
'public' => 1,
|
738 |
-
'editable' => 1,
|
739 |
-
'min_chars' => 8,
|
740 |
-
'max_chars' => 30,
|
741 |
-
'force_good_pass' => 1,
|
742 |
-
'force_confirm_pass' => 1,
|
743 |
-
'label_confirm_pass' => __('Confirm Password','ultimate-member')
|
744 |
-
),
|
745 |
-
|
746 |
-
'first_name' => array(
|
747 |
-
'title' => __('First Name','ultimate-member'),
|
748 |
-
'metakey' => 'first_name',
|
749 |
-
'type' => 'text',
|
750 |
-
'label' => __('First Name','ultimate-member'),
|
751 |
-
'required' => 0,
|
752 |
-
'public' => 1,
|
753 |
-
'editable' => 1,
|
754 |
-
),
|
755 |
-
|
756 |
-
'last_name' => array(
|
757 |
-
'title' => __('Last Name','ultimate-member'),
|
758 |
-
'metakey' => 'last_name',
|
759 |
-
'type' => 'text',
|
760 |
-
'label' => __('Last Name','ultimate-member'),
|
761 |
-
'required' => 0,
|
762 |
-
'public' => 1,
|
763 |
-
'editable' => 1,
|
764 |
-
),
|
765 |
-
|
766 |
-
'nickname' => array(
|
767 |
-
'title' => __('Nickname','ultimate-member'),
|
768 |
-
'metakey' => 'nickname',
|
769 |
-
'type' => 'text',
|
770 |
-
'label' => __('Nickname','ultimate-member'),
|
771 |
-
'required' => 0,
|
772 |
-
'public' => 1,
|
773 |
-
'editable' => 1,
|
774 |
-
),
|
775 |
-
|
776 |
-
'user_url' => array(
|
777 |
-
'title' => __('Website URL','ultimate-member'),
|
778 |
-
'metakey' => 'user_url',
|
779 |
-
'type' => 'url',
|
780 |
-
'label' => __('Website URL','ultimate-member'),
|
781 |
-
'required' => 1,
|
782 |
-
'public' => 1,
|
783 |
-
'editable' => 1,
|
784 |
-
'validate' => 'url'
|
785 |
-
),
|
786 |
-
|
787 |
-
'user_registered' => array(
|
788 |
-
'title' => __('Registration Date','ultimate-member'),
|
789 |
-
'metakey' => 'user_registered',
|
790 |
-
'type' => 'text',
|
791 |
-
'label' => __('Registration Date','ultimate-member'),
|
792 |
-
'required' => 0,
|
793 |
-
'public' => 1,
|
794 |
-
'editable' => 1,
|
795 |
-
'edit_forbidden' => 1,
|
796 |
-
),
|
797 |
-
|
798 |
-
'_um_last_login' => array(
|
799 |
-
'title' => __('Last Login','ultimate-member'),
|
800 |
-
'metakey' => '_um_last_login',
|
801 |
-
'type' => 'text',
|
802 |
-
'label' => __('Last Login','ultimate-member'),
|
803 |
-
'required' => 0,
|
804 |
-
'public' => 1,
|
805 |
-
'editable' => 1,
|
806 |
-
'edit_forbidden' => 1,
|
807 |
-
),
|
808 |
-
|
809 |
-
'user_email' => array(
|
810 |
-
'title' => __('E-mail Address','ultimate-member'),
|
811 |
-
'metakey' => 'user_email',
|
812 |
-
'type' => 'text',
|
813 |
-
'label' => __('E-mail Address','ultimate-member'),
|
814 |
-
'required' => 0,
|
815 |
-
'public' => 1,
|
816 |
-
'validate' => 'unique_email',
|
817 |
-
'autocomplete' => 'off'
|
818 |
-
),
|
819 |
-
|
820 |
-
'secondary_user_email' => array(
|
821 |
-
'title' => __('Secondary E-mail Address','ultimate-member'),
|
822 |
-
'metakey' => 'secondary_user_email',
|
823 |
-
'type' => 'text',
|
824 |
-
'label' => __('Secondary E-mail Address','ultimate-member'),
|
825 |
-
'required' => 0,
|
826 |
-
'public' => 1,
|
827 |
-
'editable' => 1,
|
828 |
-
'validate' => 'unique_email',
|
829 |
-
'autocomplete' => 'off'
|
830 |
-
),
|
831 |
-
|
832 |
-
'description' => array(
|
833 |
-
'title' => __('Biography','ultimate-member'),
|
834 |
-
'metakey' => 'description',
|
835 |
-
'type' => 'textarea',
|
836 |
-
'label' => __('Biography','ultimate-member'),
|
837 |
-
'html' => 0,
|
838 |
-
'required' => 0,
|
839 |
-
'public' => 1,
|
840 |
-
'editable' => 1,
|
841 |
-
'max_words' => 40,
|
842 |
-
'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
|
843 |
-
),
|
844 |
-
|
845 |
-
'birth_date' => array(
|
846 |
-
'title' => __('Birth Date','ultimate-member'),
|
847 |
-
'metakey' => 'birth_date',
|
848 |
-
'type' => 'date',
|
849 |
-
'label' => __('Birth Date','ultimate-member'),
|
850 |
-
'required' => 0,
|
851 |
-
'public' => 1,
|
852 |
-
'editable' => 1,
|
853 |
-
'pretty_format' => 1,
|
854 |
-
'years' => 115,
|
855 |
-
'years_x' => 'past',
|
856 |
-
'icon' => 'um-faicon-calendar'
|
857 |
-
),
|
858 |
-
|
859 |
-
'gender' => array(
|
860 |
-
'title' => __('Gender','ultimate-member'),
|
861 |
-
'metakey' => 'gender',
|
862 |
-
'type' => 'radio',
|
863 |
-
'label' => __('Gender','ultimate-member'),
|
864 |
-
'required' => 0,
|
865 |
-
'public' => 1,
|
866 |
-
'editable' => 1,
|
867 |
-
'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
|
868 |
-
),
|
869 |
-
|
870 |
-
'country' => array(
|
871 |
-
'title' => __('Country','ultimate-member'),
|
872 |
-
'metakey' => 'country',
|
873 |
-
'type' => 'select',
|
874 |
-
'label' => __('Country','ultimate-member'),
|
875 |
-
'placeholder' => __('Choose a Country','ultimate-member'),
|
876 |
-
'required' => 0,
|
877 |
-
'public' => 1,
|
878 |
-
'editable' => 1,
|
879 |
-
'options' => $this->get('countries')
|
880 |
-
),
|
881 |
-
|
882 |
-
'facebook' => array(
|
883 |
-
'title' => __('Facebook','ultimate-member'),
|
884 |
-
'metakey' => 'facebook',
|
885 |
-
'type' => 'url',
|
886 |
-
'label' => __('Facebook','ultimate-member'),
|
887 |
-
'required' => 0,
|
888 |
-
'public' => 1,
|
889 |
-
'editable' => 1,
|
890 |
-
'url_target' => '_blank',
|
891 |
-
'url_rel' => 'nofollow',
|
892 |
-
'icon' => 'um-faicon-facebook',
|
893 |
-
'validate' => 'facebook_url',
|
894 |
-
'url_text' => 'Facebook',
|
895 |
-
'advanced' => 'social',
|
896 |
-
'color' => '#3B5999',
|
897 |
-
'match' => 'https://facebook.com/',
|
898 |
-
),
|
899 |
-
|
900 |
-
'twitter' => array(
|
901 |
-
'title' => __('Twitter','ultimate-member'),
|
902 |
-
'metakey' => 'twitter',
|
903 |
-
'type' => 'url',
|
904 |
-
'label' => __('Twitter','ultimate-member'),
|
905 |
-
'required' => 0,
|
906 |
-
'public' => 1,
|
907 |
-
'editable' => 1,
|
908 |
-
'url_target' => '_blank',
|
909 |
-
'url_rel' => 'nofollow',
|
910 |
-
'icon' => 'um-faicon-twitter',
|
911 |
-
'validate' => 'twitter_url',
|
912 |
-
'url_text' => 'Twitter',
|
913 |
-
'advanced' => 'social',
|
914 |
-
'color' => '#4099FF',
|
915 |
-
'match' => 'https://twitter.com/',
|
916 |
-
),
|
917 |
-
|
918 |
-
'linkedin' => array(
|
919 |
-
'title' => __('LinkedIn','ultimate-member'),
|
920 |
-
'metakey' => 'linkedin',
|
921 |
-
'type' => 'url',
|
922 |
-
'label' => __('LinkedIn','ultimate-member'),
|
923 |
-
'required' => 0,
|
924 |
-
'public' => 1,
|
925 |
-
'editable' => 1,
|
926 |
-
'url_target' => '_blank',
|
927 |
-
'url_rel' => 'nofollow',
|
928 |
-
'icon' => 'um-faicon-linkedin',
|
929 |
-
'validate' => 'linkedin_url',
|
930 |
-
'url_text' => 'LinkedIn',
|
931 |
-
'advanced' => 'social',
|
932 |
-
'color' => '#0976b4',
|
933 |
-
'match' => 'https://linkedin.com/in/',
|
934 |
-
),
|
935 |
-
|
936 |
-
'googleplus' => array(
|
937 |
-
'title' => __('Google+','ultimate-member'),
|
938 |
-
'metakey' => 'googleplus',
|
939 |
-
'type' => 'url',
|
940 |
-
'label' => __('Google+','ultimate-member'),
|
941 |
-
'required' => 0,
|
942 |
-
'public' => 1,
|
943 |
-
'editable' => 1,
|
944 |
-
'url_target' => '_blank',
|
945 |
-
'url_rel' => 'nofollow',
|
946 |
-
'icon' => 'um-faicon-google-plus',
|
947 |
-
'validate' => 'google_url',
|
948 |
-
'url_text' => 'Google+',
|
949 |
-
'advanced' => 'social',
|
950 |
-
'color' => '#dd4b39',
|
951 |
-
'match' => 'https://google.com/+',
|
952 |
-
),
|
953 |
-
|
954 |
-
'instagram' => array(
|
955 |
-
'title' => __('Instagram','ultimate-member'),
|
956 |
-
'metakey' => 'instagram',
|
957 |
-
'type' => 'url',
|
958 |
-
'label' => __('Instagram','ultimate-member'),
|
959 |
-
'required' => 0,
|
960 |
-
'public' => 1,
|
961 |
-
'editable' => 1,
|
962 |
-
'url_target' => '_blank',
|
963 |
-
'url_rel' => 'nofollow',
|
964 |
-
'icon' => 'um-faicon-instagram',
|
965 |
-
'validate' => 'instagram_url',
|
966 |
-
'url_text' => 'Instagram',
|
967 |
-
'advanced' => 'social',
|
968 |
-
'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
|
969 |
-
'match' => 'https://instagram.com/',
|
970 |
-
),
|
971 |
-
|
972 |
-
'skype' => array(
|
973 |
-
'title' => __('Skype ID','ultimate-member'),
|
974 |
-
'metakey' => 'skype',
|
975 |
-
'type' => 'url',
|
976 |
-
'label' => __('Skype ID','ultimate-member'),
|
977 |
-
'required' => 0,
|
978 |
-
'public' => 1,
|
979 |
-
'editable' => 1,
|
980 |
-
'url_target' => '_blank',
|
981 |
-
'url_rel' => 'nofollow',
|
982 |
-
'icon' => 'um-faicon-skype',
|
983 |
-
'validate' => 'skype',
|
984 |
-
'url_text' => 'Skype',
|
985 |
-
),
|
986 |
-
|
987 |
-
'youtube' => array(
|
988 |
-
'title' => __('YouTube','ultimate-member'),
|
989 |
-
'metakey' => 'youtube',
|
990 |
-
'type' => 'url',
|
991 |
-
'label' => __('YouTube','ultimate-member'),
|
992 |
-
'required' => 0,
|
993 |
-
'public' => 1,
|
994 |
-
'editable' => 1,
|
995 |
-
'url_target' => '_blank',
|
996 |
-
'url_rel' => 'nofollow',
|
997 |
-
'icon' => 'um-faicon-youtube',
|
998 |
-
'validate' => 'youtube_url',
|
999 |
-
'url_text' => 'YouTube',
|
1000 |
-
'advanced' => 'social',
|
1001 |
-
'color' => '#e52d27',
|
1002 |
-
'match' => 'https://youtube.com/',
|
1003 |
-
),
|
1004 |
-
|
1005 |
-
'soundcloud' => array(
|
1006 |
-
'title' => __('SoundCloud','ultimate-member'),
|
1007 |
-
'metakey' => 'soundcloud',
|
1008 |
-
'type' => 'url',
|
1009 |
-
'label' => __('SoundCloud','ultimate-member'),
|
1010 |
-
'required' => 0,
|
1011 |
-
'public' => 1,
|
1012 |
-
'editable' => 1,
|
1013 |
-
'url_target' => '_blank',
|
1014 |
-
'url_rel' => 'nofollow',
|
1015 |
-
'icon' => 'um-faicon-soundcloud',
|
1016 |
-
'validate' => 'soundcloud_url',
|
1017 |
-
'url_text' => 'SoundCloud',
|
1018 |
-
'advanced' => 'social',
|
1019 |
-
'color' => '#f50',
|
1020 |
-
'match' => 'https://soundcloud.com/',
|
1021 |
-
),
|
1022 |
-
|
1023 |
-
'vkontakte' => array(
|
1024 |
-
'title' => __('VKontakte','ultimate-member'),
|
1025 |
-
'metakey' => 'vkontakte',
|
1026 |
-
'type' => 'url',
|
1027 |
-
'label' => __('VKontakte','ultimate-member'),
|
1028 |
-
'required' => 0,
|
1029 |
-
'public' => 1,
|
1030 |
-
'editable' => 1,
|
1031 |
-
'url_target' => '_blank',
|
1032 |
-
'url_rel' => 'nofollow',
|
1033 |
-
'icon' => 'um-faicon-vk',
|
1034 |
-
'validate' => 'vk_url',
|
1035 |
-
'url_text' => 'VKontakte',
|
1036 |
-
'advanced' => 'social',
|
1037 |
-
'color' => '#2B587A',
|
1038 |
-
'match' => 'https://vk.com/',
|
1039 |
-
),
|
1040 |
-
|
1041 |
-
'role_select' => array(
|
1042 |
-
'title' => __('Roles (Dropdown)','ultimate-member'),
|
1043 |
-
'metakey' => 'role_select',
|
1044 |
-
'type' => 'select',
|
1045 |
-
'label' => __('Account Type','ultimate-member'),
|
1046 |
-
'placeholder' => 'Choose account type',
|
1047 |
-
'required' => 0,
|
1048 |
-
'public' => 1,
|
1049 |
-
'editable' => 1,
|
1050 |
-
'options' => $um_roles,
|
1051 |
-
),
|
1052 |
-
|
1053 |
-
'role_radio' => array(
|
1054 |
-
'title' => __('Roles (Radio)','ultimate-member'),
|
1055 |
-
'metakey' => 'role_radio',
|
1056 |
-
'type' => 'radio',
|
1057 |
-
'label' => __('Account Type','ultimate-member'),
|
1058 |
-
'required' => 0,
|
1059 |
-
'public' => 1,
|
1060 |
-
'editable' => 1,
|
1061 |
-
'options' => $um_roles,
|
1062 |
-
),
|
1063 |
-
|
1064 |
-
'languages' => array(
|
1065 |
-
'title' => __('Languages','ultimate-member'),
|
1066 |
-
'metakey' => 'languages',
|
1067 |
-
'type' => 'multiselect',
|
1068 |
-
'label' => __('Languages Spoken','ultimate-member'),
|
1069 |
-
'placeholder' => __('Select languages','ultimate-member'),
|
1070 |
-
'required' => 0,
|
1071 |
-
'public' => 1,
|
1072 |
-
'editable' => 1,
|
1073 |
-
'options' => $this->get('languages'),
|
1074 |
-
),
|
1075 |
-
|
1076 |
-
'phone_number' => array(
|
1077 |
-
'title' => __('Phone Number','ultimate-member'),
|
1078 |
-
'metakey' => 'phone_number',
|
1079 |
-
'type' => 'text',
|
1080 |
-
'label' => __('Phone Number','ultimate-member'),
|
1081 |
-
'required' => 0,
|
1082 |
-
'public' => 1,
|
1083 |
-
'editable' => 1,
|
1084 |
-
'validate' => 'phone_number',
|
1085 |
-
'icon' => 'um-faicon-phone',
|
1086 |
-
),
|
1087 |
-
|
1088 |
-
'mobile_number' => array(
|
1089 |
-
'title' => __('Mobile Number','ultimate-member'),
|
1090 |
-
'metakey' => 'mobile_number',
|
1091 |
-
'type' => 'text',
|
1092 |
-
'label' => __('Mobile Number','ultimate-member'),
|
1093 |
-
'required' => 0,
|
1094 |
-
'public' => 1,
|
1095 |
-
'editable' => 1,
|
1096 |
-
'validate' => 'phone_number',
|
1097 |
-
'icon' => 'um-faicon-mobile',
|
1098 |
-
),
|
1099 |
-
|
1100 |
-
// private use ( not public list )
|
1101 |
-
|
1102 |
-
'profile_photo' => array(
|
1103 |
-
'title' => __('Profile Photo','ultimate-member'),
|
1104 |
-
'metakey' => 'profile_photo',
|
1105 |
-
'type' => 'image',
|
1106 |
-
'label' => __('Change your profile photo','ultimate-member'),
|
1107 |
-
'upload_text' => __('Upload your photo here','ultimate-member'),
|
1108 |
-
'icon' => 'um-faicon-camera',
|
1109 |
-
'crop' => 1,
|
1110 |
-
'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
|
1111 |
-
'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1112 |
-
'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1113 |
-
'private_use' => true,
|
1114 |
-
),
|
1115 |
-
|
1116 |
-
'cover_photo' => array(
|
1117 |
-
'title' => __('Cover Photo','ultimate-member'),
|
1118 |
-
'metakey' => 'cover_photo',
|
1119 |
-
'type' => 'image',
|
1120 |
-
'label' => __('Change your cover photo','ultimate-member'),
|
1121 |
-
'upload_text' => __('Upload profile cover here','ultimate-member'),
|
1122 |
-
'icon' => 'um-faicon-picture-o',
|
1123 |
-
'crop' => 2,
|
1124 |
-
'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
|
1125 |
-
'modal_size' => 'large',
|
1126 |
-
'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
|
1127 |
-
'min_width' => UM()->options()->get('cover_min_width'),
|
1128 |
-
'private_use' => true,
|
1129 |
-
),
|
1130 |
-
|
1131 |
-
'username_b' => array(
|
1132 |
-
'title' => __('Username or E-mail','ultimate-member'),
|
1133 |
-
'metakey' => 'username_b',
|
1134 |
-
'type' => 'text',
|
1135 |
-
'placeholder' => __('Enter your username or email','ultimate-member'),
|
1136 |
-
'required' => 1,
|
1137 |
-
'public' => 1,
|
1138 |
-
'editable' => 0,
|
1139 |
-
'private_use' => true,
|
1140 |
-
),
|
1141 |
-
|
1142 |
-
// account page use ( not public )
|
1143 |
-
|
1144 |
-
'profile_privacy' => array(
|
1145 |
-
'title' => __( 'Profile Privacy', 'ultimate-member' ),
|
1146 |
-
'metakey' => 'profile_privacy',
|
1147 |
-
'type' => 'select',
|
1148 |
-
'label' => __( 'Profile Privacy', 'ultimate-member' ),
|
1149 |
-
'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
|
1150 |
-
'required' => 0,
|
1151 |
-
'public' => 1,
|
1152 |
-
'editable' => 1,
|
1153 |
-
'default' => 'Everyone',
|
1154 |
-
'options' => $profile_privacy,
|
1155 |
-
'allowclear' => 0,
|
1156 |
-
'account_only' => true,
|
1157 |
-
'required_perm' => 'can_make_private_profile',
|
1158 |
-
),
|
1159 |
-
|
1160 |
-
'profile_noindex' => array(
|
1161 |
-
'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1162 |
-
'metakey' => 'profile_noindex',
|
1163 |
-
'type' => 'select',
|
1164 |
-
'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1165 |
-
'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
|
1166 |
-
'required' => 0,
|
1167 |
-
'public' => 1,
|
1168 |
-
'editable' => 1,
|
1169 |
-
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
|
1170 |
-
'options' => array(
|
1171 |
-
'0' => __( 'No', 'ultimate-member' ),
|
1172 |
-
'1' => __( 'Yes', 'ultimate-member' ),
|
1173 |
-
),
|
1174 |
-
'allowclear' => 0,
|
1175 |
-
'account_only' => true,
|
1176 |
-
'required_perm' => 'can_make_private_profile',
|
1177 |
-
),
|
1178 |
-
|
1179 |
-
'hide_in_members' => array(
|
1180 |
-
'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1181 |
-
'metakey' => 'hide_in_members',
|
1182 |
-
'type' => 'radio',
|
1183 |
-
'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1184 |
-
'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
|
1185 |
-
'required' => 0,
|
1186 |
-
'public' => 1,
|
1187 |
-
'editable' => 1,
|
1188 |
-
'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
|
1189 |
-
'options' => array(
|
1190 |
-
'No' => __( 'No', 'ultimate-member' ),
|
1191 |
-
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1192 |
-
),
|
1193 |
-
'account_only' => true,
|
1194 |
-
'required_opt' => array( 'members_page', 1 ),
|
1195 |
-
),
|
1196 |
-
|
1197 |
-
'delete_account' => array(
|
1198 |
-
'title' => __( 'Delete Account', 'ultimate-member' ),
|
1199 |
-
'metakey' => 'delete_account',
|
1200 |
-
'type' => 'radio',
|
1201 |
-
'label' => __( 'Delete Account', 'ultimate-member'),
|
1202 |
-
'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
|
1203 |
-
'required' => 0,
|
1204 |
-
'public' => 1,
|
1205 |
-
'editable' => 1,
|
1206 |
-
'default' => __( 'No', 'ultimate-member' ),
|
1207 |
-
'options' => array(
|
1208 |
-
__( 'Yes', 'ultimate-member' ),
|
1209 |
-
__( 'No', 'ultimate-member' )
|
1210 |
-
),
|
1211 |
-
'account_only' => true,
|
1212 |
-
),
|
1213 |
-
|
1214 |
-
'single_user_password' => array(
|
1215 |
-
'title' => __( 'Password', 'ultimate-member' ),
|
1216 |
-
'metakey' => 'single_user_password',
|
1217 |
-
'type' => 'password',
|
1218 |
-
'label' => __( 'Password', 'ultimate-member' ),
|
1219 |
-
'required' => 1,
|
1220 |
-
'public' => 1,
|
1221 |
-
'editable' => 1,
|
1222 |
-
'account_only' => true,
|
1223 |
-
),
|
1224 |
-
|
1225 |
-
);
|
1226 |
-
|
1227 |
-
/**
|
1228 |
-
* UM hook
|
1229 |
-
*
|
1230 |
-
* @type filter
|
1231 |
-
* @title um_predefined_fields_hook
|
1232 |
-
* @description Extend Predefined Fields
|
1233 |
-
* @input_vars
|
1234 |
-
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
1235 |
-
* @change_log
|
1236 |
-
* ["Since: 2.0"]
|
1237 |
-
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
1238 |
-
* @example
|
1239 |
-
* <?php
|
1240 |
-
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
1241 |
-
* function my_predefined_fields( $predefined_fields ) {
|
1242 |
-
* // your code here
|
1243 |
-
* return $predefined_fields;
|
1244 |
-
* }
|
1245 |
-
* ?>
|
1246 |
-
*/
|
1247 |
-
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
1248 |
-
}
|
1249 |
-
|
1250 |
-
|
1251 |
-
/**
|
1252 |
-
* Custom Fields
|
1253 |
-
*/
|
1254 |
-
function set_custom_fields() {
|
1255 |
-
|
1256 |
-
if ( is_array( $this->saved_fields ) ) {
|
1257 |
-
|
1258 |
-
$this->custom_fields = $this->saved_fields;
|
1259 |
-
|
1260 |
-
} else {
|
1261 |
-
|
1262 |
-
$this->custom_fields = '';
|
1263 |
-
|
1264 |
-
}
|
1265 |
-
|
1266 |
-
$custom = $this->custom_fields;
|
1267 |
-
$predefined = $this->predefined_fields;
|
1268 |
-
|
1269 |
-
if ( is_array( $custom ) ){
|
1270 |
-
$this->all_user_fields = array_merge( $predefined, $custom );
|
1271 |
-
} else {
|
1272 |
-
$this->all_user_fields = $predefined;
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
}
|
1276 |
-
|
1277 |
-
|
1278 |
-
/**
|
1279 |
-
* Get all fields without metakeys
|
1280 |
-
*
|
1281 |
-
* @since 2.0.56
|
1282 |
-
*
|
1283 |
-
* @return array
|
1284 |
-
*/
|
1285 |
-
function get_fields_without_metakey() {
|
1286 |
-
$fields_without_metakey = array(
|
1287 |
-
'block',
|
1288 |
-
'shortcode',
|
1289 |
-
'spacing',
|
1290 |
-
'divider',
|
1291 |
-
'group'
|
1292 |
-
);
|
1293 |
-
|
1294 |
-
|
1295 |
-
/**
|
1296 |
-
* UM hook
|
1297 |
-
*
|
1298 |
-
* @type filter
|
1299 |
-
* @title um_fields_without_metakey
|
1300 |
-
* @description Field Types without meta key
|
1301 |
-
* @input_vars
|
1302 |
-
* [{"var":"$types","type":"array","desc":"Field Types"}]
|
1303 |
-
* @change_log
|
1304 |
-
* ["Since: 2.0"]
|
1305 |
-
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
1306 |
-
* @example
|
1307 |
-
* <?php
|
1308 |
-
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
1309 |
-
* function my_fields_without_metakey( $types ) {
|
1310 |
-
* // your code here
|
1311 |
-
* return $types;
|
1312 |
-
* }
|
1313 |
-
* ?>
|
1314 |
-
*/
|
1315 |
-
return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
1316 |
-
}
|
1317 |
-
|
1318 |
-
|
1319 |
-
/**
|
1320 |
-
* May be used to show a dropdown, or source for user meta
|
1321 |
-
*
|
1322 |
-
* @param null $exclude_types
|
1323 |
-
* @param bool $show_all
|
1324 |
-
*
|
1325 |
-
* @return array
|
1326 |
-
*/
|
1327 |
-
function all_user_fields( $exclude_types = null, $show_all = false ) {
|
1328 |
-
|
1329 |
-
$fields_without_metakey = $this->get_fields_without_metakey();
|
1330 |
-
$fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
|
1331 |
-
|
1332 |
-
if ( ! $show_all ) {
|
1333 |
-
$this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
|
1334 |
-
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
|
1335 |
-
} else {
|
1336 |
-
$this->fields_dropdown = $fields_without_metakey;
|
1337 |
-
}
|
1338 |
-
|
1339 |
-
$custom = $this->custom_fields;
|
1340 |
-
$predefined = $this->predefined_fields;
|
1341 |
-
|
1342 |
-
if ( $exclude_types ) {
|
1343 |
-
$exclude_types = explode( ',', $exclude_types );
|
1344 |
-
}
|
1345 |
-
|
1346 |
-
$all = array( 0 => '' );
|
1347 |
-
|
1348 |
-
if ( is_array( $custom ) ) {
|
1349 |
-
$all = $all + array_merge( $predefined, $custom );
|
1350 |
-
} else {
|
1351 |
-
$all = $all + $predefined;
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
foreach ( $all as $k => $arr ) {
|
1355 |
-
|
1356 |
-
if ( $k == 0 ) {
|
1357 |
-
unset( $all[ $k ] );
|
1358 |
-
}
|
1359 |
-
|
1360 |
-
if ( isset( $arr['title'] ) ) {
|
1361 |
-
$all[ $k ]['title'] = stripslashes( $arr['title'] );
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
|
1365 |
-
unset( $all[ $k ] );
|
1366 |
-
}
|
1367 |
-
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
1368 |
-
if ( ! $show_all ) {
|
1369 |
-
unset( $all[ $k ] );
|
1370 |
-
}
|
1371 |
-
}
|
1372 |
-
if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
|
1373 |
-
unset( $all[ $k ] );
|
1374 |
-
}
|
1375 |
-
}
|
1376 |
-
|
1377 |
-
$all = UM()->fields()->array_sort_by_column( $all, 'title' );
|
1378 |
-
|
1379 |
-
return $all;
|
1380 |
-
}
|
1381 |
-
|
1382 |
-
|
1383 |
-
/**
|
1384 |
-
* Possible validation types for fields
|
1385 |
-
*
|
1386 |
-
* @return mixed
|
1387 |
-
*/
|
1388 |
-
function validation_types() {
|
1389 |
-
|
1390 |
-
$array[0] = __('None','ultimate-member');
|
1391 |
-
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
|
1392 |
-
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
|
1393 |
-
$array['english'] = __('English letters only','ultimate-member');
|
1394 |
-
$array['facebook_url'] = __('Facebook URL','ultimate-member');
|
1395 |
-
$array['google_url'] = __('Google+ URL','ultimate-member');
|
1396 |
-
$array['instagram_url'] = __('Instagram URL','ultimate-member');
|
1397 |
-
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
|
1398 |
-
$array['vk_url'] = __('VKontakte URL','ultimate-member');
|
1399 |
-
$array['lowercase'] = __('Lowercase only','ultimate-member');
|
1400 |
-
$array['numeric'] = __('Numeric value only','ultimate-member');
|
1401 |
-
$array['phone_number'] = __('Phone Number','ultimate-member');
|
1402 |
-
$array['skype'] = __('Skype ID','ultimate-member');
|
1403 |
-
$array['soundcloud'] = __('SoundCloud Profile','ultimate-member');
|
1404 |
-
$array['twitter_url'] = __('Twitter URL','ultimate-member');
|
1405 |
-
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
1406 |
-
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
1407 |
-
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
1408 |
-
$array['unique_username'] = __('Unique Username','ultimate-member');
|
1409 |
-
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1410 |
-
$array['url'] = __('Website URL','ultimate-member');
|
1411 |
-
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1412 |
-
$array['custom'] = __('Custom Validation','ultimate-member');
|
1413 |
-
|
1414 |
-
/**
|
1415 |
-
* UM hook
|
1416 |
-
*
|
1417 |
-
* @type filter
|
1418 |
-
* @title um_admin_field_validation_hook
|
1419 |
-
* @description Extend validation types
|
1420 |
-
* @input_vars
|
1421 |
-
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
1422 |
-
* @change_log
|
1423 |
-
* ["Since: 2.0"]
|
1424 |
-
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
1425 |
-
* @example
|
1426 |
-
* <?php
|
1427 |
-
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
1428 |
-
* function my_admin_field_validation( $types ) {
|
1429 |
-
* // your code here
|
1430 |
-
* return $types;
|
1431 |
-
* }
|
1432 |
-
* ?>
|
1433 |
-
*/
|
1434 |
-
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
1435 |
-
return $array;
|
1436 |
-
}
|
1437 |
-
|
1438 |
-
|
1439 |
-
/**
|
1440 |
-
* Get predefined options
|
1441 |
-
*
|
1442 |
-
* @param $data
|
1443 |
-
*
|
1444 |
-
* @return array|mixed|void
|
1445 |
-
*/
|
1446 |
-
function get( $data ) {
|
1447 |
-
switch ( $data ) {
|
1448 |
-
|
1449 |
-
case 'languages':
|
1450 |
-
$array = array(
|
1451 |
-
"aa" => __("Afar",'ultimate-member'),
|
1452 |
-
"ab" => __("Abkhazian",'ultimate-member'),
|
1453 |
-
"ae" => __("Avestan",'ultimate-member'),
|
1454 |
-
"af" => __("Afrikaans",'ultimate-member'),
|
1455 |
-
"ak" => __("Akan",'ultimate-member'),
|
1456 |
-
"am" => __("Amharic",'ultimate-member'),
|
1457 |
-
"an" => __("Aragonese",'ultimate-member'),
|
1458 |
-
"ar" => __("Arabic",'ultimate-member'),
|
1459 |
-
"as" => __("Assamese",'ultimate-member'),
|
1460 |
-
"av" => __("Avaric",'ultimate-member'),
|
1461 |
-
"ay" => __("Aymara",'ultimate-member'),
|
1462 |
-
"az" => __("Azerbaijani",'ultimate-member'),
|
1463 |
-
"ba" => __("Bashkir",'ultimate-member'),
|
1464 |
-
"be" => __("Belarusian",'ultimate-member'),
|
1465 |
-
"bg" => __("Bulgarian",'ultimate-member'),
|
1466 |
-
"bh" => __("Bihari",'ultimate-member'),
|
1467 |
-
"bi" => __("Bislama",'ultimate-member'),
|
1468 |
-
"bm" => __("Bambara",'ultimate-member'),
|
1469 |
-
"bn" => __("Bengali",'ultimate-member'),
|
1470 |
-
"bo" => __("Tibetan",'ultimate-member'),
|
1471 |
-
"br" => __("Breton",'ultimate-member'),
|
1472 |
-
"bs" => __("Bosnian",'ultimate-member'),
|
1473 |
-
"ca" => __("Catalan",'ultimate-member'),
|
1474 |
-
"ce" => __("Chechen",'ultimate-member'),
|
1475 |
-
"ch" => __("Chamorro",'ultimate-member'),
|
1476 |
-
"co" => __("Corsican",'ultimate-member'),
|
1477 |
-
"cr" => __("Cree",'ultimate-member'),
|
1478 |
-
"cs" => __("Czech",'ultimate-member'),
|
1479 |
-
"cu" => __("Church Slavic",'ultimate-member'),
|
1480 |
-
"cv" => __("Chuvash",'ultimate-member'),
|
1481 |
-
"cy" => __("Welsh",'ultimate-member'),
|
1482 |
-
"da" => __("Danish",'ultimate-member'),
|
1483 |
-
"de" => __("German",'ultimate-member'),
|
1484 |
-
"dv" => __("Divehi",'ultimate-member'),
|
1485 |
-
"dz" => __("Dzongkha",'ultimate-member'),
|
1486 |
-
"ee" => __("Ewe",'ultimate-member'),
|
1487 |
-
"el" => __("Greek",'ultimate-member'),
|
1488 |
-
"en" => __("English",'ultimate-member'),
|
1489 |
-
"eo" => __("Esperanto",'ultimate-member'),
|
1490 |
-
"es" => __("Spanish",'ultimate-member'),
|
1491 |
-
"et" => __("Estonian",'ultimate-member'),
|
1492 |
-
"eu" => __("Basque",'ultimate-member'),
|
1493 |
-
"fa" => __("Persian",'ultimate-member'),
|
1494 |
-
"ff" => __("Fulah",'ultimate-member'),
|
1495 |
-
"fi" => __("Finnish",'ultimate-member'),
|
1496 |
-
"fj" => __("Fijian",'ultimate-member'),
|
1497 |
-
"fo" => __("Faroese",'ultimate-member'),
|
1498 |
-
"fr" => __("French",'ultimate-member'),
|
1499 |
-
"fy" => __("Western Frisian",'ultimate-member'),
|
1500 |
-
"ga" => __("Irish",'ultimate-member'),
|
1501 |
-
"gd" => __("Scottish Gaelic",'ultimate-member'),
|
1502 |
-
"gl" => __("Galician",'ultimate-member'),
|
1503 |
-
"gn" => __("Guarani",'ultimate-member'),
|
1504 |
-
"gu" => __("Gujarati",'ultimate-member'),
|
1505 |
-
"gv" => __("Manx",'ultimate-member'),
|
1506 |
-
"ha" => __("Hausa",'ultimate-member'),
|
1507 |
-
"he" => __("Hebrew",'ultimate-member'),
|
1508 |
-
"hi" => __("Hindi",'ultimate-member'),
|
1509 |
-
"ho" => __("Hiri Motu",'ultimate-member'),
|
1510 |
-
"hr" => __("Croatian",'ultimate-member'),
|
1511 |
-
"ht" => __("Haitian",'ultimate-member'),
|
1512 |
-
"hu" => __("Hungarian",'ultimate-member'),
|
1513 |
-
"hy" => __("Armenian",'ultimate-member'),
|
1514 |
-
"hz" => __("Herero",'ultimate-member'),
|
1515 |
-
"ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
|
1516 |
-
"id" => __("Indonesian",'ultimate-member'),
|
1517 |
-
"ie" => __("Interlingue",'ultimate-member'),
|
1518 |
-
"ig" => __("Igbo",'ultimate-member'),
|
1519 |
-
"ii" => __("Sichuan Yi",'ultimate-member'),
|
1520 |
-
"ik" => __("Inupiaq",'ultimate-member'),
|
1521 |
-
"io" => __("Ido",'ultimate-member'),
|
1522 |
-
"is" => __("Icelandic",'ultimate-member'),
|
1523 |
-
"it" => __("Italian",'ultimate-member'),
|
1524 |
-
"iu" => __("Inuktitut",'ultimate-member'),
|
1525 |
-
"ja" => __("Japanese",'ultimate-member'),
|
1526 |
-
"jv" => __("Javanese",'ultimate-member'),
|
1527 |
-
"ka" => __("Georgian",'ultimate-member'),
|
1528 |
-
"kg" => __("Kongo",'ultimate-member'),
|
1529 |
-
"ki" => __("Kikuyu",'ultimate-member'),
|
1530 |
-
"kj" => __("Kwanyama",'ultimate-member'),
|
1531 |
-
"kk" => __("Kazakh",'ultimate-member'),
|
1532 |
-
"kl" => __("Kalaallisut",'ultimate-member'),
|
1533 |
-
"km" => __("Khmer",'ultimate-member'),
|
1534 |
-
"kn" => __("Kannada",'ultimate-member'),
|
1535 |
-
"ko" => __("Korean",'ultimate-member'),
|
1536 |
-
"kr" => __("Kanuri",'ultimate-member'),
|
1537 |
-
"ks" => __("Kashmiri",'ultimate-member'),
|
1538 |
-
"ku" => __("Kurdish",'ultimate-member'),
|
1539 |
-
"kv" => __("Komi",'ultimate-member'),
|
1540 |
-
"kw" => __("Cornish",'ultimate-member'),
|
1541 |
-
"ky" => __("Kirghiz",'ultimate-member'),
|
1542 |
-
"la" => __("Latin",'ultimate-member'),
|
1543 |
-
"lb" => __("Luxembourgish",'ultimate-member'),
|
1544 |
-
"lg" => __("Ganda",'ultimate-member'),
|
1545 |
-
"li" => __("Limburgish",'ultimate-member'),
|
1546 |
-
"ln" => __("Lingala",'ultimate-member'),
|
1547 |
-
"lo" => __("Lao",'ultimate-member'),
|
1548 |
-
"lt" => __("Lithuanian",'ultimate-member'),
|
1549 |
-
"lu" => __("Luba-Katanga",'ultimate-member'),
|
1550 |
-
"lv" => __("Latvian",'ultimate-member'),
|
1551 |
-
"mg" => __("Malagasy",'ultimate-member'),
|
1552 |
-
"mh" => __("Marshallese",'ultimate-member'),
|
1553 |
-
"mi" => __("Maori",'ultimate-member'),
|
1554 |
-
"mk" => __("Macedonian",'ultimate-member'),
|
1555 |
-
"ml" => __("Malayalam",'ultimate-member'),
|
1556 |
-
"mn" => __("Mongolian",'ultimate-member'),
|
1557 |
-
"mr" => __("Marathi",'ultimate-member'),
|
1558 |
-
"ms" => __("Malay",'ultimate-member'),
|
1559 |
-
"mt" => __("Maltese",'ultimate-member'),
|
1560 |
-
"my" => __("Burmese",'ultimate-member'),
|
1561 |
-
"na" => __("Nauru",'ultimate-member'),
|
1562 |
-
"nb" => __("Norwegian Bokmal",'ultimate-member'),
|
1563 |
-
"nd" => __("North Ndebele",'ultimate-member'),
|
1564 |
-
"ne" => __("Nepali",'ultimate-member'),
|
1565 |
-
"ng" => __("Ndonga",'ultimate-member'),
|
1566 |
-
"nl" => __("Dutch",'ultimate-member'),
|
1567 |
-
"nn" => __("Norwegian Nynorsk",'ultimate-member'),
|
1568 |
-
"no" => __("Norwegian",'ultimate-member'),
|
1569 |
-
"nr" => __("South Ndebele",'ultimate-member'),
|
1570 |
-
"nv" => __("Navajo",'ultimate-member'),
|
1571 |
-
"ny" => __("Chichewa",'ultimate-member'),
|
1572 |
-
"oc" => __("Occitan",'ultimate-member'),
|
1573 |
-
"oj" => __("Ojibwa",'ultimate-member'),
|
1574 |
-
"om" => __("Oromo",'ultimate-member'),
|
1575 |
-
"or" => __("Oriya",'ultimate-member'),
|
1576 |
-
"os" => __("Ossetian",'ultimate-member'),
|
1577 |
-
"pa" => __("Panjabi",'ultimate-member'),
|
1578 |
-
"pi" => __("Pali",'ultimate-member'),
|
1579 |
-
"pl" => __("Polish",'ultimate-member'),
|
1580 |
-
"ps" => __("Pashto",'ultimate-member'),
|
1581 |
-
"pt" => __("Portuguese",'ultimate-member'),
|
1582 |
-
"qu" => __("Quechua",'ultimate-member'),
|
1583 |
-
"rm" => __("Raeto-Romance",'ultimate-member'),
|
1584 |
-
"rn" => __("Kirundi",'ultimate-member'),
|
1585 |
-
"ro" => __("Romanian",'ultimate-member'),
|
1586 |
-
"ru" => __("Russian",'ultimate-member'),
|
1587 |
-
"rw" => __("Kinyarwanda",'ultimate-member'),
|
1588 |
-
"sa" => __("Sanskrit",'ultimate-member'),
|
1589 |
-
"sc" => __("Sardinian",'ultimate-member'),
|
1590 |
-
"sd" => __("Sindhi",'ultimate-member'),
|
1591 |
-
"se" => __("Northern Sami",'ultimate-member'),
|
1592 |
-
"sg" => __("Sango",'ultimate-member'),
|
1593 |
-
"si" => __("Sinhala",'ultimate-member'),
|
1594 |
-
"sk" => __("Slovak",'ultimate-member'),
|
1595 |
-
"sl" => __("Slovenian",'ultimate-member'),
|
1596 |
-
"sm" => __("Samoan",'ultimate-member'),
|
1597 |
-
"sn" => __("Shona",'ultimate-member'),
|
1598 |
-
"so" => __("Somali",'ultimate-member'),
|
1599 |
-
"sq" => __("Albanian",'ultimate-member'),
|
1600 |
-
"sr" => __("Serbian",'ultimate-member'),
|
1601 |
-
"ss" => __("Swati",'ultimate-member'),
|
1602 |
-
"st" => __("Southern Sotho",'ultimate-member'),
|
1603 |
-
"su" => __("Sundanese",'ultimate-member'),
|
1604 |
-
"sv" => __("Swedish",'ultimate-member'),
|
1605 |
-
"sw" => __("Swahili",'ultimate-member'),
|
1606 |
-
"ta" => __("Tamil",'ultimate-member'),
|
1607 |
-
"te" => __("Telugu",'ultimate-member'),
|
1608 |
-
"tg" => __("Tajik",'ultimate-member'),
|
1609 |
-
"th" => __("Thai",'ultimate-member'),
|
1610 |
-
"ti" => __("Tigrinya",'ultimate-member'),
|
1611 |
-
"tk" => __("Turkmen",'ultimate-member'),
|
1612 |
-
"tl" => __("Tagalog",'ultimate-member'),
|
1613 |
-
"tn" => __("Tswana",'ultimate-member'),
|
1614 |
-
"to" => __("Tonga",'ultimate-member'),
|
1615 |
-
"tr" => __("Turkish",'ultimate-member'),
|
1616 |
-
"ts" => __("Tsonga",'ultimate-member'),
|
1617 |
-
"tt" => __("Tatar",'ultimate-member'),
|
1618 |
-
"tw" => __("Twi",'ultimate-member'),
|
1619 |
-
"ty" => __("Tahitian",'ultimate-member'),
|
1620 |
-
"ug" => __("Uighur",'ultimate-member'),
|
1621 |
-
"uk" => __("Ukrainian",'ultimate-member'),
|
1622 |
-
"ur" => __("Urdu",'ultimate-member'),
|
1623 |
-
"uz" => __("Uzbek",'ultimate-member'),
|
1624 |
-
"ve" => __("Venda",'ultimate-member'),
|
1625 |
-
"vi" => __("Vietnamese",'ultimate-member'),
|
1626 |
-
"vo" => __("Volapuk",'ultimate-member'),
|
1627 |
-
"wa" => __("Walloon",'ultimate-member'),
|
1628 |
-
"wo" => __("Wolof",'ultimate-member'),
|
1629 |
-
"xh" => __("Xhosa",'ultimate-member'),
|
1630 |
-
"yi" => __("Yiddish",'ultimate-member'),
|
1631 |
-
"yo" => __("Yoruba",'ultimate-member'),
|
1632 |
-
"za" => __("Zhuang",'ultimate-member'),
|
1633 |
-
"zh" => __("Chinese",'ultimate-member'),
|
1634 |
-
"zu" => __("Zulu",'ultimate-member')
|
1635 |
-
);
|
1636 |
-
break;
|
1637 |
-
|
1638 |
-
case 'countries':
|
1639 |
-
$array = array (
|
1640 |
-
'AF' => __('Afghanistan','ultimate-member'),
|
1641 |
-
'AX' => __('Åland Islands','ultimate-member'),
|
1642 |
-
'AL' => __('Albania','ultimate-member'),
|
1643 |
-
'DZ' => __('Algeria','ultimate-member'),
|
1644 |
-
'AS' => __('American Samoa','ultimate-member'),
|
1645 |
-
'AD' => __('Andorra','ultimate-member'),
|
1646 |
-
'AO' => __('Angola','ultimate-member'),
|
1647 |
-
'AI' => __('Anguilla','ultimate-member'),
|
1648 |
-
'AQ' => __('Antarctica','ultimate-member'),
|
1649 |
-
'AG' => __('Antigua and Barbuda','ultimate-member'),
|
1650 |
-
'AR' => __('Argentina','ultimate-member'),
|
1651 |
-
'AM' => __('Armenia','ultimate-member'),
|
1652 |
-
'AW' => __('Aruba','ultimate-member'),
|
1653 |
-
'AU' => __('Australia','ultimate-member'),
|
1654 |
-
'AT' => __('Austria','ultimate-member'),
|
1655 |
-
'AZ' => __('Azerbaijan','ultimate-member'),
|
1656 |
-
'BS' => __('Bahamas','ultimate-member'),
|
1657 |
-
'BH' => __('Bahrain','ultimate-member'),
|
1658 |
-
'BD' => __('Bangladesh','ultimate-member'),
|
1659 |
-
'BB' => __('Barbados','ultimate-member'),
|
1660 |
-
'BY' => __('Belarus','ultimate-member'),
|
1661 |
-
'BE' => __('Belgium','ultimate-member'),
|
1662 |
-
'BZ' => __('Belize','ultimate-member'),
|
1663 |
-
'BJ' => __('Benin','ultimate-member'),
|
1664 |
-
'BM' => __('Bermuda','ultimate-member'),
|
1665 |
-
'BT' => __('Bhutan','ultimate-member'),
|
1666 |
-
'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
|
1667 |
-
'BA' => __('Bosnia and Herzegovina','ultimate-member'),
|
1668 |
-
'BW' => __('Botswana','ultimate-member'),
|
1669 |
-
'BV' => __('Bouvet Island','ultimate-member'),
|
1670 |
-
'BR' => __('Brazil','ultimate-member'),
|
1671 |
-
'IO' => __('British Indian Ocean Territory','ultimate-member'),
|
1672 |
-
'BN' => __('Brunei Darussalam','ultimate-member'),
|
1673 |
-
'BG' => __('Bulgaria','ultimate-member'),
|
1674 |
-
'BF' => __('Burkina Faso','ultimate-member'),
|
1675 |
-
'BI' => __('Burundi','ultimate-member'),
|
1676 |
-
'KH' => __('Cambodia','ultimate-member'),
|
1677 |
-
'CM' => __('Cameroon','ultimate-member'),
|
1678 |
-
'CA' => __('Canada','ultimate-member'),
|
1679 |
-
'CV' => __('Cape Verde','ultimate-member'),
|
1680 |
-
'KY' => __('Cayman Islands','ultimate-member'),
|
1681 |
-
'CF' => __('Central African Republic','ultimate-member'),
|
1682 |
-
'TD' => __('Chad','ultimate-member'),
|
1683 |
-
'CL' => __('Chile','ultimate-member'),
|
1684 |
-
'CN' => __('China','ultimate-member'),
|
1685 |
-
'CX' => __('Christmas Island','ultimate-member'),
|
1686 |
-
'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
|
1687 |
-
'CO' => __('Colombia','ultimate-member'),
|
1688 |
-
'KM' => __('Comoros','ultimate-member'),
|
1689 |
-
'CG' => __('Congo','ultimate-member'),
|
1690 |
-
'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
|
1691 |
-
'CK' => __('Cook Islands','ultimate-member'),
|
1692 |
-
'CR' => __('Costa Rica','ultimate-member'),
|
1693 |
-
'CI' => __("Côte d'Ivoire",'ultimate-member'),
|
1694 |
-
'HR' => __('Croatia','ultimate-member'),
|
1695 |
-
'CU' => __('Cuba','ultimate-member'),
|
1696 |
-
'CY' => __('Cyprus','ultimate-member'),
|
1697 |
-
'CZ' => __('Czech Republic','ultimate-member'),
|
1698 |
-
'DK' => __('Denmark','ultimate-member'),
|
1699 |
-
'DJ' => __('Djibouti','ultimate-member'),
|
1700 |
-
'DM' => __('Dominica','ultimate-member'),
|
1701 |
-
'DO' => __('Dominican Republic','ultimate-member'),
|
1702 |
-
'EC' => __('Ecuador','ultimate-member'),
|
1703 |
-
'EG' => __('Egypt','ultimate-member'),
|
1704 |
-
'SV' => __('El Salvador','ultimate-member'),
|
1705 |
-
'GQ' => __('Equatorial Guinea','ultimate-member'),
|
1706 |
-
'ER' => __('Eritrea','ultimate-member'),
|
1707 |
-
'EE' => __('Estonia','ultimate-member'),
|
1708 |
-
'ET' => __('Ethiopia','ultimate-member'),
|
1709 |
-
'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
|
1710 |
-
'FO' => __('Faroe Islands','ultimate-member'),
|
1711 |
-
'FJ' => __('Fiji','ultimate-member'),
|
1712 |
-
'FI' => __('Finland','ultimate-member'),
|
1713 |
-
'FR' => __('France','ultimate-member'),
|
1714 |
-
'GF' => __('French Guiana','ultimate-member'),
|
1715 |
-
'PF' => __('French Polynesia','ultimate-member'),
|
1716 |
-
'TF' => __('French Southern Territories','ultimate-member'),
|
1717 |
-
'GA' => __('Gabon','ultimate-member'),
|
1718 |
-
'GM' => __('Gambia','ultimate-member'),
|
1719 |
-
'GE' => __('Georgia','ultimate-member'),
|
1720 |
-
'DE' => __('Germany','ultimate-member'),
|
1721 |
-
'GH' => __('Ghana','ultimate-member'),
|
1722 |
-
'GI' => __('Gibraltar','ultimate-member'),
|
1723 |
-
'GR' => __('Greece','ultimate-member'),
|
1724 |
-
'GL' => __('Greenland','ultimate-member'),
|
1725 |
-
'GD' => __('Grenada','ultimate-member'),
|
1726 |
-
'GP' => __('Guadeloupe','ultimate-member'),
|
1727 |
-
'GU' => __('Guam','ultimate-member'),
|
1728 |
-
'GT' => __('Guatemala','ultimate-member'),
|
1729 |
-
'GG' => __('Guernsey','ultimate-member'),
|
1730 |
-
'GN' => __('Guinea','ultimate-member'),
|
1731 |
-
'GW' => __('Guinea-Bissau','ultimate-member'),
|
1732 |
-
'GY' => __('Guyana','ultimate-member'),
|
1733 |
-
'HT' => __('Haiti','ultimate-member'),
|
1734 |
-
'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
|
1735 |
-
'VA' => __('Holy See (Vatican City State)','ultimate-member'),
|
1736 |
-
'HN' => __('Honduras','ultimate-member'),
|
1737 |
-
'HK' => __('Hong Kong','ultimate-member'),
|
1738 |
-
'HU' => __('Hungary','ultimate-member'),
|
1739 |
-
'IS' => __('Iceland','ultimate-member'),
|
1740 |
-
'IN' => __('India','ultimate-member'),
|
1741 |
-
'ID' => __('Indonesia','ultimate-member'),
|
1742 |
-
'IR' => __('Iran, Islamic Republic of','ultimate-member'),
|
1743 |
-
'IQ' => __('Iraq','ultimate-member'),
|
1744 |
-
'IE' => __('Ireland','ultimate-member'),
|
1745 |
-
'IM' => __('Isle of Man','ultimate-member'),
|
1746 |
-
'IL' => __('Israel','ultimate-member'),
|
1747 |
-
'IT' => __('Italy','ultimate-member'),
|
1748 |
-
'JM' => __('Jamaica','ultimate-member'),
|
1749 |
-
'JP' => __('Japan','ultimate-member'),
|
1750 |
-
'JE' => __('Jersey','ultimate-member'),
|
1751 |
-
'JO' => __('Jordan','ultimate-member'),
|
1752 |
-
'KZ' => __('Kazakhstan','ultimate-member'),
|
1753 |
-
'KE' => __('Kenya','ultimate-member'),
|
1754 |
-
'KI' => __('Kiribati','ultimate-member'),
|
1755 |
-
'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
|
1756 |
-
'KR' => __('Korea, Republic of','ultimate-member'),
|
1757 |
-
'KW' => __('Kuwait','ultimate-member'),
|
1758 |
-
'KG' => __('Kyrgyzstan','ultimate-member'),
|
1759 |
-
'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
|
1760 |
-
'LV' => __('Latvia','ultimate-member'),
|
1761 |
-
'LB' => __('Lebanon','ultimate-member'),
|
1762 |
-
'LS' => __('Lesotho','ultimate-member'),
|
1763 |
-
'LR' => __('Liberia','ultimate-member'),
|
1764 |
-
'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
|
1765 |
-
'LI' => __('Liechtenstein','ultimate-member'),
|
1766 |
-
'LT' => __('Lithuania','ultimate-member'),
|
1767 |
-
'LU' => __('Luxembourg','ultimate-member'),
|
1768 |
-
'MO' => __('Macao','ultimate-member'),
|
1769 |
-
'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
|
1770 |
-
'MG' => __('Madagascar','ultimate-member'),
|
1771 |
-
'MW' => __('Malawi','ultimate-member'),
|
1772 |
-
'MY' => __('Malaysia','ultimate-member'),
|
1773 |
-
'MV' => __('Maldives','ultimate-member'),
|
1774 |
-
'ML' => __('Mali','ultimate-member'),
|
1775 |
-
'MT' => __('Malta','ultimate-member'),
|
1776 |
-
'MH' => __('Marshall Islands','ultimate-member'),
|
1777 |
-
'MQ' => __('Martinique','ultimate-member'),
|
1778 |
-
'MR' => __('Mauritania','ultimate-member'),
|
1779 |
-
'MU' => __('Mauritius','ultimate-member'),
|
1780 |
-
'YT' => __('Mayotte','ultimate-member'),
|
1781 |
-
'MX' => __('Mexico','ultimate-member'),
|
1782 |
-
'FM' => __('Micronesia, Federated States of','ultimate-member'),
|
1783 |
-
'MD' => __('Moldova, Republic of','ultimate-member'),
|
1784 |
-
'MC' => __('Monaco','ultimate-member'),
|
1785 |
-
'MN' => __('Mongolia','ultimate-member'),
|
1786 |
-
'ME' => __('Montenegro','ultimate-member'),
|
1787 |
-
'MS' => __('Montserrat','ultimate-member'),
|
1788 |
-
'MA' => __('Morocco','ultimate-member'),
|
1789 |
-
'MZ' => __('Mozambique','ultimate-member'),
|
1790 |
-
'MM' => __('Myanmar','ultimate-member'),
|
1791 |
-
'NA' => __('Namibia','ultimate-member'),
|
1792 |
-
'NR' => __('Nauru','ultimate-member'),
|
1793 |
-
'NP' => __('Nepal','ultimate-member'),
|
1794 |
-
'NL' => __('Netherlands','ultimate-member'),
|
1795 |
-
'AN' => __('Netherlands Antilles','ultimate-member'),
|
1796 |
-
'NC' => __('New Caledonia','ultimate-member'),
|
1797 |
-
'NZ' => __('New Zealand','ultimate-member'),
|
1798 |
-
'NI' => __('Nicaragua','ultimate-member'),
|
1799 |
-
'NE' => __('Niger','ultimate-member'),
|
1800 |
-
'NG' => __('Nigeria','ultimate-member'),
|
1801 |
-
'NU' => __('Niue','ultimate-member'),
|
1802 |
-
'NF' => __('Norfolk Island','ultimate-member'),
|
1803 |
-
'MP' => __('Northern Mariana Islands','ultimate-member'),
|
1804 |
-
'NO' => __('Norway','ultimate-member'),
|
1805 |
-
'OM' => __('Oman','ultimate-member'),
|
1806 |
-
'PK' => __('Pakistan','ultimate-member'),
|
1807 |
-
'PW' => __('Palau','ultimate-member'),
|
1808 |
-
'PS' => __('Palestine','ultimate-member'),
|
1809 |
-
'PA' => __('Panama','ultimate-member'),
|
1810 |
-
'PG' => __('Papua New Guinea','ultimate-member'),
|
1811 |
-
'PY' => __('Paraguay','ultimate-member'),
|
1812 |
-
'PE' => __('Peru','ultimate-member'),
|
1813 |
-
'PH' => __('Philippines','ultimate-member'),
|
1814 |
-
'PN' => __('Pitcairn','ultimate-member'),
|
1815 |
-
'PL' => __('Poland','ultimate-member'),
|
1816 |
-
'PT' => __('Portugal','ultimate-member'),
|
1817 |
-
'PR' => __('Puerto Rico','ultimate-member'),
|
1818 |
-
'QA' => __('Qatar','ultimate-member'),
|
1819 |
-
'RE' => __('Réunion','ultimate-member'),
|
1820 |
-
'RO' => __('Romania','ultimate-member'),
|
1821 |
-
'RU' => __('Russian Federation','ultimate-member'),
|
1822 |
-
'RW' => __('Rwanda','ultimate-member'),
|
1823 |
-
'BL' => __('Saint Barthélemy','ultimate-member'),
|
1824 |
-
'SH' => __('Saint Helena','ultimate-member'),
|
1825 |
-
'KN' => __('Saint Kitts and Nevis','ultimate-member'),
|
1826 |
-
'LC' => __('Saint Lucia','ultimate-member'),
|
1827 |
-
'MF' => __('Saint Martin (French part)','ultimate-member'),
|
1828 |
-
'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
|
1829 |
-
'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
|
1830 |
-
'WS' => __('Samoa','ultimate-member'),
|
1831 |
-
'SM' => __('San Marino','ultimate-member'),
|
1832 |
-
'ST' => __('Sao Tome and Principe','ultimate-member'),
|
1833 |
-
'SA' => __('Saudi Arabia','ultimate-member'),
|
1834 |
-
'SN' => __('Senegal','ultimate-member'),
|
1835 |
-
'RS' => __('Serbia','ultimate-member'),
|
1836 |
-
'SC' => __('Seychelles','ultimate-member'),
|
1837 |
-
'SL' => __('Sierra Leone','ultimate-member'),
|
1838 |
-
'SG' => __('Singapore','ultimate-member'),
|
1839 |
-
'SK' => __('Slovakia','ultimate-member'),
|
1840 |
-
'SI' => __('Slovenia','ultimate-member'),
|
1841 |
-
'SB' => __('Solomon Islands','ultimate-member'),
|
1842 |
-
'SO' => __('Somalia','ultimate-member'),
|
1843 |
-
'ZA' => __('South Africa','ultimate-member'),
|
1844 |
-
'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
|
1845 |
-
'SS' => __('South Sudan','ultimate-member'),
|
1846 |
-
'ES' => __('Spain','ultimate-member'),
|
1847 |
-
'LK' => __('Sri Lanka','ultimate-member'),
|
1848 |
-
'SD' => __('Sudan','ultimate-member'),
|
1849 |
-
'SR' => __('Suriname','ultimate-member'),
|
1850 |
-
'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
|
1851 |
-
'SZ' => __('Swaziland','ultimate-member'),
|
1852 |
-
'SE' => __('Sweden','ultimate-member'),
|
1853 |
-
'CH' => __('Switzerland','ultimate-member'),
|
1854 |
-
'SY' => __('Syrian Arab Republic','ultimate-member'),
|
1855 |
-
'TW' => __('Taiwan, Province of China','ultimate-member'),
|
1856 |
-
'TJ' => __('Tajikistan','ultimate-member'),
|
1857 |
-
'TZ' => __('Tanzania, United Republic of','ultimate-member'),
|
1858 |
-
'TH' => __('Thailand','ultimate-member'),
|
1859 |
-
'TL' => __('Timor-Leste','ultimate-member'),
|
1860 |
-
'TG' => __('Togo','ultimate-member'),
|
1861 |
-
'TK' => __('Tokelau','ultimate-member'),
|
1862 |
-
'TO' => __('Tonga','ultimate-member'),
|
1863 |
-
'TT' => __('Trinidad and Tobago','ultimate-member'),
|
1864 |
-
'TN' => __('Tunisia','ultimate-member'),
|
1865 |
-
'TR' => __('Turkey','ultimate-member'),
|
1866 |
-
'TM' => __('Turkmenistan','ultimate-member'),
|
1867 |
-
'TC' => __('Turks and Caicos Islands','ultimate-member'),
|
1868 |
-
'TV' => __('Tuvalu','ultimate-member'),
|
1869 |
-
'UG' => __('Uganda','ultimate-member'),
|
1870 |
-
'UA' => __('Ukraine','ultimate-member'),
|
1871 |
-
'AE' => __('United Arab Emirates','ultimate-member'),
|
1872 |
-
'GB' => __('United Kingdom','ultimate-member'),
|
1873 |
-
'US' => __('United States','ultimate-member'),
|
1874 |
-
'UM' => __('United States Minor Outlying Islands','ultimate-member'),
|
1875 |
-
'UY' => __('Uruguay','ultimate-member'),
|
1876 |
-
'UZ' => __('Uzbekistan','ultimate-member'),
|
1877 |
-
'VU' => __('Vanuatu','ultimate-member'),
|
1878 |
-
'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
|
1879 |
-
'VN' => __('Viet Nam','ultimate-member'),
|
1880 |
-
'VG' => __('Virgin Islands, British','ultimate-member'),
|
1881 |
-
'VI' => __('Virgin Islands, U.S.','ultimate-member'),
|
1882 |
-
'WF' => __('Wallis and Futuna','ultimate-member'),
|
1883 |
-
'EH' => __('Western Sahara','ultimate-member'),
|
1884 |
-
'YE' => __('Yemen','ultimate-member'),
|
1885 |
-
'ZM' => __('Zambia','ultimate-member'),
|
1886 |
-
'ZW' => __('Zimbabwe','ultimate-member'),
|
1887 |
-
);
|
1888 |
-
break;
|
1889 |
-
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
/**
|
1893 |
-
* UM hook
|
1894 |
-
*
|
1895 |
-
* @type filter
|
1896 |
-
* @title um_{$data}_predefined_field_options
|
1897 |
-
* @description Extend Predefined Fields options. Where $data - field key.
|
1898 |
-
* @input_vars
|
1899 |
-
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
1900 |
-
* @change_log
|
1901 |
-
* ["Since: 2.0"]
|
1902 |
-
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
1903 |
-
* @example
|
1904 |
-
* <?php
|
1905 |
-
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
1906 |
-
* function my_predefined_field( $options ) {
|
1907 |
-
* // your code here
|
1908 |
-
* return $options;
|
1909 |
-
* }
|
1910 |
-
* ?>
|
1911 |
-
*/
|
1912 |
-
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
1913 |
-
return $array;
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
}
|
1917 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Builtin' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Builtin
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Builtin {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
public $predefined_fields = array();
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
var $all_user_fields = array();
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
var $core_fields = array();
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Builtin constructor.
|
37 |
+
*/
|
38 |
+
function __construct() {
|
39 |
+
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
40 |
+
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
41 |
+
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
42 |
+
$this->saved_fields = get_option( 'um_fields' );
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
function get_all_user_fields() {
|
50 |
+
return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Regular or multi-select/options
|
56 |
+
*
|
57 |
+
* @param $field
|
58 |
+
* @param $attrs
|
59 |
+
*
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
function is_dropdown_field( $field, $attrs ) {
|
63 |
+
|
64 |
+
if ( isset( $attrs['options'] ) ) {
|
65 |
+
return true;
|
66 |
+
}
|
67 |
+
|
68 |
+
$fields = $this->all_user_fields;
|
69 |
+
|
70 |
+
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get a field
|
80 |
+
*
|
81 |
+
* @param $field
|
82 |
+
*
|
83 |
+
* @return mixed|string
|
84 |
+
*/
|
85 |
+
function get_a_field( $field ) {
|
86 |
+
$fields = $this->all_user_fields;
|
87 |
+
if ( isset( $fields[ $field ] ) ) {
|
88 |
+
return $fields[ $field ];
|
89 |
+
}
|
90 |
+
return '';
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get specific fields
|
96 |
+
*
|
97 |
+
* @param $fields
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
function get_specific_fields( $fields ) {
|
102 |
+
$fields = explode( ',', $fields );
|
103 |
+
$array = array();
|
104 |
+
foreach ( $fields as $field ) {
|
105 |
+
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
106 |
+
$array[ $field ] = $this->predefined_fields[ $field ];
|
107 |
+
}
|
108 |
+
}
|
109 |
+
return $array;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get specific field
|
115 |
+
*
|
116 |
+
* @param $fields
|
117 |
+
*
|
118 |
+
* @return array|mixed
|
119 |
+
*/
|
120 |
+
function get_specific_field( $fields ) {
|
121 |
+
$fields = explode( ',', $fields );
|
122 |
+
$array = array();
|
123 |
+
foreach ( $fields as $field ) {
|
124 |
+
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
125 |
+
$array = $this->predefined_fields[ $field ];
|
126 |
+
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
|
127 |
+
$array = $this->saved_fields[ $field ];
|
128 |
+
}
|
129 |
+
}
|
130 |
+
return $array;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Checks for a unique field error
|
136 |
+
*
|
137 |
+
* @param $key
|
138 |
+
*
|
139 |
+
* @return int|string
|
140 |
+
*/
|
141 |
+
function unique_field_err( $key ) {
|
142 |
+
if ( empty( $key ) ) {
|
143 |
+
return __( 'Please provide a meta key', 'ultimate-member' );
|
144 |
+
}
|
145 |
+
if ( isset( $this->core_fields[ $key ] ) ) {
|
146 |
+
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
147 |
+
}
|
148 |
+
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
149 |
+
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
150 |
+
}
|
151 |
+
if ( isset( $this->saved_fields[ $key ] ) ) {
|
152 |
+
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
153 |
+
}
|
154 |
+
if ( ! UM()->validation()->safe_string( $key ) ) {
|
155 |
+
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
156 |
+
}
|
157 |
+
|
158 |
+
return 0;
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Check date range errors (start date)
|
164 |
+
*
|
165 |
+
* @param $date
|
166 |
+
*
|
167 |
+
* @return int|string
|
168 |
+
*/
|
169 |
+
function date_range_start_err( $date ) {
|
170 |
+
if ( empty( $date ) ) {
|
171 |
+
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
172 |
+
}
|
173 |
+
if ( ! UM()->validation()->validate_date( $date ) ) {
|
174 |
+
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
175 |
+
}
|
176 |
+
|
177 |
+
return 0;
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Check date range errors (end date)
|
183 |
+
*
|
184 |
+
* @param $date
|
185 |
+
* @param $start_date
|
186 |
+
*
|
187 |
+
* @return int|string
|
188 |
+
*/
|
189 |
+
function date_range_end_err( $date, $start_date ) {
|
190 |
+
if ( empty( $date ) ) {
|
191 |
+
return __( 'Please provide a date range end', 'ultimate-member' );
|
192 |
+
}
|
193 |
+
if ( ! UM()->validation()->validate_date( $date ) ) {
|
194 |
+
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
195 |
+
}
|
196 |
+
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
197 |
+
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
198 |
+
}
|
199 |
+
return 0;
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Get a core field attrs
|
205 |
+
*
|
206 |
+
* @param $type
|
207 |
+
*
|
208 |
+
* @return array|mixed
|
209 |
+
*/
|
210 |
+
function get_core_field_attrs( $type ) {
|
211 |
+
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Core Fields
|
217 |
+
*/
|
218 |
+
function set_core_fields() {
|
219 |
+
|
220 |
+
$this->core_fields = array(
|
221 |
+
|
222 |
+
'row' => array(
|
223 |
+
'name' => 'Row',
|
224 |
+
'in_fields' => false,
|
225 |
+
'form_only' => true,
|
226 |
+
'conditional_support' => 0,
|
227 |
+
'icon' => 'um-faicon-pencil',
|
228 |
+
'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
|
229 |
+
'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
|
230 |
+
),
|
231 |
+
|
232 |
+
'text' => array(
|
233 |
+
'name' => 'Text Box',
|
234 |
+
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
235 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
236 |
+
'col3' => array('_required','_editable','_icon'),
|
237 |
+
'validate' => array(
|
238 |
+
'_title' => array(
|
239 |
+
'mode' => 'required',
|
240 |
+
'error' => __('You must provide a title','ultimate-member')
|
241 |
+
),
|
242 |
+
'_metakey' => array(
|
243 |
+
'mode' => 'unique',
|
244 |
+
),
|
245 |
+
)
|
246 |
+
),
|
247 |
+
|
248 |
+
'number' => array(
|
249 |
+
'name' => __('Number','ultimate-member'),
|
250 |
+
'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
|
251 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
|
252 |
+
'col3' => array('_required','_editable','_icon'),
|
253 |
+
'validate' => array(
|
254 |
+
'_title' => array(
|
255 |
+
'mode' => 'required',
|
256 |
+
'error' => __('You must provide a title','ultimate-member')
|
257 |
+
),
|
258 |
+
'_metakey' => array(
|
259 |
+
'mode' => 'unique',
|
260 |
+
),
|
261 |
+
)
|
262 |
+
),
|
263 |
+
|
264 |
+
'textarea' => array(
|
265 |
+
'name' => 'Textarea',
|
266 |
+
'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
|
267 |
+
'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
|
268 |
+
'col3' => array('_required','_editable','_icon'),
|
269 |
+
'validate' => array(
|
270 |
+
'_title' => array(
|
271 |
+
'mode' => 'required',
|
272 |
+
'error' => __('You must provide a title','ultimate-member')
|
273 |
+
),
|
274 |
+
'_metakey' => array(
|
275 |
+
'mode' => 'unique',
|
276 |
+
),
|
277 |
+
)
|
278 |
+
),
|
279 |
+
|
280 |
+
'select' => array(
|
281 |
+
'name' => 'Dropdown',
|
282 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
283 |
+
'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
|
284 |
+
'col3' => array('_required','_editable','_icon'),
|
285 |
+
'validate' => array(
|
286 |
+
'_title' => array(
|
287 |
+
'mode' => 'required',
|
288 |
+
'error' => __('You must provide a title','ultimate-member')
|
289 |
+
),
|
290 |
+
'_metakey' => array(
|
291 |
+
'mode' => 'unique',
|
292 |
+
),
|
293 |
+
'_options' => array(
|
294 |
+
'mode' => 'required',
|
295 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
296 |
+
),
|
297 |
+
)
|
298 |
+
),
|
299 |
+
|
300 |
+
'multiselect' => array(
|
301 |
+
'name' => 'Multi-Select',
|
302 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
303 |
+
'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
|
304 |
+
'col3' => array('_required','_editable','_icon'),
|
305 |
+
'validate' => array(
|
306 |
+
'_title' => array(
|
307 |
+
'mode' => 'required',
|
308 |
+
'error' => __('You must provide a title','ultimate-member')
|
309 |
+
),
|
310 |
+
'_metakey' => array(
|
311 |
+
'mode' => 'unique',
|
312 |
+
),
|
313 |
+
'_options' => array(
|
314 |
+
'mode' => 'required',
|
315 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
316 |
+
),
|
317 |
+
)
|
318 |
+
),
|
319 |
+
|
320 |
+
'radio' => array(
|
321 |
+
'name' => 'Radio',
|
322 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
323 |
+
'col2' => array('_label','_public','_roles'),
|
324 |
+
'col3' => array('_required','_editable','_icon'),
|
325 |
+
'validate' => array(
|
326 |
+
'_title' => array(
|
327 |
+
'mode' => 'required',
|
328 |
+
'error' => __('You must provide a title','ultimate-member')
|
329 |
+
),
|
330 |
+
'_metakey' => array(
|
331 |
+
'mode' => 'unique',
|
332 |
+
),
|
333 |
+
'_options' => array(
|
334 |
+
'mode' => 'required',
|
335 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
336 |
+
),
|
337 |
+
)
|
338 |
+
),
|
339 |
+
|
340 |
+
'checkbox' => array(
|
341 |
+
'name' => 'Checkbox',
|
342 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
343 |
+
'col2' => array('_label','_public','_roles','_max_selections'),
|
344 |
+
'col3' => array('_required','_editable','_icon'),
|
345 |
+
'validate' => array(
|
346 |
+
'_title' => array(
|
347 |
+
'mode' => 'required',
|
348 |
+
'error' => __('You must provide a title','ultimate-member')
|
349 |
+
),
|
350 |
+
'_metakey' => array(
|
351 |
+
'mode' => 'unique',
|
352 |
+
),
|
353 |
+
'_options' => array(
|
354 |
+
'mode' => 'required',
|
355 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
356 |
+
),
|
357 |
+
)
|
358 |
+
),
|
359 |
+
|
360 |
+
'url' => array(
|
361 |
+
'name' => 'URL',
|
362 |
+
'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
|
363 |
+
'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
|
364 |
+
'col3' => array('_required','_editable','_icon'),
|
365 |
+
'validate' => array(
|
366 |
+
'_title' => array(
|
367 |
+
'mode' => 'required',
|
368 |
+
'error' => __('You must provide a title','ultimate-member')
|
369 |
+
),
|
370 |
+
'_metakey' => array(
|
371 |
+
'mode' => 'unique',
|
372 |
+
),
|
373 |
+
)
|
374 |
+
),
|
375 |
+
|
376 |
+
'password' => array(
|
377 |
+
'name' => 'Password',
|
378 |
+
'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
|
379 |
+
'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
|
380 |
+
'col3' => array('_required','_editable','_icon'),
|
381 |
+
'validate' => array(
|
382 |
+
'_title' => array(
|
383 |
+
'mode' => 'required',
|
384 |
+
'error' => __('You must provide a title','ultimate-member')
|
385 |
+
),
|
386 |
+
'_metakey' => array(
|
387 |
+
'mode' => 'unique',
|
388 |
+
),
|
389 |
+
)
|
390 |
+
),
|
391 |
+
|
392 |
+
'image' => array(
|
393 |
+
'name' => 'Image Upload',
|
394 |
+
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
|
395 |
+
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
396 |
+
'col3' => array('_required','_editable','_icon'),
|
397 |
+
'validate' => array(
|
398 |
+
'_title' => array(
|
399 |
+
'mode' => 'required',
|
400 |
+
'error' => __('You must provide a title','ultimate-member')
|
401 |
+
),
|
402 |
+
'_metakey' => array(
|
403 |
+
'mode' => 'unique',
|
404 |
+
),
|
405 |
+
'_max_size' => array(
|
406 |
+
'mode' => 'numeric',
|
407 |
+
'error' => __('Please enter a valid size','ultimate-member')
|
408 |
+
),
|
409 |
+
)
|
410 |
+
),
|
411 |
+
|
412 |
+
'file' => array(
|
413 |
+
'name' => 'File Upload',
|
414 |
+
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
|
415 |
+
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
416 |
+
'col3' => array('_required','_editable','_icon'),
|
417 |
+
'validate' => array(
|
418 |
+
'_title' => array(
|
419 |
+
'mode' => 'required',
|
420 |
+
'error' => __('You must provide a title','ultimate-member')
|
421 |
+
),
|
422 |
+
'_metakey' => array(
|
423 |
+
'mode' => 'unique',
|
424 |
+
),
|
425 |
+
'_max_size' => array(
|
426 |
+
'mode' => 'numeric',
|
427 |
+
'error' => __( 'Please enter a valid size', 'ultimate-member' )
|
428 |
+
),
|
429 |
+
)
|
430 |
+
),
|
431 |
+
|
432 |
+
'date' => array(
|
433 |
+
'name' => 'Date Picker',
|
434 |
+
'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
|
435 |
+
'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
|
436 |
+
'col3' => array( '_required', '_editable', '_icon' ),
|
437 |
+
'validate' => array(
|
438 |
+
'_title' => array(
|
439 |
+
'mode' => 'required',
|
440 |
+
'error' => __( 'You must provide a title', 'ultimate-member' )
|
441 |
+
),
|
442 |
+
'_metakey' => array(
|
443 |
+
'mode' => 'unique',
|
444 |
+
),
|
445 |
+
'_years' => array(
|
446 |
+
'mode' => 'numeric',
|
447 |
+
'error' => __( 'Number of years is not valid', 'ultimate-member' )
|
448 |
+
),
|
449 |
+
'_range_start' => array(
|
450 |
+
'mode' => 'range-start',
|
451 |
+
),
|
452 |
+
'_range_end' => array(
|
453 |
+
'mode' => 'range-end',
|
454 |
+
),
|
455 |
+
)
|
456 |
+
),
|
457 |
+
|
458 |
+
'time' => array(
|
459 |
+
'name' => 'Time Picker',
|
460 |
+
'col1' => array('_title','_metakey','_help','_format','_visibility'),
|
461 |
+
'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
|
462 |
+
'col3' => array('_required','_editable','_icon'),
|
463 |
+
'validate' => array(
|
464 |
+
'_title' => array(
|
465 |
+
'mode' => 'required',
|
466 |
+
'error' => __( 'You must provide a title', 'ultimate-member' )
|
467 |
+
),
|
468 |
+
'_metakey' => array(
|
469 |
+
'mode' => 'unique',
|
470 |
+
),
|
471 |
+
)
|
472 |
+
),
|
473 |
+
|
474 |
+
'rating' => array(
|
475 |
+
'name' => 'Rating',
|
476 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
477 |
+
'col2' => array('_label','_public','_roles','_number','_default'),
|
478 |
+
'col3' => array('_required','_editable','_icon'),
|
479 |
+
'validate' => array(
|
480 |
+
'_title' => array(
|
481 |
+
'mode' => 'required',
|
482 |
+
'error' => __('You must provide a title','ultimate-member')
|
483 |
+
),
|
484 |
+
'_metakey' => array(
|
485 |
+
'mode' => 'unique',
|
486 |
+
),
|
487 |
+
)
|
488 |
+
),
|
489 |
+
|
490 |
+
'block' => array(
|
491 |
+
'name' => 'Content Block',
|
492 |
+
'col1' => array('_title','_visibility'),
|
493 |
+
'col2' => array('_public','_roles'),
|
494 |
+
'col_full' => array('_content'),
|
495 |
+
'mce_content' => true,
|
496 |
+
'validate' => array(
|
497 |
+
'_title' => array(
|
498 |
+
'mode' => 'required',
|
499 |
+
'error' => __('You must provide a title','ultimate-member')
|
500 |
+
),
|
501 |
+
)
|
502 |
+
),
|
503 |
+
|
504 |
+
'shortcode' => array(
|
505 |
+
'name' => 'Shortcode',
|
506 |
+
'col1' => array('_title','_visibility'),
|
507 |
+
'col2' => array('_public','_roles'),
|
508 |
+
'col_full' => array('_content'),
|
509 |
+
'validate' => array(
|
510 |
+
'_title' => array(
|
511 |
+
'mode' => 'required',
|
512 |
+
'error' => __('You must provide a title','ultimate-member')
|
513 |
+
),
|
514 |
+
'_content' => array(
|
515 |
+
'mode' => 'required',
|
516 |
+
'error' => __('You must add a shortcode to the content area','ultimate-member')
|
517 |
+
),
|
518 |
+
)
|
519 |
+
),
|
520 |
+
|
521 |
+
'spacing' => array(
|
522 |
+
'name' => 'Spacing',
|
523 |
+
'col1' => array('_title','_visibility'),
|
524 |
+
'col2' => array('_spacing'),
|
525 |
+
'form_only' => true,
|
526 |
+
'validate' => array(
|
527 |
+
'_title' => array(
|
528 |
+
'mode' => 'required',
|
529 |
+
'error' => __('You must provide a title','ultimate-member')
|
530 |
+
),
|
531 |
+
)
|
532 |
+
),
|
533 |
+
|
534 |
+
'divider' => array(
|
535 |
+
'name' => 'Divider',
|
536 |
+
'col1' => array('_title','_width','_divider_text','_visibility'),
|
537 |
+
'col2' => array('_style','_color','_public','_roles'),
|
538 |
+
'form_only' => true,
|
539 |
+
'validate' => array(
|
540 |
+
'_title' => array(
|
541 |
+
'mode' => 'required',
|
542 |
+
'error' => __('You must provide a title','ultimate-member')
|
543 |
+
),
|
544 |
+
)
|
545 |
+
),
|
546 |
+
|
547 |
+
'googlemap' => array(
|
548 |
+
'name' => 'Google Map',
|
549 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
550 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
551 |
+
'col3' => array('_required','_editable','_icon'),
|
552 |
+
'validate' => array(
|
553 |
+
'_title' => array(
|
554 |
+
'mode' => 'required',
|
555 |
+
'error' => __('You must provide a title','ultimate-member')
|
556 |
+
),
|
557 |
+
'_metakey' => array(
|
558 |
+
'mode' => 'unique',
|
559 |
+
),
|
560 |
+
)
|
561 |
+
),
|
562 |
+
|
563 |
+
'youtube_video' => array(
|
564 |
+
'name' => 'YouTube Video',
|
565 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
566 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
567 |
+
'col3' => array('_required','_editable','_icon'),
|
568 |
+
'validate' => array(
|
569 |
+
'_title' => array(
|
570 |
+
'mode' => 'required',
|
571 |
+
'error' => __('You must provide a title','ultimate-member')
|
572 |
+
),
|
573 |
+
'_metakey' => array(
|
574 |
+
'mode' => 'unique',
|
575 |
+
),
|
576 |
+
)
|
577 |
+
),
|
578 |
+
|
579 |
+
'vimeo_video' => array(
|
580 |
+
'name' => 'Vimeo Video',
|
581 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
582 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
583 |
+
'col3' => array('_required','_editable','_icon'),
|
584 |
+
'validate' => array(
|
585 |
+
'_title' => array(
|
586 |
+
'mode' => 'required',
|
587 |
+
'error' => __('You must provide a title','ultimate-member')
|
588 |
+
),
|
589 |
+
'_metakey' => array(
|
590 |
+
'mode' => 'unique',
|
591 |
+
),
|
592 |
+
)
|
593 |
+
),
|
594 |
+
|
595 |
+
'soundcloud_track' => array(
|
596 |
+
'name' => 'SoundCloud Track',
|
597 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
598 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
599 |
+
'col3' => array('_required','_editable','_icon'),
|
600 |
+
'validate' => array(
|
601 |
+
'_title' => array(
|
602 |
+
'mode' => 'required',
|
603 |
+
'error' => __('You must provide a title','ultimate-member')
|
604 |
+
),
|
605 |
+
'_metakey' => array(
|
606 |
+
'mode' => 'unique',
|
607 |
+
),
|
608 |
+
)
|
609 |
+
),
|
610 |
+
|
611 |
+
/*'group' => array(
|
612 |
+
'name' => 'Field Group',
|
613 |
+
'col1' => array('_title','_max_entries'),
|
614 |
+
'col2' => array('_label','_public','_roles'),
|
615 |
+
'form_only' => true,
|
616 |
+
'validate' => array(
|
617 |
+
'_title' => array(
|
618 |
+
'mode' => 'required',
|
619 |
+
'error' => 'You must provide a title'
|
620 |
+
),
|
621 |
+
'_label' => array(
|
622 |
+
'mode' => 'required',
|
623 |
+
'error' => 'You must provide a label'
|
624 |
+
),
|
625 |
+
)
|
626 |
+
),*/
|
627 |
+
|
628 |
+
);
|
629 |
+
|
630 |
+
/**
|
631 |
+
* UM hook
|
632 |
+
*
|
633 |
+
* @type filter
|
634 |
+
* @title um_core_fields_hook
|
635 |
+
* @description UM Core Fields
|
636 |
+
* @input_vars
|
637 |
+
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
638 |
+
* @change_log
|
639 |
+
* ["Since: 2.0"]
|
640 |
+
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
641 |
+
* @example
|
642 |
+
* <?php
|
643 |
+
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
644 |
+
* function my_core_fields( $core_fields ) {
|
645 |
+
* // your code here
|
646 |
+
* return $core_fields;
|
647 |
+
* }
|
648 |
+
* ?>
|
649 |
+
*/
|
650 |
+
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
651 |
+
}
|
652 |
+
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Predefined Fields
|
656 |
+
*/
|
657 |
+
function set_predefined_fields() {
|
658 |
+
global $wp_roles;
|
659 |
+
|
660 |
+
$um_roles = array();
|
661 |
+
if ( ! empty( $wp_roles->roles ) ) {
|
662 |
+
$role_keys = get_option( 'um_roles', array() );
|
663 |
+
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
|
664 |
+
$role_keys = array_map( function( $item ) {
|
665 |
+
return 'um_' . $item;
|
666 |
+
}, $role_keys );
|
667 |
+
} else {
|
668 |
+
$role_keys = array();
|
669 |
+
}
|
670 |
+
|
671 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
672 |
+
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
673 |
+
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* UM hook
|
677 |
+
*
|
678 |
+
* @type filter
|
679 |
+
* @title um_profile_privacy_options
|
680 |
+
* @description Profile Privacy Options
|
681 |
+
* @input_vars
|
682 |
+
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
683 |
+
* @change_log
|
684 |
+
* ["Since: 2.0"]
|
685 |
+
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
686 |
+
* @example
|
687 |
+
* <?php
|
688 |
+
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
689 |
+
* function my_profile_privacy_options( $privacy_options ) {
|
690 |
+
* // your code here
|
691 |
+
* return $privacy_options;
|
692 |
+
* }
|
693 |
+
* ?>
|
694 |
+
*/
|
695 |
+
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
696 |
+
'Everyone' => __( 'Everyone', 'ultimate-member' ),
|
697 |
+
'Only me' => __( 'Only me', 'ultimate-member' )
|
698 |
+
) );
|
699 |
+
|
700 |
+
/*
|
701 |
+
* it's important create key for array equals value of 'metakey'.
|
702 |
+
*
|
703 |
+
*/
|
704 |
+
|
705 |
+
$this->predefined_fields = array(
|
706 |
+
|
707 |
+
'user_login' => array(
|
708 |
+
'title' => __('Username','ultimate-member'),
|
709 |
+
'metakey' => 'user_login',
|
710 |
+
'type' => 'text',
|
711 |
+
'label' => __('Username','ultimate-member'),
|
712 |
+
'required' => 1,
|
713 |
+
'public' => 1,
|
714 |
+
'editable' => 0,
|
715 |
+
'validate' => 'unique_username',
|
716 |
+
'min_chars' => 3,
|
717 |
+
'max_chars' => 24
|
718 |
+
),
|
719 |
+
|
720 |
+
'username' => array(
|
721 |
+
'title' => __('Username or E-mail','ultimate-member'),
|
722 |
+
'metakey' => 'username',
|
723 |
+
'type' => 'text',
|
724 |
+
'label' => __('Username or E-mail','ultimate-member'),
|
725 |
+
'required' => 1,
|
726 |
+
'public' => 1,
|
727 |
+
'editable' => 0,
|
728 |
+
'validate' => 'unique_username_or_email',
|
729 |
+
),
|
730 |
+
|
731 |
+
'user_password' => array(
|
732 |
+
'title' => __('Password','ultimate-member'),
|
733 |
+
'metakey' => 'user_password',
|
734 |
+
'type' => 'password',
|
735 |
+
'label' => __('Password','ultimate-member'),
|
736 |
+
'required' => 1,
|
737 |
+
'public' => 1,
|
738 |
+
'editable' => 1,
|
739 |
+
'min_chars' => 8,
|
740 |
+
'max_chars' => 30,
|
741 |
+
'force_good_pass' => 1,
|
742 |
+
'force_confirm_pass' => 1,
|
743 |
+
'label_confirm_pass' => __('Confirm Password','ultimate-member')
|
744 |
+
),
|
745 |
+
|
746 |
+
'first_name' => array(
|
747 |
+
'title' => __('First Name','ultimate-member'),
|
748 |
+
'metakey' => 'first_name',
|
749 |
+
'type' => 'text',
|
750 |
+
'label' => __('First Name','ultimate-member'),
|
751 |
+
'required' => 0,
|
752 |
+
'public' => 1,
|
753 |
+
'editable' => 1,
|
754 |
+
),
|
755 |
+
|
756 |
+
'last_name' => array(
|
757 |
+
'title' => __('Last Name','ultimate-member'),
|
758 |
+
'metakey' => 'last_name',
|
759 |
+
'type' => 'text',
|
760 |
+
'label' => __('Last Name','ultimate-member'),
|
761 |
+
'required' => 0,
|
762 |
+
'public' => 1,
|
763 |
+
'editable' => 1,
|
764 |
+
),
|
765 |
+
|
766 |
+
'nickname' => array(
|
767 |
+
'title' => __('Nickname','ultimate-member'),
|
768 |
+
'metakey' => 'nickname',
|
769 |
+
'type' => 'text',
|
770 |
+
'label' => __('Nickname','ultimate-member'),
|
771 |
+
'required' => 0,
|
772 |
+
'public' => 1,
|
773 |
+
'editable' => 1,
|
774 |
+
),
|
775 |
+
|
776 |
+
'user_url' => array(
|
777 |
+
'title' => __('Website URL','ultimate-member'),
|
778 |
+
'metakey' => 'user_url',
|
779 |
+
'type' => 'url',
|
780 |
+
'label' => __('Website URL','ultimate-member'),
|
781 |
+
'required' => 1,
|
782 |
+
'public' => 1,
|
783 |
+
'editable' => 1,
|
784 |
+
'validate' => 'url'
|
785 |
+
),
|
786 |
+
|
787 |
+
'user_registered' => array(
|
788 |
+
'title' => __('Registration Date','ultimate-member'),
|
789 |
+
'metakey' => 'user_registered',
|
790 |
+
'type' => 'text',
|
791 |
+
'label' => __('Registration Date','ultimate-member'),
|
792 |
+
'required' => 0,
|
793 |
+
'public' => 1,
|
794 |
+
'editable' => 1,
|
795 |
+
'edit_forbidden' => 1,
|
796 |
+
),
|
797 |
+
|
798 |
+
'_um_last_login' => array(
|
799 |
+
'title' => __('Last Login','ultimate-member'),
|
800 |
+
'metakey' => '_um_last_login',
|
801 |
+
'type' => 'text',
|
802 |
+
'label' => __('Last Login','ultimate-member'),
|
803 |
+
'required' => 0,
|
804 |
+
'public' => 1,
|
805 |
+
'editable' => 1,
|
806 |
+
'edit_forbidden' => 1,
|
807 |
+
),
|
808 |
+
|
809 |
+
'user_email' => array(
|
810 |
+
'title' => __('E-mail Address','ultimate-member'),
|
811 |
+
'metakey' => 'user_email',
|
812 |
+
'type' => 'text',
|
813 |
+
'label' => __('E-mail Address','ultimate-member'),
|
814 |
+
'required' => 0,
|
815 |
+
'public' => 1,
|
816 |
+
'validate' => 'unique_email',
|
817 |
+
'autocomplete' => 'off'
|
818 |
+
),
|
819 |
+
|
820 |
+
'secondary_user_email' => array(
|
821 |
+
'title' => __('Secondary E-mail Address','ultimate-member'),
|
822 |
+
'metakey' => 'secondary_user_email',
|
823 |
+
'type' => 'text',
|
824 |
+
'label' => __('Secondary E-mail Address','ultimate-member'),
|
825 |
+
'required' => 0,
|
826 |
+
'public' => 1,
|
827 |
+
'editable' => 1,
|
828 |
+
'validate' => 'unique_email',
|
829 |
+
'autocomplete' => 'off'
|
830 |
+
),
|
831 |
+
|
832 |
+
'description' => array(
|
833 |
+
'title' => __('Biography','ultimate-member'),
|
834 |
+
'metakey' => 'description',
|
835 |
+
'type' => 'textarea',
|
836 |
+
'label' => __('Biography','ultimate-member'),
|
837 |
+
'html' => 0,
|
838 |
+
'required' => 0,
|
839 |
+
'public' => 1,
|
840 |
+
'editable' => 1,
|
841 |
+
'max_words' => 40,
|
842 |
+
'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
|
843 |
+
),
|
844 |
+
|
845 |
+
'birth_date' => array(
|
846 |
+
'title' => __('Birth Date','ultimate-member'),
|
847 |
+
'metakey' => 'birth_date',
|
848 |
+
'type' => 'date',
|
849 |
+
'label' => __('Birth Date','ultimate-member'),
|
850 |
+
'required' => 0,
|
851 |
+
'public' => 1,
|
852 |
+
'editable' => 1,
|
853 |
+
'pretty_format' => 1,
|
854 |
+
'years' => 115,
|
855 |
+
'years_x' => 'past',
|
856 |
+
'icon' => 'um-faicon-calendar'
|
857 |
+
),
|
858 |
+
|
859 |
+
'gender' => array(
|
860 |
+
'title' => __('Gender','ultimate-member'),
|
861 |
+
'metakey' => 'gender',
|
862 |
+
'type' => 'radio',
|
863 |
+
'label' => __('Gender','ultimate-member'),
|
864 |
+
'required' => 0,
|
865 |
+
'public' => 1,
|
866 |
+
'editable' => 1,
|
867 |
+
'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
|
868 |
+
),
|
869 |
+
|
870 |
+
'country' => array(
|
871 |
+
'title' => __('Country','ultimate-member'),
|
872 |
+
'metakey' => 'country',
|
873 |
+
'type' => 'select',
|
874 |
+
'label' => __('Country','ultimate-member'),
|
875 |
+
'placeholder' => __('Choose a Country','ultimate-member'),
|
876 |
+
'required' => 0,
|
877 |
+
'public' => 1,
|
878 |
+
'editable' => 1,
|
879 |
+
'options' => $this->get('countries')
|
880 |
+
),
|
881 |
+
|
882 |
+
'facebook' => array(
|
883 |
+
'title' => __('Facebook','ultimate-member'),
|
884 |
+
'metakey' => 'facebook',
|
885 |
+
'type' => 'url',
|
886 |
+
'label' => __('Facebook','ultimate-member'),
|
887 |
+
'required' => 0,
|
888 |
+
'public' => 1,
|
889 |
+
'editable' => 1,
|
890 |
+
'url_target' => '_blank',
|
891 |
+
'url_rel' => 'nofollow',
|
892 |
+
'icon' => 'um-faicon-facebook',
|
893 |
+
'validate' => 'facebook_url',
|
894 |
+
'url_text' => 'Facebook',
|
895 |
+
'advanced' => 'social',
|
896 |
+
'color' => '#3B5999',
|
897 |
+
'match' => 'https://facebook.com/',
|
898 |
+
),
|
899 |
+
|
900 |
+
'twitter' => array(
|
901 |
+
'title' => __('Twitter','ultimate-member'),
|
902 |
+
'metakey' => 'twitter',
|
903 |
+
'type' => 'url',
|
904 |
+
'label' => __('Twitter','ultimate-member'),
|
905 |
+
'required' => 0,
|
906 |
+
'public' => 1,
|
907 |
+
'editable' => 1,
|
908 |
+
'url_target' => '_blank',
|
909 |
+
'url_rel' => 'nofollow',
|
910 |
+
'icon' => 'um-faicon-twitter',
|
911 |
+
'validate' => 'twitter_url',
|
912 |
+
'url_text' => 'Twitter',
|
913 |
+
'advanced' => 'social',
|
914 |
+
'color' => '#4099FF',
|
915 |
+
'match' => 'https://twitter.com/',
|
916 |
+
),
|
917 |
+
|
918 |
+
'linkedin' => array(
|
919 |
+
'title' => __('LinkedIn','ultimate-member'),
|
920 |
+
'metakey' => 'linkedin',
|
921 |
+
'type' => 'url',
|
922 |
+
'label' => __('LinkedIn','ultimate-member'),
|
923 |
+
'required' => 0,
|
924 |
+
'public' => 1,
|
925 |
+
'editable' => 1,
|
926 |
+
'url_target' => '_blank',
|
927 |
+
'url_rel' => 'nofollow',
|
928 |
+
'icon' => 'um-faicon-linkedin',
|
929 |
+
'validate' => 'linkedin_url',
|
930 |
+
'url_text' => 'LinkedIn',
|
931 |
+
'advanced' => 'social',
|
932 |
+
'color' => '#0976b4',
|
933 |
+
'match' => 'https://linkedin.com/in/',
|
934 |
+
),
|
935 |
+
|
936 |
+
'googleplus' => array(
|
937 |
+
'title' => __('Google+','ultimate-member'),
|
938 |
+
'metakey' => 'googleplus',
|
939 |
+
'type' => 'url',
|
940 |
+
'label' => __('Google+','ultimate-member'),
|
941 |
+
'required' => 0,
|
942 |
+
'public' => 1,
|
943 |
+
'editable' => 1,
|
944 |
+
'url_target' => '_blank',
|
945 |
+
'url_rel' => 'nofollow',
|
946 |
+
'icon' => 'um-faicon-google-plus',
|
947 |
+
'validate' => 'google_url',
|
948 |
+
'url_text' => 'Google+',
|
949 |
+
'advanced' => 'social',
|
950 |
+
'color' => '#dd4b39',
|
951 |
+
'match' => 'https://google.com/+',
|
952 |
+
),
|
953 |
+
|
954 |
+
'instagram' => array(
|
955 |
+
'title' => __('Instagram','ultimate-member'),
|
956 |
+
'metakey' => 'instagram',
|
957 |
+
'type' => 'url',
|
958 |
+
'label' => __('Instagram','ultimate-member'),
|
959 |
+
'required' => 0,
|
960 |
+
'public' => 1,
|
961 |
+
'editable' => 1,
|
962 |
+
'url_target' => '_blank',
|
963 |
+
'url_rel' => 'nofollow',
|
964 |
+
'icon' => 'um-faicon-instagram',
|
965 |
+
'validate' => 'instagram_url',
|
966 |
+
'url_text' => 'Instagram',
|
967 |
+
'advanced' => 'social',
|
968 |
+
'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
|
969 |
+
'match' => 'https://instagram.com/',
|
970 |
+
),
|
971 |
+
|
972 |
+
'skype' => array(
|
973 |
+
'title' => __('Skype ID','ultimate-member'),
|
974 |
+
'metakey' => 'skype',
|
975 |
+
'type' => 'url',
|
976 |
+
'label' => __('Skype ID','ultimate-member'),
|
977 |
+
'required' => 0,
|
978 |
+
'public' => 1,
|
979 |
+
'editable' => 1,
|
980 |
+
'url_target' => '_blank',
|
981 |
+
'url_rel' => 'nofollow',
|
982 |
+
'icon' => 'um-faicon-skype',
|
983 |
+
'validate' => 'skype',
|
984 |
+
'url_text' => 'Skype',
|
985 |
+
),
|
986 |
+
|
987 |
+
'youtube' => array(
|
988 |
+
'title' => __('YouTube','ultimate-member'),
|
989 |
+
'metakey' => 'youtube',
|
990 |
+
'type' => 'url',
|
991 |
+
'label' => __('YouTube','ultimate-member'),
|
992 |
+
'required' => 0,
|
993 |
+
'public' => 1,
|
994 |
+
'editable' => 1,
|
995 |
+
'url_target' => '_blank',
|
996 |
+
'url_rel' => 'nofollow',
|
997 |
+
'icon' => 'um-faicon-youtube',
|
998 |
+
'validate' => 'youtube_url',
|
999 |
+
'url_text' => 'YouTube',
|
1000 |
+
'advanced' => 'social',
|
1001 |
+
'color' => '#e52d27',
|
1002 |
+
'match' => 'https://youtube.com/',
|
1003 |
+
),
|
1004 |
+
|
1005 |
+
'soundcloud' => array(
|
1006 |
+
'title' => __( 'SoundCloud', 'ultimate-member' ),
|
1007 |
+
'metakey' => 'soundcloud',
|
1008 |
+
'type' => 'url',
|
1009 |
+
'label' => __( 'SoundCloud', 'ultimate-member' ),
|
1010 |
+
'required' => 0,
|
1011 |
+
'public' => 1,
|
1012 |
+
'editable' => 1,
|
1013 |
+
'url_target' => '_blank',
|
1014 |
+
'url_rel' => 'nofollow',
|
1015 |
+
'icon' => 'um-faicon-soundcloud',
|
1016 |
+
'validate' => 'soundcloud_url',
|
1017 |
+
'url_text' => 'SoundCloud',
|
1018 |
+
'advanced' => 'social',
|
1019 |
+
'color' => '#f50',
|
1020 |
+
'match' => 'https://soundcloud.com/',
|
1021 |
+
),
|
1022 |
+
|
1023 |
+
'vkontakte' => array(
|
1024 |
+
'title' => __('VKontakte','ultimate-member'),
|
1025 |
+
'metakey' => 'vkontakte',
|
1026 |
+
'type' => 'url',
|
1027 |
+
'label' => __('VKontakte','ultimate-member'),
|
1028 |
+
'required' => 0,
|
1029 |
+
'public' => 1,
|
1030 |
+
'editable' => 1,
|
1031 |
+
'url_target' => '_blank',
|
1032 |
+
'url_rel' => 'nofollow',
|
1033 |
+
'icon' => 'um-faicon-vk',
|
1034 |
+
'validate' => 'vk_url',
|
1035 |
+
'url_text' => 'VKontakte',
|
1036 |
+
'advanced' => 'social',
|
1037 |
+
'color' => '#2B587A',
|
1038 |
+
'match' => 'https://vk.com/',
|
1039 |
+
),
|
1040 |
+
|
1041 |
+
'role_select' => array(
|
1042 |
+
'title' => __('Roles (Dropdown)','ultimate-member'),
|
1043 |
+
'metakey' => 'role_select',
|
1044 |
+
'type' => 'select',
|
1045 |
+
'label' => __('Account Type','ultimate-member'),
|
1046 |
+
'placeholder' => 'Choose account type',
|
1047 |
+
'required' => 0,
|
1048 |
+
'public' => 1,
|
1049 |
+
'editable' => 1,
|
1050 |
+
'options' => $um_roles,
|
1051 |
+
),
|
1052 |
+
|
1053 |
+
'role_radio' => array(
|
1054 |
+
'title' => __('Roles (Radio)','ultimate-member'),
|
1055 |
+
'metakey' => 'role_radio',
|
1056 |
+
'type' => 'radio',
|
1057 |
+
'label' => __('Account Type','ultimate-member'),
|
1058 |
+
'required' => 0,
|
1059 |
+
'public' => 1,
|
1060 |
+
'editable' => 1,
|
1061 |
+
'options' => $um_roles,
|
1062 |
+
),
|
1063 |
+
|
1064 |
+
'languages' => array(
|
1065 |
+
'title' => __('Languages','ultimate-member'),
|
1066 |
+
'metakey' => 'languages',
|
1067 |
+
'type' => 'multiselect',
|
1068 |
+
'label' => __('Languages Spoken','ultimate-member'),
|
1069 |
+
'placeholder' => __('Select languages','ultimate-member'),
|
1070 |
+
'required' => 0,
|
1071 |
+
'public' => 1,
|
1072 |
+
'editable' => 1,
|
1073 |
+
'options' => $this->get('languages'),
|
1074 |
+
),
|
1075 |
+
|
1076 |
+
'phone_number' => array(
|
1077 |
+
'title' => __('Phone Number','ultimate-member'),
|
1078 |
+
'metakey' => 'phone_number',
|
1079 |
+
'type' => 'text',
|
1080 |
+
'label' => __('Phone Number','ultimate-member'),
|
1081 |
+
'required' => 0,
|
1082 |
+
'public' => 1,
|
1083 |
+
'editable' => 1,
|
1084 |
+
'validate' => 'phone_number',
|
1085 |
+
'icon' => 'um-faicon-phone',
|
1086 |
+
),
|
1087 |
+
|
1088 |
+
'mobile_number' => array(
|
1089 |
+
'title' => __('Mobile Number','ultimate-member'),
|
1090 |
+
'metakey' => 'mobile_number',
|
1091 |
+
'type' => 'text',
|
1092 |
+
'label' => __('Mobile Number','ultimate-member'),
|
1093 |
+
'required' => 0,
|
1094 |
+
'public' => 1,
|
1095 |
+
'editable' => 1,
|
1096 |
+
'validate' => 'phone_number',
|
1097 |
+
'icon' => 'um-faicon-mobile',
|
1098 |
+
),
|
1099 |
+
|
1100 |
+
// private use ( not public list )
|
1101 |
+
|
1102 |
+
'profile_photo' => array(
|
1103 |
+
'title' => __('Profile Photo','ultimate-member'),
|
1104 |
+
'metakey' => 'profile_photo',
|
1105 |
+
'type' => 'image',
|
1106 |
+
'label' => __('Change your profile photo','ultimate-member'),
|
1107 |
+
'upload_text' => __('Upload your photo here','ultimate-member'),
|
1108 |
+
'icon' => 'um-faicon-camera',
|
1109 |
+
'crop' => 1,
|
1110 |
+
'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
|
1111 |
+
'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1112 |
+
'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1113 |
+
'private_use' => true,
|
1114 |
+
),
|
1115 |
+
|
1116 |
+
'cover_photo' => array(
|
1117 |
+
'title' => __('Cover Photo','ultimate-member'),
|
1118 |
+
'metakey' => 'cover_photo',
|
1119 |
+
'type' => 'image',
|
1120 |
+
'label' => __('Change your cover photo','ultimate-member'),
|
1121 |
+
'upload_text' => __('Upload profile cover here','ultimate-member'),
|
1122 |
+
'icon' => 'um-faicon-picture-o',
|
1123 |
+
'crop' => 2,
|
1124 |
+
'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
|
1125 |
+
'modal_size' => 'large',
|
1126 |
+
'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
|
1127 |
+
'min_width' => UM()->options()->get('cover_min_width'),
|
1128 |
+
'private_use' => true,
|
1129 |
+
),
|
1130 |
+
|
1131 |
+
'username_b' => array(
|
1132 |
+
'title' => __('Username or E-mail','ultimate-member'),
|
1133 |
+
'metakey' => 'username_b',
|
1134 |
+
'type' => 'text',
|
1135 |
+
'placeholder' => __('Enter your username or email','ultimate-member'),
|
1136 |
+
'required' => 1,
|
1137 |
+
'public' => 1,
|
1138 |
+
'editable' => 0,
|
1139 |
+
'private_use' => true,
|
1140 |
+
),
|
1141 |
+
|
1142 |
+
// account page use ( not public )
|
1143 |
+
|
1144 |
+
'profile_privacy' => array(
|
1145 |
+
'title' => __( 'Profile Privacy', 'ultimate-member' ),
|
1146 |
+
'metakey' => 'profile_privacy',
|
1147 |
+
'type' => 'select',
|
1148 |
+
'label' => __( 'Profile Privacy', 'ultimate-member' ),
|
1149 |
+
'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
|
1150 |
+
'required' => 0,
|
1151 |
+
'public' => 1,
|
1152 |
+
'editable' => 1,
|
1153 |
+
'default' => 'Everyone',
|
1154 |
+
'options' => $profile_privacy,
|
1155 |
+
'allowclear' => 0,
|
1156 |
+
'account_only' => true,
|
1157 |
+
'required_perm' => 'can_make_private_profile',
|
1158 |
+
),
|
1159 |
+
|
1160 |
+
'profile_noindex' => array(
|
1161 |
+
'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1162 |
+
'metakey' => 'profile_noindex',
|
1163 |
+
'type' => 'select',
|
1164 |
+
'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1165 |
+
'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
|
1166 |
+
'required' => 0,
|
1167 |
+
'public' => 1,
|
1168 |
+
'editable' => 1,
|
1169 |
+
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
|
1170 |
+
'options' => array(
|
1171 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1172 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1173 |
+
),
|
1174 |
+
'allowclear' => 0,
|
1175 |
+
'account_only' => true,
|
1176 |
+
'required_perm' => 'can_make_private_profile',
|
1177 |
+
),
|
1178 |
+
|
1179 |
+
'hide_in_members' => array(
|
1180 |
+
'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1181 |
+
'metakey' => 'hide_in_members',
|
1182 |
+
'type' => 'radio',
|
1183 |
+
'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1184 |
+
'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
|
1185 |
+
'required' => 0,
|
1186 |
+
'public' => 1,
|
1187 |
+
'editable' => 1,
|
1188 |
+
'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
|
1189 |
+
'options' => array(
|
1190 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1191 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1192 |
+
),
|
1193 |
+
'account_only' => true,
|
1194 |
+
'required_opt' => array( 'members_page', 1 ),
|
1195 |
+
),
|
1196 |
+
|
1197 |
+
'delete_account' => array(
|
1198 |
+
'title' => __( 'Delete Account', 'ultimate-member' ),
|
1199 |
+
'metakey' => 'delete_account',
|
1200 |
+
'type' => 'radio',
|
1201 |
+
'label' => __( 'Delete Account', 'ultimate-member'),
|
1202 |
+
'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
|
1203 |
+
'required' => 0,
|
1204 |
+
'public' => 1,
|
1205 |
+
'editable' => 1,
|
1206 |
+
'default' => __( 'No', 'ultimate-member' ),
|
1207 |
+
'options' => array(
|
1208 |
+
__( 'Yes', 'ultimate-member' ),
|
1209 |
+
__( 'No', 'ultimate-member' )
|
1210 |
+
),
|
1211 |
+
'account_only' => true,
|
1212 |
+
),
|
1213 |
+
|
1214 |
+
'single_user_password' => array(
|
1215 |
+
'title' => __( 'Password', 'ultimate-member' ),
|
1216 |
+
'metakey' => 'single_user_password',
|
1217 |
+
'type' => 'password',
|
1218 |
+
'label' => __( 'Password', 'ultimate-member' ),
|
1219 |
+
'required' => 1,
|
1220 |
+
'public' => 1,
|
1221 |
+
'editable' => 1,
|
1222 |
+
'account_only' => true,
|
1223 |
+
),
|
1224 |
+
|
1225 |
+
);
|
1226 |
+
|
1227 |
+
/**
|
1228 |
+
* UM hook
|
1229 |
+
*
|
1230 |
+
* @type filter
|
1231 |
+
* @title um_predefined_fields_hook
|
1232 |
+
* @description Extend Predefined Fields
|
1233 |
+
* @input_vars
|
1234 |
+
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
1235 |
+
* @change_log
|
1236 |
+
* ["Since: 2.0"]
|
1237 |
+
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
1238 |
+
* @example
|
1239 |
+
* <?php
|
1240 |
+
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
1241 |
+
* function my_predefined_fields( $predefined_fields ) {
|
1242 |
+
* // your code here
|
1243 |
+
* return $predefined_fields;
|
1244 |
+
* }
|
1245 |
+
* ?>
|
1246 |
+
*/
|
1247 |
+
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
|
1251 |
+
/**
|
1252 |
+
* Custom Fields
|
1253 |
+
*/
|
1254 |
+
function set_custom_fields() {
|
1255 |
+
|
1256 |
+
if ( is_array( $this->saved_fields ) ) {
|
1257 |
+
|
1258 |
+
$this->custom_fields = $this->saved_fields;
|
1259 |
+
|
1260 |
+
} else {
|
1261 |
+
|
1262 |
+
$this->custom_fields = '';
|
1263 |
+
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
$custom = $this->custom_fields;
|
1267 |
+
$predefined = $this->predefined_fields;
|
1268 |
+
|
1269 |
+
if ( is_array( $custom ) ){
|
1270 |
+
$this->all_user_fields = array_merge( $predefined, $custom );
|
1271 |
+
} else {
|
1272 |
+
$this->all_user_fields = $predefined;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
|
1278 |
+
/**
|
1279 |
+
* Get all fields without metakeys
|
1280 |
+
*
|
1281 |
+
* @since 2.0.56
|
1282 |
+
*
|
1283 |
+
* @return array
|
1284 |
+
*/
|
1285 |
+
function get_fields_without_metakey() {
|
1286 |
+
$fields_without_metakey = array(
|
1287 |
+
'block',
|
1288 |
+
'shortcode',
|
1289 |
+
'spacing',
|
1290 |
+
'divider',
|
1291 |
+
'group'
|
1292 |
+
);
|
1293 |
+
|
1294 |
+
|
1295 |
+
/**
|
1296 |
+
* UM hook
|
1297 |
+
*
|
1298 |
+
* @type filter
|
1299 |
+
* @title um_fields_without_metakey
|
1300 |
+
* @description Field Types without meta key
|
1301 |
+
* @input_vars
|
1302 |
+
* [{"var":"$types","type":"array","desc":"Field Types"}]
|
1303 |
+
* @change_log
|
1304 |
+
* ["Since: 2.0"]
|
1305 |
+
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
1306 |
+
* @example
|
1307 |
+
* <?php
|
1308 |
+
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
1309 |
+
* function my_fields_without_metakey( $types ) {
|
1310 |
+
* // your code here
|
1311 |
+
* return $types;
|
1312 |
+
* }
|
1313 |
+
* ?>
|
1314 |
+
*/
|
1315 |
+
return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
|
1319 |
+
/**
|
1320 |
+
* May be used to show a dropdown, or source for user meta
|
1321 |
+
*
|
1322 |
+
* @param null $exclude_types
|
1323 |
+
* @param bool $show_all
|
1324 |
+
*
|
1325 |
+
* @return array
|
1326 |
+
*/
|
1327 |
+
function all_user_fields( $exclude_types = null, $show_all = false ) {
|
1328 |
+
|
1329 |
+
$fields_without_metakey = $this->get_fields_without_metakey();
|
1330 |
+
$fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
|
1331 |
+
|
1332 |
+
if ( ! $show_all ) {
|
1333 |
+
$this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
|
1334 |
+
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
|
1335 |
+
} else {
|
1336 |
+
$this->fields_dropdown = $fields_without_metakey;
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
$custom = $this->custom_fields;
|
1340 |
+
$predefined = $this->predefined_fields;
|
1341 |
+
|
1342 |
+
if ( $exclude_types ) {
|
1343 |
+
$exclude_types = explode( ',', $exclude_types );
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
$all = array( 0 => '' );
|
1347 |
+
|
1348 |
+
if ( is_array( $custom ) ) {
|
1349 |
+
$all = $all + array_merge( $predefined, $custom );
|
1350 |
+
} else {
|
1351 |
+
$all = $all + $predefined;
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
foreach ( $all as $k => $arr ) {
|
1355 |
+
|
1356 |
+
if ( $k == 0 ) {
|
1357 |
+
unset( $all[ $k ] );
|
1358 |
+
}
|
1359 |
+
|
1360 |
+
if ( isset( $arr['title'] ) ) {
|
1361 |
+
$all[ $k ]['title'] = stripslashes( $arr['title'] );
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
|
1365 |
+
unset( $all[ $k ] );
|
1366 |
+
}
|
1367 |
+
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
1368 |
+
if ( ! $show_all ) {
|
1369 |
+
unset( $all[ $k ] );
|
1370 |
+
}
|
1371 |
+
}
|
1372 |
+
if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
|
1373 |
+
unset( $all[ $k ] );
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
$all = UM()->fields()->array_sort_by_column( $all, 'title' );
|
1378 |
+
|
1379 |
+
return $all;
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
|
1383 |
+
/**
|
1384 |
+
* Possible validation types for fields
|
1385 |
+
*
|
1386 |
+
* @return mixed
|
1387 |
+
*/
|
1388 |
+
function validation_types() {
|
1389 |
+
|
1390 |
+
$array[0] = __('None','ultimate-member');
|
1391 |
+
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
|
1392 |
+
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
|
1393 |
+
$array['english'] = __('English letters only','ultimate-member');
|
1394 |
+
$array['facebook_url'] = __('Facebook URL','ultimate-member');
|
1395 |
+
$array['google_url'] = __('Google+ URL','ultimate-member');
|
1396 |
+
$array['instagram_url'] = __('Instagram URL','ultimate-member');
|
1397 |
+
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
|
1398 |
+
$array['vk_url'] = __('VKontakte URL','ultimate-member');
|
1399 |
+
$array['lowercase'] = __('Lowercase only','ultimate-member');
|
1400 |
+
$array['numeric'] = __('Numeric value only','ultimate-member');
|
1401 |
+
$array['phone_number'] = __('Phone Number','ultimate-member');
|
1402 |
+
$array['skype'] = __('Skype ID','ultimate-member');
|
1403 |
+
$array['soundcloud'] = __( 'SoundCloud Profile', 'ultimate-member' );
|
1404 |
+
$array['twitter_url'] = __('Twitter URL','ultimate-member');
|
1405 |
+
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
1406 |
+
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
1407 |
+
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
1408 |
+
$array['unique_username'] = __('Unique Username','ultimate-member');
|
1409 |
+
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1410 |
+
$array['url'] = __('Website URL','ultimate-member');
|
1411 |
+
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1412 |
+
$array['custom'] = __('Custom Validation','ultimate-member');
|
1413 |
+
|
1414 |
+
/**
|
1415 |
+
* UM hook
|
1416 |
+
*
|
1417 |
+
* @type filter
|
1418 |
+
* @title um_admin_field_validation_hook
|
1419 |
+
* @description Extend validation types
|
1420 |
+
* @input_vars
|
1421 |
+
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
1422 |
+
* @change_log
|
1423 |
+
* ["Since: 2.0"]
|
1424 |
+
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
1425 |
+
* @example
|
1426 |
+
* <?php
|
1427 |
+
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
1428 |
+
* function my_admin_field_validation( $types ) {
|
1429 |
+
* // your code here
|
1430 |
+
* return $types;
|
1431 |
+
* }
|
1432 |
+
* ?>
|
1433 |
+
*/
|
1434 |
+
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
1435 |
+
return $array;
|
1436 |
+
}
|
1437 |
+
|
1438 |
+
|
1439 |
+
/**
|
1440 |
+
* Get predefined options
|
1441 |
+
*
|
1442 |
+
* @param $data
|
1443 |
+
*
|
1444 |
+
* @return array|mixed|void
|
1445 |
+
*/
|
1446 |
+
function get( $data ) {
|
1447 |
+
switch ( $data ) {
|
1448 |
+
|
1449 |
+
case 'languages':
|
1450 |
+
$array = array(
|
1451 |
+
"aa" => __("Afar",'ultimate-member'),
|
1452 |
+
"ab" => __("Abkhazian",'ultimate-member'),
|
1453 |
+
"ae" => __("Avestan",'ultimate-member'),
|
1454 |
+
"af" => __("Afrikaans",'ultimate-member'),
|
1455 |
+
"ak" => __("Akan",'ultimate-member'),
|
1456 |
+
"am" => __("Amharic",'ultimate-member'),
|
1457 |
+
"an" => __("Aragonese",'ultimate-member'),
|
1458 |
+
"ar" => __("Arabic",'ultimate-member'),
|
1459 |
+
"as" => __("Assamese",'ultimate-member'),
|
1460 |
+
"av" => __("Avaric",'ultimate-member'),
|
1461 |
+
"ay" => __("Aymara",'ultimate-member'),
|
1462 |
+
"az" => __("Azerbaijani",'ultimate-member'),
|
1463 |
+
"ba" => __("Bashkir",'ultimate-member'),
|
1464 |
+
"be" => __("Belarusian",'ultimate-member'),
|
1465 |
+
"bg" => __("Bulgarian",'ultimate-member'),
|
1466 |
+
"bh" => __("Bihari",'ultimate-member'),
|
1467 |
+
"bi" => __("Bislama",'ultimate-member'),
|
1468 |
+
"bm" => __("Bambara",'ultimate-member'),
|
1469 |
+
"bn" => __("Bengali",'ultimate-member'),
|
1470 |
+
"bo" => __("Tibetan",'ultimate-member'),
|
1471 |
+
"br" => __("Breton",'ultimate-member'),
|
1472 |
+
"bs" => __("Bosnian",'ultimate-member'),
|
1473 |
+
"ca" => __("Catalan",'ultimate-member'),
|
1474 |
+
"ce" => __("Chechen",'ultimate-member'),
|
1475 |
+
"ch" => __("Chamorro",'ultimate-member'),
|
1476 |
+
"co" => __("Corsican",'ultimate-member'),
|
1477 |
+
"cr" => __("Cree",'ultimate-member'),
|
1478 |
+
"cs" => __("Czech",'ultimate-member'),
|
1479 |
+
"cu" => __("Church Slavic",'ultimate-member'),
|
1480 |
+
"cv" => __("Chuvash",'ultimate-member'),
|
1481 |
+
"cy" => __("Welsh",'ultimate-member'),
|
1482 |
+
"da" => __("Danish",'ultimate-member'),
|
1483 |
+
"de" => __("German",'ultimate-member'),
|
1484 |
+
"dv" => __("Divehi",'ultimate-member'),
|
1485 |
+
"dz" => __("Dzongkha",'ultimate-member'),
|
1486 |
+
"ee" => __("Ewe",'ultimate-member'),
|
1487 |
+
"el" => __("Greek",'ultimate-member'),
|
1488 |
+
"en" => __("English",'ultimate-member'),
|
1489 |
+
"eo" => __("Esperanto",'ultimate-member'),
|
1490 |
+
"es" => __("Spanish",'ultimate-member'),
|
1491 |
+
"et" => __("Estonian",'ultimate-member'),
|
1492 |
+
"eu" => __("Basque",'ultimate-member'),
|
1493 |
+
"fa" => __("Persian",'ultimate-member'),
|
1494 |
+
"ff" => __("Fulah",'ultimate-member'),
|
1495 |
+
"fi" => __("Finnish",'ultimate-member'),
|
1496 |
+
"fj" => __("Fijian",'ultimate-member'),
|
1497 |
+
"fo" => __("Faroese",'ultimate-member'),
|
1498 |
+
"fr" => __("French",'ultimate-member'),
|
1499 |
+
"fy" => __("Western Frisian",'ultimate-member'),
|
1500 |
+
"ga" => __("Irish",'ultimate-member'),
|
1501 |
+
"gd" => __("Scottish Gaelic",'ultimate-member'),
|
1502 |
+
"gl" => __("Galician",'ultimate-member'),
|
1503 |
+
"gn" => __("Guarani",'ultimate-member'),
|
1504 |
+
"gu" => __("Gujarati",'ultimate-member'),
|
1505 |
+
"gv" => __("Manx",'ultimate-member'),
|
1506 |
+
"ha" => __("Hausa",'ultimate-member'),
|
1507 |
+
"he" => __("Hebrew",'ultimate-member'),
|
1508 |
+
"hi" => __("Hindi",'ultimate-member'),
|
1509 |
+
"ho" => __("Hiri Motu",'ultimate-member'),
|
1510 |
+
"hr" => __("Croatian",'ultimate-member'),
|
1511 |
+
"ht" => __("Haitian",'ultimate-member'),
|
1512 |
+
"hu" => __("Hungarian",'ultimate-member'),
|
1513 |
+
"hy" => __("Armenian",'ultimate-member'),
|
1514 |
+
"hz" => __("Herero",'ultimate-member'),
|
1515 |
+
"ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
|
1516 |
+
"id" => __("Indonesian",'ultimate-member'),
|
1517 |
+
"ie" => __("Interlingue",'ultimate-member'),
|
1518 |
+
"ig" => __("Igbo",'ultimate-member'),
|
1519 |
+
"ii" => __("Sichuan Yi",'ultimate-member'),
|
1520 |
+
"ik" => __("Inupiaq",'ultimate-member'),
|
1521 |
+
"io" => __("Ido",'ultimate-member'),
|
1522 |
+
"is" => __("Icelandic",'ultimate-member'),
|
1523 |
+
"it" => __("Italian",'ultimate-member'),
|
1524 |
+
"iu" => __("Inuktitut",'ultimate-member'),
|
1525 |
+
"ja" => __("Japanese",'ultimate-member'),
|
1526 |
+
"jv" => __("Javanese",'ultimate-member'),
|
1527 |
+
"ka" => __("Georgian",'ultimate-member'),
|
1528 |
+
"kg" => __("Kongo",'ultimate-member'),
|
1529 |
+
"ki" => __("Kikuyu",'ultimate-member'),
|
1530 |
+
"kj" => __("Kwanyama",'ultimate-member'),
|
1531 |
+
"kk" => __("Kazakh",'ultimate-member'),
|
1532 |
+
"kl" => __("Kalaallisut",'ultimate-member'),
|
1533 |
+
"km" => __("Khmer",'ultimate-member'),
|
1534 |
+
"kn" => __("Kannada",'ultimate-member'),
|
1535 |
+
"ko" => __("Korean",'ultimate-member'),
|
1536 |
+
"kr" => __("Kanuri",'ultimate-member'),
|
1537 |
+
"ks" => __("Kashmiri",'ultimate-member'),
|
1538 |
+
"ku" => __("Kurdish",'ultimate-member'),
|
1539 |
+
"kv" => __("Komi",'ultimate-member'),
|
1540 |
+
"kw" => __("Cornish",'ultimate-member'),
|
1541 |
+
"ky" => __("Kirghiz",'ultimate-member'),
|
1542 |
+
"la" => __("Latin",'ultimate-member'),
|
1543 |
+
"lb" => __("Luxembourgish",'ultimate-member'),
|
1544 |
+
"lg" => __("Ganda",'ultimate-member'),
|
1545 |
+
"li" => __("Limburgish",'ultimate-member'),
|
1546 |
+
"ln" => __("Lingala",'ultimate-member'),
|
1547 |
+
"lo" => __("Lao",'ultimate-member'),
|
1548 |
+
"lt" => __("Lithuanian",'ultimate-member'),
|
1549 |
+
"lu" => __("Luba-Katanga",'ultimate-member'),
|
1550 |
+
"lv" => __("Latvian",'ultimate-member'),
|
1551 |
+
"mg" => __("Malagasy",'ultimate-member'),
|
1552 |
+
"mh" => __("Marshallese",'ultimate-member'),
|
1553 |
+
"mi" => __("Maori",'ultimate-member'),
|
1554 |
+
"mk" => __("Macedonian",'ultimate-member'),
|
1555 |
+
"ml" => __("Malayalam",'ultimate-member'),
|
1556 |
+
"mn" => __("Mongolian",'ultimate-member'),
|
1557 |
+
"mr" => __("Marathi",'ultimate-member'),
|
1558 |
+
"ms" => __("Malay",'ultimate-member'),
|
1559 |
+
"mt" => __("Maltese",'ultimate-member'),
|
1560 |
+
"my" => __("Burmese",'ultimate-member'),
|
1561 |
+
"na" => __("Nauru",'ultimate-member'),
|
1562 |
+
"nb" => __("Norwegian Bokmal",'ultimate-member'),
|
1563 |
+
"nd" => __("North Ndebele",'ultimate-member'),
|
1564 |
+
"ne" => __("Nepali",'ultimate-member'),
|
1565 |
+
"ng" => __("Ndonga",'ultimate-member'),
|
1566 |
+
"nl" => __("Dutch",'ultimate-member'),
|
1567 |
+
"nn" => __("Norwegian Nynorsk",'ultimate-member'),
|
1568 |
+
"no" => __("Norwegian",'ultimate-member'),
|
1569 |
+
"nr" => __("South Ndebele",'ultimate-member'),
|
1570 |
+
"nv" => __("Navajo",'ultimate-member'),
|
1571 |
+
"ny" => __("Chichewa",'ultimate-member'),
|
1572 |
+
"oc" => __("Occitan",'ultimate-member'),
|
1573 |
+
"oj" => __("Ojibwa",'ultimate-member'),
|
1574 |
+
"om" => __("Oromo",'ultimate-member'),
|
1575 |
+
"or" => __("Oriya",'ultimate-member'),
|
1576 |
+
"os" => __("Ossetian",'ultimate-member'),
|
1577 |
+
"pa" => __("Panjabi",'ultimate-member'),
|
1578 |
+
"pi" => __("Pali",'ultimate-member'),
|
1579 |
+
"pl" => __("Polish",'ultimate-member'),
|
1580 |
+
"ps" => __("Pashto",'ultimate-member'),
|
1581 |
+
"pt" => __("Portuguese",'ultimate-member'),
|
1582 |
+
"qu" => __("Quechua",'ultimate-member'),
|
1583 |
+
"rm" => __("Raeto-Romance",'ultimate-member'),
|
1584 |
+
"rn" => __("Kirundi",'ultimate-member'),
|
1585 |
+
"ro" => __("Romanian",'ultimate-member'),
|
1586 |
+
"ru" => __("Russian",'ultimate-member'),
|
1587 |
+
"rw" => __("Kinyarwanda",'ultimate-member'),
|
1588 |
+
"sa" => __("Sanskrit",'ultimate-member'),
|
1589 |
+
"sc" => __("Sardinian",'ultimate-member'),
|
1590 |
+
"sd" => __("Sindhi",'ultimate-member'),
|
1591 |
+
"se" => __("Northern Sami",'ultimate-member'),
|
1592 |
+
"sg" => __("Sango",'ultimate-member'),
|
1593 |
+
"si" => __("Sinhala",'ultimate-member'),
|
1594 |
+
"sk" => __("Slovak",'ultimate-member'),
|
1595 |
+
"sl" => __("Slovenian",'ultimate-member'),
|
1596 |
+
"sm" => __("Samoan",'ultimate-member'),
|
1597 |
+
"sn" => __("Shona",'ultimate-member'),
|
1598 |
+
"so" => __("Somali",'ultimate-member'),
|
1599 |
+
"sq" => __("Albanian",'ultimate-member'),
|
1600 |
+
"sr" => __("Serbian",'ultimate-member'),
|
1601 |
+
"ss" => __("Swati",'ultimate-member'),
|
1602 |
+
"st" => __("Southern Sotho",'ultimate-member'),
|
1603 |
+
"su" => __("Sundanese",'ultimate-member'),
|
1604 |
+
"sv" => __("Swedish",'ultimate-member'),
|
1605 |
+
"sw" => __("Swahili",'ultimate-member'),
|
1606 |
+
"ta" => __("Tamil",'ultimate-member'),
|
1607 |
+
"te" => __("Telugu",'ultimate-member'),
|
1608 |
+
"tg" => __("Tajik",'ultimate-member'),
|
1609 |
+
"th" => __("Thai",'ultimate-member'),
|
1610 |
+
"ti" => __("Tigrinya",'ultimate-member'),
|
1611 |
+
"tk" => __("Turkmen",'ultimate-member'),
|
1612 |
+
"tl" => __("Tagalog",'ultimate-member'),
|
1613 |
+
"tn" => __("Tswana",'ultimate-member'),
|
1614 |
+
"to" => __("Tonga",'ultimate-member'),
|
1615 |
+
"tr" => __("Turkish",'ultimate-member'),
|
1616 |
+
"ts" => __("Tsonga",'ultimate-member'),
|
1617 |
+
"tt" => __("Tatar",'ultimate-member'),
|
1618 |
+
"tw" => __("Twi",'ultimate-member'),
|
1619 |
+
"ty" => __("Tahitian",'ultimate-member'),
|
1620 |
+
"ug" => __("Uighur",'ultimate-member'),
|
1621 |
+
"uk" => __("Ukrainian",'ultimate-member'),
|
1622 |
+
"ur" => __("Urdu",'ultimate-member'),
|
1623 |
+
"uz" => __("Uzbek",'ultimate-member'),
|
1624 |
+
"ve" => __("Venda",'ultimate-member'),
|
1625 |
+
"vi" => __("Vietnamese",'ultimate-member'),
|
1626 |
+
"vo" => __("Volapuk",'ultimate-member'),
|
1627 |
+
"wa" => __("Walloon",'ultimate-member'),
|
1628 |
+
"wo" => __("Wolof",'ultimate-member'),
|
1629 |
+
"xh" => __("Xhosa",'ultimate-member'),
|
1630 |
+
"yi" => __("Yiddish",'ultimate-member'),
|
1631 |
+
"yo" => __("Yoruba",'ultimate-member'),
|
1632 |
+
"za" => __("Zhuang",'ultimate-member'),
|
1633 |
+
"zh" => __("Chinese",'ultimate-member'),
|
1634 |
+
"zu" => __("Zulu",'ultimate-member')
|
1635 |
+
);
|
1636 |
+
break;
|
1637 |
+
|
1638 |
+
case 'countries':
|
1639 |
+
$array = array (
|
1640 |
+
'AF' => __('Afghanistan','ultimate-member'),
|
1641 |
+
'AX' => __('Åland Islands','ultimate-member'),
|
1642 |
+
'AL' => __('Albania','ultimate-member'),
|
1643 |
+
'DZ' => __('Algeria','ultimate-member'),
|
1644 |
+
'AS' => __('American Samoa','ultimate-member'),
|
1645 |
+
'AD' => __('Andorra','ultimate-member'),
|
1646 |
+
'AO' => __('Angola','ultimate-member'),
|
1647 |
+
'AI' => __('Anguilla','ultimate-member'),
|
1648 |
+
'AQ' => __('Antarctica','ultimate-member'),
|
1649 |
+
'AG' => __('Antigua and Barbuda','ultimate-member'),
|
1650 |
+
'AR' => __('Argentina','ultimate-member'),
|
1651 |
+
'AM' => __('Armenia','ultimate-member'),
|
1652 |
+
'AW' => __('Aruba','ultimate-member'),
|
1653 |
+
'AU' => __('Australia','ultimate-member'),
|
1654 |
+
'AT' => __('Austria','ultimate-member'),
|
1655 |
+
'AZ' => __('Azerbaijan','ultimate-member'),
|
1656 |
+
'BS' => __('Bahamas','ultimate-member'),
|
1657 |
+
'BH' => __('Bahrain','ultimate-member'),
|
1658 |
+
'BD' => __('Bangladesh','ultimate-member'),
|
1659 |
+
'BB' => __('Barbados','ultimate-member'),
|
1660 |
+
'BY' => __('Belarus','ultimate-member'),
|
1661 |
+
'BE' => __('Belgium','ultimate-member'),
|
1662 |
+
'BZ' => __('Belize','ultimate-member'),
|
1663 |
+
'BJ' => __('Benin','ultimate-member'),
|
1664 |
+
'BM' => __('Bermuda','ultimate-member'),
|
1665 |
+
'BT' => __('Bhutan','ultimate-member'),
|
1666 |
+
'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
|
1667 |
+
'BA' => __('Bosnia and Herzegovina','ultimate-member'),
|
1668 |
+
'BW' => __('Botswana','ultimate-member'),
|
1669 |
+
'BV' => __('Bouvet Island','ultimate-member'),
|
1670 |
+
'BR' => __('Brazil','ultimate-member'),
|
1671 |
+
'IO' => __('British Indian Ocean Territory','ultimate-member'),
|
1672 |
+
'BN' => __('Brunei Darussalam','ultimate-member'),
|
1673 |
+
'BG' => __('Bulgaria','ultimate-member'),
|
1674 |
+
'BF' => __('Burkina Faso','ultimate-member'),
|
1675 |
+
'BI' => __('Burundi','ultimate-member'),
|
1676 |
+
'KH' => __('Cambodia','ultimate-member'),
|
1677 |
+
'CM' => __('Cameroon','ultimate-member'),
|
1678 |
+
'CA' => __('Canada','ultimate-member'),
|
1679 |
+
'CV' => __('Cape Verde','ultimate-member'),
|
1680 |
+
'KY' => __('Cayman Islands','ultimate-member'),
|
1681 |
+
'CF' => __('Central African Republic','ultimate-member'),
|
1682 |
+
'TD' => __('Chad','ultimate-member'),
|
1683 |
+
'CL' => __('Chile','ultimate-member'),
|
1684 |
+
'CN' => __('China','ultimate-member'),
|
1685 |
+
'CX' => __('Christmas Island','ultimate-member'),
|
1686 |
+
'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
|
1687 |
+
'CO' => __('Colombia','ultimate-member'),
|
1688 |
+
'KM' => __('Comoros','ultimate-member'),
|
1689 |
+
'CG' => __('Congo','ultimate-member'),
|
1690 |
+
'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
|
1691 |
+
'CK' => __('Cook Islands','ultimate-member'),
|
1692 |
+
'CR' => __('Costa Rica','ultimate-member'),
|
1693 |
+
'CI' => __("Côte d'Ivoire",'ultimate-member'),
|
1694 |
+
'HR' => __('Croatia','ultimate-member'),
|
1695 |
+
'CU' => __('Cuba','ultimate-member'),
|
1696 |
+
'CY' => __('Cyprus','ultimate-member'),
|
1697 |
+
'CZ' => __('Czech Republic','ultimate-member'),
|
1698 |
+
'DK' => __('Denmark','ultimate-member'),
|
1699 |
+
'DJ' => __('Djibouti','ultimate-member'),
|
1700 |
+
'DM' => __('Dominica','ultimate-member'),
|
1701 |
+
'DO' => __('Dominican Republic','ultimate-member'),
|
1702 |
+
'EC' => __('Ecuador','ultimate-member'),
|
1703 |
+
'EG' => __('Egypt','ultimate-member'),
|
1704 |
+
'SV' => __('El Salvador','ultimate-member'),
|
1705 |
+
'GQ' => __('Equatorial Guinea','ultimate-member'),
|
1706 |
+
'ER' => __('Eritrea','ultimate-member'),
|
1707 |
+
'EE' => __('Estonia','ultimate-member'),
|
1708 |
+
'ET' => __('Ethiopia','ultimate-member'),
|
1709 |
+
'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
|
1710 |
+
'FO' => __('Faroe Islands','ultimate-member'),
|
1711 |
+
'FJ' => __('Fiji','ultimate-member'),
|
1712 |
+
'FI' => __('Finland','ultimate-member'),
|
1713 |
+
'FR' => __('France','ultimate-member'),
|
1714 |
+
'GF' => __('French Guiana','ultimate-member'),
|
1715 |
+
'PF' => __('French Polynesia','ultimate-member'),
|
1716 |
+
'TF' => __('French Southern Territories','ultimate-member'),
|
1717 |
+
'GA' => __('Gabon','ultimate-member'),
|
1718 |
+
'GM' => __('Gambia','ultimate-member'),
|
1719 |
+
'GE' => __('Georgia','ultimate-member'),
|
1720 |
+
'DE' => __('Germany','ultimate-member'),
|
1721 |
+
'GH' => __('Ghana','ultimate-member'),
|
1722 |
+
'GI' => __('Gibraltar','ultimate-member'),
|
1723 |
+
'GR' => __('Greece','ultimate-member'),
|
1724 |
+
'GL' => __('Greenland','ultimate-member'),
|
1725 |
+
'GD' => __('Grenada','ultimate-member'),
|
1726 |
+
'GP' => __('Guadeloupe','ultimate-member'),
|
1727 |
+
'GU' => __('Guam','ultimate-member'),
|
1728 |
+
'GT' => __('Guatemala','ultimate-member'),
|
1729 |
+
'GG' => __('Guernsey','ultimate-member'),
|
1730 |
+
'GN' => __('Guinea','ultimate-member'),
|
1731 |
+
'GW' => __('Guinea-Bissau','ultimate-member'),
|
1732 |
+
'GY' => __('Guyana','ultimate-member'),
|
1733 |
+
'HT' => __('Haiti','ultimate-member'),
|
1734 |
+
'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
|
1735 |
+
'VA' => __('Holy See (Vatican City State)','ultimate-member'),
|
1736 |
+
'HN' => __('Honduras','ultimate-member'),
|
1737 |
+
'HK' => __('Hong Kong','ultimate-member'),
|
1738 |
+
'HU' => __('Hungary','ultimate-member'),
|
1739 |
+
'IS' => __('Iceland','ultimate-member'),
|
1740 |
+
'IN' => __('India','ultimate-member'),
|
1741 |
+
'ID' => __('Indonesia','ultimate-member'),
|
1742 |
+
'IR' => __('Iran, Islamic Republic of','ultimate-member'),
|
1743 |
+
'IQ' => __('Iraq','ultimate-member'),
|
1744 |
+
'IE' => __('Ireland','ultimate-member'),
|
1745 |
+
'IM' => __('Isle of Man','ultimate-member'),
|
1746 |
+
'IL' => __('Israel','ultimate-member'),
|
1747 |
+
'IT' => __('Italy','ultimate-member'),
|
1748 |
+
'JM' => __('Jamaica','ultimate-member'),
|
1749 |
+
'JP' => __('Japan','ultimate-member'),
|
1750 |
+
'JE' => __('Jersey','ultimate-member'),
|
1751 |
+
'JO' => __('Jordan','ultimate-member'),
|
1752 |
+
'KZ' => __('Kazakhstan','ultimate-member'),
|
1753 |
+
'KE' => __('Kenya','ultimate-member'),
|
1754 |
+
'KI' => __('Kiribati','ultimate-member'),
|
1755 |
+
'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
|
1756 |
+
'KR' => __('Korea, Republic of','ultimate-member'),
|
1757 |
+
'KW' => __('Kuwait','ultimate-member'),
|
1758 |
+
'KG' => __('Kyrgyzstan','ultimate-member'),
|
1759 |
+
'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
|
1760 |
+
'LV' => __('Latvia','ultimate-member'),
|
1761 |
+
'LB' => __('Lebanon','ultimate-member'),
|
1762 |
+
'LS' => __('Lesotho','ultimate-member'),
|
1763 |
+
'LR' => __('Liberia','ultimate-member'),
|
1764 |
+
'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
|
1765 |
+
'LI' => __('Liechtenstein','ultimate-member'),
|
1766 |
+
'LT' => __('Lithuania','ultimate-member'),
|
1767 |
+
'LU' => __('Luxembourg','ultimate-member'),
|
1768 |
+
'MO' => __('Macao','ultimate-member'),
|
1769 |
+
'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
|
1770 |
+
'MG' => __('Madagascar','ultimate-member'),
|
1771 |
+
'MW' => __('Malawi','ultimate-member'),
|
1772 |
+
'MY' => __('Malaysia','ultimate-member'),
|
1773 |
+
'MV' => __('Maldives','ultimate-member'),
|
1774 |
+
'ML' => __('Mali','ultimate-member'),
|
1775 |
+
'MT' => __('Malta','ultimate-member'),
|
1776 |
+
'MH' => __('Marshall Islands','ultimate-member'),
|
1777 |
+
'MQ' => __('Martinique','ultimate-member'),
|
1778 |
+
'MR' => __('Mauritania','ultimate-member'),
|
1779 |
+
'MU' => __('Mauritius','ultimate-member'),
|
1780 |
+
'YT' => __('Mayotte','ultimate-member'),
|
1781 |
+
'MX' => __('Mexico','ultimate-member'),
|
1782 |
+
'FM' => __('Micronesia, Federated States of','ultimate-member'),
|
1783 |
+
'MD' => __('Moldova, Republic of','ultimate-member'),
|
1784 |
+
'MC' => __('Monaco','ultimate-member'),
|
1785 |
+
'MN' => __('Mongolia','ultimate-member'),
|
1786 |
+
'ME' => __('Montenegro','ultimate-member'),
|
1787 |
+
'MS' => __('Montserrat','ultimate-member'),
|
1788 |
+
'MA' => __('Morocco','ultimate-member'),
|
1789 |
+
'MZ' => __('Mozambique','ultimate-member'),
|
1790 |
+
'MM' => __('Myanmar','ultimate-member'),
|
1791 |
+
'NA' => __('Namibia','ultimate-member'),
|
1792 |
+
'NR' => __('Nauru','ultimate-member'),
|
1793 |
+
'NP' => __('Nepal','ultimate-member'),
|
1794 |
+
'NL' => __('Netherlands','ultimate-member'),
|
1795 |
+
'AN' => __('Netherlands Antilles','ultimate-member'),
|
1796 |
+
'NC' => __('New Caledonia','ultimate-member'),
|
1797 |
+
'NZ' => __('New Zealand','ultimate-member'),
|
1798 |
+
'NI' => __('Nicaragua','ultimate-member'),
|
1799 |
+
'NE' => __('Niger','ultimate-member'),
|
1800 |
+
'NG' => __('Nigeria','ultimate-member'),
|
1801 |
+
'NU' => __('Niue','ultimate-member'),
|
1802 |
+
'NF' => __('Norfolk Island','ultimate-member'),
|
1803 |
+
'MP' => __('Northern Mariana Islands','ultimate-member'),
|
1804 |
+
'NO' => __('Norway','ultimate-member'),
|
1805 |
+
'OM' => __('Oman','ultimate-member'),
|
1806 |
+
'PK' => __('Pakistan','ultimate-member'),
|
1807 |
+
'PW' => __('Palau','ultimate-member'),
|
1808 |
+
'PS' => __('Palestine','ultimate-member'),
|
1809 |
+
'PA' => __('Panama','ultimate-member'),
|
1810 |
+
'PG' => __('Papua New Guinea','ultimate-member'),
|
1811 |
+
'PY' => __('Paraguay','ultimate-member'),
|
1812 |
+
'PE' => __('Peru','ultimate-member'),
|
1813 |
+
'PH' => __('Philippines','ultimate-member'),
|
1814 |
+
'PN' => __('Pitcairn','ultimate-member'),
|
1815 |
+
'PL' => __('Poland','ultimate-member'),
|
1816 |
+
'PT' => __('Portugal','ultimate-member'),
|
1817 |
+
'PR' => __('Puerto Rico','ultimate-member'),
|
1818 |
+
'QA' => __('Qatar','ultimate-member'),
|
1819 |
+
'RE' => __('Réunion','ultimate-member'),
|
1820 |
+
'RO' => __('Romania','ultimate-member'),
|
1821 |
+
'RU' => __('Russian Federation','ultimate-member'),
|
1822 |
+
'RW' => __('Rwanda','ultimate-member'),
|
1823 |
+
'BL' => __('Saint Barthélemy','ultimate-member'),
|
1824 |
+
'SH' => __('Saint Helena','ultimate-member'),
|
1825 |
+
'KN' => __('Saint Kitts and Nevis','ultimate-member'),
|
1826 |
+
'LC' => __('Saint Lucia','ultimate-member'),
|
1827 |
+
'MF' => __('Saint Martin (French part)','ultimate-member'),
|
1828 |
+
'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
|
1829 |
+
'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
|
1830 |
+
'WS' => __('Samoa','ultimate-member'),
|
1831 |
+
'SM' => __('San Marino','ultimate-member'),
|
1832 |
+
'ST' => __('Sao Tome and Principe','ultimate-member'),
|
1833 |
+
'SA' => __('Saudi Arabia','ultimate-member'),
|
1834 |
+
'SN' => __('Senegal','ultimate-member'),
|
1835 |
+
'RS' => __('Serbia','ultimate-member'),
|
1836 |
+
'SC' => __('Seychelles','ultimate-member'),
|
1837 |
+
'SL' => __('Sierra Leone','ultimate-member'),
|
1838 |
+
'SG' => __('Singapore','ultimate-member'),
|
1839 |
+
'SK' => __('Slovakia','ultimate-member'),
|
1840 |
+
'SI' => __('Slovenia','ultimate-member'),
|
1841 |
+
'SB' => __('Solomon Islands','ultimate-member'),
|
1842 |
+
'SO' => __('Somalia','ultimate-member'),
|
1843 |
+
'ZA' => __('South Africa','ultimate-member'),
|
1844 |
+
'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
|
1845 |
+
'SS' => __('South Sudan','ultimate-member'),
|
1846 |
+
'ES' => __('Spain','ultimate-member'),
|
1847 |
+
'LK' => __('Sri Lanka','ultimate-member'),
|
1848 |
+
'SD' => __('Sudan','ultimate-member'),
|
1849 |
+
'SR' => __('Suriname','ultimate-member'),
|
1850 |
+
'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
|
1851 |
+
'SZ' => __('Swaziland','ultimate-member'),
|
1852 |
+
'SE' => __('Sweden','ultimate-member'),
|
1853 |
+
'CH' => __('Switzerland','ultimate-member'),
|
1854 |
+
'SY' => __('Syrian Arab Republic','ultimate-member'),
|
1855 |
+
'TW' => __('Taiwan, Province of China','ultimate-member'),
|
1856 |
+
'TJ' => __('Tajikistan','ultimate-member'),
|
1857 |
+
'TZ' => __('Tanzania, United Republic of','ultimate-member'),
|
1858 |
+
'TH' => __('Thailand','ultimate-member'),
|
1859 |
+
'TL' => __('Timor-Leste','ultimate-member'),
|
1860 |
+
'TG' => __('Togo','ultimate-member'),
|
1861 |
+
'TK' => __('Tokelau','ultimate-member'),
|
1862 |
+
'TO' => __('Tonga','ultimate-member'),
|
1863 |
+
'TT' => __('Trinidad and Tobago','ultimate-member'),
|
1864 |
+
'TN' => __('Tunisia','ultimate-member'),
|
1865 |
+
'TR' => __('Turkey','ultimate-member'),
|
1866 |
+
'TM' => __('Turkmenistan','ultimate-member'),
|
1867 |
+
'TC' => __('Turks and Caicos Islands','ultimate-member'),
|
1868 |
+
'TV' => __('Tuvalu','ultimate-member'),
|
1869 |
+
'UG' => __('Uganda','ultimate-member'),
|
1870 |
+
'UA' => __('Ukraine','ultimate-member'),
|
1871 |
+
'AE' => __('United Arab Emirates','ultimate-member'),
|
1872 |
+
'GB' => __('United Kingdom','ultimate-member'),
|
1873 |
+
'US' => __('United States','ultimate-member'),
|
1874 |
+
'UM' => __('United States Minor Outlying Islands','ultimate-member'),
|
1875 |
+
'UY' => __('Uruguay','ultimate-member'),
|
1876 |
+
'UZ' => __('Uzbekistan','ultimate-member'),
|
1877 |
+
'VU' => __('Vanuatu','ultimate-member'),
|
1878 |
+
'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
|
1879 |
+
'VN' => __('Viet Nam','ultimate-member'),
|
1880 |
+
'VG' => __('Virgin Islands, British','ultimate-member'),
|
1881 |
+
'VI' => __('Virgin Islands, U.S.','ultimate-member'),
|
1882 |
+
'WF' => __('Wallis and Futuna','ultimate-member'),
|
1883 |
+
'EH' => __('Western Sahara','ultimate-member'),
|
1884 |
+
'YE' => __('Yemen','ultimate-member'),
|
1885 |
+
'ZM' => __('Zambia','ultimate-member'),
|
1886 |
+
'ZW' => __('Zimbabwe','ultimate-member'),
|
1887 |
+
);
|
1888 |
+
break;
|
1889 |
+
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
/**
|
1893 |
+
* UM hook
|
1894 |
+
*
|
1895 |
+
* @type filter
|
1896 |
+
* @title um_{$data}_predefined_field_options
|
1897 |
+
* @description Extend Predefined Fields options. Where $data - field key.
|
1898 |
+
* @input_vars
|
1899 |
+
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
1900 |
+
* @change_log
|
1901 |
+
* ["Since: 2.0"]
|
1902 |
+
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
1903 |
+
* @example
|
1904 |
+
* <?php
|
1905 |
+
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
1906 |
+
* function my_predefined_field( $options ) {
|
1907 |
+
* // your code here
|
1908 |
+
* return $options;
|
1909 |
+
* }
|
1910 |
+
* ?>
|
1911 |
+
*/
|
1912 |
+
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
1913 |
+
return $array;
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
}
|
1917 |
+
}
|
includes/core/class-fields.php
CHANGED
@@ -1757,7 +1757,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
1757 |
if ( ! isset( $array['max_files_error'] ) ) {
|
1758 |
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1759 |
}
|
1760 |
-
if (
|
1761 |
$array['max_size'] = 999999999;
|
1762 |
}
|
1763 |
if ( ! isset( $array['upload_help_text'] ) ) {
|
@@ -1798,7 +1798,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
1798 |
if ( ! isset( $array['max_files_error'] ) ) {
|
1799 |
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1800 |
}
|
1801 |
-
if (
|
1802 |
$array['max_size'] = 999999999;
|
1803 |
}
|
1804 |
if ( ! isset( $array['upload_help_text'] ) ) {
|
1757 |
if ( ! isset( $array['max_files_error'] ) ) {
|
1758 |
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1759 |
}
|
1760 |
+
if ( empty( $array['max_size'] ) ) {
|
1761 |
$array['max_size'] = 999999999;
|
1762 |
}
|
1763 |
if ( ! isset( $array['upload_help_text'] ) ) {
|
1798 |
if ( ! isset( $array['max_files_error'] ) ) {
|
1799 |
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1800 |
}
|
1801 |
+
if ( empty( $array['max_size'] ) ) {
|
1802 |
$array['max_size'] = 999999999;
|
1803 |
}
|
1804 |
if ( ! isset( $array['upload_help_text'] ) ) {
|
includes/core/class-member-directory.php
CHANGED
@@ -1,2640 +1,2644 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Member_Directory
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class Member_Directory {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Member Directory Views
|
20 |
-
*
|
21 |
-
* @var array
|
22 |
-
*/
|
23 |
-
var $view_types = array();
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @var array
|
28 |
-
*/
|
29 |
-
var $sort_fields = array();
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
var $default_sorting = array();
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @var array
|
40 |
-
*/
|
41 |
-
var $filter_fields = array();
|
42 |
-
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @var array
|
46 |
-
*/
|
47 |
-
var $custom_filters_in_query = array();
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
var $filter_supported_fields = array();
|
52 |
-
|
53 |
-
|
54 |
-
var $filter_types = array();
|
55 |
-
|
56 |
-
|
57 |
-
var $core_search_fields = array(
|
58 |
-
'user_login',
|
59 |
-
'user_url',
|
60 |
-
'display_name',
|
61 |
-
'user_email',
|
62 |
-
'user_nicename',
|
63 |
-
);
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @var
|
68 |
-
*/
|
69 |
-
var $query_args;
|
70 |
-
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @var User Card cover size
|
74 |
-
*/
|
75 |
-
var $cover_size;
|
76 |
-
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @var User Avatar size
|
80 |
-
*/
|
81 |
-
var $avatar_size;
|
82 |
-
|
83 |
-
|
84 |
-
/**
|
85 |
-
* @var bool Searching marker
|
86 |
-
*/
|
87 |
-
var $is_search = false;
|
88 |
-
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Member_Directory constructor.
|
92 |
-
*/
|
93 |
-
function __construct() {
|
94 |
-
add_filter( 'plugins_loaded', array( &$this, 'init_variables' ), 99999 );
|
95 |
-
add_filter( 'init', array( &$this, 'init_filter_types' ), 2 );
|
96 |
-
|
97 |
-
add_action( 'template_redirect', array( &$this, 'access_members' ), 555 );
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @return bool
|
103 |
-
*/
|
104 |
-
function get_hide_in_members_default() {
|
105 |
-
$default = false;
|
106 |
-
$option = UM()->options()->get( 'account_hide_in_directory_default' );
|
107 |
-
if ( $option == 'Yes' ) {
|
108 |
-
$default = true;
|
109 |
-
}
|
110 |
-
|
111 |
-
$default = apply_filters( 'um_member_directory_hide_in_members_default', $default );
|
112 |
-
return $default;
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Getting member directory post ID via hash
|
118 |
-
* Hash is unique attr, which we use visible at frontend
|
119 |
-
*
|
120 |
-
* @param string $hash
|
121 |
-
*
|
122 |
-
* @return bool|int
|
123 |
-
*/
|
124 |
-
function get_directory_by_hash( $hash ) {
|
125 |
-
global $wpdb;
|
126 |
-
|
127 |
-
$directory_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE SUBSTRING( MD5( ID ), 11, 5 ) = %s", $hash ) );
|
128 |
-
|
129 |
-
if ( empty( $directory_id ) ) {
|
130 |
-
return false;
|
131 |
-
}
|
132 |
-
|
133 |
-
return (int) $directory_id;
|
134 |
-
}
|
135 |
-
|
136 |
-
|
137 |
-
/**
|
138 |
-
* @param $id
|
139 |
-
*
|
140 |
-
* @return bool|string
|
141 |
-
*/
|
142 |
-
function get_directory_hash( $id ) {
|
143 |
-
$hash = substr( md5( $id ), 10, 5 );
|
144 |
-
return $hash;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Get view Type template
|
150 |
-
* @param string $type
|
151 |
-
*
|
152 |
-
* @return string
|
153 |
-
*/
|
154 |
-
function get_type_basename( $type ) {
|
155 |
-
return apply_filters( "um_member_directory_{$type}_type_template_basename", '' );
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Tag conversion for member directory
|
161 |
-
*
|
162 |
-
* @param string $string
|
163 |
-
* @param array $array
|
164 |
-
*
|
165 |
-
* @return string
|
166 |
-
*/
|
167 |
-
function convert_tags( $string, $array ) {
|
168 |
-
|
169 |
-
$search = array(
|
170 |
-
'{total_users}',
|
171 |
-
);
|
172 |
-
|
173 |
-
$replace = array(
|
174 |
-
$array['total_users'],
|
175 |
-
);
|
176 |
-
|
177 |
-
$string = str_replace( $search, $replace, $string );
|
178 |
-
return $string;
|
179 |
-
}
|
180 |
-
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Members page allowed?
|
184 |
-
*
|
185 |
-
* can be disabled by "Enable Members Directory" option
|
186 |
-
*
|
187 |
-
*/
|
188 |
-
function access_members() {
|
189 |
-
if ( UM()->options()->get( 'members_page' ) == 0 && um_is_core_page( 'members' ) ) {
|
190 |
-
um_redirect_home();
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
/**
|
196 |
-
* @param $value
|
197 |
-
* @param $key
|
198 |
-
* @param $post_id
|
199 |
-
*
|
200 |
-
* @return array
|
201 |
-
*/
|
202 |
-
public function before_save_data( $value, $key, $post_id ) {
|
203 |
-
|
204 |
-
$post = get_post( $post_id );
|
205 |
-
|
206 |
-
if ( 'um_directory' === $post->post_type ) {
|
207 |
-
|
208 |
-
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
|
209 |
-
$value = array_keys( $value );
|
210 |
-
} elseif ( '_um_search_filters' === $key ) {
|
211 |
-
|
212 |
-
$temp_value = array();
|
213 |
-
|
214 |
-
if ( ! empty( $value ) ) {
|
215 |
-
foreach ( $value as $k ) {
|
216 |
-
$filter_type = $this->filter_types[ $k ];
|
217 |
-
if ( ! empty( $filter_type ) ) {
|
218 |
-
if ( 'slider' === $filter_type ) {
|
219 |
-
if ( ! empty( $_POST[ $k ] ) ) {
|
220 |
-
$
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
$temp_value[ $k ] =
|
242 |
-
}
|
243 |
-
}
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
}
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
'
|
297 |
-
'
|
298 |
-
'
|
299 |
-
'
|
300 |
-
'
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
'
|
320 |
-
'
|
321 |
-
'
|
322 |
-
'
|
323 |
-
'
|
324 |
-
'
|
325 |
-
'
|
326 |
-
'
|
327 |
-
'
|
328 |
-
'
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
if (
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
'
|
371 |
-
'
|
372 |
-
'
|
373 |
-
'
|
374 |
-
'
|
375 |
-
'
|
376 |
-
'
|
377 |
-
'
|
378 |
-
'
|
379 |
-
'
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
$value = '
|
396 |
-
break;
|
397 |
-
case '
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
case '
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
case '
|
410 |
-
case '
|
411 |
-
$value = '
|
412 |
-
break;
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
*
|
427 |
-
*
|
428 |
-
*
|
429 |
-
*
|
430 |
-
* @
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
if ( $
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
if ( ! empty( $
|
445 |
-
|
446 |
-
}
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
$
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
*
|
468 |
-
*
|
469 |
-
*
|
470 |
-
* @
|
471 |
-
*
|
472 |
-
* @
|
473 |
-
*
|
474 |
-
* @
|
475 |
-
*
|
476 |
-
*
|
477 |
-
*
|
478 |
-
*
|
479 |
-
*
|
480 |
-
* }
|
481 |
-
*
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
*
|
497 |
-
*
|
498 |
-
*
|
499 |
-
* @
|
500 |
-
*
|
501 |
-
* @
|
502 |
-
*
|
503 |
-
* @
|
504 |
-
*
|
505 |
-
*
|
506 |
-
*
|
507 |
-
*
|
508 |
-
*
|
509 |
-
*
|
510 |
-
*
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
$values_array =
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
*
|
622 |
-
*
|
623 |
-
*
|
624 |
-
*
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
$attrs['options'] =
|
636 |
-
}
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
}
|
649 |
-
|
650 |
-
if (
|
651 |
-
$attrs['
|
652 |
-
}
|
653 |
-
|
654 |
-
if (
|
655 |
-
$attrs['
|
656 |
-
}
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
<?php
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
if (
|
684 |
-
$opt = $k;
|
685 |
-
}
|
686 |
-
|
687 |
-
if (
|
688 |
-
$opt = $k;
|
689 |
-
}
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
data-
|
742 |
-
data-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
data-
|
778 |
-
data-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
$
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
//
|
833 |
-
//
|
834 |
-
//
|
835 |
-
//
|
836 |
-
//
|
837 |
-
//
|
838 |
-
//
|
839 |
-
//
|
840 |
-
// $
|
841 |
-
//
|
842 |
-
// $
|
843 |
-
//
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
if (
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
if ( UM()->
|
1085 |
-
return;
|
1086 |
-
}
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
$this->
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
}
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
}
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
$
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
$
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
array(
|
1277 |
-
'key' => 'full_name',
|
1278 |
-
'compare' => '
|
1279 |
-
)
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
$this->query_args['
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
'key' => '_um_last_login',
|
1307 |
-
'compare' => '
|
1308 |
-
),
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
$this->query_args['
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
'
|
1320 |
-
'key' => '
|
1321 |
-
'compare' => 'EXISTS',
|
1322 |
-
),
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
'
|
1341 |
-
'
|
1342 |
-
)
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
$
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
*
|
1374 |
-
*
|
1375 |
-
*
|
1376 |
-
*
|
1377 |
-
* @
|
1378 |
-
*
|
1379 |
-
*
|
1380 |
-
*
|
1381 |
-
* @
|
1382 |
-
*
|
1383 |
-
*
|
1384 |
-
*
|
1385 |
-
*
|
1386 |
-
*
|
1387 |
-
*
|
1388 |
-
*
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
*
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
array(
|
1450 |
-
'value' => $search,
|
1451 |
-
'compare' => '
|
1452 |
-
),
|
1453 |
-
array(
|
1454 |
-
'value' =>
|
1455 |
-
'compare' => 'LIKE',
|
1456 |
-
),
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
$
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
*
|
1474 |
-
*
|
1475 |
-
*
|
1476 |
-
* @param $
|
1477 |
-
* @param
|
1478 |
-
*
|
1479 |
-
* @
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
$
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
$
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
$
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
$
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
*
|
1586 |
-
*
|
1587 |
-
*
|
1588 |
-
* @
|
1589 |
-
*
|
1590 |
-
* @
|
1591 |
-
*
|
1592 |
-
* @
|
1593 |
-
*
|
1594 |
-
*
|
1595 |
-
*
|
1596 |
-
*
|
1597 |
-
*
|
1598 |
-
* }
|
1599 |
-
*
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
'
|
1644 |
-
'
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
'
|
1649 |
-
'
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
'
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
$
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
'
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
'
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
}
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
'
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
*
|
1860 |
-
*
|
1861 |
-
*
|
1862 |
-
* @
|
1863 |
-
*
|
1864 |
-
* @
|
1865 |
-
*
|
1866 |
-
* @
|
1867 |
-
*
|
1868 |
-
*
|
1869 |
-
*
|
1870 |
-
*
|
1871 |
-
*
|
1872 |
-
* }
|
1873 |
-
*
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
'
|
1914 |
-
'
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
'
|
1919 |
-
'
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
'
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
'
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
}
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
'
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
$
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
*
|
2082 |
-
*
|
2083 |
-
*
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
$
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
if ( ! empty( $
|
2103 |
-
$
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
$
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
if (
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
*
|
2163 |
-
*
|
2164 |
-
*
|
2165 |
-
* @
|
2166 |
-
*
|
2167 |
-
* @
|
2168 |
-
*
|
2169 |
-
* @
|
2170 |
-
*
|
2171 |
-
*
|
2172 |
-
*
|
2173 |
-
*
|
2174 |
-
*
|
2175 |
-
*
|
2176 |
-
*
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
'
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
$
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
'
|
2250 |
-
'
|
2251 |
-
'
|
2252 |
-
'
|
2253 |
-
'
|
2254 |
-
'
|
2255 |
-
'
|
2256 |
-
'
|
2257 |
-
'
|
2258 |
-
'
|
2259 |
-
'
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
$
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
$this->
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
*
|
2435 |
-
*
|
2436 |
-
*
|
2437 |
-
*
|
2438 |
-
* @
|
2439 |
-
*
|
2440 |
-
*
|
2441 |
-
*
|
2442 |
-
* @
|
2443 |
-
*
|
2444 |
-
*
|
2445 |
-
*
|
2446 |
-
*
|
2447 |
-
*
|
2448 |
-
*
|
2449 |
-
*
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
if ( isset( $this->query_args['
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
*
|
2474 |
-
*
|
2475 |
-
*
|
2476 |
-
*
|
2477 |
-
* @
|
2478 |
-
*
|
2479 |
-
*
|
2480 |
-
*
|
2481 |
-
*
|
2482 |
-
*
|
2483 |
-
*
|
2484 |
-
*
|
2485 |
-
*
|
2486 |
-
*
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
*
|
2506 |
-
*
|
2507 |
-
*
|
2508 |
-
*
|
2509 |
-
* @
|
2510 |
-
*
|
2511 |
-
*
|
2512 |
-
*
|
2513 |
-
*
|
2514 |
-
*
|
2515 |
-
*
|
2516 |
-
*
|
2517 |
-
*
|
2518 |
-
*
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
*
|
2532 |
-
*
|
2533 |
-
*
|
2534 |
-
* @
|
2535 |
-
*
|
2536 |
-
* @
|
2537 |
-
*
|
2538 |
-
* @
|
2539 |
-
*
|
2540 |
-
*
|
2541 |
-
*
|
2542 |
-
*
|
2543 |
-
*
|
2544 |
-
*
|
2545 |
-
*
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
$
|
2555 |
-
|
2556 |
-
$
|
2557 |
-
|
2558 |
-
$this->
|
2559 |
-
|
2560 |
-
$
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
*
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
*
|
2607 |
-
*
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Member_Directory
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class Member_Directory {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Member Directory Views
|
20 |
+
*
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
var $view_types = array();
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var array
|
28 |
+
*/
|
29 |
+
var $sort_fields = array();
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
var $default_sorting = array();
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
var $filter_fields = array();
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @var array
|
46 |
+
*/
|
47 |
+
var $custom_filters_in_query = array();
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
var $filter_supported_fields = array();
|
52 |
+
|
53 |
+
|
54 |
+
var $filter_types = array();
|
55 |
+
|
56 |
+
|
57 |
+
var $core_search_fields = array(
|
58 |
+
'user_login',
|
59 |
+
'user_url',
|
60 |
+
'display_name',
|
61 |
+
'user_email',
|
62 |
+
'user_nicename',
|
63 |
+
);
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @var
|
68 |
+
*/
|
69 |
+
var $query_args;
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @var User Card cover size
|
74 |
+
*/
|
75 |
+
var $cover_size;
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @var User Avatar size
|
80 |
+
*/
|
81 |
+
var $avatar_size;
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @var bool Searching marker
|
86 |
+
*/
|
87 |
+
var $is_search = false;
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Member_Directory constructor.
|
92 |
+
*/
|
93 |
+
function __construct() {
|
94 |
+
add_filter( 'plugins_loaded', array( &$this, 'init_variables' ), 99999 );
|
95 |
+
add_filter( 'init', array( &$this, 'init_filter_types' ), 2 );
|
96 |
+
|
97 |
+
add_action( 'template_redirect', array( &$this, 'access_members' ), 555 );
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return bool
|
103 |
+
*/
|
104 |
+
function get_hide_in_members_default() {
|
105 |
+
$default = false;
|
106 |
+
$option = UM()->options()->get( 'account_hide_in_directory_default' );
|
107 |
+
if ( $option == 'Yes' ) {
|
108 |
+
$default = true;
|
109 |
+
}
|
110 |
+
|
111 |
+
$default = apply_filters( 'um_member_directory_hide_in_members_default', $default );
|
112 |
+
return $default;
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Getting member directory post ID via hash
|
118 |
+
* Hash is unique attr, which we use visible at frontend
|
119 |
+
*
|
120 |
+
* @param string $hash
|
121 |
+
*
|
122 |
+
* @return bool|int
|
123 |
+
*/
|
124 |
+
function get_directory_by_hash( $hash ) {
|
125 |
+
global $wpdb;
|
126 |
+
|
127 |
+
$directory_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE SUBSTRING( MD5( ID ), 11, 5 ) = %s", $hash ) );
|
128 |
+
|
129 |
+
if ( empty( $directory_id ) ) {
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
|
133 |
+
return (int) $directory_id;
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @param $id
|
139 |
+
*
|
140 |
+
* @return bool|string
|
141 |
+
*/
|
142 |
+
function get_directory_hash( $id ) {
|
143 |
+
$hash = substr( md5( $id ), 10, 5 );
|
144 |
+
return $hash;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get view Type template
|
150 |
+
* @param string $type
|
151 |
+
*
|
152 |
+
* @return string
|
153 |
+
*/
|
154 |
+
function get_type_basename( $type ) {
|
155 |
+
return apply_filters( "um_member_directory_{$type}_type_template_basename", '' );
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Tag conversion for member directory
|
161 |
+
*
|
162 |
+
* @param string $string
|
163 |
+
* @param array $array
|
164 |
+
*
|
165 |
+
* @return string
|
166 |
+
*/
|
167 |
+
function convert_tags( $string, $array ) {
|
168 |
+
|
169 |
+
$search = array(
|
170 |
+
'{total_users}',
|
171 |
+
);
|
172 |
+
|
173 |
+
$replace = array(
|
174 |
+
$array['total_users'],
|
175 |
+
);
|
176 |
+
|
177 |
+
$string = str_replace( $search, $replace, $string );
|
178 |
+
return $string;
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Members page allowed?
|
184 |
+
*
|
185 |
+
* can be disabled by "Enable Members Directory" option
|
186 |
+
*
|
187 |
+
*/
|
188 |
+
function access_members() {
|
189 |
+
if ( UM()->options()->get( 'members_page' ) == 0 && um_is_core_page( 'members' ) ) {
|
190 |
+
um_redirect_home();
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
/**
|
196 |
+
* @param $value
|
197 |
+
* @param $key
|
198 |
+
* @param $post_id
|
199 |
+
*
|
200 |
+
* @return array
|
201 |
+
*/
|
202 |
+
public function before_save_data( $value, $key, $post_id ) {
|
203 |
+
|
204 |
+
$post = get_post( $post_id );
|
205 |
+
|
206 |
+
if ( 'um_directory' === $post->post_type ) {
|
207 |
+
|
208 |
+
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
|
209 |
+
$value = array_keys( $value );
|
210 |
+
} elseif ( '_um_search_filters' === $key ) {
|
211 |
+
|
212 |
+
$temp_value = array();
|
213 |
+
|
214 |
+
if ( ! empty( $value ) ) {
|
215 |
+
foreach ( $value as $k ) {
|
216 |
+
$filter_type = $this->filter_types[ $k ];
|
217 |
+
if ( ! empty( $filter_type ) ) {
|
218 |
+
if ( 'slider' === $filter_type ) {
|
219 |
+
if ( ! empty( $_POST[ $k ] ) ) {
|
220 |
+
if ( count( $_POST[ $k ] ) > 1 ) {
|
221 |
+
$temp_value[ $k ] = array_map( 'intval', $_POST[ $k ] );
|
222 |
+
} else {
|
223 |
+
$temp_value[ $k ] = (int) $_POST[ $k ];
|
224 |
+
}
|
225 |
+
}
|
226 |
+
} elseif ( 'timepicker' === $filter_type || 'datepicker' === $filter_type ) {
|
227 |
+
if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) {
|
228 |
+
$temp_value[ $k ] = array(
|
229 |
+
sanitize_text_field( $_POST[ $k . '_from' ] ),
|
230 |
+
sanitize_text_field( $_POST[ $k . '_to' ] ),
|
231 |
+
);
|
232 |
+
}
|
233 |
+
} elseif ( 'select' === $filter_type ) {
|
234 |
+
if ( ! empty( $_POST[ $k ] ) ) {
|
235 |
+
if ( is_array( $_POST[ $k ] ) ) {
|
236 |
+
$temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
|
237 |
+
} else {
|
238 |
+
$temp_value[ $k ] = array( trim( $_POST[ $k ] ) );
|
239 |
+
}
|
240 |
+
|
241 |
+
$temp_value[ $k ] = array_map( 'sanitize_text_field', $temp_value[ $k ] );
|
242 |
+
}
|
243 |
+
} else {
|
244 |
+
if ( ! empty( $_POST[ $k ] ) ) {
|
245 |
+
$temp_value[ $k ] = trim( sanitize_text_field( $_POST[ $k ] ) );
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
$value = $temp_value;
|
253 |
+
} elseif ( '_um_sorting_fields' === $key ) {
|
254 |
+
if ( ! empty( $value['other_data'] ) ) {
|
255 |
+
$other_data = $value['other_data'];
|
256 |
+
unset( $value['other_data'] );
|
257 |
+
|
258 |
+
foreach ( $value as $k => &$row ) {
|
259 |
+
if ( ! empty( $other_data[ $k ]['meta_key'] ) ) {
|
260 |
+
$metakey = sanitize_text_field( $other_data[ $k ]['meta_key'] );
|
261 |
+
if ( ! empty( $metakey ) ) {
|
262 |
+
if ( ! empty( $other_data[ $k ]['label'] ) ) {
|
263 |
+
$metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
|
264 |
+
}
|
265 |
+
$row = array(
|
266 |
+
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey,
|
267 |
+
);
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
}
|
272 |
+
} elseif ( '_um_sortby_custom' === $key ) {
|
273 |
+
$value = sanitize_text_field( $value );
|
274 |
+
} elseif ( '_um_sortby_custom_label' === $key ) {
|
275 |
+
$value = wp_strip_all_tags( $value );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
return $value;
|
280 |
+
}
|
281 |
+
|
282 |
+
|
283 |
+
/**
|
284 |
+
*
|
285 |
+
*/
|
286 |
+
function init_variables() {
|
287 |
+
|
288 |
+
// Types
|
289 |
+
$this->view_types = apply_filters( 'um_member_directory_views', array(
|
290 |
+
'grid' => array( 'title' => __( 'Grid', 'ultimate-member' ), 'icon' => 'um-faicon-th' ),
|
291 |
+
'list' => array( 'title' => __( 'List', 'ultimate-member' ), 'icon' => 'um-faicon-list' ),
|
292 |
+
) );
|
293 |
+
|
294 |
+
// Sort
|
295 |
+
$this->sort_fields = apply_filters( 'um_members_directory_sort_fields', array(
|
296 |
+
'user_registered_desc' => __( 'New users first', 'ultimate-member' ),
|
297 |
+
'user_registered_asc' => __( 'Old users first', 'ultimate-member' ),
|
298 |
+
'username' => __( 'Username', 'ultimate-member' ),
|
299 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
300 |
+
'first_name' => __( 'First name', 'ultimate-member' ),
|
301 |
+
'last_name' => __( 'Last name', 'ultimate-member' ),
|
302 |
+
'display_name' => __( 'Display name', 'ultimate-member' ),
|
303 |
+
'last_first_name' => __( 'Last & First name', 'ultimate-member' ),
|
304 |
+
'last_login' => __( 'Last login', 'ultimate-member' ),
|
305 |
+
|
306 |
+
) );
|
307 |
+
|
308 |
+
asort( $this->sort_fields );
|
309 |
+
|
310 |
+
$this->default_sorting = apply_filters( 'um_members_directory_default_sort', array_merge( $this->sort_fields, array(
|
311 |
+
'random' => __( 'Random', 'ultimate-member' ),
|
312 |
+
'other' => __( 'Other (Custom Field)', 'ultimate-member' ),
|
313 |
+
) ) );
|
314 |
+
|
315 |
+
asort( $this->default_sorting );
|
316 |
+
|
317 |
+
// Filters
|
318 |
+
$this->filter_fields = array(
|
319 |
+
'country' => __( 'Country', 'ultimate-member' ),
|
320 |
+
'gender' => __( 'Gender', 'ultimate-member' ),
|
321 |
+
'languages' => __( 'Languages', 'ultimate-member' ),
|
322 |
+
'role' => __( 'Roles', 'ultimate-member' ),
|
323 |
+
'birth_date' => __( 'Age', 'ultimate-member' ),
|
324 |
+
'last_login' => __( 'Last Login', 'ultimate-member' ),
|
325 |
+
'user_registered' => __( 'User Registered', 'ultimate-member' ),
|
326 |
+
'first_name' => __( 'First Name', 'ultimate-member' ),
|
327 |
+
'last_name' => __( 'Last Name', 'ultimate-member' ),
|
328 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
329 |
+
'secondary_user_email' => __( 'Secondary E-mail Address', 'ultimate-member' ),
|
330 |
+
'description' => __( 'Biography', 'ultimate-member' ),
|
331 |
+
'phone_number' => __( 'Phone Number', 'ultimate-member' ),
|
332 |
+
'mobile_number' => __( 'Mobile Number', 'ultimate-member' ),
|
333 |
+
);
|
334 |
+
|
335 |
+
$this->filter_supported_fields = apply_filters( 'um_members_directory_custom_field_types_supported_filter', array( 'date', 'time', 'select', 'multiselect', 'radio', 'checkbox', 'rating', 'text', 'textarea', 'number' ) );
|
336 |
+
|
337 |
+
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
338 |
+
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
339 |
+
|
340 |
+
if ( $key == '_um_last_login' ) {
|
341 |
+
continue;
|
342 |
+
}
|
343 |
+
|
344 |
+
if ( isset( $data['type'] ) && in_array( $data['type'], $this->filter_supported_fields ) ) {
|
345 |
+
if ( isset( $data['title'] ) && array_search( $data['title'], $this->filter_fields ) !== false ) {
|
346 |
+
$data['title'] = $data['title'] . ' (' . $key . ')';
|
347 |
+
}
|
348 |
+
|
349 |
+
$title = isset( $data['title'] ) ? $data['title'] : ( isset( $data['label'] ) ? $data['label'] : '' );
|
350 |
+
if ( empty( $title ) ) {
|
351 |
+
continue;
|
352 |
+
}
|
353 |
+
|
354 |
+
$this->filter_fields[ $key ] = $title;
|
355 |
+
}
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
$this->filter_fields = apply_filters( 'um_members_directory_filter_fields', $this->filter_fields );
|
360 |
+
|
361 |
+
ksort( $this->filter_fields );
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
/**
|
366 |
+
*
|
367 |
+
*/
|
368 |
+
function init_filter_types() {
|
369 |
+
$this->filter_types = apply_filters( 'um_members_directory_filter_types', array(
|
370 |
+
'country' => 'select',
|
371 |
+
'gender' => 'select',
|
372 |
+
'languages' => 'select',
|
373 |
+
'role' => 'select',
|
374 |
+
'birth_date' => 'slider',
|
375 |
+
'last_login' => 'datepicker',
|
376 |
+
'user_registered' => 'datepicker',
|
377 |
+
'first_name' => 'text',
|
378 |
+
'last_name' => 'text',
|
379 |
+
'nickname' => 'text',
|
380 |
+
'secondary_user_email' => 'text',
|
381 |
+
'description' => 'text',
|
382 |
+
'phone_number' => 'text',
|
383 |
+
'mobile_number' => 'text',
|
384 |
+
) );
|
385 |
+
|
386 |
+
$fields = UM()->builtin()->all_user_fields;
|
387 |
+
|
388 |
+
$custom_fields_types = array_flip( array_keys( $this->filter_fields ) );
|
389 |
+
foreach ( $custom_fields_types as $key => &$value ) {
|
390 |
+
if ( ! isset( $fields[ $key ] ) ) {
|
391 |
+
unset( $custom_fields_types[ $key ] );
|
392 |
+
} else {
|
393 |
+
switch ( $fields[ $key ]['type'] ) {
|
394 |
+
default:
|
395 |
+
$value = apply_filters( 'um_custom_field_filter_type', 'select', $fields[ $key ] );
|
396 |
+
break;
|
397 |
+
case 'text':
|
398 |
+
case 'textarea':
|
399 |
+
$value = 'text';
|
400 |
+
break;
|
401 |
+
case 'date':
|
402 |
+
$value = 'datepicker';
|
403 |
+
break;
|
404 |
+
case 'time':
|
405 |
+
$value = 'timepicker';
|
406 |
+
break;
|
407 |
+
case 'select':
|
408 |
+
case 'multiselect':
|
409 |
+
case 'radio':
|
410 |
+
case 'checkbox':
|
411 |
+
$value = 'select';
|
412 |
+
break;
|
413 |
+
case 'number':
|
414 |
+
case 'rating':
|
415 |
+
$value = 'slider';
|
416 |
+
break;
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
$this->filter_types = array_merge( $custom_fields_types, $this->filter_types );
|
422 |
+
}
|
423 |
+
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Render member's directory
|
427 |
+
* filters selectboxes
|
428 |
+
*
|
429 |
+
* @param string $filter
|
430 |
+
* @param array $directory_data
|
431 |
+
* @param mixed $default_value
|
432 |
+
* @param bool $admin
|
433 |
+
*
|
434 |
+
* @return string $filter
|
435 |
+
*/
|
436 |
+
function show_filter( $filter, $directory_data, $default_value = false, $admin = false ) {
|
437 |
+
|
438 |
+
if ( empty( $this->filter_types[ $filter ] ) ) {
|
439 |
+
return '';
|
440 |
+
}
|
441 |
+
|
442 |
+
if ( $default_value === false ) {
|
443 |
+
$default_filters = array();
|
444 |
+
if ( ! empty( $directory_data['search_filters'] ) ) {
|
445 |
+
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
446 |
+
}
|
447 |
+
|
448 |
+
if ( ! empty( $default_filters[ $filter ] ) && $this->filter_types[ $filter ] != 'select' ) {
|
449 |
+
return '';
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
$field_key = $filter;
|
454 |
+
if ( $filter == 'last_login' ) {
|
455 |
+
$field_key = '_um_last_login';
|
456 |
+
}
|
457 |
+
if ( $filter == 'role' ) {
|
458 |
+
$field_key = 'role_select';
|
459 |
+
}
|
460 |
+
|
461 |
+
$fields = UM()->builtin()->all_user_fields;
|
462 |
+
|
463 |
+
if ( isset( $fields[ $field_key ] ) ) {
|
464 |
+
$attrs = $fields[ $field_key ];
|
465 |
+
} else {
|
466 |
+
/**
|
467 |
+
* UM hook
|
468 |
+
*
|
469 |
+
* @type filter
|
470 |
+
* @title um_custom_search_field_{$filter}
|
471 |
+
* @description Custom search settings by $filter
|
472 |
+
* @input_vars
|
473 |
+
* [{"var":"$settings","type":"array","desc":"Search Settings"}]
|
474 |
+
* @change_log
|
475 |
+
* ["Since: 2.0"]
|
476 |
+
* @usage
|
477 |
+
* <?php add_filter( 'um_custom_search_field_{$filter}', 'function_name', 10, 1 ); ?>
|
478 |
+
* @example
|
479 |
+
* <?php
|
480 |
+
* add_filter( 'um_custom_search_field_{$filter}', 'my_custom_search_field', 10, 1 );
|
481 |
+
* function my_change_email_template_file( $settings ) {
|
482 |
+
* // your code here
|
483 |
+
* return $settings;
|
484 |
+
* }
|
485 |
+
* ?>
|
486 |
+
*/
|
487 |
+
$attrs = apply_filters( "um_custom_search_field_{$filter}", array(), $field_key );
|
488 |
+
}
|
489 |
+
|
490 |
+
// skip private invisible fields
|
491 |
+
if ( ! um_can_view_field( $attrs ) ) {
|
492 |
+
return '';
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* UM hook
|
497 |
+
*
|
498 |
+
* @type filter
|
499 |
+
* @title um_search_fields
|
500 |
+
* @description Filter all search fields
|
501 |
+
* @input_vars
|
502 |
+
* [{"var":"$settings","type":"array","desc":"Search Fields"}]
|
503 |
+
* @change_log
|
504 |
+
* ["Since: 2.0"]
|
505 |
+
* @usage
|
506 |
+
* <?php add_filter( 'um_search_fields', 'function_name', 10, 1 ); ?>
|
507 |
+
* @example
|
508 |
+
* <?php
|
509 |
+
* add_filter( 'um_search_fields', 'my_search_fields', 10, 1 );
|
510 |
+
* function my_search_fields( $settings ) {
|
511 |
+
* // your code here
|
512 |
+
* return $settings;
|
513 |
+
* }
|
514 |
+
* ?>
|
515 |
+
*/
|
516 |
+
$attrs = apply_filters( 'um_search_fields', $attrs, $field_key, $directory_data['form_id'] );
|
517 |
+
|
518 |
+
$unique_hash = substr( md5( $directory_data['form_id'] ), 10, 5 );
|
519 |
+
|
520 |
+
ob_start();
|
521 |
+
|
522 |
+
switch ( $this->filter_types[ $filter ] ) {
|
523 |
+
default: {
|
524 |
+
|
525 |
+
do_action( "um_member_directory_filter_type_{$this->filter_types[ $filter ]}", $filter, $directory_data, $unique_hash, $attrs, $default_value );
|
526 |
+
|
527 |
+
break;
|
528 |
+
}
|
529 |
+
case 'text': {
|
530 |
+
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) : $default_value; ?>
|
531 |
+
<input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
|
532 |
+
placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
|
533 |
+
value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
|
534 |
+
aria-label="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>" />
|
535 |
+
<?php
|
536 |
+
break;
|
537 |
+
}
|
538 |
+
case 'select': {
|
539 |
+
|
540 |
+
// getting value from GET line
|
541 |
+
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? explode( '||', sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ) : array();
|
542 |
+
|
543 |
+
// new
|
544 |
+
global $wpdb;
|
545 |
+
|
546 |
+
if ( $attrs['metakey'] != 'role_select' ) {
|
547 |
+
$values_array = $wpdb->get_col(
|
548 |
+
$wpdb->prepare(
|
549 |
+
"SELECT DISTINCT meta_value
|
550 |
+
FROM $wpdb->usermeta
|
551 |
+
WHERE meta_key = %s AND
|
552 |
+
meta_value != ''",
|
553 |
+
$attrs['metakey']
|
554 |
+
)
|
555 |
+
);
|
556 |
+
} else {
|
557 |
+
$users_roles = count_users();
|
558 |
+
$values_array = ( ! empty( $users_roles['avail_roles'] ) && is_array( $users_roles['avail_roles'] ) ) ? array_keys( array_filter( $users_roles['avail_roles'] ) ) : array();
|
559 |
+
}
|
560 |
+
|
561 |
+
if ( ! empty( $values_array ) && in_array( $attrs['type'], array( 'select', 'multiselect', 'checkbox', 'radio' ) ) ) {
|
562 |
+
$values_array = array_map( 'maybe_unserialize', $values_array );
|
563 |
+
$temp_values = array();
|
564 |
+
foreach ( $values_array as $values ) {
|
565 |
+
if ( is_array( $values ) ) {
|
566 |
+
$temp_values = array_merge( $temp_values, $values );
|
567 |
+
} else {
|
568 |
+
$temp_values[] = $values;
|
569 |
+
}
|
570 |
+
}
|
571 |
+
$values_array = array_unique( $temp_values );
|
572 |
+
}
|
573 |
+
|
574 |
+
if ( $attrs['metakey'] != 'online_status' && empty( $values_array ) ) {
|
575 |
+
ob_get_clean();
|
576 |
+
return '';
|
577 |
+
}
|
578 |
+
|
579 |
+
if ( isset( $attrs['metakey'] ) && strstr( $attrs['metakey'], 'role_' ) ) {
|
580 |
+
$shortcode_roles = get_post_meta( $directory_data['form_id'], '_um_roles', true );
|
581 |
+
$um_roles = UM()->roles()->get_roles( false );
|
582 |
+
|
583 |
+
if ( ! empty( $shortcode_roles ) && is_array( $shortcode_roles ) ) {
|
584 |
+
$attrs['options'] = array();
|
585 |
+
|
586 |
+
foreach ( $um_roles as $key => $value ) {
|
587 |
+
if ( in_array( $key, $shortcode_roles ) ) {
|
588 |
+
$attrs['options'][ $key ] = $value;
|
589 |
+
}
|
590 |
+
}
|
591 |
+
} else {
|
592 |
+
$attrs['options'] = array();
|
593 |
+
|
594 |
+
foreach ( $um_roles as $key => $value ) {
|
595 |
+
$attrs['options'][ $key ] = $value;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
}
|
599 |
+
|
600 |
+
$custom_dropdown = '';
|
601 |
+
if ( ! empty( $attrs['custom_dropdown_options_source'] ) ) {
|
602 |
+
$attrs['custom'] = true;
|
603 |
+
|
604 |
+
if ( ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
605 |
+
|
606 |
+
$custom_dropdown .= ' data-member-directory="yes"';
|
607 |
+
$custom_dropdown .= ' data-um-parent="' . esc_attr( $attrs['parent_dropdown_relationship'] ) . '"';
|
608 |
+
|
609 |
+
if ( isset( $_GET[ 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ] ) ) {
|
610 |
+
$_POST['parent_option_name'] = $attrs['parent_dropdown_relationship'];
|
611 |
+
$_POST['parent_option'] = explode( '||', filter_input( INPUT_GET, 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ) );
|
612 |
+
}
|
613 |
+
}
|
614 |
+
|
615 |
+
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$filter}", $attrs['custom_dropdown_options_source'], $attrs );
|
616 |
+
$custom_dropdown .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
617 |
+
|
618 |
+
$attrs['options'] = UM()->fields()->get_options_from_callback( $attrs, $attrs['type'] );
|
619 |
+
} else {
|
620 |
+
/**
|
621 |
+
* UM hook
|
622 |
+
*
|
623 |
+
* @type filter
|
624 |
+
* @title um_select_option_value
|
625 |
+
* @description Enable options pair by field $data
|
626 |
+
* @input_vars
|
627 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
628 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
629 |
+
*/
|
630 |
+
$option_pairs = apply_filters( 'um_select_options_pair', null, $attrs );
|
631 |
+
}
|
632 |
+
|
633 |
+
if ( $attrs['metakey'] != 'online_status' ) {
|
634 |
+
if ( $attrs['metakey'] != 'role_select' && $attrs['metakey'] != 'mycred_rank' && empty( $custom_dropdown ) && empty( $option_pairs ) ) {
|
635 |
+
$attrs['options'] = array_intersect( array_map( 'stripslashes', array_map( 'trim', $attrs['options'] ) ), $values_array );
|
636 |
+
} elseif ( ! empty( $custom_dropdown ) ) {
|
637 |
+
$attrs['options'] = array_intersect_key( array_map( 'trim', $attrs['options'] ), array_flip( $values_array ) );
|
638 |
+
} else {
|
639 |
+
$attrs['options'] = array_intersect_key( array_map( 'trim', $attrs['options'] ), array_flip( $values_array ) );
|
640 |
+
}
|
641 |
+
}
|
642 |
+
|
643 |
+
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options', $attrs['options'], $values_array, $attrs );
|
644 |
+
|
645 |
+
if ( empty( $attrs['options'] ) || ! is_array( $attrs['options'] ) ) {
|
646 |
+
ob_get_clean();
|
647 |
+
return '';
|
648 |
+
}
|
649 |
+
|
650 |
+
if ( ! empty( $attrs['custom_dropdown_options_source'] ) && ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
651 |
+
$attrs['options'] = array();
|
652 |
+
}
|
653 |
+
|
654 |
+
if ( isset( $attrs['label'] ) ) {
|
655 |
+
$attrs['label'] = strip_tags( $attrs['label'] );
|
656 |
+
}
|
657 |
+
|
658 |
+
if ( ! empty( $default_filters[ $filter ] ) ) {
|
659 |
+
$attrs['options'] = array_intersect( $attrs['options'], $default_filters[ $filter ] );
|
660 |
+
}
|
661 |
+
|
662 |
+
ksort( $attrs['options'] );
|
663 |
+
|
664 |
+
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options_sorted', $attrs['options'], $attrs );
|
665 |
+
|
666 |
+
$label = isset( $attrs['label'] ) ? $attrs['label'] : ''; ?>
|
667 |
+
|
668 |
+
<select class="um-s1" id="<?php echo esc_attr( $filter ); ?>" name="<?php echo esc_attr( $filter ); ?><?php if ( $admin && count( $attrs['options'] ) > 1 ) { ?>[]<?php } ?>"
|
669 |
+
data-placeholder="<?php esc_attr_e( stripslashes( $label ), 'ultimate-member' ); ?>"
|
670 |
+
aria-label="<?php esc_attr_e( stripslashes( $label ), 'ultimate-member' ); ?>"
|
671 |
+
<?php if ( $admin && count( $attrs['options'] ) > 1 ) { ?>multiple<?php } ?>
|
672 |
+
<?php echo $custom_dropdown; ?>>
|
673 |
+
|
674 |
+
<option></option>
|
675 |
+
|
676 |
+
<?php if ( ! empty( $attrs['options'] ) ) {
|
677 |
+
foreach ( $attrs['options'] as $k => $v ) {
|
678 |
+
|
679 |
+
$v = stripslashes( $v );
|
680 |
+
|
681 |
+
$opt = $v;
|
682 |
+
|
683 |
+
if ( strstr( $filter, 'role_' ) || $filter == 'role' ) {
|
684 |
+
$opt = $k;
|
685 |
+
}
|
686 |
+
|
687 |
+
if ( isset( $attrs['custom'] ) ) {
|
688 |
+
$opt = $k;
|
689 |
+
}
|
690 |
+
|
691 |
+
if ( ! empty( $option_pairs ) ) {
|
692 |
+
$opt = $k;
|
693 |
+
} ?>
|
694 |
+
|
695 |
+
<option value="<?php echo esc_attr( $opt ); ?>" data-value_label="<?php esc_attr_e( $v, 'ultimate-member' ); ?>"
|
696 |
+
<?php disabled( ! empty( $filter_from_url ) && in_array( $opt, $filter_from_url ) );
|
697 |
+
|
698 |
+
if ( $admin ) {
|
699 |
+
if ( ! is_array( $default_value ) ) {
|
700 |
+
$default_value = array( $default_value );
|
701 |
+
}
|
702 |
+
|
703 |
+
selected( in_array( $opt, $default_value ) );
|
704 |
+
} else {
|
705 |
+
selected( $opt === $default_value );
|
706 |
+
} ?>>
|
707 |
+
<?php _e( $v, 'ultimate-member' ); ?>
|
708 |
+
</option>
|
709 |
+
|
710 |
+
<?php }
|
711 |
+
} ?>
|
712 |
+
|
713 |
+
</select>
|
714 |
+
|
715 |
+
<?php break;
|
716 |
+
}
|
717 |
+
case 'slider': {
|
718 |
+
$range = $this->slider_filters_range( $filter, $directory_data );
|
719 |
+
if ( $range ) {
|
720 |
+
list( $single_placeholder, $plural_placeholder ) = $this->slider_range_placeholder( $filter, $attrs ); ?>
|
721 |
+
|
722 |
+
<input type="hidden" id="<?php echo $filter; ?>_min" name="<?php echo $filter; ?>[]" class="um_range_min" value="<?php echo ! empty( $default_value ) ? esc_attr( min( $default_value ) ) : '' ?>" />
|
723 |
+
<input type="hidden" id="<?php echo $filter; ?>_max" name="<?php echo $filter; ?>[]" class="um_range_max" value="<?php echo ! empty( $default_value ) ? esc_attr( max( $default_value ) ) : '' ?>" />
|
724 |
+
<div class="um-slider" data-field_name="<?php echo $filter; ?>" data-min="<?php echo esc_attr( $range[0] ); ?>" data-max="<?php echo esc_attr( $range[1] ); ?>"></div>
|
725 |
+
<div class="um-slider-range" data-placeholder-s="<?php echo esc_attr( $single_placeholder ); ?>" data-placeholder-p="<?php echo esc_attr( $plural_placeholder ); ?>" data-label="<?php echo ( ! empty( $attrs['label'] ) ) ? esc_attr__( stripslashes( $attrs['label'] ), 'ultimate-member' ) : ''; ?>"></div>
|
726 |
+
<?php }
|
727 |
+
|
728 |
+
break;
|
729 |
+
}
|
730 |
+
case 'datepicker': {
|
731 |
+
|
732 |
+
$range = $this->datepicker_filters_range( $filter );
|
733 |
+
|
734 |
+
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $attrs['title'];
|
735 |
+
|
736 |
+
if ( $range ) { ?>
|
737 |
+
|
738 |
+
<input type="text" id="<?php echo $filter; ?>_from" name="<?php echo $filter; ?>_from" class="um-datepicker-filter"
|
739 |
+
placeholder="<?php esc_attr_e( sprintf( '%s From', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
740 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
741 |
+
data-date_min="<?php echo $range[0] ?>" data-date_max="<?php echo $range[1] ?>"
|
742 |
+
data-filter_name="<?php echo $filter; ?>" data-range="from" data-value="<?php echo ! empty( $default_value ) ? esc_attr( strtotime( min( $default_value ) ) ) : '' ?>" />
|
743 |
+
<input type="text" id="<?php echo $filter; ?>_to" name="<?php echo $filter; ?>_to" class="um-datepicker-filter"
|
744 |
+
placeholder="<?php esc_attr_e( sprintf( '%s To', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
745 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
746 |
+
data-date_min="<?php echo $range[0] ?>" data-date_max="<?php echo $range[1] ?>"
|
747 |
+
data-filter_name="<?php echo $filter; ?>" data-range="to" data-value="<?php echo ! empty( $default_value ) ? esc_attr( strtotime( max( $default_value ) ) ) : '' ?>" />
|
748 |
+
|
749 |
+
<?php }
|
750 |
+
|
751 |
+
break;
|
752 |
+
}
|
753 |
+
case 'timepicker': {
|
754 |
+
|
755 |
+
$range = $this->timepicker_filters_range( $filter );
|
756 |
+
|
757 |
+
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $attrs['title'];
|
758 |
+
|
759 |
+
switch ( $attrs['format'] ) {
|
760 |
+
case 'g:i a':
|
761 |
+
$js_format = 'h:i a';
|
762 |
+
break;
|
763 |
+
case 'g:i A':
|
764 |
+
$js_format = 'h:i A';
|
765 |
+
break;
|
766 |
+
case 'H:i':
|
767 |
+
$js_format = 'HH:i';
|
768 |
+
break;
|
769 |
+
}
|
770 |
+
|
771 |
+
if ( $range ) { ?>
|
772 |
+
|
773 |
+
<input type="text" id="<?php echo $filter; ?>_from" name="<?php echo $filter; ?>_from" class="um-timepicker-filter"
|
774 |
+
placeholder="<?php esc_attr_e( sprintf( '%s From', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
775 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
776 |
+
data-min="<?php echo $range[0] ?>" data-max="<?php echo $range[1] ?>"
|
777 |
+
data-format="<?php echo esc_attr( $js_format ) ?>" data-intervals="<?php echo esc_attr( $attrs['intervals'] ) ?>"
|
778 |
+
data-filter_name="<?php echo $filter; ?>" data-range="from" />
|
779 |
+
<input type="text" id="<?php echo $filter; ?>_to" name="<?php echo $filter; ?>_to" class="um-timepicker-filter"
|
780 |
+
placeholder="<?php esc_attr_e( sprintf( '%s To', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
781 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
782 |
+
data-min="<?php echo $range[0] ?>" data-max="<?php echo $range[1] ?>"
|
783 |
+
data-format="<?php echo esc_attr( $js_format ) ?>" data-intervals="<?php echo esc_attr( $attrs['intervals'] ) ?>"
|
784 |
+
data-filter_name="<?php echo $filter; ?>" data-range="to" />
|
785 |
+
|
786 |
+
<?php }
|
787 |
+
|
788 |
+
break;
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
+
$filter = ob_get_clean();
|
793 |
+
return $filter;
|
794 |
+
}
|
795 |
+
|
796 |
+
|
797 |
+
/**
|
798 |
+
* @param string $filter
|
799 |
+
* @param array $directory_data
|
800 |
+
*
|
801 |
+
* @return mixed
|
802 |
+
*/
|
803 |
+
function slider_filters_range( $filter, $directory_data ) {
|
804 |
+
global $wpdb;
|
805 |
+
|
806 |
+
$range = false;
|
807 |
+
|
808 |
+
switch ( $filter ) {
|
809 |
+
|
810 |
+
default: {
|
811 |
+
|
812 |
+
$meta = $wpdb->get_row( $wpdb->prepare(
|
813 |
+
"SELECT MIN( CONVERT( meta_value, DECIMAL ) ) as min_meta,
|
814 |
+
MAX( CONVERT( meta_value, DECIMAL ) ) as max_meta,
|
815 |
+
COUNT( DISTINCT meta_value ) as amount
|
816 |
+
FROM {$wpdb->usermeta}
|
817 |
+
WHERE meta_key = %s",
|
818 |
+
$filter
|
819 |
+
), ARRAY_A );
|
820 |
+
|
821 |
+
if ( isset( $meta['min_meta'] ) && isset( $meta['max_meta'] ) && isset( $meta['amount'] ) && $meta['amount'] > 1 ) {
|
822 |
+
$range = array( (float) $meta['min_meta'], (float) $meta['max_meta'] );
|
823 |
+
}
|
824 |
+
|
825 |
+
$range = apply_filters( 'um_member_directory_filter_slider_common', $range, $directory_data, $filter );
|
826 |
+
$range = apply_filters( "um_member_directory_filter_{$filter}_slider", $range, $directory_data );
|
827 |
+
|
828 |
+
break;
|
829 |
+
}
|
830 |
+
case 'birth_date': {
|
831 |
+
|
832 |
+
// $meta = $wpdb->get_col(
|
833 |
+
// "SELECT meta_value
|
834 |
+
// FROM {$wpdb->usermeta}
|
835 |
+
// WHERE meta_key = 'birth_date' AND
|
836 |
+
// meta_value != ''"
|
837 |
+
// );
|
838 |
+
//
|
839 |
+
// if ( empty( $meta ) || count( $meta ) < 2 ) {
|
840 |
+
// $range = false;
|
841 |
+
// } elseif ( is_array( $meta ) ) {
|
842 |
+
// $birth_dates = array_filter( array_map( 'strtotime', $meta ), 'is_numeric' );
|
843 |
+
// sort( $birth_dates );
|
844 |
+
// $min_meta = array_shift( $birth_dates );
|
845 |
+
// $max_meta = array_pop( $birth_dates );
|
846 |
+
// $range = array( $this->borndate( $max_meta ), $this->borndate( $min_meta ) );
|
847 |
+
// }
|
848 |
+
|
849 |
+
$meta = $wpdb->get_row(
|
850 |
+
"SELECT MIN( meta_value ) as min_meta,
|
851 |
+
MAX( meta_value ) as max_meta,
|
852 |
+
COUNT( DISTINCT meta_value ) as amount
|
853 |
+
FROM {$wpdb->usermeta}
|
854 |
+
WHERE meta_key = 'birth_date' AND
|
855 |
+
meta_value != ''",
|
856 |
+
ARRAY_A );
|
857 |
+
|
858 |
+
if ( isset( $meta['min_meta'] ) && isset( $meta['max_meta'] ) && isset( $meta['amount'] ) && $meta['amount'] > 1 ) {
|
859 |
+
$range = array( $this->borndate( strtotime( $meta['max_meta'] ) ), $this->borndate( strtotime( $meta['min_meta'] ) ) );
|
860 |
+
}
|
861 |
+
|
862 |
+
break;
|
863 |
+
}
|
864 |
+
|
865 |
+
}
|
866 |
+
|
867 |
+
return $range;
|
868 |
+
}
|
869 |
+
|
870 |
+
|
871 |
+
/**
|
872 |
+
* @param $filter
|
873 |
+
*
|
874 |
+
* @return mixed
|
875 |
+
*/
|
876 |
+
function slider_range_placeholder( $filter, $attrs ) {
|
877 |
+
switch ( $filter ) {
|
878 |
+
default: {
|
879 |
+
$label = ucwords( str_replace( array( 'um_', '_' ), array( '', ' ' ), $filter ) );
|
880 |
+
$placeholders = apply_filters( 'um_member_directory_filter_slider_range_placeholder', false, $filter );
|
881 |
+
|
882 |
+
if ( ! $placeholders ) {
|
883 |
+
switch ( $attrs['type'] ) {
|
884 |
+
default:
|
885 |
+
$placeholders = array(
|
886 |
+
"<strong>$label:</strong> {value}",
|
887 |
+
"<strong>$label:</strong> {min_range} - {max_range}",
|
888 |
+
);
|
889 |
+
break;
|
890 |
+
case 'rating':
|
891 |
+
$placeholders = array(
|
892 |
+
"<strong>$label:</strong> {value}" . __( ' stars', 'ultimate-member' ),
|
893 |
+
"<strong>$label:</strong> {min_range} - {max_range}" . __( ' stars', 'ultimate-member' )
|
894 |
+
);
|
895 |
+
break;
|
896 |
+
}
|
897 |
+
}
|
898 |
+
|
899 |
+
break;
|
900 |
+
}
|
901 |
+
case 'birth_date': {
|
902 |
+
$placeholders = array(
|
903 |
+
__( '<strong>Age:</strong> {value} years old', 'ultimate-member' ),
|
904 |
+
__( '<strong>Age:</strong> {min_range} - {max_range} years old', 'ultimate-member' )
|
905 |
+
);
|
906 |
+
break;
|
907 |
+
}
|
908 |
+
}
|
909 |
+
|
910 |
+
return $placeholders;
|
911 |
+
}
|
912 |
+
|
913 |
+
|
914 |
+
/**
|
915 |
+
* @param $filter
|
916 |
+
*
|
917 |
+
* @return mixed
|
918 |
+
*/
|
919 |
+
function datepicker_filters_range( $filter ) {
|
920 |
+
global $wpdb;
|
921 |
+
|
922 |
+
switch ( $filter ) {
|
923 |
+
|
924 |
+
default: {
|
925 |
+
|
926 |
+
global $wpdb;
|
927 |
+
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value
|
928 |
+
FROM {$wpdb->usermeta}
|
929 |
+
WHERE meta_key = %s
|
930 |
+
ORDER BY meta_value DESC", $filter ) );
|
931 |
+
|
932 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
933 |
+
$range = false;
|
934 |
+
} elseif ( ! empty( $meta ) ) {
|
935 |
+
$range = array( strtotime( min( $meta ) ), strtotime( max( $meta ) ) );
|
936 |
+
}
|
937 |
+
|
938 |
+
$range = apply_filters( "um_member_directory_filter_{$filter}_datepicker", $range );
|
939 |
+
|
940 |
+
break;
|
941 |
+
}
|
942 |
+
case 'last_login': {
|
943 |
+
$meta = $wpdb->get_col( "SELECT DISTINCT meta_value
|
944 |
+
FROM {$wpdb->usermeta}
|
945 |
+
WHERE meta_key='_um_last_login'
|
946 |
+
ORDER BY meta_value DESC" );
|
947 |
+
|
948 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
949 |
+
$range = false;
|
950 |
+
} elseif ( ! empty( $meta ) ) {
|
951 |
+
$range = array( min( $meta ), max( $meta ) );
|
952 |
+
}
|
953 |
+
|
954 |
+
break;
|
955 |
+
}
|
956 |
+
case 'user_registered': {
|
957 |
+
$meta = $wpdb->get_col(
|
958 |
+
"SELECT DISTINCT user_registered
|
959 |
+
FROM {$wpdb->users}
|
960 |
+
ORDER BY user_registered DESC"
|
961 |
+
);
|
962 |
+
|
963 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
964 |
+
$range = false;
|
965 |
+
} elseif ( ! empty( $meta ) ) {
|
966 |
+
$range = array( strtotime( min( $meta ) ), strtotime( max( $meta ) ) );
|
967 |
+
}
|
968 |
+
|
969 |
+
break;
|
970 |
+
}
|
971 |
+
|
972 |
+
}
|
973 |
+
|
974 |
+
return $range;
|
975 |
+
}
|
976 |
+
|
977 |
+
|
978 |
+
/**
|
979 |
+
* @param $filter
|
980 |
+
*
|
981 |
+
* @return mixed
|
982 |
+
*/
|
983 |
+
function timepicker_filters_range( $filter ) {
|
984 |
+
|
985 |
+
switch ( $filter ) {
|
986 |
+
|
987 |
+
default: {
|
988 |
+
|
989 |
+
global $wpdb;
|
990 |
+
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value
|
991 |
+
FROM {$wpdb->usermeta}
|
992 |
+
WHERE meta_key = %s
|
993 |
+
ORDER BY meta_value DESC", $filter ) );
|
994 |
+
|
995 |
+
$meta = array_filter( $meta );
|
996 |
+
|
997 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
998 |
+
$range = false;
|
999 |
+
} elseif ( ! empty( $meta ) ) {
|
1000 |
+
$range = array( min( $meta ), max( $meta ) );
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
|
1004 |
+
$range = apply_filters( "um_member_directory_filter_{$filter}_timepicker", $range );
|
1005 |
+
|
1006 |
+
break;
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
return $range;
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
|
1015 |
+
/**
|
1016 |
+
* @param $borndate
|
1017 |
+
*
|
1018 |
+
* @return false|string
|
1019 |
+
*/
|
1020 |
+
function borndate( $borndate ) {
|
1021 |
+
if ( date('m', $borndate) > date('m') || date('m', $borndate) == date('m') && date('d', $borndate ) > date('d')) {
|
1022 |
+
return (date('Y') - date('Y', $borndate ) - 1);
|
1023 |
+
}
|
1024 |
+
return (date('Y') - date('Y', $borndate));
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
|
1028 |
+
/**
|
1029 |
+
* Handle members can view restrictions
|
1030 |
+
*/
|
1031 |
+
function restriction_options() {
|
1032 |
+
$this->hide_not_approved();
|
1033 |
+
$this->hide_by_role();
|
1034 |
+
$this->hide_by_account_settings();
|
1035 |
+
|
1036 |
+
do_action( 'um_member_directory_restrictions_handle_extend' );
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
|
1040 |
+
/**
|
1041 |
+
*
|
1042 |
+
*/
|
1043 |
+
function hide_not_approved() {
|
1044 |
+
if ( UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1045 |
+
return;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1049 |
+
'key' => 'um_member_directory_data',
|
1050 |
+
'value' => 's:14:"account_status";s:8:"approved";',
|
1051 |
+
'compare' => 'LIKE'
|
1052 |
+
) ) );
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
|
1056 |
+
/**
|
1057 |
+
*
|
1058 |
+
*/
|
1059 |
+
function hide_by_role() {
|
1060 |
+
if ( ! is_user_logged_in() ) {
|
1061 |
+
return;
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
$roles = um_user( 'can_view_roles' );
|
1065 |
+
$roles = maybe_unserialize( $roles );
|
1066 |
+
|
1067 |
+
if ( UM()->roles()->um_user_can( 'can_view_all' ) && empty( $roles ) ) {
|
1068 |
+
return;
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1072 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1073 |
+
$this->query_args['role__in'] = array_intersect( $this->query_args['role__in'], $roles );
|
1074 |
+
} else {
|
1075 |
+
$this->query_args['role__in'] = $roles;
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
|
1080 |
+
/**
|
1081 |
+
*
|
1082 |
+
*/
|
1083 |
+
function hide_by_account_settings() {
|
1084 |
+
if ( ! UM()->options()->get( 'account_hide_in_directory' ) ) {
|
1085 |
+
return;
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
if ( UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1089 |
+
return;
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1093 |
+
'key' => 'um_member_directory_data',
|
1094 |
+
'value' => 's:15:"hide_in_members";b:0;',
|
1095 |
+
'compare' => 'LIKE'
|
1096 |
+
) ) );
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
|
1100 |
+
/**
|
1101 |
+
* Handle "General Options" metabox settings
|
1102 |
+
*
|
1103 |
+
* @param array $directory_data
|
1104 |
+
*/
|
1105 |
+
function general_options( $directory_data ) {
|
1106 |
+
$this->show_selected_roles( $directory_data );
|
1107 |
+
$this->show_only_with_avatar( $directory_data );
|
1108 |
+
$this->show_only_with_cover( $directory_data );
|
1109 |
+
$this->show_only_these_users( $directory_data );
|
1110 |
+
$this->exclude_these_users( $directory_data );
|
1111 |
+
|
1112 |
+
do_action( 'um_member_directory_general_options_handle_extend', $directory_data );
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
|
1116 |
+
/**
|
1117 |
+
* Handle "User Roles to Display" option
|
1118 |
+
*
|
1119 |
+
* @param array $directory_data
|
1120 |
+
*/
|
1121 |
+
function show_selected_roles( $directory_data ) {
|
1122 |
+
// add roles to appear in directory
|
1123 |
+
if ( ! empty( $directory_data['roles'] ) ) {
|
1124 |
+
//since WP4.4 use 'role__in' argument
|
1125 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1126 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1127 |
+
$this->query_args['role__in'] = array_intersect( $this->query_args['role__in'], maybe_unserialize( $directory_data['roles'] ) );
|
1128 |
+
} else {
|
1129 |
+
$this->query_args['role__in'] = maybe_unserialize( $directory_data['roles'] );
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
|
1135 |
+
/**
|
1136 |
+
* Handle "Only show members who have uploaded a profile photo" option
|
1137 |
+
*
|
1138 |
+
* @param array $directory_data
|
1139 |
+
*/
|
1140 |
+
function show_only_with_avatar( $directory_data ) {
|
1141 |
+
if ( $directory_data['has_profile_photo'] == 1 ) {
|
1142 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1143 |
+
'key' => 'um_member_directory_data',
|
1144 |
+
'value' => 's:13:"profile_photo";b:1;',
|
1145 |
+
'compare' => 'LIKE'
|
1146 |
+
) ) );
|
1147 |
+
}
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
|
1151 |
+
/**
|
1152 |
+
* Handle "Only show members who have uploaded a cover photo" option
|
1153 |
+
*
|
1154 |
+
* @param array $directory_data
|
1155 |
+
*/
|
1156 |
+
function show_only_with_cover( $directory_data ) {
|
1157 |
+
if ( $directory_data['has_cover_photo'] == 1 ) {
|
1158 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1159 |
+
'key' => 'um_member_directory_data',
|
1160 |
+
'value' => 's:11:"cover_photo";b:1;',
|
1161 |
+
'compare' => 'LIKE'
|
1162 |
+
) ) );
|
1163 |
+
}
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
|
1167 |
+
/**
|
1168 |
+
* Handle "Only show specific users (Enter one username per line)" option
|
1169 |
+
*
|
1170 |
+
* @param array $directory_data
|
1171 |
+
*/
|
1172 |
+
function show_only_these_users( $directory_data ) {
|
1173 |
+
if ( ! empty( $directory_data['show_these_users'] ) ) {
|
1174 |
+
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
|
1175 |
+
|
1176 |
+
if ( is_array( $show_these_users ) && ! empty( $show_these_users ) ) {
|
1177 |
+
|
1178 |
+
$users_array = array();
|
1179 |
+
|
1180 |
+
foreach ( $show_these_users as $username ) {
|
1181 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
1182 |
+
$users_array[] = $exists_id;
|
1183 |
+
}
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
if ( ! empty( $users_array ) ) {
|
1187 |
+
$this->query_args['include'] = $users_array;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
|
1195 |
+
/**
|
1196 |
+
* Handle "Exclude specific users (Enter one username per line)" option
|
1197 |
+
*
|
1198 |
+
* @param array $directory_data
|
1199 |
+
*/
|
1200 |
+
function exclude_these_users( $directory_data ) {
|
1201 |
+
if ( ! empty( $directory_data['exclude_these_users'] ) ) {
|
1202 |
+
$exclude_these_users = maybe_unserialize( $directory_data['exclude_these_users'] );
|
1203 |
+
|
1204 |
+
if ( is_array( $exclude_these_users ) && ! empty( $exclude_these_users ) ) {
|
1205 |
+
|
1206 |
+
$users_array = array();
|
1207 |
+
|
1208 |
+
foreach ( $exclude_these_users as $username ) {
|
1209 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
1210 |
+
$users_array[] = $exists_id;
|
1211 |
+
}
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
if ( ! empty( $users_array ) ) {
|
1215 |
+
$this->query_args['exclude'] = $users_array;
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
}
|
1219 |
+
}
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
|
1223 |
+
/**
|
1224 |
+
* Handle "Pagination Options" metabox settings
|
1225 |
+
*
|
1226 |
+
* @param array $directory_data
|
1227 |
+
*/
|
1228 |
+
function pagination_options( $directory_data ) {
|
1229 |
+
// number of profiles for mobile
|
1230 |
+
$profiles_per_page = $directory_data['profiles_per_page'];
|
1231 |
+
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
1232 |
+
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
$this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
|
1236 |
+
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
|
1240 |
+
/**
|
1241 |
+
* Add sorting attributes for \WP_Users_Query
|
1242 |
+
*
|
1243 |
+
* @param array $directory_data Member Directory options
|
1244 |
+
*/
|
1245 |
+
function sorting_query( $directory_data ) {
|
1246 |
+
// sort members by
|
1247 |
+
$this->query_args['order'] = 'ASC';
|
1248 |
+
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
1249 |
+
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
1250 |
+
|
1251 |
+
$custom_sort = array();
|
1252 |
+
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
1253 |
+
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
1254 |
+
foreach ( $sorting_fields as $field ) {
|
1255 |
+
if ( is_array( $field ) ) {
|
1256 |
+
$field_keys = array_keys( $field );
|
1257 |
+
$custom_sort[] = $field_keys[0];
|
1258 |
+
}
|
1259 |
+
}
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
if ( 'username' == $sortby ) {
|
1263 |
+
|
1264 |
+
$this->query_args['orderby'] = 'user_login';
|
1265 |
+
$this->query_args['order'] = 'ASC';
|
1266 |
+
|
1267 |
+
} elseif ( 'display_name' == $sortby ) {
|
1268 |
+
|
1269 |
+
$display_name = UM()->options()->get( 'display_name' );
|
1270 |
+
if ( $display_name == 'username' ) {
|
1271 |
+
$this->query_args['orderby'] = 'user_login';
|
1272 |
+
$this->query_args['order'] = 'ASC';
|
1273 |
+
} else {
|
1274 |
+
$this->query_args['meta_query'][] = array(
|
1275 |
+
'relation' => 'OR',
|
1276 |
+
'full_name' => array(
|
1277 |
+
'key' => 'full_name',
|
1278 |
+
'compare' => 'EXISTS'
|
1279 |
+
),
|
1280 |
+
array(
|
1281 |
+
'key' => 'full_name',
|
1282 |
+
'compare' => 'NOT EXISTS'
|
1283 |
+
)
|
1284 |
+
);
|
1285 |
+
|
1286 |
+
$this->query_args['orderby'] = 'full_name, display_name';
|
1287 |
+
$this->query_args['order'] = 'ASC';
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
|
1291 |
+
|
1292 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $sortby . '_c' => array(
|
1293 |
+
'key' => $sortby,
|
1294 |
+
'compare' => 'EXISTS',
|
1295 |
+
), ) );
|
1296 |
+
|
1297 |
+
$this->query_args['orderby'] = array( $sortby . '_c' => 'ASC' );
|
1298 |
+
unset( $this->query_args['order'] );
|
1299 |
+
|
1300 |
+
} elseif ( $sortby == 'last_login' ) {
|
1301 |
+
|
1302 |
+
$this->query_args['orderby'] = array( 'um_last_login' => 'DESC' );
|
1303 |
+
$this->query_args['meta_query'][] = array(
|
1304 |
+
'relation' => 'OR',
|
1305 |
+
array(
|
1306 |
+
'key' => '_um_last_login',
|
1307 |
+
'compare' => 'EXISTS',
|
1308 |
+
),
|
1309 |
+
'um_last_login' => array(
|
1310 |
+
'key' => '_um_last_login',
|
1311 |
+
'compare' => 'NOT EXISTS',
|
1312 |
+
),
|
1313 |
+
);
|
1314 |
+
unset( $this->query_args['order'] );
|
1315 |
+
|
1316 |
+
} elseif ( $sortby == 'last_first_name' ) {
|
1317 |
+
|
1318 |
+
$this->query_args['meta_query'][] = array(
|
1319 |
+
'last_name_c' => array(
|
1320 |
+
'key' => 'last_name',
|
1321 |
+
'compare' => 'EXISTS',
|
1322 |
+
),
|
1323 |
+
'first_name_c' => array(
|
1324 |
+
'key' => 'first_name',
|
1325 |
+
'compare' => 'EXISTS',
|
1326 |
+
),
|
1327 |
+
);
|
1328 |
+
|
1329 |
+
$this->query_args['orderby'] = array( 'last_name_c' => 'ASC', 'first_name_c' => 'ASC' );
|
1330 |
+
unset( $this->query_args['order'] );
|
1331 |
+
|
1332 |
+
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) {
|
1333 |
+
|
1334 |
+
$custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data );
|
1335 |
+
|
1336 |
+
$this->query_args['meta_query'][] = array(
|
1337 |
+
'relation' => 'OR',
|
1338 |
+
$sortby . '_cs' => array(
|
1339 |
+
'key' => $sortby,
|
1340 |
+
'compare' => 'EXISTS',
|
1341 |
+
'type' => $custom_sort_type,
|
1342 |
+
),
|
1343 |
+
array(
|
1344 |
+
'key' => $sortby,
|
1345 |
+
'compare' => 'NOT EXISTS',
|
1346 |
+
)
|
1347 |
+
);
|
1348 |
+
|
1349 |
+
$this->query_args['orderby'] = array( $sortby . '_cs' => 'ASC', 'user_login' => 'ASC' );
|
1350 |
+
|
1351 |
+
} else {
|
1352 |
+
|
1353 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
1354 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
1355 |
+
$order = 'DESC';
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
1359 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
1360 |
+
$order = 'ASC';
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
$this->query_args['orderby'] = $sortby;
|
1364 |
+
if ( isset( $order ) ) {
|
1365 |
+
$this->query_args['order'] = $order;
|
1366 |
+
}
|
1367 |
+
|
1368 |
+
add_filter( 'pre_user_query', array( &$this, 'sortby_randomly' ), 10, 1 );
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
|
1372 |
+
/**
|
1373 |
+
* UM hook
|
1374 |
+
*
|
1375 |
+
* @type filter
|
1376 |
+
* @title um_modify_sortby_parameter
|
1377 |
+
* @description Change query sort by attributes for search at Members Directory
|
1378 |
+
* @input_vars
|
1379 |
+
* [{"var":"$query_args","type":"array","desc":"Query Arguments"},
|
1380 |
+
* {"var":"$sortby","type":"string","desc":"Sort by"}]
|
1381 |
+
* @change_log
|
1382 |
+
* ["Since: 2.0"]
|
1383 |
+
* @usage
|
1384 |
+
* <?php add_filter( 'um_modify_sortby_parameter', 'function_name', 10, 2 ); ?>
|
1385 |
+
* @example
|
1386 |
+
* <?php
|
1387 |
+
* add_filter( 'um_modify_sortby_parameter', 'my_modify_sortby_parameter', 10, 2 );
|
1388 |
+
* function my_modify_sortby_parameter( $query_args, $sortby ) {
|
1389 |
+
* // your code here
|
1390 |
+
* return $query_args;
|
1391 |
+
* }
|
1392 |
+
* ?>
|
1393 |
+
*/
|
1394 |
+
$this->query_args = apply_filters( 'um_modify_sortby_parameter', $this->query_args, $sortby );
|
1395 |
+
}
|
1396 |
+
|
1397 |
+
|
1398 |
+
/**
|
1399 |
+
* Sorting random
|
1400 |
+
*
|
1401 |
+
* @param object $query
|
1402 |
+
*
|
1403 |
+
* @return mixed
|
1404 |
+
*/
|
1405 |
+
function sortby_randomly( $query ) {
|
1406 |
+
if ( 'random' == $query->query_vars['orderby'] ) {
|
1407 |
+
|
1408 |
+
if ( um_is_session_started() === false ) {
|
1409 |
+
@session_start();
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
// Reset seed on load of initial
|
1413 |
+
if ( empty( $_REQUEST['directory_id'] ) && isset( $_SESSION['um_member_directory_seed'] ) ) {
|
1414 |
+
unset( $_SESSION['um_member_directory_seed'] );
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
// Get seed from session variable if it exists
|
1418 |
+
$seed = false;
|
1419 |
+
if ( isset( $_SESSION['um_member_directory_seed'] ) ) {
|
1420 |
+
$seed = $_SESSION['um_member_directory_seed'];
|
1421 |
+
}
|
1422 |
+
|
1423 |
+
// Set new seed if none exists
|
1424 |
+
if ( ! $seed ) {
|
1425 |
+
$seed = rand();
|
1426 |
+
$_SESSION['um_member_directory_seed'] = $seed;
|
1427 |
+
}
|
1428 |
+
|
1429 |
+
$query->query_orderby = 'ORDER by RAND(' . $seed . ')';
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
return $query;
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
|
1436 |
+
|
1437 |
+
/**
|
1438 |
+
* Handle general search line request
|
1439 |
+
*/
|
1440 |
+
function general_search() {
|
1441 |
+
//general search
|
1442 |
+
if ( ! empty( $_POST['search'] ) ) {
|
1443 |
+
// complex using with change_meta_sql function
|
1444 |
+
|
1445 |
+
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1446 |
+
|
1447 |
+
$meta_query = array(
|
1448 |
+
'relation' => 'OR',
|
1449 |
+
array(
|
1450 |
+
'value' => $search,
|
1451 |
+
'compare' => '=',
|
1452 |
+
),
|
1453 |
+
array(
|
1454 |
+
'value' => $search,
|
1455 |
+
'compare' => 'LIKE',
|
1456 |
+
),
|
1457 |
+
array(
|
1458 |
+
'value' => serialize( (string) $search ),
|
1459 |
+
'compare' => 'LIKE',
|
1460 |
+
),
|
1461 |
+
);
|
1462 |
+
|
1463 |
+
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1464 |
+
|
1465 |
+
$this->query_args['meta_query'][] = $meta_query;
|
1466 |
+
|
1467 |
+
$this->is_search = true;
|
1468 |
+
}
|
1469 |
+
}
|
1470 |
+
|
1471 |
+
|
1472 |
+
/**
|
1473 |
+
* Change mySQL meta query join attribute
|
1474 |
+
* for search only by UM user meta fields and WP core fields in WP Users table
|
1475 |
+
*
|
1476 |
+
* @param array $sql Array containing the query's JOIN and WHERE clauses.
|
1477 |
+
* @param $queries
|
1478 |
+
* @param $type
|
1479 |
+
* @param $primary_table
|
1480 |
+
* @param $primary_id_column
|
1481 |
+
* @param \WP_User_Query $context
|
1482 |
+
*
|
1483 |
+
* @return mixed
|
1484 |
+
*/
|
1485 |
+
function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
|
1486 |
+
if ( ! empty( $_POST['search'] ) ) {
|
1487 |
+
global $wpdb;
|
1488 |
+
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1489 |
+
if ( ! empty( $search ) ) {
|
1490 |
+
|
1491 |
+
$meta_value = '%' . $wpdb->esc_like( $search ) . '%';
|
1492 |
+
$search_meta = $wpdb->prepare( '%s', $meta_value );
|
1493 |
+
|
1494 |
+
preg_match(
|
1495 |
+
'/^(.*).meta_value LIKE ' . addslashes( $search_meta ) . '[^\)]/im',
|
1496 |
+
$sql['where'],
|
1497 |
+
$join_matches
|
1498 |
+
);
|
1499 |
+
|
1500 |
+
if ( isset( $join_matches[1] ) ) {
|
1501 |
+
$meta_join_for_search = trim( $join_matches[1] );
|
1502 |
+
|
1503 |
+
// skip private invisible fields
|
1504 |
+
$custom_fields = array();
|
1505 |
+
foreach ( array_keys( UM()->builtin()->all_user_fields ) as $field_key ) {
|
1506 |
+
$data = UM()->fields()->get_field( $field_key );
|
1507 |
+
if ( ! um_can_view_field( $data ) ) {
|
1508 |
+
continue;
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
$custom_fields[] = $field_key;
|
1512 |
+
}
|
1513 |
+
|
1514 |
+
$custom_fields = apply_filters( 'um_general_search_custom_fields', $custom_fields );
|
1515 |
+
|
1516 |
+
if ( ! empty( $custom_fields ) ) {
|
1517 |
+
$sql['join'] = preg_replace(
|
1518 |
+
'/(' . $meta_join_for_search . ' ON \( ' . $wpdb->users . '\.ID = ' . $meta_join_for_search . '\.user_id )(\))/im',
|
1519 |
+
"$1 AND " . $meta_join_for_search . ".meta_key IN( '" . implode( "','", $custom_fields ) . "' ) $2",
|
1520 |
+
$sql['join']
|
1521 |
+
);
|
1522 |
+
}
|
1523 |
+
}
|
1524 |
+
|
1525 |
+
// Add OR instead AND to search in WP core fields user_email, user_login, user_display_name
|
1526 |
+
$search_where = $context->get_search_sql( $search, $this->core_search_fields, 'both' );
|
1527 |
+
|
1528 |
+
$search_where = preg_replace( '/ AND \((.*?)\)/im', "$1 OR", $search_where );
|
1529 |
+
|
1530 |
+
$sql['where'] = preg_replace(
|
1531 |
+
'/(' . $meta_join_for_search . '.meta_value = \'' . esc_attr( $search ) . '\')/im',
|
1532 |
+
trim( $search_where ) . " $1",
|
1533 |
+
$sql['where'],
|
1534 |
+
1
|
1535 |
+
);
|
1536 |
+
}
|
1537 |
+
}
|
1538 |
+
|
1539 |
+
return $sql;
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
|
1543 |
+
/**
|
1544 |
+
* Handle filters request
|
1545 |
+
*/
|
1546 |
+
function filters( $directory_data ) {
|
1547 |
+
//filters
|
1548 |
+
$filter_query = array();
|
1549 |
+
if ( ! empty( $directory_data['search_fields'] ) ) {
|
1550 |
+
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
1551 |
+
|
1552 |
+
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
1553 |
+
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
1554 |
+
}
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
// added for user tags extension integration on individual tag page
|
1558 |
+
$ignore_empty_filters = apply_filters( 'um_member_directory_ignore_empty_filters', false );
|
1559 |
+
|
1560 |
+
if ( empty( $filter_query ) && ! $ignore_empty_filters ) {
|
1561 |
+
return;
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
$this->is_search = true;
|
1565 |
+
foreach ( $filter_query as $field => $value ) {
|
1566 |
+
$field = sanitize_text_field( $field );
|
1567 |
+
if ( is_array( $value ) ) {
|
1568 |
+
$value = array_map( 'sanitize_text_field', $value );
|
1569 |
+
} else {
|
1570 |
+
$value = sanitize_text_field( $value );
|
1571 |
+
}
|
1572 |
+
|
1573 |
+
$attrs = UM()->fields()->get_field( $field );
|
1574 |
+
// skip private invisible fields
|
1575 |
+
if ( ! um_can_view_field( $attrs ) ) {
|
1576 |
+
continue;
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
switch ( $field ) {
|
1580 |
+
default:
|
1581 |
+
|
1582 |
+
$filter_type = $this->filter_types[ $field ];
|
1583 |
+
|
1584 |
+
/**
|
1585 |
+
* UM hook
|
1586 |
+
*
|
1587 |
+
* @type filter
|
1588 |
+
* @title um_query_args_{$field}__filter
|
1589 |
+
* @description Change field's query for search at Members Directory
|
1590 |
+
* @input_vars
|
1591 |
+
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
1592 |
+
* @change_log
|
1593 |
+
* ["Since: 2.0"]
|
1594 |
+
* @usage
|
1595 |
+
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
1596 |
+
* @example
|
1597 |
+
* <?php
|
1598 |
+
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
1599 |
+
* function my_query_args_filter( $field_query ) {
|
1600 |
+
* // your code here
|
1601 |
+
* return $field_query;
|
1602 |
+
* }
|
1603 |
+
* ?>
|
1604 |
+
*/
|
1605 |
+
$field_query = apply_filters( "um_query_args_{$field}__filter", false, $field, $value, $filter_type );
|
1606 |
+
|
1607 |
+
$field_query = apply_filters( 'um_query_args_filter_global', $field_query, $field, $value, $filter_type );
|
1608 |
+
|
1609 |
+
if ( ! $field_query ) {
|
1610 |
+
|
1611 |
+
switch ( $filter_type ) {
|
1612 |
+
default:
|
1613 |
+
|
1614 |
+
$field_query = apply_filters( "um_query_args_{$field}_{$filter_type}__filter", false, $field, $value, $filter_type );
|
1615 |
+
|
1616 |
+
break;
|
1617 |
+
case 'text':
|
1618 |
+
|
1619 |
+
$value = stripslashes( $value );
|
1620 |
+
$field_query = array(
|
1621 |
+
'relation' => 'OR',
|
1622 |
+
array(
|
1623 |
+
'key' => $field,
|
1624 |
+
'value' => trim( $value ),
|
1625 |
+
'compare' => apply_filters( 'um_members_directory_filter_text', 'LIKE', $field )
|
1626 |
+
),
|
1627 |
+
);
|
1628 |
+
|
1629 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1630 |
+
|
1631 |
+
break;
|
1632 |
+
|
1633 |
+
case 'select':
|
1634 |
+
if ( is_array( $value ) ) {
|
1635 |
+
$field_query = array( 'relation' => 'OR' );
|
1636 |
+
|
1637 |
+
foreach ( $value as $single_val ) {
|
1638 |
+
$single_val = trim( stripslashes( $single_val ) );
|
1639 |
+
|
1640 |
+
$arr_meta_query = array(
|
1641 |
+
array(
|
1642 |
+
'key' => $field,
|
1643 |
+
'value' => $single_val,
|
1644 |
+
'compare' => '=',
|
1645 |
+
),
|
1646 |
+
array(
|
1647 |
+
'key' => $field,
|
1648 |
+
'value' => serialize( (string) $single_val ),
|
1649 |
+
'compare' => 'LIKE',
|
1650 |
+
),
|
1651 |
+
array(
|
1652 |
+
'key' => $field,
|
1653 |
+
'value' => '"' . $single_val . '"',
|
1654 |
+
'compare' => 'LIKE',
|
1655 |
+
)
|
1656 |
+
);
|
1657 |
+
|
1658 |
+
if ( is_numeric( $single_val ) ) {
|
1659 |
+
|
1660 |
+
$arr_meta_query[] = array(
|
1661 |
+
'key' => $field,
|
1662 |
+
'value' => serialize( (int) $single_val ),
|
1663 |
+
'compare' => 'LIKE',
|
1664 |
+
);
|
1665 |
+
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
$field_query = array_merge( $field_query, $arr_meta_query );
|
1669 |
+
}
|
1670 |
+
}
|
1671 |
+
|
1672 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1673 |
+
|
1674 |
+
break;
|
1675 |
+
case 'slider':
|
1676 |
+
|
1677 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1678 |
+
|
1679 |
+
$field_query = array(
|
1680 |
+
'key' => $field,
|
1681 |
+
'value' => $value,
|
1682 |
+
'compare' => 'BETWEEN',
|
1683 |
+
'inclusive' => true,
|
1684 |
+
'type' => 'NUMERIC',
|
1685 |
+
);
|
1686 |
+
|
1687 |
+
break;
|
1688 |
+
case 'datepicker':
|
1689 |
+
|
1690 |
+
$offset = 0;
|
1691 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1692 |
+
$offset = (int) $_POST['gmt_offset'];
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1696 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1697 |
+
$from_date = date( 'Y/m/d', $from_date );
|
1698 |
+
$to_date = date( 'Y/m/d', $to_date );
|
1699 |
+
|
1700 |
+
$field_query = array(
|
1701 |
+
'key' => $field,
|
1702 |
+
'value' => array( $from_date, $to_date ),
|
1703 |
+
'compare' => 'BETWEEN',
|
1704 |
+
'inclusive' => true,
|
1705 |
+
);
|
1706 |
+
|
1707 |
+
$this->custom_filters_in_query[ $field ] = array( $from_date, $to_date );
|
1708 |
+
|
1709 |
+
break;
|
1710 |
+
case 'timepicker':
|
1711 |
+
|
1712 |
+
if ( $value[0] == $value[1] ) {
|
1713 |
+
$field_query = array(
|
1714 |
+
'key' => $field,
|
1715 |
+
'value' => $value[0],
|
1716 |
+
);
|
1717 |
+
} else {
|
1718 |
+
$field_query = array(
|
1719 |
+
'key' => $field,
|
1720 |
+
'value' => $value,
|
1721 |
+
'compare' => 'BETWEEN',
|
1722 |
+
'type' => 'TIME',
|
1723 |
+
'inclusive' => true,
|
1724 |
+
);
|
1725 |
+
}
|
1726 |
+
|
1727 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1728 |
+
|
1729 |
+
break;
|
1730 |
+
}
|
1731 |
+
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
if ( ! empty( $field_query ) && $field_query !== true ) {
|
1735 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
1736 |
+
}
|
1737 |
+
|
1738 |
+
break;
|
1739 |
+
case 'role':
|
1740 |
+
$value = array_map( 'strtolower', $value );
|
1741 |
+
|
1742 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1743 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1744 |
+
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
1745 |
+
$um_role = array_diff( $value, $default_role );
|
1746 |
+
|
1747 |
+
foreach ( $um_role as $key => &$val ) {
|
1748 |
+
$val = 'um_' . str_replace( ' ', '-', $val );
|
1749 |
+
}
|
1750 |
+
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
1751 |
+
} else {
|
1752 |
+
$this->query_args['role__in'] = $value;
|
1753 |
+
};
|
1754 |
+
|
1755 |
+
$this->custom_filters_in_query[ $field ] = $this->query_args['role__in'];
|
1756 |
+
|
1757 |
+
break;
|
1758 |
+
case 'birth_date':
|
1759 |
+
|
1760 |
+
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
1761 |
+
$to_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ) + 1, date( 'Y', time() - ( max( $value ) + 1 ) * YEAR_IN_SECONDS ) ) );
|
1762 |
+
|
1763 |
+
$meta_query = array(
|
1764 |
+
array(
|
1765 |
+
'key' => 'birth_date',
|
1766 |
+
'value' => array( $to_date, $from_date ),
|
1767 |
+
'compare' => 'BETWEEN',
|
1768 |
+
'type' => 'DATE',
|
1769 |
+
'inclusive' => true,
|
1770 |
+
)
|
1771 |
+
);
|
1772 |
+
|
1773 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
1774 |
+
|
1775 |
+
$this->custom_filters_in_query[ $field ] = array( $to_date, $from_date );
|
1776 |
+
|
1777 |
+
break;
|
1778 |
+
case 'user_registered':
|
1779 |
+
|
1780 |
+
$offset = 0;
|
1781 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1782 |
+
$offset = (int) $_POST['gmt_offset'];
|
1783 |
+
}
|
1784 |
+
|
1785 |
+
$from_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', min( $value ) ) . "+$offset hours" ) );
|
1786 |
+
$to_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', max( $value ) ) . "+$offset hours" ) );
|
1787 |
+
|
1788 |
+
$date_query = array(
|
1789 |
+
array(
|
1790 |
+
'column' => 'user_registered',
|
1791 |
+
'before' => $to_date,
|
1792 |
+
'after' => $from_date,
|
1793 |
+
'inclusive' => true,
|
1794 |
+
),
|
1795 |
+
);
|
1796 |
+
|
1797 |
+
if ( empty( $this->query_args['date_query'] ) ) {
|
1798 |
+
$this->query_args['date_query'] = $date_query;
|
1799 |
+
} else {
|
1800 |
+
$this->query_args['date_query'] = array_merge( $this->query_args['date_query'], array( $date_query ) );
|
1801 |
+
}
|
1802 |
+
|
1803 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1804 |
+
|
1805 |
+
break;
|
1806 |
+
case 'last_login':
|
1807 |
+
|
1808 |
+
$offset = 0;
|
1809 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1810 |
+
$offset = (int) $_POST['gmt_offset'];
|
1811 |
+
}
|
1812 |
+
|
1813 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1814 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1815 |
+
$meta_query = array(
|
1816 |
+
array(
|
1817 |
+
'key' => '_um_last_login',
|
1818 |
+
'value' => array( $from_date, $to_date ),
|
1819 |
+
'compare' => 'BETWEEN',
|
1820 |
+
'inclusive' => true,
|
1821 |
+
)
|
1822 |
+
);
|
1823 |
+
|
1824 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1825 |
+
|
1826 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
1827 |
+
break;
|
1828 |
+
}
|
1829 |
+
|
1830 |
+
}
|
1831 |
+
}
|
1832 |
+
|
1833 |
+
|
1834 |
+
/**
|
1835 |
+
* Set default filters
|
1836 |
+
*
|
1837 |
+
* @param $directory_data
|
1838 |
+
*/
|
1839 |
+
function default_filters( $directory_data ) {
|
1840 |
+
$default_filters = array();
|
1841 |
+
if ( ! empty( $directory_data['search_filters'] ) ) {
|
1842 |
+
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
1843 |
+
}
|
1844 |
+
|
1845 |
+
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
1846 |
+
|
1847 |
+
if ( empty( $default_filters ) ) {
|
1848 |
+
return;
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
foreach ( $default_filters as $field => $value ) {
|
1852 |
+
|
1853 |
+
switch ( $field ) {
|
1854 |
+
default:
|
1855 |
+
|
1856 |
+
$filter_type = $this->filter_types[ $field ];
|
1857 |
+
|
1858 |
+
/**
|
1859 |
+
* UM hook
|
1860 |
+
*
|
1861 |
+
* @type filter
|
1862 |
+
* @title um_query_args_{$field}__filter
|
1863 |
+
* @description Change field's query for search at Members Directory
|
1864 |
+
* @input_vars
|
1865 |
+
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
1866 |
+
* @change_log
|
1867 |
+
* ["Since: 2.0"]
|
1868 |
+
* @usage
|
1869 |
+
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
1870 |
+
* @example
|
1871 |
+
* <?php
|
1872 |
+
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
1873 |
+
* function my_query_args_filter( $field_query ) {
|
1874 |
+
* // your code here
|
1875 |
+
* return $field_query;
|
1876 |
+
* }
|
1877 |
+
* ?>
|
1878 |
+
*/
|
1879 |
+
$field_query = apply_filters( "um_query_args_{$field}__filter", false, $field, $value, $filter_type );
|
1880 |
+
|
1881 |
+
if ( ! $field_query ) {
|
1882 |
+
|
1883 |
+
switch ( $filter_type ) {
|
1884 |
+
default:
|
1885 |
+
|
1886 |
+
$field_query = apply_filters( "um_query_args_{$field}_{$filter_type}__filter", false, $field, $value, $filter_type );
|
1887 |
+
|
1888 |
+
break;
|
1889 |
+
|
1890 |
+
case 'text':
|
1891 |
+
|
1892 |
+
$field_query = array(
|
1893 |
+
'key' => $field,
|
1894 |
+
'value' => $value,
|
1895 |
+
'compare' => apply_filters( 'um_members_directory_filter_text', '=', $field ),
|
1896 |
+
);
|
1897 |
+
|
1898 |
+
break;
|
1899 |
+
|
1900 |
+
case 'select':
|
1901 |
+
if ( ! is_array( $value ) ) {
|
1902 |
+
$value = array( $value );
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
$field_query = array( 'relation' => 'OR' );
|
1906 |
+
|
1907 |
+
foreach ( $value as $single_val ) {
|
1908 |
+
$single_val = trim( $single_val );
|
1909 |
+
|
1910 |
+
$arr_meta_query = array(
|
1911 |
+
array(
|
1912 |
+
'key' => $field,
|
1913 |
+
'value' => $single_val,
|
1914 |
+
'compare' => '=',
|
1915 |
+
),
|
1916 |
+
array(
|
1917 |
+
'key' => $field,
|
1918 |
+
'value' => serialize( (string) $single_val ),
|
1919 |
+
'compare' => 'LIKE',
|
1920 |
+
),
|
1921 |
+
array(
|
1922 |
+
'key' => $field,
|
1923 |
+
'value' => '"' . $single_val . '"',
|
1924 |
+
'compare' => 'LIKE',
|
1925 |
+
)
|
1926 |
+
);
|
1927 |
+
|
1928 |
+
if ( is_numeric( $single_val ) ) {
|
1929 |
+
|
1930 |
+
$arr_meta_query[] = array(
|
1931 |
+
'key' => $field,
|
1932 |
+
'value' => serialize( (int) $single_val ),
|
1933 |
+
'compare' => 'LIKE',
|
1934 |
+
);
|
1935 |
+
|
1936 |
+
}
|
1937 |
+
|
1938 |
+
$field_query = array_merge( $field_query, $arr_meta_query );
|
1939 |
+
}
|
1940 |
+
|
1941 |
+
break;
|
1942 |
+
case 'slider':
|
1943 |
+
|
1944 |
+
$field_query = array(
|
1945 |
+
'key' => $field,
|
1946 |
+
'value' => $value,
|
1947 |
+
'compare' => 'BETWEEN',
|
1948 |
+
'inclusive' => true,
|
1949 |
+
);
|
1950 |
+
|
1951 |
+
break;
|
1952 |
+
case 'datepicker':
|
1953 |
+
|
1954 |
+
$offset = 0;
|
1955 |
+
if ( is_numeric( $gmt_offset ) ) {
|
1956 |
+
$offset = $gmt_offset;
|
1957 |
+
}
|
1958 |
+
|
1959 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1960 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1961 |
+
$field_query = array(
|
1962 |
+
'key' => $field,
|
1963 |
+
'value' => array( $from_date, $to_date ),
|
1964 |
+
'compare' => 'BETWEEN',
|
1965 |
+
'inclusive' => true,
|
1966 |
+
);
|
1967 |
+
|
1968 |
+
break;
|
1969 |
+
case 'timepicker':
|
1970 |
+
|
1971 |
+
if ( $value[0] == $value[1] ) {
|
1972 |
+
$field_query = array(
|
1973 |
+
'key' => $field,
|
1974 |
+
'value' => $value[0],
|
1975 |
+
);
|
1976 |
+
} else {
|
1977 |
+
$field_query = array(
|
1978 |
+
'key' => $field,
|
1979 |
+
'value' => $value,
|
1980 |
+
'compare' => 'BETWEEN',
|
1981 |
+
'type' => 'TIME',
|
1982 |
+
'inclusive' => true,
|
1983 |
+
);
|
1984 |
+
}
|
1985 |
+
|
1986 |
+
break;
|
1987 |
+
}
|
1988 |
+
|
1989 |
+
}
|
1990 |
+
|
1991 |
+
if ( ! empty( $field_query ) && $field_query !== true ) {
|
1992 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
1993 |
+
}
|
1994 |
+
|
1995 |
+
break;
|
1996 |
+
case 'role':
|
1997 |
+
$value = is_array( $value ) ? $value : explode( '||', $value );
|
1998 |
+
$value = array_map( 'strtolower', $value );
|
1999 |
+
|
2000 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
2001 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
2002 |
+
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
2003 |
+
$um_role = array_diff( $value, $default_role );
|
2004 |
+
|
2005 |
+
foreach ( $um_role as $key => &$val ) {
|
2006 |
+
$val = 'um_' . str_replace( ' ', '-', $val );
|
2007 |
+
}
|
2008 |
+
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
2009 |
+
} else {
|
2010 |
+
$this->query_args['role__in'] = $value;
|
2011 |
+
};
|
2012 |
+
|
2013 |
+
break;
|
2014 |
+
case 'birth_date':
|
2015 |
+
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
2016 |
+
$to_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ) + 1, date( 'Y', time() - ( max( $value ) + 1 ) * YEAR_IN_SECONDS ) ) );
|
2017 |
+
|
2018 |
+
$meta_query = array(
|
2019 |
+
array(
|
2020 |
+
'key' => 'birth_date',
|
2021 |
+
'value' => array( $to_date, $from_date ),
|
2022 |
+
'compare' => 'BETWEEN',
|
2023 |
+
'type' => 'DATE',
|
2024 |
+
'inclusive' => true,
|
2025 |
+
)
|
2026 |
+
);
|
2027 |
+
|
2028 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
2029 |
+
|
2030 |
+
break;
|
2031 |
+
case 'user_registered':
|
2032 |
+
$offset = 0;
|
2033 |
+
if ( is_numeric( $gmt_offset ) ) {
|
2034 |
+
$offset = $gmt_offset;
|
2035 |
+
}
|
2036 |
+
|
2037 |
+
$from_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', min( $value ) ) . "+$offset hours" ) );
|
2038 |
+
$to_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', max( $value ) ) . "+$offset hours" ) );
|
2039 |
+
|
2040 |
+
$date_query = array(
|
2041 |
+
array(
|
2042 |
+
'column' => 'user_registered',
|
2043 |
+
'before' => $to_date,
|
2044 |
+
'after' => $from_date,
|
2045 |
+
'inclusive' => true,
|
2046 |
+
),
|
2047 |
+
);
|
2048 |
+
|
2049 |
+
if ( empty( $this->query_args['date_query'] ) ) {
|
2050 |
+
$this->query_args['date_query'] = $date_query;
|
2051 |
+
} else {
|
2052 |
+
$this->query_args['date_query'] = array_merge( $this->query_args['date_query'], array( $date_query ) );
|
2053 |
+
}
|
2054 |
+
|
2055 |
+
break;
|
2056 |
+
case 'last_login':
|
2057 |
+
$offset = 0;
|
2058 |
+
if ( is_numeric( $gmt_offset ) ) {
|
2059 |
+
$offset = $gmt_offset;
|
2060 |
+
}
|
2061 |
+
|
2062 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
2063 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
2064 |
+
$meta_query = array(
|
2065 |
+
array(
|
2066 |
+
'key' => '_um_last_login',
|
2067 |
+
'value' => array( $from_date, $to_date ),
|
2068 |
+
'compare' => 'BETWEEN',
|
2069 |
+
'inclusive' => true,
|
2070 |
+
)
|
2071 |
+
);
|
2072 |
+
|
2073 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
2074 |
+
break;
|
2075 |
+
}
|
2076 |
+
}
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
|
2080 |
+
/**
|
2081 |
+
* Get data array for pagination
|
2082 |
+
*
|
2083 |
+
*
|
2084 |
+
* @param array $directory_data
|
2085 |
+
* @param int $total_users
|
2086 |
+
*
|
2087 |
+
* @return array
|
2088 |
+
*/
|
2089 |
+
function calculate_pagination( $directory_data, $total_users ) {
|
2090 |
+
|
2091 |
+
$current_page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
2092 |
+
|
2093 |
+
$total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
|
2094 |
+
|
2095 |
+
// number of profiles for mobile
|
2096 |
+
$profiles_per_page = $directory_data['profiles_per_page'];
|
2097 |
+
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
2098 |
+
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
2099 |
+
}
|
2100 |
+
|
2101 |
+
$total_pages = 1;
|
2102 |
+
if ( ! empty( $profiles_per_page ) ) {
|
2103 |
+
$total_pages = ceil( $total_users / $profiles_per_page );
|
2104 |
+
}
|
2105 |
+
|
2106 |
+
if ( ! empty( $total_pages ) ) {
|
2107 |
+
$index1 = 0 - ( $current_page - 2 ) + 1;
|
2108 |
+
$to = $current_page + 2;
|
2109 |
+
if ( $index1 > 0 ) {
|
2110 |
+
$to += $index1;
|
2111 |
+
}
|
2112 |
+
|
2113 |
+
$index2 = $total_pages - ( $current_page + 2 );
|
2114 |
+
$from = $current_page - 2;
|
2115 |
+
if ( $index2 < 0 ) {
|
2116 |
+
$from += $index2;
|
2117 |
+
}
|
2118 |
+
|
2119 |
+
$pages_to_show = range(
|
2120 |
+
( $from > 0 ) ? $from : 1,
|
2121 |
+
( $to <= $total_pages ) ? $to : $total_pages
|
2122 |
+
);
|
2123 |
+
}
|
2124 |
+
|
2125 |
+
|
2126 |
+
$pagination_data = array(
|
2127 |
+
'pages_to_show' => ( ! empty( $pages_to_show ) && count( $pages_to_show ) > 1 ) ? array_values( $pages_to_show ) : array(),
|
2128 |
+
'current_page' => $current_page,
|
2129 |
+
'total_pages' => $total_pages,
|
2130 |
+
'total_users' => $total_users,
|
2131 |
+
);
|
2132 |
+
|
2133 |
+
$pagination_data['header'] = $this->convert_tags( $directory_data['header'], $pagination_data );
|
2134 |
+
$pagination_data['header_single'] = $this->convert_tags( $directory_data['header_single'], $pagination_data );
|
2135 |
+
|
2136 |
+
return $pagination_data;
|
2137 |
+
}
|
2138 |
+
|
2139 |
+
|
2140 |
+
/**
|
2141 |
+
* @param int $user_id
|
2142 |
+
*
|
2143 |
+
* @return array
|
2144 |
+
*/
|
2145 |
+
function build_user_actions_list( $user_id ) {
|
2146 |
+
|
2147 |
+
$actions = array();
|
2148 |
+
if ( ! is_user_logged_in() ) {
|
2149 |
+
return $actions;
|
2150 |
+
}
|
2151 |
+
|
2152 |
+
if ( get_current_user_id() != $user_id ) {
|
2153 |
+
|
2154 |
+
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
2155 |
+
$actions['um-editprofile'] = array(
|
2156 |
+
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
2157 |
+
'url' => um_edit_profile_url(),
|
2158 |
+
);
|
2159 |
+
}
|
2160 |
+
|
2161 |
+
/**
|
2162 |
+
* UM hook
|
2163 |
+
*
|
2164 |
+
* @type filter
|
2165 |
+
* @title um_admin_user_actions_hook
|
2166 |
+
* @description Extend admin actions for each user
|
2167 |
+
* @input_vars
|
2168 |
+
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
2169 |
+
* @change_log
|
2170 |
+
* ["Since: 2.0"]
|
2171 |
+
* @usage
|
2172 |
+
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
2173 |
+
* @example
|
2174 |
+
* <?php
|
2175 |
+
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
2176 |
+
* function my_admin_user_actions( $actions ) {
|
2177 |
+
* // your code here
|
2178 |
+
* return $actions;
|
2179 |
+
* }
|
2180 |
+
* ?>
|
2181 |
+
*/
|
2182 |
+
$admin_actions = apply_filters( 'um_admin_user_actions_hook', array(), $user_id );
|
2183 |
+
if ( ! empty( $admin_actions ) ) {
|
2184 |
+
foreach ( $admin_actions as $id => $arr ) {
|
2185 |
+
$url = add_query_arg( array( 'um_action' => $id, 'uid' => $user_id ), um_get_core_page( 'user' ) );
|
2186 |
+
|
2187 |
+
$actions[ $id ] = array(
|
2188 |
+
'title' => $arr['label'],
|
2189 |
+
'url' => $url,
|
2190 |
+
);
|
2191 |
+
}
|
2192 |
+
}
|
2193 |
+
|
2194 |
+
$actions = apply_filters( 'um_member_directory_users_card_actions', $actions, $user_id );
|
2195 |
+
|
2196 |
+
} else {
|
2197 |
+
|
2198 |
+
if ( empty( UM()->user()->cannot_edit ) ) {
|
2199 |
+
$actions['um-editprofile'] = array(
|
2200 |
+
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
2201 |
+
'url' => um_edit_profile_url(),
|
2202 |
+
);
|
2203 |
+
}
|
2204 |
+
|
2205 |
+
$actions['um-myaccount'] = array(
|
2206 |
+
'title' => __( 'My Account', 'ultimate-member' ),
|
2207 |
+
'url' => um_get_core_page( 'account' ),
|
2208 |
+
);
|
2209 |
+
|
2210 |
+
$actions['um-logout'] = array(
|
2211 |
+
'title' => __( 'Logout', 'ultimate-member' ),
|
2212 |
+
'url' => um_get_core_page( 'logout' ),
|
2213 |
+
);
|
2214 |
+
|
2215 |
+
$actions = apply_filters( 'um_member_directory_my_user_card_actions', $actions, $user_id );
|
2216 |
+
}
|
2217 |
+
|
2218 |
+
|
2219 |
+
return $actions;
|
2220 |
+
}
|
2221 |
+
|
2222 |
+
|
2223 |
+
/**
|
2224 |
+
* @param int $user_id
|
2225 |
+
* @param array $directory_data
|
2226 |
+
*
|
2227 |
+
* @return array
|
2228 |
+
*/
|
2229 |
+
function build_user_card_data( $user_id, $directory_data ) {
|
2230 |
+
|
2231 |
+
um_fetch_user( $user_id );
|
2232 |
+
|
2233 |
+
$dropdown_actions = $this->build_user_actions_list( $user_id );
|
2234 |
+
|
2235 |
+
$actions = array();
|
2236 |
+
$can_edit = UM()->roles()->um_current_user_can( 'edit', $user_id );
|
2237 |
+
|
2238 |
+
// Replace hook 'um_members_just_after_name'
|
2239 |
+
ob_start();
|
2240 |
+
do_action( 'um_members_just_after_name', $user_id, $directory_data );
|
2241 |
+
$hook_just_after_name = ob_get_clean();
|
2242 |
+
|
2243 |
+
// Replace hook 'um_members_after_user_name'
|
2244 |
+
ob_start();
|
2245 |
+
do_action( 'um_members_after_user_name', $user_id, $directory_data );
|
2246 |
+
$hook_after_user_name = ob_get_clean();
|
2247 |
+
|
2248 |
+
$data_array = array(
|
2249 |
+
'card_anchor' => substr( md5( $user_id ), 10, 5 ),
|
2250 |
+
'id' => $user_id,
|
2251 |
+
'role' => um_user( 'role' ),
|
2252 |
+
'account_status' => um_user( 'account_status' ),
|
2253 |
+
'account_status_name' => um_user( 'account_status_name' ),
|
2254 |
+
'cover_photo' => um_user( 'cover_photo', $this->cover_size ),
|
2255 |
+
'display_name' => um_user( 'display_name' ),
|
2256 |
+
'profile_url' => um_user_profile_url(),
|
2257 |
+
'can_edit' => $can_edit,
|
2258 |
+
'edit_profile_url' => um_edit_profile_url(),
|
2259 |
+
'avatar' => get_avatar( $user_id, $this->avatar_size ),
|
2260 |
+
'display_name_html' => um_user( 'display_name', 'html' ),
|
2261 |
+
'dropdown_actions' => $dropdown_actions,
|
2262 |
+
'hook_just_after_name' => preg_replace( '/^\s+/im', '', $hook_just_after_name ),
|
2263 |
+
'hook_after_user_name' => preg_replace( '/^\s+/im', '', $hook_after_user_name ),
|
2264 |
+
);
|
2265 |
+
|
2266 |
+
if ( ! empty( $directory_data['show_tagline'] ) ) {
|
2267 |
+
|
2268 |
+
if ( ! empty( $directory_data['tagline_fields'] ) ) {
|
2269 |
+
$directory_data['tagline_fields'] = maybe_unserialize( $directory_data['tagline_fields'] );
|
2270 |
+
|
2271 |
+
if ( is_array( $directory_data['tagline_fields'] ) ) {
|
2272 |
+
foreach ( $directory_data['tagline_fields'] as $key ) {
|
2273 |
+
if ( ! $key ) {
|
2274 |
+
continue;
|
2275 |
+
}
|
2276 |
+
|
2277 |
+
$value = um_filtered_value( $key );
|
2278 |
+
|
2279 |
+
if ( ! $value ) {
|
2280 |
+
continue;
|
2281 |
+
}
|
2282 |
+
|
2283 |
+
$data_array[ $key ] = $value;
|
2284 |
+
}
|
2285 |
+
}
|
2286 |
+
}
|
2287 |
+
}
|
2288 |
+
|
2289 |
+
if ( ! empty( $directory_data['show_userinfo'] ) ) {
|
2290 |
+
|
2291 |
+
if ( ! empty( $directory_data['reveal_fields'] ) ) {
|
2292 |
+
|
2293 |
+
$directory_data['reveal_fields'] = maybe_unserialize( $directory_data['reveal_fields'] );
|
2294 |
+
|
2295 |
+
if ( is_array( $directory_data['reveal_fields'] ) ) {
|
2296 |
+
foreach ( $directory_data['reveal_fields'] as $key ) {
|
2297 |
+
if ( ! $key ) {
|
2298 |
+
continue;
|
2299 |
+
}
|
2300 |
+
|
2301 |
+
$value = um_filtered_value( $key );
|
2302 |
+
if ( ! $value ) {
|
2303 |
+
continue;
|
2304 |
+
}
|
2305 |
+
|
2306 |
+
$label = UM()->fields()->get_label( $key );
|
2307 |
+
if ( $key == 'role_select' || $key == 'role_radio' ) {
|
2308 |
+
$label = strtr( $label, array(
|
2309 |
+
' (Dropdown)' => '',
|
2310 |
+
' (Radio)' => ''
|
2311 |
+
) );
|
2312 |
+
}
|
2313 |
+
|
2314 |
+
$data_array[ "label_{$key}" ] = __( $label, 'ultimate-member' );
|
2315 |
+
$data_array[ $key ] = $value;
|
2316 |
+
}
|
2317 |
+
}
|
2318 |
+
}
|
2319 |
+
|
2320 |
+
if ( ! empty( $directory_data['show_social'] ) ) {
|
2321 |
+
ob_start();
|
2322 |
+
UM()->fields()->show_social_urls();
|
2323 |
+
$social_urls = ob_get_clean();
|
2324 |
+
|
2325 |
+
$data_array['social_urls'] = $social_urls;
|
2326 |
+
}
|
2327 |
+
}
|
2328 |
+
|
2329 |
+
$data_array = apply_filters( 'um_ajax_get_members_data', $data_array, $user_id, $directory_data );
|
2330 |
+
|
2331 |
+
um_reset_user_clean();
|
2332 |
+
|
2333 |
+
return $data_array;
|
2334 |
+
}
|
2335 |
+
|
2336 |
+
|
2337 |
+
/**
|
2338 |
+
* Update limit query
|
2339 |
+
*
|
2340 |
+
* @param $user_query
|
2341 |
+
*/
|
2342 |
+
function pagination_changes( $user_query ) {
|
2343 |
+
global $wpdb;
|
2344 |
+
|
2345 |
+
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
2346 |
+
$directory_data = UM()->query()->post_data( $directory_id );
|
2347 |
+
|
2348 |
+
$qv = $user_query->query_vars;
|
2349 |
+
|
2350 |
+
$number = $qv['number'];
|
2351 |
+
if ( ! empty( $directory_data['max_users'] ) && $qv['paged']*$qv['number'] > $directory_data['max_users'] ) {
|
2352 |
+
$number = ( $qv['paged']*$qv['number'] - ( $qv['paged']*$qv['number'] - $directory_data['max_users'] ) ) % $qv['number'];
|
2353 |
+
}
|
2354 |
+
|
2355 |
+
// limit
|
2356 |
+
if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
|
2357 |
+
if ( $qv['offset'] ) {
|
2358 |
+
$user_query->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $number );
|
2359 |
+
} else {
|
2360 |
+
$user_query->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $number );
|
2361 |
+
}
|
2362 |
+
}
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
|
2366 |
+
function predefined_no_caps( $directory_data ) {
|
2367 |
+
//predefined result for user without capabilities to see other members
|
2368 |
+
if ( is_user_logged_in() && ! UM()->roles()->um_user_can( 'can_view_all' ) ) {
|
2369 |
+
$pagination_data = array(
|
2370 |
+
'pages_to_show' => array(),
|
2371 |
+
'current_page' => 1,
|
2372 |
+
'total_pages' => 0,
|
2373 |
+
'total_users' => 0,
|
2374 |
+
);
|
2375 |
+
|
2376 |
+
$pagination_data['header'] = $this->convert_tags( $directory_data['header'], $pagination_data );
|
2377 |
+
$pagination_data['header_single'] = $this->convert_tags( $directory_data['header_single'], $pagination_data );
|
2378 |
+
|
2379 |
+
wp_send_json_success( array( 'users' => array(), 'pagination' => $pagination_data ) );
|
2380 |
+
}
|
2381 |
+
}
|
2382 |
+
|
2383 |
+
|
2384 |
+
/**
|
2385 |
+
* Main Query function for getting members via AJAX
|
2386 |
+
*/
|
2387 |
+
function ajax_get_members() {
|
2388 |
+
UM()->check_ajax_nonce();
|
2389 |
+
|
2390 |
+
global $wpdb;
|
2391 |
+
|
2392 |
+
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
2393 |
+
$directory_data = UM()->query()->post_data( $directory_id );
|
2394 |
+
|
2395 |
+
//predefined result for user without capabilities to see other members
|
2396 |
+
$this->predefined_no_caps( $directory_data );
|
2397 |
+
|
2398 |
+
do_action( 'um_member_directory_before_query' );
|
2399 |
+
|
2400 |
+
// Prepare for BIG SELECT query
|
2401 |
+
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
|
2402 |
+
|
2403 |
+
// Prepare default user query values
|
2404 |
+
$this->query_args = array(
|
2405 |
+
'fields' => 'ids',
|
2406 |
+
'number' => 0,
|
2407 |
+
'meta_query' => array(
|
2408 |
+
'relation' => 'AND'
|
2409 |
+
),
|
2410 |
+
);
|
2411 |
+
|
2412 |
+
|
2413 |
+
// handle different restrictions
|
2414 |
+
$this->restriction_options();
|
2415 |
+
|
2416 |
+
// handle general options
|
2417 |
+
$this->general_options( $directory_data );
|
2418 |
+
|
2419 |
+
// handle pagination options
|
2420 |
+
$this->pagination_options( $directory_data );
|
2421 |
+
|
2422 |
+
// handle sorting options
|
2423 |
+
$this->sorting_query( $directory_data );
|
2424 |
+
|
2425 |
+
// handle general search line
|
2426 |
+
$this->general_search();
|
2427 |
+
|
2428 |
+
// handle filters
|
2429 |
+
$this->filters( $directory_data );
|
2430 |
+
|
2431 |
+
$this->default_filters( $directory_data );
|
2432 |
+
|
2433 |
+
/**
|
2434 |
+
* UM hook
|
2435 |
+
*
|
2436 |
+
* @type filter
|
2437 |
+
* @title um_prepare_user_query_args
|
2438 |
+
* @description Extend member directory query arguments
|
2439 |
+
* @input_vars
|
2440 |
+
* [{"var":"$query_args","type":"array","desc":"Members Query Arguments"},
|
2441 |
+
* {"var":"$directory_settings","type":"array","desc":"Member Directory Settings"}]
|
2442 |
+
* @change_log
|
2443 |
+
* ["Since: 2.0"]
|
2444 |
+
* @usage
|
2445 |
+
* <?php add_filter( 'um_prepare_user_query_args', 'function_name', 10, 2 ); ?>
|
2446 |
+
* @example
|
2447 |
+
* <?php
|
2448 |
+
* add_filter( 'um_prepare_user_query_args', 'my_prepare_user_query_args', 10, 2 );
|
2449 |
+
* function my_prepare_user_query_args( $query_args, $directory_settings ) {
|
2450 |
+
* // your code here
|
2451 |
+
* return $query_args;
|
2452 |
+
* }
|
2453 |
+
* ?>
|
2454 |
+
*/
|
2455 |
+
$this->query_args = apply_filters( 'um_prepare_user_query_args', $this->query_args, $directory_data );
|
2456 |
+
|
2457 |
+
//unset empty meta_query attribute
|
2458 |
+
if ( isset( $this->query_args['meta_query']['relation'] ) && count( $this->query_args['meta_query'] ) == 1 ) {
|
2459 |
+
unset( $this->query_args['meta_query'] );
|
2460 |
+
}
|
2461 |
+
|
2462 |
+
if ( isset( $this->query_args['role__in'] ) && empty( $this->query_args['role__in'] ) ) {
|
2463 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
2464 |
+
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
|
2465 |
+
'users' => array(),
|
2466 |
+
'is_search' => $this->is_search,
|
2467 |
+
), $directory_data );
|
2468 |
+
|
2469 |
+
wp_send_json_success( $member_directory_response );
|
2470 |
+
}
|
2471 |
+
|
2472 |
+
/**
|
2473 |
+
* UM hook
|
2474 |
+
*
|
2475 |
+
* @type action
|
2476 |
+
* @title um_user_before_query
|
2477 |
+
* @description Action before users query on member directory
|
2478 |
+
* @input_vars
|
2479 |
+
* [{"var":"$query_args","type":"array","desc":"Query arguments"},
|
2480 |
+
* {"var":"$md_class","type":"um\core\Member_Directory","desc":"Member Directory class"}]
|
2481 |
+
* @change_log
|
2482 |
+
* ["Since: 2.0"]
|
2483 |
+
* @usage add_action( 'um_user_before_query', 'function_name', 10, 1 );
|
2484 |
+
* @example
|
2485 |
+
* <?php
|
2486 |
+
* add_action( 'um_user_before_query', 'my_user_before_query', 10, 1 );
|
2487 |
+
* function my_user_before_query( $query_args ) {
|
2488 |
+
* // your code here
|
2489 |
+
* }
|
2490 |
+
* ?>
|
2491 |
+
*/
|
2492 |
+
do_action( 'um_user_before_query', $this->query_args, $this );
|
2493 |
+
|
2494 |
+
add_filter( 'get_meta_sql', array( &$this, 'change_meta_sql' ), 10, 6 );
|
2495 |
+
|
2496 |
+
add_filter( 'pre_user_query', array( &$this, 'pagination_changes' ), 10, 1 );
|
2497 |
+
|
2498 |
+
$user_query = new \WP_User_Query( $this->query_args );
|
2499 |
+
|
2500 |
+
remove_filter( 'pre_user_query', array( &$this, 'pagination_changes' ), 10 );
|
2501 |
+
|
2502 |
+
remove_filter( 'get_meta_sql', array( &$this, 'change_meta_sql' ), 10 );
|
2503 |
+
|
2504 |
+
/**
|
2505 |
+
* UM hook
|
2506 |
+
*
|
2507 |
+
* @type action
|
2508 |
+
* @title um_user_after_query
|
2509 |
+
* @description Action before users query on member directory
|
2510 |
+
* @input_vars
|
2511 |
+
* [{"var":"$query_args","type":"array","desc":"Query arguments"},
|
2512 |
+
* {"var":"$user_query","type":"array","desc":"User Query"}]
|
2513 |
+
* @change_log
|
2514 |
+
* ["Since: 2.0"]
|
2515 |
+
* @usage add_action( 'um_user_after_query', 'function_name', 10, 2 );
|
2516 |
+
* @example
|
2517 |
+
* <?php
|
2518 |
+
* add_action( 'um_user_after_query', 'my_user_after_query', 10, 2 );
|
2519 |
+
* function my_user_after_query( $query_args, $user_query ) {
|
2520 |
+
* // your code here
|
2521 |
+
* }
|
2522 |
+
* ?>
|
2523 |
+
*/
|
2524 |
+
do_action( 'um_user_after_query', $this->query_args, $user_query );
|
2525 |
+
|
2526 |
+
$pagination_data = $this->calculate_pagination( $directory_data, $user_query->total_users );
|
2527 |
+
|
2528 |
+
$user_ids = ! empty( $user_query->results ) ? array_unique( $user_query->results ) : array();
|
2529 |
+
|
2530 |
+
/**
|
2531 |
+
* UM hook
|
2532 |
+
*
|
2533 |
+
* @type filter
|
2534 |
+
* @title um_prepare_user_results_array
|
2535 |
+
* @description Extend member directory query result
|
2536 |
+
* @input_vars
|
2537 |
+
* [{"var":"$result","type":"array","desc":"Members Query Result"}]
|
2538 |
+
* @change_log
|
2539 |
+
* ["Since: 2.0"]
|
2540 |
+
* @usage
|
2541 |
+
* <?php add_filter( 'um_prepare_user_results_array', 'function_name', 10, 2 ); ?>
|
2542 |
+
* @example
|
2543 |
+
* <?php
|
2544 |
+
* add_filter( 'um_prepare_user_results_array', 'my_prepare_user_results', 10, 2 );
|
2545 |
+
* function my_prepare_user_results( $user_ids, $query ) {
|
2546 |
+
* // your code here
|
2547 |
+
* return $user_ids;
|
2548 |
+
* }
|
2549 |
+
* ?>
|
2550 |
+
*/
|
2551 |
+
$user_ids = apply_filters( 'um_prepare_user_results_array', $user_ids, $this->query_args );
|
2552 |
+
|
2553 |
+
|
2554 |
+
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
2555 |
+
|
2556 |
+
$this->cover_size = UM()->mobile()->isTablet() ? $sizes[1] : end( $sizes );
|
2557 |
+
|
2558 |
+
$this->cover_size = apply_filters( 'um_member_directory_cover_image_size', $this->cover_size, $directory_data );
|
2559 |
+
|
2560 |
+
$avatar_size = UM()->options()->get( 'profile_photosize' );
|
2561 |
+
$this->avatar_size = str_replace( 'px', '', $avatar_size );
|
2562 |
+
$this->avatar_size = apply_filters( 'um_member_directory_avatar_image_size', $this->avatar_size, $directory_data );
|
2563 |
+
|
2564 |
+
$users = array();
|
2565 |
+
foreach ( $user_ids as $user_id ) {
|
2566 |
+
$users[] = $this->build_user_card_data( $user_id, $directory_data );
|
2567 |
+
}
|
2568 |
+
|
2569 |
+
um_reset_user();
|
2570 |
+
// end of user card
|
2571 |
+
|
2572 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
2573 |
+
'pagination' => $pagination_data,
|
2574 |
+
'users' => $users,
|
2575 |
+
'is_search' => $this->is_search,
|
2576 |
+
), $directory_data );
|
2577 |
+
|
2578 |
+
wp_send_json_success( $member_directory_response );
|
2579 |
+
}
|
2580 |
+
|
2581 |
+
|
2582 |
+
/**
|
2583 |
+
* New menu
|
2584 |
+
*
|
2585 |
+
* @param string $element
|
2586 |
+
* @param string $trigger
|
2587 |
+
* @param array $items
|
2588 |
+
*/
|
2589 |
+
function dropdown_menu( $element, $trigger, $items = array() ) {
|
2590 |
+
// !!!!Important: all links in the dropdown items must have "class" attribute
|
2591 |
+
?>
|
2592 |
+
|
2593 |
+
<div class="um-new-dropdown" data-element="<?php echo $element; ?>" data-trigger="<?php echo $trigger; ?>">
|
2594 |
+
<ul>
|
2595 |
+
<?php foreach ( $items as $k => $v ) { ?>
|
2596 |
+
<li><?php echo $v; ?></li>
|
2597 |
+
<?php } ?>
|
2598 |
+
</ul>
|
2599 |
+
</div>
|
2600 |
+
|
2601 |
+
<?php
|
2602 |
+
}
|
2603 |
+
|
2604 |
+
|
2605 |
+
/**
|
2606 |
+
* New menu JS
|
2607 |
+
*
|
2608 |
+
* @param string $element
|
2609 |
+
* @param string $trigger
|
2610 |
+
* @param string $item
|
2611 |
+
* @param string $additional_attributes
|
2612 |
+
*/
|
2613 |
+
function dropdown_menu_js( $element, $trigger, $item, $additional_attributes = '' ) {
|
2614 |
+
?>
|
2615 |
+
|
2616 |
+
<div class="um-new-dropdown" data-element="<?php echo $element; ?>" data-trigger="<?php echo $trigger; ?>">
|
2617 |
+
<ul>
|
2618 |
+
<# _.each( <?php echo $item; ?>.dropdown_actions, function( action, key, list ) { #>
|
2619 |
+
<li><a href="<# if ( typeof action.url != 'undefined' ) { #>{{{action.url}}}<# } else { #>javascript:void(0);<# }#>" class="{{{key}}}"<?php echo $additional_attributes ? " $additional_attributes" : '' ?>>{{{action.title}}}</a></li>
|
2620 |
+
<# }); #>
|
2621 |
+
</ul>
|
2622 |
+
</div>
|
2623 |
+
|
2624 |
+
<?php
|
2625 |
+
}
|
2626 |
+
|
2627 |
+
|
2628 |
+
/**
|
2629 |
+
* AJAX handler - Get options for the member directory "Admin filtering"
|
2630 |
+
* @version 2.1.12
|
2631 |
+
*/
|
2632 |
+
function default_filter_settings() {
|
2633 |
+
UM()->admin()->check_ajax_nonce();
|
2634 |
+
|
2635 |
+
// we can't use function "sanitize_key" because it changes uppercase to lowercase
|
2636 |
+
$filter_key = sanitize_text_field( $_REQUEST['key'] );
|
2637 |
+
$directory_id = absint( $_REQUEST['directory_id'] );
|
2638 |
+
|
2639 |
+
$html = $this->show_filter( $filter_key, array( 'form_id' => $directory_id ), false, true );
|
2640 |
+
|
2641 |
+
wp_send_json_success( array( 'field_html' => $html ) );
|
2642 |
+
}
|
2643 |
+
}
|
2644 |
+
}
|
includes/core/class-password.php
CHANGED
@@ -1,716 +1,721 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
// Exit if accessed directly
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
-
|
8 |
-
|
9 |
-
if ( ! class_exists( 'um\core\Password' ) ) {
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Password
|
14 |
-
* @package um\core
|
15 |
-
*/
|
16 |
-
class Password {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Password constructor.
|
21 |
-
*/
|
22 |
-
function __construct() {
|
23 |
-
add_shortcode( 'ultimatemember_password', array( &$this, 'ultimatemember_password' ) );
|
24 |
-
|
25 |
-
add_action( 'template_redirect', array( &$this, 'form_init' ), 10001 );
|
26 |
-
|
27 |
-
add_action( 'um_reset_password_errors_hook', array( &$this, 'um_reset_password_errors_hook' ) );
|
28 |
-
add_action( 'um_reset_password_process_hook', array( &$this,'um_reset_password_process_hook' ) );
|
29 |
-
|
30 |
-
add_action( 'um_change_password_errors_hook', array( &$this, 'um_change_password_errors_hook' ) );
|
31 |
-
add_action( 'um_change_password_process_hook', array( &$this,'um_change_password_process_hook' ) );
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Get Reset URL
|
37 |
-
*
|
38 |
-
* @return bool|string
|
39 |
-
*/
|
40 |
-
function reset_url() {
|
41 |
-
$user_id = um_user( 'ID' );
|
42 |
-
|
43 |
-
delete_option( "um_cache_userdata_{$user_id}" );
|
44 |
-
|
45 |
-
//new reset password key via WP native field
|
46 |
-
$user_data = get_userdata( $user_id );
|
47 |
-
$key = UM()->user()->maybe_generate_password_reset_key( $user_data );
|
48 |
-
|
49 |
-
$url = add_query_arg( array( 'act' => 'reset_password', 'hash' => $key, 'user_id' => $user_id ), um_get_core_page( 'password-reset' ) );
|
50 |
-
return $url;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Add class based on shortcode
|
56 |
-
*
|
57 |
-
* @param string $mode
|
58 |
-
*
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
function get_class( $mode ) {
|
62 |
-
|
63 |
-
$classes = 'um-'.$mode;
|
64 |
-
|
65 |
-
if ( is_admin() ) {
|
66 |
-
$classes .= ' um-in-admin';
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( UM()->fields()->editing == true ) {
|
70 |
-
$classes .= ' um-editing';
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( UM()->fields()->viewing == true ) {
|
74 |
-
$classes .= ' um-viewing';
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* UM hook
|
79 |
-
*
|
80 |
-
* @type filter
|
81 |
-
* @title um_form_official_classes__hook
|
82 |
-
* @description Change form additional classes
|
83 |
-
* @input_vars
|
84 |
-
* [{"var":"$classes","type":"string","desc":"Form additional classes"}]
|
85 |
-
* @change_log
|
86 |
-
* ["Since: 2.0"]
|
87 |
-
* @usage
|
88 |
-
* <?php add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 ); ?>
|
89 |
-
* @example
|
90 |
-
* <?php
|
91 |
-
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
92 |
-
* function my_form_official_classes( $classes ) {
|
93 |
-
* // your code here
|
94 |
-
* return $classes;
|
95 |
-
* }
|
96 |
-
* ?>
|
97 |
-
*/
|
98 |
-
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
99 |
-
return $classes;
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Shortcode
|
105 |
-
*
|
106 |
-
* @param array $args
|
107 |
-
*
|
108 |
-
* @return string
|
109 |
-
*/
|
110 |
-
function ultimatemember_password( $args = array() ) {
|
111 |
-
ob_start();
|
112 |
-
|
113 |
-
$defaults = array(
|
114 |
-
'template' => 'password-reset',
|
115 |
-
'mode' => 'password',
|
116 |
-
'form_id' => 'um_password_id',
|
117 |
-
'max_width' => '450px',
|
118 |
-
'align' => 'center',
|
119 |
-
);
|
120 |
-
$args = wp_parse_args( $args, $defaults );
|
121 |
-
|
122 |
-
if ( empty( $args['use_custom_settings'] ) ) {
|
123 |
-
$args = array_merge( $args, UM()->shortcodes()->get_css_args( $args ) );
|
124 |
-
} else {
|
125 |
-
$args = array_merge( UM()->shortcodes()->get_css_args( $args ), $args );
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* UM hook
|
130 |
-
*
|
131 |
-
* @type filter
|
132 |
-
* @title um_reset_password_shortcode_args_filter
|
133 |
-
* @description Extend Reset Password Arguments
|
134 |
-
* @input_vars
|
135 |
-
* [{"var":"$args","type":"array","desc":"Shortcode arguments"}]
|
136 |
-
* @change_log
|
137 |
-
* ["Since: 2.0"]
|
138 |
-
* @usage
|
139 |
-
* <?php add_filter( 'um_reset_password_shortcode_args_filter', 'function_name', 10, 1 ); ?>
|
140 |
-
* @example
|
141 |
-
* <?php
|
142 |
-
* add_filter( 'um_reset_password_shortcode_args_filter', 'my_reset_password_shortcode_args', 10, 1 );
|
143 |
-
* function my_reset_password_shortcode_args( $args ) {
|
144 |
-
* // your code here
|
145 |
-
* return $args;
|
146 |
-
* }
|
147 |
-
* ?>
|
148 |
-
*/
|
149 |
-
$args = apply_filters( 'um_reset_password_shortcode_args_filter', $args );
|
150 |
-
|
151 |
-
if ( isset( $this->change_password ) ) {
|
152 |
-
$args['template'] = 'password-change';
|
153 |
-
$args['rp_key'] = '';
|
154 |
-
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
155 |
-
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
156 |
-
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
157 |
-
|
158 |
-
$user = get_user_by( 'login', $rp_login );
|
159 |
-
$args['user_id'] = $user->ID;
|
160 |
-
$args['rp_key'] = $rp_key;
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
UM()->fields()->set_id = 'um_password_id';
|
165 |
-
|
166 |
-
/**
|
167 |
-
* @var $mode
|
168 |
-
* @var $template
|
169 |
-
*/
|
170 |
-
extract( $args, EXTR_SKIP );
|
171 |
-
|
172 |
-
/**
|
173 |
-
* UM hook
|
174 |
-
*
|
175 |
-
* @type action
|
176 |
-
* @title um_pre_{$mode}_shortcode
|
177 |
-
* @description Action pre-load password form shortcode
|
178 |
-
* @input_vars
|
179 |
-
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
180 |
-
* @change_log
|
181 |
-
* ["Since: 2.0"]
|
182 |
-
* @usage add_action( 'um_pre_{$mode}_shortcode', 'function_name', 10, 1 );
|
183 |
-
* @example
|
184 |
-
* <?php
|
185 |
-
* add_action( 'um_pre_{$mode}_shortcode', 'my_pre_password_shortcode', 10, 1 );
|
186 |
-
* function my_pre_password_shortcode( $args ) {
|
187 |
-
* // your code here
|
188 |
-
* }
|
189 |
-
* ?>
|
190 |
-
*/
|
191 |
-
do_action( "um_pre_{$mode}_shortcode", $args );
|
192 |
-
/**
|
193 |
-
* UM hook
|
194 |
-
*
|
195 |
-
* @type action
|
196 |
-
* @title um_before_form_is_loaded
|
197 |
-
* @description Action pre-load password form shortcode
|
198 |
-
* @input_vars
|
199 |
-
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
200 |
-
* @change_log
|
201 |
-
* ["Since: 2.0"]
|
202 |
-
* @usage add_action( 'um_before_form_is_loaded', 'function_name', 10, 1 );
|
203 |
-
* @example
|
204 |
-
* <?php
|
205 |
-
* add_action( 'um_before_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
206 |
-
* function my_before_form_is_loaded( $args ) {
|
207 |
-
* // your code here
|
208 |
-
* }
|
209 |
-
* ?>
|
210 |
-
*/
|
211 |
-
do_action( "um_before_form_is_loaded", $args );
|
212 |
-
/**
|
213 |
-
* UM hook
|
214 |
-
*
|
215 |
-
* @type action
|
216 |
-
* @title um_before_{$mode}_form_is_loaded
|
217 |
-
* @description Action pre-load password form shortcode
|
218 |
-
* @input_vars
|
219 |
-
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
220 |
-
* @change_log
|
221 |
-
* ["Since: 2.0"]
|
222 |
-
* @usage add_action( 'um_before_{$mode}_form_is_loaded', 'function_name', 10, 1 );
|
223 |
-
* @example
|
224 |
-
* <?php
|
225 |
-
* add_action( 'um_before_{$mode}_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
226 |
-
* function my_before_form_is_loaded( $args ) {
|
227 |
-
* // your code here
|
228 |
-
* }
|
229 |
-
* ?>
|
230 |
-
*/
|
231 |
-
do_action( "um_before_{$mode}_form_is_loaded", $args );
|
232 |
-
|
233 |
-
UM()->shortcodes()->template_load( $template, $args );
|
234 |
-
|
235 |
-
if ( ! is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
236 |
-
UM()->shortcodes()->dynamic_css( $args );
|
237 |
-
}
|
238 |
-
|
239 |
-
$output = ob_get_clean();
|
240 |
-
return $output;
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Check if a legitimate password reset request is in action
|
246 |
-
*
|
247 |
-
* @return bool
|
248 |
-
*/
|
249 |
-
function is_reset_request() {
|
250 |
-
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
|
251 |
-
return true;
|
252 |
-
}
|
253 |
-
|
254 |
-
return false;
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Check if a legitimate password change request is in action
|
260 |
-
*
|
261 |
-
*
|
262 |
-
* @return bool
|
263 |
-
*/
|
264 |
-
function is_change_request() {
|
265 |
-
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
|
266 |
-
return true;
|
267 |
-
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
268 |
-
return true;
|
269 |
-
}
|
270 |
-
|
271 |
-
return false;
|
272 |
-
}
|
273 |
-
|
274 |
-
|
275 |
-
/**
|
276 |
-
* Password page form
|
277 |
-
*/
|
278 |
-
public function form_init() {
|
279 |
-
if ( um_is_core_page( 'password-reset' ) ) {
|
280 |
-
UM()->fields()->set_mode = 'password';
|
281 |
-
}
|
282 |
-
|
283 |
-
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
|
284 |
-
wp_fix_server_vars();
|
285 |
-
|
286 |
-
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
287 |
-
|
288 |
-
if ( isset( $_GET['hash'] ) ) {
|
289 |
-
$userdata = get_userdata( wp_unslash( absint( $_GET['user_id'] ) ) );
|
290 |
-
if ( ! $userdata || is_wp_error( $userdata ) ) {
|
291 |
-
wp_redirect( add_query_arg( array( 'act' => 'reset_password', 'error' => 'invalidkey' ), get_permalink() ) );
|
292 |
-
exit;
|
293 |
-
}
|
294 |
-
$rp_login = $userdata->user_login;
|
295 |
-
$rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
|
296 |
-
|
297 |
-
$user = check_password_reset_key( $rp_key, $rp_login );
|
298 |
-
|
299 |
-
if ( is_wp_error( $user ) ) {
|
300 |
-
$this->setcookie( $rp_cookie, false );
|
301 |
-
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
302 |
-
} else {
|
303 |
-
$value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
|
304 |
-
$this->setcookie( $rp_cookie, $value );
|
305 |
-
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
|
306 |
-
}
|
307 |
-
|
308 |
-
exit;
|
309 |
-
}
|
310 |
-
|
311 |
-
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
312 |
-
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
313 |
-
$user = check_password_reset_key( $rp_key, $rp_login );
|
314 |
-
} else {
|
315 |
-
$user = false;
|
316 |
-
}
|
317 |
-
|
318 |
-
if ( ( ! $user || is_wp_error( $user ) ) && ! isset( $_GET['updated'] ) ) {
|
319 |
-
$this->setcookie( $rp_cookie, false );
|
320 |
-
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
321 |
-
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
322 |
-
} else {
|
323 |
-
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
324 |
-
}
|
325 |
-
exit;
|
326 |
-
}
|
327 |
-
|
328 |
-
$this->change_password = true;
|
329 |
-
}
|
330 |
-
|
331 |
-
if ( $this->is_reset_request() ) {
|
332 |
-
|
333 |
-
UM()->form()->post_form = $_POST;
|
334 |
-
|
335 |
-
if ( empty( UM()->form()->post_form['mode'] ) ) {
|
336 |
-
UM()->form()->post_form['mode'] = 'password';
|
337 |
-
}
|
338 |
-
|
339 |
-
/**
|
340 |
-
* UM hook
|
341 |
-
*
|
342 |
-
* @type action
|
343 |
-
* @title um_reset_password_errors_hook
|
344 |
-
* @description Action on reset password submit form
|
345 |
-
* @input_vars
|
346 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
347 |
-
* @change_log
|
348 |
-
* ["Since: 2.0"]
|
349 |
-
* @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 );
|
350 |
-
* @example
|
351 |
-
* <?php
|
352 |
-
* add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
|
353 |
-
* function my_reset_password_errors( $post ) {
|
354 |
-
* // your code here
|
355 |
-
* }
|
356 |
-
* ?>
|
357 |
-
*/
|
358 |
-
do_action( 'um_reset_password_errors_hook', UM()->form()->post_form );
|
359 |
-
|
360 |
-
if ( ! isset( UM()->form()->errors ) ) {
|
361 |
-
|
362 |
-
/**
|
363 |
-
* UM hook
|
364 |
-
*
|
365 |
-
* @type action
|
366 |
-
* @title um_reset_password_process_hook
|
367 |
-
* @description Action on reset password success submit form
|
368 |
-
* @input_vars
|
369 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
370 |
-
* @change_log
|
371 |
-
* ["Since: 2.0"]
|
372 |
-
* @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 );
|
373 |
-
* @example
|
374 |
-
* <?php
|
375 |
-
* add_action( 'um_reset_password_process_hook', 'my_reset_password_process', 10, 1 );
|
376 |
-
* function my_reset_password_process( $post ) {
|
377 |
-
* // your code here
|
378 |
-
* }
|
379 |
-
* ?>
|
380 |
-
*/
|
381 |
-
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
382 |
-
|
383 |
-
}
|
384 |
-
}
|
385 |
-
|
386 |
-
if ( $this->is_change_request() ) {
|
387 |
-
UM()->form()->post_form = $_POST;
|
388 |
-
|
389 |
-
/**
|
390 |
-
* UM hook
|
391 |
-
*
|
392 |
-
* @type action
|
393 |
-
* @title um_change_password_errors_hook
|
394 |
-
* @description Action on change password submit form
|
395 |
-
* @input_vars
|
396 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
397 |
-
* @change_log
|
398 |
-
* ["Since: 2.0"]
|
399 |
-
* @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 );
|
400 |
-
* @example
|
401 |
-
* <?php
|
402 |
-
* add_action( 'um_change_password_errors_hook', 'my_change_password_errors', 10, 1 );
|
403 |
-
* function my_change_password_errors( $post ) {
|
404 |
-
* // your code here
|
405 |
-
* }
|
406 |
-
* ?>
|
407 |
-
*/
|
408 |
-
do_action( 'um_change_password_errors_hook', UM()->form()->post_form );
|
409 |
-
|
410 |
-
if ( ! isset( UM()->form()->errors ) ) {
|
411 |
-
|
412 |
-
/**
|
413 |
-
* UM hook
|
414 |
-
*
|
415 |
-
* @type action
|
416 |
-
* @title um_change_password_process_hook
|
417 |
-
* @description Action on change password success submit form
|
418 |
-
* @input_vars
|
419 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
420 |
-
* @change_log
|
421 |
-
* ["Since: 2.0"]
|
422 |
-
* @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 );
|
423 |
-
* @example
|
424 |
-
* <?php
|
425 |
-
* add_action( 'um_change_password_process_hook', 'my_change_password_process', 10, 1 );
|
426 |
-
* function my_change_password_process( $post ) {
|
427 |
-
* // your code here
|
428 |
-
* }
|
429 |
-
* ?>
|
430 |
-
*/
|
431 |
-
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
432 |
-
|
433 |
-
}
|
434 |
-
}
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
/**
|
439 |
-
* Error handler: reset password
|
440 |
-
*
|
441 |
-
* @param $args
|
442 |
-
*/
|
443 |
-
public function um_reset_password_errors_hook( $args ) {
|
444 |
-
if ( '' !== $args[ UM()->honeypot ] ) {
|
445 |
-
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
446 |
-
}
|
447 |
-
|
448 |
-
$user = '';
|
449 |
-
|
450 |
-
foreach ( $args as $key => $val ) {
|
451 |
-
if ( strstr( $key, 'username_b' ) ) {
|
452 |
-
$user = trim( sanitize_text_field( $val ) );
|
453 |
-
}
|
454 |
-
}
|
455 |
-
|
456 |
-
if ( empty( $user ) ) {
|
457 |
-
UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
|
458 |
-
}
|
459 |
-
|
460 |
-
if ( ( ! is_email( $user ) && ! username_exists( $user ) ) || ( is_email( $user ) && ! email_exists( $user ) ) ) {
|
461 |
-
UM()->form()->add_error( 'username_b', __( 'We can\'t find an account registered with that address or username', 'ultimate-member' ) );
|
462 |
-
} else {
|
463 |
-
|
464 |
-
if ( is_email( $user ) ) {
|
465 |
-
$user_id = email_exists( $user );
|
466 |
-
} else {
|
467 |
-
$user_id = username_exists( $user );
|
468 |
-
}
|
469 |
-
|
470 |
-
$attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
|
471 |
-
$is_admin = user_can( absint( $user_id ), 'manage_options' );
|
472 |
-
|
473 |
-
if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
|
474 |
-
|
475 |
-
if ( ! ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) ) {
|
476 |
-
// Doesn't trigger this when a user has admin capabilities and when reset password limit is disabled for admins
|
477 |
-
$limit = UM()->options()->get( 'reset_password_limit_number' );
|
478 |
-
if ( $attempts >= $limit ) {
|
479 |
-
UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email', 'ultimate-member' ) );
|
480 |
-
} else {
|
481 |
-
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
|
482 |
-
}
|
483 |
-
}
|
484 |
-
}
|
485 |
-
}
|
486 |
-
|
487 |
-
}
|
488 |
-
|
489 |
-
|
490 |
-
/**
|
491 |
-
* Process a new request
|
492 |
-
*
|
493 |
-
* @param $args
|
494 |
-
*/
|
495 |
-
public function um_reset_password_process_hook( $args ) {
|
496 |
-
$user = null;
|
497 |
-
|
498 |
-
foreach ( $args as $key => $val ) {
|
499 |
-
if ( strstr( $key, 'username_b' ) ) {
|
500 |
-
$user = trim( sanitize_text_field( $val ) );
|
501 |
-
}
|
502 |
-
}
|
503 |
-
|
504 |
-
if ( username_exists( $user ) ) {
|
505 |
-
$data = get_user_by( 'login', $user );
|
506 |
-
} elseif ( email_exists( $user ) ) {
|
507 |
-
$data = get_user_by( 'email', $user );
|
508 |
-
}
|
509 |
-
|
510 |
-
um_fetch_user( $data->ID );
|
511 |
-
|
512 |
-
UM()->user()->password_reset();
|
513 |
-
|
514 |
-
exit( wp_redirect( um_get_core_page('password-reset', 'checkemail' ) ) );
|
515 |
-
}
|
516 |
-
|
517 |
-
|
518 |
-
/**
|
519 |
-
* Error handler: changing password
|
520 |
-
*
|
521 |
-
* @param $args
|
522 |
-
*/
|
523 |
-
public function um_change_password_errors_hook( $args ) {
|
524 |
-
if ( isset( $args[ UM()->honeypot ] ) && '' !== $args[ UM()->honeypot ] ) {
|
525 |
-
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
526 |
-
}
|
527 |
-
|
528 |
-
if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
|
529 |
-
is_user_logged_in() && isset( $args['user_id'] ) && absint( $args['user_id'] ) !== get_current_user_id() ) {
|
530 |
-
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
531 |
-
}
|
532 |
-
|
533 |
-
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
|
534 |
-
UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
|
535 |
-
}
|
536 |
-
|
537 |
-
if ( isset( $args['user_password'] ) ) {
|
538 |
-
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
539 |
-
}
|
540 |
-
if ( isset( $args['confirm_user_password'] ) ) {
|
541 |
-
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
542 |
-
}
|
543 |
-
|
544 |
-
if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
}
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
*
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
*
|
643 |
-
*
|
644 |
-
* @
|
645 |
-
*
|
646 |
-
* @
|
647 |
-
* @
|
648 |
-
*
|
649 |
-
*
|
650 |
-
*
|
651 |
-
*
|
652 |
-
*
|
653 |
-
*
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
*
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
}
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
// Exit if accessed directly
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
+
|
8 |
+
|
9 |
+
if ( ! class_exists( 'um\core\Password' ) ) {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Password
|
14 |
+
* @package um\core
|
15 |
+
*/
|
16 |
+
class Password {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Password constructor.
|
21 |
+
*/
|
22 |
+
function __construct() {
|
23 |
+
add_shortcode( 'ultimatemember_password', array( &$this, 'ultimatemember_password' ) );
|
24 |
+
|
25 |
+
add_action( 'template_redirect', array( &$this, 'form_init' ), 10001 );
|
26 |
+
|
27 |
+
add_action( 'um_reset_password_errors_hook', array( &$this, 'um_reset_password_errors_hook' ) );
|
28 |
+
add_action( 'um_reset_password_process_hook', array( &$this,'um_reset_password_process_hook' ) );
|
29 |
+
|
30 |
+
add_action( 'um_change_password_errors_hook', array( &$this, 'um_change_password_errors_hook' ) );
|
31 |
+
add_action( 'um_change_password_process_hook', array( &$this,'um_change_password_process_hook' ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get Reset URL
|
37 |
+
*
|
38 |
+
* @return bool|string
|
39 |
+
*/
|
40 |
+
function reset_url() {
|
41 |
+
$user_id = um_user( 'ID' );
|
42 |
+
|
43 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
44 |
+
|
45 |
+
//new reset password key via WP native field
|
46 |
+
$user_data = get_userdata( $user_id );
|
47 |
+
$key = UM()->user()->maybe_generate_password_reset_key( $user_data );
|
48 |
+
|
49 |
+
$url = add_query_arg( array( 'act' => 'reset_password', 'hash' => $key, 'user_id' => $user_id ), um_get_core_page( 'password-reset' ) );
|
50 |
+
return $url;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Add class based on shortcode
|
56 |
+
*
|
57 |
+
* @param string $mode
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
function get_class( $mode ) {
|
62 |
+
|
63 |
+
$classes = 'um-'.$mode;
|
64 |
+
|
65 |
+
if ( is_admin() ) {
|
66 |
+
$classes .= ' um-in-admin';
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( UM()->fields()->editing == true ) {
|
70 |
+
$classes .= ' um-editing';
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( UM()->fields()->viewing == true ) {
|
74 |
+
$classes .= ' um-viewing';
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* UM hook
|
79 |
+
*
|
80 |
+
* @type filter
|
81 |
+
* @title um_form_official_classes__hook
|
82 |
+
* @description Change form additional classes
|
83 |
+
* @input_vars
|
84 |
+
* [{"var":"$classes","type":"string","desc":"Form additional classes"}]
|
85 |
+
* @change_log
|
86 |
+
* ["Since: 2.0"]
|
87 |
+
* @usage
|
88 |
+
* <?php add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 ); ?>
|
89 |
+
* @example
|
90 |
+
* <?php
|
91 |
+
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
92 |
+
* function my_form_official_classes( $classes ) {
|
93 |
+
* // your code here
|
94 |
+
* return $classes;
|
95 |
+
* }
|
96 |
+
* ?>
|
97 |
+
*/
|
98 |
+
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
99 |
+
return $classes;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Shortcode
|
105 |
+
*
|
106 |
+
* @param array $args
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
function ultimatemember_password( $args = array() ) {
|
111 |
+
ob_start();
|
112 |
+
|
113 |
+
$defaults = array(
|
114 |
+
'template' => 'password-reset',
|
115 |
+
'mode' => 'password',
|
116 |
+
'form_id' => 'um_password_id',
|
117 |
+
'max_width' => '450px',
|
118 |
+
'align' => 'center',
|
119 |
+
);
|
120 |
+
$args = wp_parse_args( $args, $defaults );
|
121 |
+
|
122 |
+
if ( empty( $args['use_custom_settings'] ) ) {
|
123 |
+
$args = array_merge( $args, UM()->shortcodes()->get_css_args( $args ) );
|
124 |
+
} else {
|
125 |
+
$args = array_merge( UM()->shortcodes()->get_css_args( $args ), $args );
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* UM hook
|
130 |
+
*
|
131 |
+
* @type filter
|
132 |
+
* @title um_reset_password_shortcode_args_filter
|
133 |
+
* @description Extend Reset Password Arguments
|
134 |
+
* @input_vars
|
135 |
+
* [{"var":"$args","type":"array","desc":"Shortcode arguments"}]
|
136 |
+
* @change_log
|
137 |
+
* ["Since: 2.0"]
|
138 |
+
* @usage
|
139 |
+
* <?php add_filter( 'um_reset_password_shortcode_args_filter', 'function_name', 10, 1 ); ?>
|
140 |
+
* @example
|
141 |
+
* <?php
|
142 |
+
* add_filter( 'um_reset_password_shortcode_args_filter', 'my_reset_password_shortcode_args', 10, 1 );
|
143 |
+
* function my_reset_password_shortcode_args( $args ) {
|
144 |
+
* // your code here
|
145 |
+
* return $args;
|
146 |
+
* }
|
147 |
+
* ?>
|
148 |
+
*/
|
149 |
+
$args = apply_filters( 'um_reset_password_shortcode_args_filter', $args );
|
150 |
+
|
151 |
+
if ( isset( $this->change_password ) ) {
|
152 |
+
$args['template'] = 'password-change';
|
153 |
+
$args['rp_key'] = '';
|
154 |
+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
155 |
+
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
156 |
+
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
157 |
+
|
158 |
+
$user = get_user_by( 'login', $rp_login );
|
159 |
+
$args['user_id'] = $user->ID;
|
160 |
+
$args['rp_key'] = $rp_key;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
UM()->fields()->set_id = 'um_password_id';
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @var $mode
|
168 |
+
* @var $template
|
169 |
+
*/
|
170 |
+
extract( $args, EXTR_SKIP );
|
171 |
+
|
172 |
+
/**
|
173 |
+
* UM hook
|
174 |
+
*
|
175 |
+
* @type action
|
176 |
+
* @title um_pre_{$mode}_shortcode
|
177 |
+
* @description Action pre-load password form shortcode
|
178 |
+
* @input_vars
|
179 |
+
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
180 |
+
* @change_log
|
181 |
+
* ["Since: 2.0"]
|
182 |
+
* @usage add_action( 'um_pre_{$mode}_shortcode', 'function_name', 10, 1 );
|
183 |
+
* @example
|
184 |
+
* <?php
|
185 |
+
* add_action( 'um_pre_{$mode}_shortcode', 'my_pre_password_shortcode', 10, 1 );
|
186 |
+
* function my_pre_password_shortcode( $args ) {
|
187 |
+
* // your code here
|
188 |
+
* }
|
189 |
+
* ?>
|
190 |
+
*/
|
191 |
+
do_action( "um_pre_{$mode}_shortcode", $args );
|
192 |
+
/**
|
193 |
+
* UM hook
|
194 |
+
*
|
195 |
+
* @type action
|
196 |
+
* @title um_before_form_is_loaded
|
197 |
+
* @description Action pre-load password form shortcode
|
198 |
+
* @input_vars
|
199 |
+
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
200 |
+
* @change_log
|
201 |
+
* ["Since: 2.0"]
|
202 |
+
* @usage add_action( 'um_before_form_is_loaded', 'function_name', 10, 1 );
|
203 |
+
* @example
|
204 |
+
* <?php
|
205 |
+
* add_action( 'um_before_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
206 |
+
* function my_before_form_is_loaded( $args ) {
|
207 |
+
* // your code here
|
208 |
+
* }
|
209 |
+
* ?>
|
210 |
+
*/
|
211 |
+
do_action( "um_before_form_is_loaded", $args );
|
212 |
+
/**
|
213 |
+
* UM hook
|
214 |
+
*
|
215 |
+
* @type action
|
216 |
+
* @title um_before_{$mode}_form_is_loaded
|
217 |
+
* @description Action pre-load password form shortcode
|
218 |
+
* @input_vars
|
219 |
+
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
220 |
+
* @change_log
|
221 |
+
* ["Since: 2.0"]
|
222 |
+
* @usage add_action( 'um_before_{$mode}_form_is_loaded', 'function_name', 10, 1 );
|
223 |
+
* @example
|
224 |
+
* <?php
|
225 |
+
* add_action( 'um_before_{$mode}_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
226 |
+
* function my_before_form_is_loaded( $args ) {
|
227 |
+
* // your code here
|
228 |
+
* }
|
229 |
+
* ?>
|
230 |
+
*/
|
231 |
+
do_action( "um_before_{$mode}_form_is_loaded", $args );
|
232 |
+
|
233 |
+
UM()->shortcodes()->template_load( $template, $args );
|
234 |
+
|
235 |
+
if ( ! is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
236 |
+
UM()->shortcodes()->dynamic_css( $args );
|
237 |
+
}
|
238 |
+
|
239 |
+
$output = ob_get_clean();
|
240 |
+
return $output;
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Check if a legitimate password reset request is in action
|
246 |
+
*
|
247 |
+
* @return bool
|
248 |
+
*/
|
249 |
+
function is_reset_request() {
|
250 |
+
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
|
251 |
+
return true;
|
252 |
+
}
|
253 |
+
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Check if a legitimate password change request is in action
|
260 |
+
*
|
261 |
+
*
|
262 |
+
* @return bool
|
263 |
+
*/
|
264 |
+
function is_change_request() {
|
265 |
+
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
|
266 |
+
return true;
|
267 |
+
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
268 |
+
return true;
|
269 |
+
}
|
270 |
+
|
271 |
+
return false;
|
272 |
+
}
|
273 |
+
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Password page form
|
277 |
+
*/
|
278 |
+
public function form_init() {
|
279 |
+
if ( um_is_core_page( 'password-reset' ) ) {
|
280 |
+
UM()->fields()->set_mode = 'password';
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
|
284 |
+
wp_fix_server_vars();
|
285 |
+
|
286 |
+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
287 |
+
|
288 |
+
if ( isset( $_GET['hash'] ) ) {
|
289 |
+
$userdata = get_userdata( wp_unslash( absint( $_GET['user_id'] ) ) );
|
290 |
+
if ( ! $userdata || is_wp_error( $userdata ) ) {
|
291 |
+
wp_redirect( add_query_arg( array( 'act' => 'reset_password', 'error' => 'invalidkey' ), get_permalink() ) );
|
292 |
+
exit;
|
293 |
+
}
|
294 |
+
$rp_login = $userdata->user_login;
|
295 |
+
$rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
|
296 |
+
|
297 |
+
$user = check_password_reset_key( $rp_key, $rp_login );
|
298 |
+
|
299 |
+
if ( is_wp_error( $user ) ) {
|
300 |
+
$this->setcookie( $rp_cookie, false );
|
301 |
+
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
302 |
+
} else {
|
303 |
+
$value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
|
304 |
+
$this->setcookie( $rp_cookie, $value );
|
305 |
+
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
|
306 |
+
}
|
307 |
+
|
308 |
+
exit;
|
309 |
+
}
|
310 |
+
|
311 |
+
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
312 |
+
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
313 |
+
$user = check_password_reset_key( $rp_key, $rp_login );
|
314 |
+
} else {
|
315 |
+
$user = false;
|
316 |
+
}
|
317 |
+
|
318 |
+
if ( ( ! $user || is_wp_error( $user ) ) && ! isset( $_GET['updated'] ) ) {
|
319 |
+
$this->setcookie( $rp_cookie, false );
|
320 |
+
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
321 |
+
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
322 |
+
} else {
|
323 |
+
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
324 |
+
}
|
325 |
+
exit;
|
326 |
+
}
|
327 |
+
|
328 |
+
$this->change_password = true;
|
329 |
+
}
|
330 |
+
|
331 |
+
if ( $this->is_reset_request() ) {
|
332 |
+
|
333 |
+
UM()->form()->post_form = $_POST;
|
334 |
+
|
335 |
+
if ( empty( UM()->form()->post_form['mode'] ) ) {
|
336 |
+
UM()->form()->post_form['mode'] = 'password';
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* UM hook
|
341 |
+
*
|
342 |
+
* @type action
|
343 |
+
* @title um_reset_password_errors_hook
|
344 |
+
* @description Action on reset password submit form
|
345 |
+
* @input_vars
|
346 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
347 |
+
* @change_log
|
348 |
+
* ["Since: 2.0"]
|
349 |
+
* @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 );
|
350 |
+
* @example
|
351 |
+
* <?php
|
352 |
+
* add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
|
353 |
+
* function my_reset_password_errors( $post ) {
|
354 |
+
* // your code here
|
355 |
+
* }
|
356 |
+
* ?>
|
357 |
+
*/
|
358 |
+
do_action( 'um_reset_password_errors_hook', UM()->form()->post_form );
|
359 |
+
|
360 |
+
if ( ! isset( UM()->form()->errors ) ) {
|
361 |
+
|
362 |
+
/**
|
363 |
+
* UM hook
|
364 |
+
*
|
365 |
+
* @type action
|
366 |
+
* @title um_reset_password_process_hook
|
367 |
+
* @description Action on reset password success submit form
|
368 |
+
* @input_vars
|
369 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
370 |
+
* @change_log
|
371 |
+
* ["Since: 2.0"]
|
372 |
+
* @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 );
|
373 |
+
* @example
|
374 |
+
* <?php
|
375 |
+
* add_action( 'um_reset_password_process_hook', 'my_reset_password_process', 10, 1 );
|
376 |
+
* function my_reset_password_process( $post ) {
|
377 |
+
* // your code here
|
378 |
+
* }
|
379 |
+
* ?>
|
380 |
+
*/
|
381 |
+
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
382 |
+
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
if ( $this->is_change_request() ) {
|
387 |
+
UM()->form()->post_form = $_POST;
|
388 |
+
|
389 |
+
/**
|
390 |
+
* UM hook
|
391 |
+
*
|
392 |
+
* @type action
|
393 |
+
* @title um_change_password_errors_hook
|
394 |
+
* @description Action on change password submit form
|
395 |
+
* @input_vars
|
396 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
397 |
+
* @change_log
|
398 |
+
* ["Since: 2.0"]
|
399 |
+
* @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 );
|
400 |
+
* @example
|
401 |
+
* <?php
|
402 |
+
* add_action( 'um_change_password_errors_hook', 'my_change_password_errors', 10, 1 );
|
403 |
+
* function my_change_password_errors( $post ) {
|
404 |
+
* // your code here
|
405 |
+
* }
|
406 |
+
* ?>
|
407 |
+
*/
|
408 |
+
do_action( 'um_change_password_errors_hook', UM()->form()->post_form );
|
409 |
+
|
410 |
+
if ( ! isset( UM()->form()->errors ) ) {
|
411 |
+
|
412 |
+
/**
|
413 |
+
* UM hook
|
414 |
+
*
|
415 |
+
* @type action
|
416 |
+
* @title um_change_password_process_hook
|
417 |
+
* @description Action on change password success submit form
|
418 |
+
* @input_vars
|
419 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
420 |
+
* @change_log
|
421 |
+
* ["Since: 2.0"]
|
422 |
+
* @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 );
|
423 |
+
* @example
|
424 |
+
* <?php
|
425 |
+
* add_action( 'um_change_password_process_hook', 'my_change_password_process', 10, 1 );
|
426 |
+
* function my_change_password_process( $post ) {
|
427 |
+
* // your code here
|
428 |
+
* }
|
429 |
+
* ?>
|
430 |
+
*/
|
431 |
+
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
432 |
+
|
433 |
+
}
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Error handler: reset password
|
440 |
+
*
|
441 |
+
* @param $args
|
442 |
+
*/
|
443 |
+
public function um_reset_password_errors_hook( $args ) {
|
444 |
+
if ( '' !== $args[ UM()->honeypot ] ) {
|
445 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
446 |
+
}
|
447 |
+
|
448 |
+
$user = '';
|
449 |
+
|
450 |
+
foreach ( $args as $key => $val ) {
|
451 |
+
if ( strstr( $key, 'username_b' ) ) {
|
452 |
+
$user = trim( sanitize_text_field( $val ) );
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
if ( empty( $user ) ) {
|
457 |
+
UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
|
458 |
+
}
|
459 |
+
|
460 |
+
if ( ( ! is_email( $user ) && ! username_exists( $user ) ) || ( is_email( $user ) && ! email_exists( $user ) ) ) {
|
461 |
+
UM()->form()->add_error( 'username_b', __( 'We can\'t find an account registered with that address or username', 'ultimate-member' ) );
|
462 |
+
} else {
|
463 |
+
|
464 |
+
if ( is_email( $user ) ) {
|
465 |
+
$user_id = email_exists( $user );
|
466 |
+
} else {
|
467 |
+
$user_id = username_exists( $user );
|
468 |
+
}
|
469 |
+
|
470 |
+
$attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
|
471 |
+
$is_admin = user_can( absint( $user_id ), 'manage_options' );
|
472 |
+
|
473 |
+
if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
|
474 |
+
|
475 |
+
if ( ! ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) ) {
|
476 |
+
// Doesn't trigger this when a user has admin capabilities and when reset password limit is disabled for admins
|
477 |
+
$limit = UM()->options()->get( 'reset_password_limit_number' );
|
478 |
+
if ( $attempts >= $limit ) {
|
479 |
+
UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email', 'ultimate-member' ) );
|
480 |
+
} else {
|
481 |
+
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
}
|
488 |
+
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Process a new request
|
492 |
+
*
|
493 |
+
* @param $args
|
494 |
+
*/
|
495 |
+
public function um_reset_password_process_hook( $args ) {
|
496 |
+
$user = null;
|
497 |
+
|
498 |
+
foreach ( $args as $key => $val ) {
|
499 |
+
if ( strstr( $key, 'username_b' ) ) {
|
500 |
+
$user = trim( sanitize_text_field( $val ) );
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
if ( username_exists( $user ) ) {
|
505 |
+
$data = get_user_by( 'login', $user );
|
506 |
+
} elseif ( email_exists( $user ) ) {
|
507 |
+
$data = get_user_by( 'email', $user );
|
508 |
+
}
|
509 |
+
|
510 |
+
um_fetch_user( $data->ID );
|
511 |
+
|
512 |
+
UM()->user()->password_reset();
|
513 |
+
|
514 |
+
exit( wp_redirect( um_get_core_page('password-reset', 'checkemail' ) ) );
|
515 |
+
}
|
516 |
+
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Error handler: changing password
|
520 |
+
*
|
521 |
+
* @param $args
|
522 |
+
*/
|
523 |
+
public function um_change_password_errors_hook( $args ) {
|
524 |
+
if ( isset( $args[ UM()->honeypot ] ) && '' !== $args[ UM()->honeypot ] ) {
|
525 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
526 |
+
}
|
527 |
+
|
528 |
+
if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
|
529 |
+
is_user_logged_in() && isset( $args['user_id'] ) && absint( $args['user_id'] ) !== get_current_user_id() ) {
|
530 |
+
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
531 |
+
}
|
532 |
+
|
533 |
+
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
|
534 |
+
UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
|
535 |
+
}
|
536 |
+
|
537 |
+
if ( isset( $args['user_password'] ) ) {
|
538 |
+
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
539 |
+
}
|
540 |
+
if ( isset( $args['confirm_user_password'] ) ) {
|
541 |
+
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
542 |
+
}
|
543 |
+
|
544 |
+
if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
|
545 |
+
|
546 |
+
$min_length = UM()->options()->get( 'password_min_chars' );
|
547 |
+
$min_length = ! empty( $min_length ) ? $min_length : 8;
|
548 |
+
$max_length = UM()->options()->get( 'password_max_chars' );
|
549 |
+
$max_length = ! empty( $max_length ) ? $max_length : 30;
|
550 |
+
|
551 |
+
if ( mb_strlen( $args['user_password'] ) < $min_length ) {
|
552 |
+
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain at least %d characters', 'ultimate-member' ), $min_length ) );
|
553 |
+
}
|
554 |
+
|
555 |
+
if ( mb_strlen( $args['user_password'] ) > $max_length ) {
|
556 |
+
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain less than %d characters', 'ultimate-member' ), $max_length ) );
|
557 |
+
}
|
558 |
+
|
559 |
+
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
|
560 |
+
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
561 |
+
}
|
562 |
+
}
|
563 |
+
|
564 |
+
if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) {
|
565 |
+
UM()->form()->add_error( 'confirm_user_password', __( 'You must confirm your new password', 'ultimate-member' ) );
|
566 |
+
}
|
567 |
+
|
568 |
+
if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] !== $args['confirm_user_password'] ) {
|
569 |
+
UM()->form()->add_error( 'confirm_user_password', __( 'Your passwords do not match', 'ultimate-member' ) );
|
570 |
+
}
|
571 |
+
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Process a change request
|
577 |
+
*
|
578 |
+
* @param $args
|
579 |
+
*/
|
580 |
+
public function um_change_password_process_hook( $args ) {
|
581 |
+
if ( isset( $args['_um_password_change'] ) && $args['_um_password_change'] == 1 ) {
|
582 |
+
|
583 |
+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
584 |
+
$user = get_userdata( absint( $args['user_id'] ) );
|
585 |
+
|
586 |
+
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
587 |
+
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
588 |
+
|
589 |
+
if ( $user->user_login != $rp_login ) {
|
590 |
+
$user = false;
|
591 |
+
} else {
|
592 |
+
$user = check_password_reset_key( $rp_key, $rp_login );
|
593 |
+
if ( isset( $args['user_password'] ) && ! hash_equals( $rp_key, $args['rp_key'] ) ) {
|
594 |
+
$user = false;
|
595 |
+
}
|
596 |
+
}
|
597 |
+
} else {
|
598 |
+
$user = false;
|
599 |
+
}
|
600 |
+
|
601 |
+
if ( ! $user || is_wp_error( $user ) ) {
|
602 |
+
$this->setcookie( $rp_cookie, false );
|
603 |
+
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
604 |
+
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
605 |
+
} else {
|
606 |
+
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
607 |
+
}
|
608 |
+
exit;
|
609 |
+
}
|
610 |
+
|
611 |
+
|
612 |
+
$errors = new \WP_Error();
|
613 |
+
/**
|
614 |
+
* Fires before the password reset procedure is validated.
|
615 |
+
*
|
616 |
+
* @since 3.5.0
|
617 |
+
*
|
618 |
+
* @param object $errors WP Error object.
|
619 |
+
* @param \WP_User|\WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise.
|
620 |
+
*/
|
621 |
+
do_action( 'validate_password_reset', $errors, $user );
|
622 |
+
|
623 |
+
if ( ( ! $errors->get_error_code() ) ) {
|
624 |
+
reset_password( $user, sanitize_text_field( $args['user_password'] ) );
|
625 |
+
|
626 |
+
// send the Password Changed Email
|
627 |
+
UM()->user()->password_changed();
|
628 |
+
|
629 |
+
// clear temporary data
|
630 |
+
$attempts = (int) get_user_meta( $user->ID, 'password_rst_attempts', true );
|
631 |
+
if ( $attempts ) {
|
632 |
+
update_user_meta( $user->ID, 'password_rst_attempts', 0 );
|
633 |
+
}
|
634 |
+
$this->setcookie( $rp_cookie, false );
|
635 |
+
|
636 |
+
// logout
|
637 |
+
if ( is_user_logged_in() ) {
|
638 |
+
wp_logout();
|
639 |
+
}
|
640 |
+
|
641 |
+
/**
|
642 |
+
* UM hook
|
643 |
+
*
|
644 |
+
* @type action
|
645 |
+
* @title um_after_changing_user_password
|
646 |
+
* @description Hook that runs after user change their password
|
647 |
+
* @input_vars
|
648 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
649 |
+
* @change_log
|
650 |
+
* ["Since: 2.0"]
|
651 |
+
* @usage add_action( 'um_after_changing_user_password', 'function_name', 10, 1 );
|
652 |
+
* @example
|
653 |
+
* <?php
|
654 |
+
* add_action( 'um_after_changing_user_password', 'my_after_changing_user_password', 10, 1 );
|
655 |
+
* function my_user_login_extra( $user_id ) {
|
656 |
+
* // your code here
|
657 |
+
* }
|
658 |
+
* ?>
|
659 |
+
*/
|
660 |
+
do_action( 'um_after_changing_user_password', absint( $args['user_id'] ) );
|
661 |
+
|
662 |
+
exit( wp_redirect( um_get_core_page( 'login', 'password_changed' ) ) );
|
663 |
+
}
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Disable page caching and set or clear cookie
|
670 |
+
*
|
671 |
+
* @param string $name
|
672 |
+
* @param string $value
|
673 |
+
* @param int $expire
|
674 |
+
* @param string $path
|
675 |
+
*/
|
676 |
+
public function setcookie( $name, $value = '', $expire = 0, $path = '' ) {
|
677 |
+
if ( empty( $value ) ) {
|
678 |
+
$expire = time() - YEAR_IN_SECONDS;
|
679 |
+
}
|
680 |
+
if ( empty( $path ) ) {
|
681 |
+
list( $path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
682 |
+
}
|
683 |
+
|
684 |
+
$levels = ob_get_level();
|
685 |
+
for ( $i = 0; $i < $levels; $i++ ) {
|
686 |
+
@ob_end_clean();
|
687 |
+
}
|
688 |
+
|
689 |
+
nocache_headers();
|
690 |
+
setcookie( $name, $value, $expire, $path, COOKIE_DOMAIN, is_ssl(), true );
|
691 |
+
}
|
692 |
+
|
693 |
+
|
694 |
+
/**
|
695 |
+
* UM Placeholders for reset password
|
696 |
+
*
|
697 |
+
* @param $placeholders
|
698 |
+
*
|
699 |
+
* @return array
|
700 |
+
*/
|
701 |
+
function add_placeholder( $placeholders ) {
|
702 |
+
$placeholders[] = '{password_reset_link}';
|
703 |
+
$placeholders[] = '{password}';
|
704 |
+
return $placeholders;
|
705 |
+
}
|
706 |
+
|
707 |
+
|
708 |
+
/**
|
709 |
+
* UM Replace Placeholders for reset password
|
710 |
+
*
|
711 |
+
* @param $replace_placeholders
|
712 |
+
*
|
713 |
+
* @return array
|
714 |
+
*/
|
715 |
+
function add_replace_placeholder( $replace_placeholders ) {
|
716 |
+
$replace_placeholders[] = um_user( 'password_reset_link' );
|
717 |
+
$replace_placeholders[] = esc_html__( 'Your set password', 'ultimate-member' );
|
718 |
+
return $replace_placeholders;
|
719 |
+
}
|
720 |
+
}
|
721 |
+
}
|
includes/core/class-user-posts.php
CHANGED
@@ -29,12 +29,13 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
|
|
29 |
*/
|
30 |
function add_posts() {
|
31 |
$args = array(
|
32 |
-
'post_type'
|
33 |
-
'posts_per_page'
|
34 |
-
'offset'
|
35 |
-
'author'
|
36 |
-
'post_status'
|
37 |
-
'um_main_query'
|
|
|
38 |
);
|
39 |
|
40 |
/**
|
@@ -108,12 +109,13 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
|
|
108 |
$page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
|
109 |
|
110 |
$args = array(
|
111 |
-
'post_type'
|
112 |
-
'posts_per_page'
|
113 |
-
'offset'
|
114 |
-
'author'
|
115 |
-
'post_status'
|
116 |
-
'um_main_query'
|
|
|
117 |
);
|
118 |
|
119 |
/**
|
29 |
*/
|
30 |
function add_posts() {
|
31 |
$args = array(
|
32 |
+
'post_type' => 'post',
|
33 |
+
'posts_per_page' => 10,
|
34 |
+
'offset' => 0,
|
35 |
+
'author' => um_get_requested_user(),
|
36 |
+
'post_status' => array( 'publish' ),
|
37 |
+
'um_main_query' => true,
|
38 |
+
'suppress_filters' => false,
|
39 |
);
|
40 |
|
41 |
/**
|
109 |
$page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
|
110 |
|
111 |
$args = array(
|
112 |
+
'post_type' => 'post',
|
113 |
+
'posts_per_page' => 10,
|
114 |
+
'offset' => ( $page - 1 ) * 10,
|
115 |
+
'author' => $author,
|
116 |
+
'post_status' => array( 'publish' ),
|
117 |
+
'um_main_query' => true,
|
118 |
+
'suppress_filters' => false,
|
119 |
);
|
120 |
|
121 |
/**
|
includes/core/class-user.php
CHANGED
@@ -1,2177 +1,2185 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\User' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class User
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class User {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
*
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
$this->
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
add_action( '
|
68 |
-
|
69 |
-
|
70 |
-
add_action( '
|
71 |
-
|
72 |
-
|
73 |
-
add_action( '
|
74 |
-
add_action( '
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
add_action( '
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
add_action( '
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
add_action( '
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
$
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
break;
|
234 |
-
case '
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
case '
|
244 |
-
$md_data['
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
*
|
268 |
-
*
|
269 |
-
*
|
270 |
-
*
|
271 |
-
*
|
272 |
-
*
|
273 |
-
*
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
*
|
279 |
-
*
|
280 |
-
*
|
281 |
-
*
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
*
|
287 |
-
*
|
288 |
-
* @
|
289 |
-
*
|
290 |
-
*
|
291 |
-
*
|
292 |
-
*
|
293 |
-
*
|
294 |
-
*
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
*
|
413 |
-
*
|
414 |
-
*
|
415 |
-
* @
|
416 |
-
*
|
417 |
-
*
|
418 |
-
*
|
419 |
-
*
|
420 |
-
*
|
421 |
-
*
|
422 |
-
* ?>
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
$
|
491 |
-
|
492 |
-
$
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
$
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
$
|
535 |
-
$
|
536 |
-
$
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
$
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
$
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
*
|
610 |
-
*
|
611 |
-
* @
|
612 |
-
* @
|
613 |
-
*
|
614 |
-
*
|
615 |
-
*
|
616 |
-
*
|
617 |
-
*
|
618 |
-
*
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
if (
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
*
|
661 |
-
*
|
662 |
-
* @
|
663 |
-
* @
|
664 |
-
*
|
665 |
-
*
|
666 |
-
*
|
667 |
-
*
|
668 |
-
*
|
669 |
-
*
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
*
|
698 |
-
*
|
699 |
-
* @
|
700 |
-
*
|
701 |
-
* @
|
702 |
-
*
|
703 |
-
*
|
704 |
-
*
|
705 |
-
*
|
706 |
-
*
|
707 |
-
*
|
708 |
-
* ?>
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
}
|
802 |
-
|
803 |
-
|
804 |
-
/**
|
805 |
-
*
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
$
|
822 |
-
}
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
*
|
853 |
-
*
|
854 |
-
* @
|
855 |
-
*
|
856 |
-
* @
|
857 |
-
*
|
858 |
-
*
|
859 |
-
*
|
860 |
-
*
|
861 |
-
*
|
862 |
-
*
|
863 |
-
* ?>
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
}
|
894 |
-
|
895 |
-
|
896 |
-
/**
|
897 |
-
*
|
898 |
-
*/
|
899 |
-
function
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
*
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
$this->
|
934 |
-
}
|
935 |
-
|
936 |
-
if ( $
|
937 |
-
$this->
|
938 |
-
}
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
$this->
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
$this->
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
$this->data =
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
if ( $this->usermeta['account_status'][0]
|
988 |
-
$this->usermeta['
|
989 |
-
}
|
990 |
-
|
991 |
-
if ( $this->usermeta['account_status'][0] == '
|
992 |
-
$this->usermeta['account_status_name'][0] = __('
|
993 |
-
}
|
994 |
-
|
995 |
-
if ( $this->usermeta['account_status'][0] == '
|
996 |
-
$this->usermeta['account_status_name'][0] = __('
|
997 |
-
}
|
998 |
-
|
999 |
-
if ( $this->usermeta['account_status'][0] == '
|
1000 |
-
$this->usermeta['account_status_name'][0] = __('
|
1001 |
-
}
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
$this->
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
// add
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
*
|
1027 |
-
*
|
1028 |
-
* @
|
1029 |
-
*
|
1030 |
-
* @
|
1031 |
-
*
|
1032 |
-
*
|
1033 |
-
*
|
1034 |
-
*
|
1035 |
-
*
|
1036 |
-
*
|
1037 |
-
* ?>
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
$this->
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
*
|
1077 |
-
*/
|
1078 |
-
function clean
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
*
|
1101 |
-
*
|
1102 |
-
* @
|
1103 |
-
|
1104 |
-
|
1105 |
-
*
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
if ( isset( $submitted['
|
1137 |
-
unset( $submitted['
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
*
|
1164 |
-
*
|
1165 |
-
* @
|
1166 |
-
*
|
1167 |
-
* @
|
1168 |
-
*
|
1169 |
-
*
|
1170 |
-
*
|
1171 |
-
*
|
1172 |
-
*
|
1173 |
-
*
|
1174 |
-
* ?>
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
*
|
1180 |
-
*
|
1181 |
-
*
|
1182 |
-
*
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
*
|
1188 |
-
*
|
1189 |
-
* @
|
1190 |
-
* @
|
1191 |
-
*
|
1192 |
-
*
|
1193 |
-
*
|
1194 |
-
*
|
1195 |
-
*
|
1196 |
-
*
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
*
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
*
|
1213 |
-
*
|
1214 |
-
* @
|
1215 |
-
* @
|
1216 |
-
*
|
1217 |
-
*
|
1218 |
-
*
|
1219 |
-
*
|
1220 |
-
*
|
1221 |
-
*
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
}
|
1234 |
-
|
1235 |
-
|
1236 |
-
/**
|
1237 |
-
* Set
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
*
|
1253 |
-
*
|
1254 |
-
* @
|
1255 |
-
*
|
1256 |
-
*
|
1257 |
-
*
|
1258 |
-
*
|
1259 |
-
*
|
1260 |
-
*
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
*
|
1278 |
-
*
|
1279 |
-
* @
|
1280 |
-
*
|
1281 |
-
*
|
1282 |
-
*
|
1283 |
-
*
|
1284 |
-
*
|
1285 |
-
*
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
*
|
1291 |
-
*
|
1292 |
-
*
|
1293 |
-
*
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
*
|
1299 |
-
*
|
1300 |
-
* @
|
1301 |
-
* @
|
1302 |
-
*
|
1303 |
-
*
|
1304 |
-
*
|
1305 |
-
*
|
1306 |
-
*
|
1307 |
-
*
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
*
|
1328 |
-
*
|
1329 |
-
*
|
1330 |
-
*
|
1331 |
-
*
|
1332 |
-
*
|
1333 |
-
*
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
*
|
1356 |
-
*
|
1357 |
-
*
|
1358 |
-
*
|
1359 |
-
*
|
1360 |
-
*
|
1361 |
-
*
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
$
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
UM()->mail()->send( um_user( 'user_email' ), '
|
1401 |
-
}
|
1402 |
-
|
1403 |
-
|
1404 |
-
/**
|
1405 |
-
*
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
*
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
*
|
1458 |
-
*
|
1459 |
-
* @
|
1460 |
-
*
|
1461 |
-
*
|
1462 |
-
*
|
1463 |
-
*
|
1464 |
-
*
|
1465 |
-
*
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
*
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
*
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
*
|
1551 |
-
*
|
1552 |
-
* @
|
1553 |
-
*
|
1554 |
-
*
|
1555 |
-
*
|
1556 |
-
*
|
1557 |
-
*
|
1558 |
-
*
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
if ( ! function_exists( '
|
1591 |
-
require_once( ABSPATH . 'wp-admin/includes/
|
1592 |
-
}
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
*
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
*
|
1689 |
-
*
|
1690 |
-
*
|
1691 |
-
* @
|
1692 |
-
*
|
1693 |
-
*
|
1694 |
-
*
|
1695 |
-
*
|
1696 |
-
*
|
1697 |
-
*
|
1698 |
-
* ?>
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
//
|
1738 |
-
$profile_noindex = true;
|
1739 |
-
|
1740 |
-
}
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
*
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
*
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
*
|
1845 |
-
*
|
1846 |
-
*
|
1847 |
-
* @
|
1848 |
-
*
|
1849 |
-
* @
|
1850 |
-
*
|
1851 |
-
*
|
1852 |
-
*
|
1853 |
-
*
|
1854 |
-
*
|
1855 |
-
*
|
1856 |
-
* ?>
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
*
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
*
|
1897 |
-
*
|
1898 |
-
* @
|
1899 |
-
*
|
1900 |
-
* @
|
1901 |
-
*
|
1902 |
-
*
|
1903 |
-
*
|
1904 |
-
*
|
1905 |
-
*
|
1906 |
-
*
|
1907 |
-
* ?>
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
}
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
}
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
),
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
$
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
);
|
2053 |
-
|
2054 |
-
$
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
*
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
*
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\User' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class User
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class User {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Data that we will set before the update profile to compare it after update
|
20 |
+
*
|
21 |
+
* @var null
|
22 |
+
*/
|
23 |
+
public $previous_data = null;
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* User constructor.
|
28 |
+
*/
|
29 |
+
function __construct() {
|
30 |
+
|
31 |
+
$this->id = 0;
|
32 |
+
$this->usermeta = null;
|
33 |
+
$this->data = null;
|
34 |
+
$this->profile = null;
|
35 |
+
$this->cannot_edit = null;
|
36 |
+
$this->password_reset_key = null;
|
37 |
+
|
38 |
+
global $wpdb;
|
39 |
+
|
40 |
+
$this->banned_keys = array(
|
41 |
+
'metabox','postbox','meta-box',
|
42 |
+
'dismissed_wp_pointers', 'session_tokens',
|
43 |
+
'screen_layout', 'wp_user-', 'dismissed',
|
44 |
+
'cap_key', $wpdb->get_blog_prefix(). 'capabilities',
|
45 |
+
'managenav', 'nav_menu', 'user_activation_key',
|
46 |
+
'level_', $wpdb->get_blog_prefix() . 'user_level'
|
47 |
+
);
|
48 |
+
|
49 |
+
add_action( 'init', array( &$this, 'set' ), 1 );
|
50 |
+
|
51 |
+
$this->preview = false;
|
52 |
+
$this->send_mail_on_delete = true;
|
53 |
+
|
54 |
+
// a list of keys that should never be in wp_usermeta
|
55 |
+
$this->update_user_keys = array(
|
56 |
+
'user_email',
|
57 |
+
'user_pass',
|
58 |
+
'user_password',
|
59 |
+
'display_name',
|
60 |
+
'user_url',
|
61 |
+
'role',
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->target_id = null;
|
65 |
+
|
66 |
+
// When the cache should be cleared
|
67 |
+
add_action( 'um_delete_user_hook', array( &$this, 'remove_cached_queue' ) );
|
68 |
+
add_action( 'um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
|
69 |
+
|
70 |
+
add_action( 'um_after_user_status_is_changed_hook', array( &$this, 'remove_cached_queue' ) );
|
71 |
+
|
72 |
+
// When user cache should be cleared
|
73 |
+
add_action( 'um_after_user_updated', array( &$this, 'remove_cache' ) );
|
74 |
+
add_action( 'um_after_user_account_updated', array( &$this, 'remove_cache' ) );
|
75 |
+
add_action( 'personal_options_update', array( &$this, 'remove_cache' ) );
|
76 |
+
//add_action('edit_user_profile_update', array(&$this, 'remove_cache') );
|
77 |
+
add_action( 'um_when_role_is_set', array( &$this, 'remove_cache' ) );
|
78 |
+
add_action( 'um_when_status_is_set', array( &$this, 'remove_cache' ) );
|
79 |
+
|
80 |
+
add_action( 'show_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
|
81 |
+
add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
|
82 |
+
add_action( 'edit_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
|
83 |
+
add_filter( 'um_user_profile_additional_fields', array( $this, 'secondary_role_field' ), 1, 2 );
|
84 |
+
|
85 |
+
//on every update of user profile (hook from wp_update_user)
|
86 |
+
add_action( 'profile_update', array( &$this, 'profile_update' ), 10, 2 ); // user_id and old_user_data
|
87 |
+
|
88 |
+
//on user update profile page
|
89 |
+
//add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
|
90 |
+
|
91 |
+
add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
|
92 |
+
add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
|
93 |
+
|
94 |
+
|
95 |
+
if ( is_multisite() ) {
|
96 |
+
add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
|
97 |
+
add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
|
98 |
+
}
|
99 |
+
|
100 |
+
add_action( 'init', array( &$this, 'check_membership' ), 10 );
|
101 |
+
|
102 |
+
if ( is_multisite() ) {
|
103 |
+
add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
|
104 |
+
} else {
|
105 |
+
add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
110 |
+
add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
111 |
+
|
112 |
+
add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* When you delete usermeta connected with member directory - reset it to default value
|
118 |
+
*
|
119 |
+
* @param int|array $meta_ids
|
120 |
+
* @param int $object_id
|
121 |
+
* @param string $meta_key
|
122 |
+
* @param mixed $_meta_value
|
123 |
+
*/
|
124 |
+
function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
|
125 |
+
$metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
|
126 |
+
if ( ! in_array( $meta_key, $metakeys ) ) {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
$md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
|
131 |
+
if ( empty( $md_data ) ) {
|
132 |
+
$md_data = array(
|
133 |
+
'account_status' => 'approved',
|
134 |
+
'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
|
135 |
+
'profile_photo' => false,
|
136 |
+
'cover_photo' => false,
|
137 |
+
'verified' => false,
|
138 |
+
);
|
139 |
+
}
|
140 |
+
|
141 |
+
switch ( $meta_key ) {
|
142 |
+
case 'account_status':
|
143 |
+
$md_data['account_status'] = 'approved';
|
144 |
+
break;
|
145 |
+
case 'hide_in_members':
|
146 |
+
$md_data['hide_in_members'] = UM()->member_directory()->get_hide_in_members_default();
|
147 |
+
break;
|
148 |
+
case 'synced_gravatar_hashed_id':
|
149 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
150 |
+
$profile_photo = get_user_meta( $object_id, 'profile_photo', true );
|
151 |
+
$synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
|
152 |
+
|
153 |
+
$md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_profile_photo );
|
154 |
+
}
|
155 |
+
|
156 |
+
break;
|
157 |
+
case 'synced_profile_photo':
|
158 |
+
$profile_photo = get_user_meta( $object_id, 'profile_photo', true );
|
159 |
+
|
160 |
+
$synced_gravatar_hashed_id = false;
|
161 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
162 |
+
$synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
|
163 |
+
}
|
164 |
+
|
165 |
+
$md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_gravatar_hashed_id );
|
166 |
+
break;
|
167 |
+
case 'profile_photo':
|
168 |
+
$synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
|
169 |
+
|
170 |
+
$synced_gravatar_hashed_id = false;
|
171 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
172 |
+
$synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
|
173 |
+
}
|
174 |
+
|
175 |
+
$md_data['profile_photo'] = ! empty( $synced_profile_photo ) || ! empty( $synced_gravatar_hashed_id );
|
176 |
+
break;
|
177 |
+
case 'cover_photo':
|
178 |
+
$md_data['cover_photo'] = false;
|
179 |
+
break;
|
180 |
+
case '_um_verified':
|
181 |
+
$md_data['verified'] = false;
|
182 |
+
break;
|
183 |
+
}
|
184 |
+
|
185 |
+
update_user_meta( $object_id, 'um_member_directory_data', $md_data );
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* When you add/update usermeta connected with member directories - set this data to member directory metakey
|
191 |
+
*
|
192 |
+
* @param int $meta_id
|
193 |
+
* @param int $object_id
|
194 |
+
* @param string $meta_key
|
195 |
+
* @param mixed $_meta_value
|
196 |
+
*/
|
197 |
+
function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
|
198 |
+
|
199 |
+
$metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
|
200 |
+
if ( ! in_array( $meta_key, $metakeys ) ) {
|
201 |
+
return;
|
202 |
+
}
|
203 |
+
|
204 |
+
$md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
|
205 |
+
if ( empty( $md_data ) ) {
|
206 |
+
$md_data = array(
|
207 |
+
'account_status' => 'approved',
|
208 |
+
'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
|
209 |
+
'profile_photo' => false,
|
210 |
+
'cover_photo' => false,
|
211 |
+
'verified' => false,
|
212 |
+
);
|
213 |
+
}
|
214 |
+
|
215 |
+
switch ( $meta_key ) {
|
216 |
+
case 'account_status':
|
217 |
+
$md_data['account_status'] = $_meta_value;
|
218 |
+
break;
|
219 |
+
case 'hide_in_members':
|
220 |
+
|
221 |
+
$hide_in_members = UM()->member_directory()->get_hide_in_members_default();
|
222 |
+
if ( ! empty( $_meta_value ) ) {
|
223 |
+
if ( $_meta_value == 'Yes' || $_meta_value == __( 'Yes', 'ultimate-member' ) ||
|
224 |
+
array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $_meta_value ) ) {
|
225 |
+
$hide_in_members = true;
|
226 |
+
} else {
|
227 |
+
$hide_in_members = false;
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
$md_data['hide_in_members'] = $hide_in_members;
|
232 |
+
|
233 |
+
break;
|
234 |
+
case 'synced_gravatar_hashed_id':
|
235 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
236 |
+
if ( empty( $md_data['profile_photo'] ) ) {
|
237 |
+
$md_data['profile_photo'] = ! empty( $_meta_value );
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
break;
|
242 |
+
case 'synced_profile_photo':
|
243 |
+
case 'profile_photo':
|
244 |
+
if ( empty( $md_data['profile_photo'] ) ) {
|
245 |
+
$md_data['profile_photo'] = ! empty( $_meta_value );
|
246 |
+
}
|
247 |
+
break;
|
248 |
+
case 'cover_photo':
|
249 |
+
$md_data['cover_photo'] = ! empty( $_meta_value );
|
250 |
+
break;
|
251 |
+
case '_um_verified':
|
252 |
+
$md_data['verified'] = $_meta_value == 'verified' ? true : false;
|
253 |
+
break;
|
254 |
+
}
|
255 |
+
|
256 |
+
update_user_meta( $object_id, 'um_member_directory_data', $md_data );
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
/**
|
261 |
+
* @param $user_id
|
262 |
+
*/
|
263 |
+
function delete_user_handler( $user_id ) {
|
264 |
+
um_fetch_user( $user_id );
|
265 |
+
|
266 |
+
/**
|
267 |
+
* UM hook
|
268 |
+
*
|
269 |
+
* @type action
|
270 |
+
* @title um_delete_user_hook
|
271 |
+
* @description On delete user
|
272 |
+
* @change_log
|
273 |
+
* ["Since: 2.0"]
|
274 |
+
* @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
|
275 |
+
* @example
|
276 |
+
* <?php
|
277 |
+
* add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
|
278 |
+
* function my_delete_user() {
|
279 |
+
* // your code here
|
280 |
+
* }
|
281 |
+
* ?>
|
282 |
+
*/
|
283 |
+
do_action( 'um_delete_user_hook' );
|
284 |
+
|
285 |
+
/**
|
286 |
+
* UM hook
|
287 |
+
*
|
288 |
+
* @type action
|
289 |
+
* @title um_delete_user
|
290 |
+
* @description On delete user
|
291 |
+
* @input_vars
|
292 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
293 |
+
* @change_log
|
294 |
+
* ["Since: 2.0"]
|
295 |
+
* @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
|
296 |
+
* @example
|
297 |
+
* <?php
|
298 |
+
* add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
|
299 |
+
* function my_delete_user( $user_id ) {
|
300 |
+
* // your code here
|
301 |
+
* }
|
302 |
+
* ?>
|
303 |
+
*/
|
304 |
+
do_action( 'um_delete_user', um_user( 'ID' ) );
|
305 |
+
|
306 |
+
// send email notifications
|
307 |
+
if ( $this->send_mail_on_delete ) {
|
308 |
+
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
|
309 |
+
|
310 |
+
$emails = um_multi_admin_email();
|
311 |
+
if ( ! empty( $emails ) ) {
|
312 |
+
foreach ( $emails as $email ) {
|
313 |
+
UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
// remove uploads
|
319 |
+
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
320 |
+
UM()->files()->remove_dir( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR );
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
/**
|
325 |
+
*
|
326 |
+
*/
|
327 |
+
function check_membership() {
|
328 |
+
if ( ! is_user_logged_in() ) {
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
|
332 |
+
um_fetch_user( get_current_user_id() );
|
333 |
+
$status = um_user( 'account_status' );
|
334 |
+
|
335 |
+
if ( 'rejected' == $status ) {
|
336 |
+
wp_logout();
|
337 |
+
session_unset();
|
338 |
+
exit( wp_redirect( um_get_core_page( 'login' ) ) );
|
339 |
+
}
|
340 |
+
|
341 |
+
um_reset_user();
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Multisite add existing user
|
347 |
+
*
|
348 |
+
* @param $user_id
|
349 |
+
* @param $result
|
350 |
+
*/
|
351 |
+
function add_um_role_existing_user( $user_id, $result ) {
|
352 |
+
// Bail if no user ID was passed
|
353 |
+
if ( empty( $user_id ) ) {
|
354 |
+
return;
|
355 |
+
}
|
356 |
+
|
357 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
358 |
+
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
359 |
+
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
$this->remove_cache( $user_id );
|
364 |
+
}
|
365 |
+
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Multisite add existing user
|
369 |
+
*
|
370 |
+
* @param $user_id
|
371 |
+
*/
|
372 |
+
function add_um_role_wpmu_new_user( $user_id ) {
|
373 |
+
// Bail if no user ID was passed
|
374 |
+
if ( empty( $user_id ) ) {
|
375 |
+
return;
|
376 |
+
}
|
377 |
+
|
378 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
379 |
+
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
380 |
+
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
$this->remove_cache( $user_id );
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Get pending users (in queue)
|
390 |
+
*/
|
391 |
+
function get_pending_users_count() {
|
392 |
+
|
393 |
+
$cached_users_queue = get_option( 'um_cached_users_queue' );
|
394 |
+
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ) {
|
395 |
+
return $cached_users_queue;
|
396 |
+
}
|
397 |
+
|
398 |
+
$args = array( 'fields' => 'ID', 'number' => 1 );
|
399 |
+
$args['meta_query']['relation'] = 'OR';
|
400 |
+
$args['meta_query'][] = array(
|
401 |
+
'key' => 'account_status',
|
402 |
+
'value' => 'awaiting_email_confirmation',
|
403 |
+
'compare' => '='
|
404 |
+
);
|
405 |
+
$args['meta_query'][] = array(
|
406 |
+
'key' => 'account_status',
|
407 |
+
'value' => 'awaiting_admin_review',
|
408 |
+
'compare' => '='
|
409 |
+
);
|
410 |
+
|
411 |
+
/**
|
412 |
+
* UM hook
|
413 |
+
*
|
414 |
+
* @type filter
|
415 |
+
* @title um_admin_pending_queue_filter
|
416 |
+
* @description Change user query arguments when get pending users
|
417 |
+
* @input_vars
|
418 |
+
* [{"var":"$args","type":"array","desc":"WP_Users query arguments"}]
|
419 |
+
* @change_log
|
420 |
+
* ["Since: 2.0"]
|
421 |
+
* @usage
|
422 |
+
* <?php add_filter( 'um_admin_pending_queue_filter', 'function_name', 10, 1 ); ?>
|
423 |
+
* @example
|
424 |
+
* <?php
|
425 |
+
* add_filter( 'um_admin_pending_queue_filter', 'my_admin_pending_queue', 10, 1 );
|
426 |
+
* function my_admin_pending_queue( $args ) {
|
427 |
+
* // your code here
|
428 |
+
* return $args;
|
429 |
+
* }
|
430 |
+
* ?>
|
431 |
+
*/
|
432 |
+
$args = apply_filters( 'um_admin_pending_queue_filter', $args );
|
433 |
+
$users = new \WP_User_Query( $args );
|
434 |
+
|
435 |
+
delete_option( 'um_cached_users_queue' );
|
436 |
+
add_option( 'um_cached_users_queue', $users->get_total(), '', 'no' );
|
437 |
+
|
438 |
+
return $users->get_total();
|
439 |
+
}
|
440 |
+
|
441 |
+
|
442 |
+
/**
|
443 |
+
* @param $user_id
|
444 |
+
*
|
445 |
+
* @return bool|mixed
|
446 |
+
*/
|
447 |
+
function get_profile_slug( $user_id ) {
|
448 |
+
// Permalink base
|
449 |
+
$permalink_base = UM()->options()->get( 'permalink_base' );
|
450 |
+
$profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
|
451 |
+
|
452 |
+
//get default username permalink if it's empty then return false
|
453 |
+
if ( empty( $profile_slug ) ) {
|
454 |
+
if ( $permalink_base != 'user_login' ) {
|
455 |
+
$profile_slug = get_user_meta( $user_id, 'um_user_profile_url_slug_user_login', true );
|
456 |
+
}
|
457 |
+
|
458 |
+
if ( empty( $profile_slug ) ) {
|
459 |
+
return false;
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
return $profile_slug;
|
464 |
+
}
|
465 |
+
|
466 |
+
|
467 |
+
/**
|
468 |
+
* @param $user_id
|
469 |
+
*
|
470 |
+
* @return bool|string
|
471 |
+
*/
|
472 |
+
function get_profile_link( $user_id ) {
|
473 |
+
$profile_slug = $this->get_profile_slug( $user_id );
|
474 |
+
|
475 |
+
if ( empty( $profile_slug ) ) {
|
476 |
+
return false;
|
477 |
+
}
|
478 |
+
|
479 |
+
return UM()->permalinks()->profile_permalink( $profile_slug );
|
480 |
+
}
|
481 |
+
|
482 |
+
|
483 |
+
/**
|
484 |
+
* Generate User Profile Slug and save to meta
|
485 |
+
*
|
486 |
+
* @param int $user_id
|
487 |
+
* @param bool $force
|
488 |
+
*/
|
489 |
+
function generate_profile_slug( $user_id, $force = false ) {
|
490 |
+
$userdata = get_userdata( $user_id );
|
491 |
+
|
492 |
+
if ( empty( $userdata ) ) {
|
493 |
+
return;
|
494 |
+
}
|
495 |
+
|
496 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
497 |
+
|
498 |
+
$current_profile_slug = $this->get_profile_slug( $user_id );
|
499 |
+
|
500 |
+
$user_in_url = '';
|
501 |
+
$permalink_base = UM()->options()->get( 'permalink_base' );
|
502 |
+
|
503 |
+
// User ID
|
504 |
+
if ( $permalink_base == 'user_id' ) {
|
505 |
+
$user_in_url = $user_id;
|
506 |
+
}
|
507 |
+
|
508 |
+
// Username
|
509 |
+
if ( $permalink_base == 'user_login' ) {
|
510 |
+
|
511 |
+
$user_in_url = $userdata->user_login;
|
512 |
+
|
513 |
+
if ( is_email( $user_in_url ) ) {
|
514 |
+
|
515 |
+
$user_email = $user_in_url;
|
516 |
+
$user_in_url = str_replace( '@', '', $user_in_url );
|
517 |
+
|
518 |
+
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
519 |
+
$search_length = strlen( '.' );
|
520 |
+
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
521 |
+
}
|
522 |
+
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
523 |
+
|
524 |
+
} else {
|
525 |
+
|
526 |
+
$user_in_url = urlencode( $user_in_url );
|
527 |
+
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
// Fisrt and Last name
|
532 |
+
$full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
|
533 |
+
if ( in_array( $permalink_base, $full_name_permalinks ) ) {
|
534 |
+
$separated = array( 'name' => '.', 'name_dash' => '-', 'name_plus' => '+' );
|
535 |
+
$separate = $separated[ $permalink_base ];
|
536 |
+
$first_name = $userdata->first_name;
|
537 |
+
$last_name = $userdata->last_name;
|
538 |
+
$full_name = trim( sprintf( '%s %s', $first_name, $last_name ) );
|
539 |
+
$full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
|
540 |
+
$profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
|
541 |
+
|
542 |
+
$append = 0;
|
543 |
+
$username = $full_name;
|
544 |
+
$_username = $full_name;
|
545 |
+
|
546 |
+
while ( 1 ) {
|
547 |
+
$username = $_username . ( empty( $append ) ? '' : " $append" );
|
548 |
+
$slug_exists_user_id = UM()->permalinks()->slug_exists_user_id( $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) );
|
549 |
+
if ( empty( $slug_exists_user_id ) || $user_id == $slug_exists_user_id ) {
|
550 |
+
break;
|
551 |
+
}
|
552 |
+
$append++;
|
553 |
+
}
|
554 |
+
|
555 |
+
$user_in_url = UM()->permalinks()->profile_slug( $username, $first_name, $last_name );
|
556 |
+
if ( empty( $user_in_url ) ) {
|
557 |
+
$user_in_url = $userdata->user_login;
|
558 |
+
|
559 |
+
if ( is_email( $user_in_url ) ) {
|
560 |
+
|
561 |
+
$user_email = $user_in_url;
|
562 |
+
$user_in_url = str_replace( '@', '', $user_in_url );
|
563 |
+
|
564 |
+
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
565 |
+
$search_length = strlen( '.' );
|
566 |
+
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
567 |
+
}
|
568 |
+
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
569 |
+
|
570 |
+
} else {
|
571 |
+
|
572 |
+
$user_in_url = sanitize_title( $user_in_url );
|
573 |
+
|
574 |
+
}
|
575 |
+
}
|
576 |
+
|
577 |
+
$user_in_url = trim( $user_in_url, $separate );
|
578 |
+
}
|
579 |
+
|
580 |
+
$user_in_url = apply_filters( 'um_change_user_profile_slug', $user_in_url, $user_id );
|
581 |
+
|
582 |
+
if ( $force || empty( $current_profile_slug ) || $current_profile_slug != $user_in_url ) {
|
583 |
+
update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Backend user creation
|
590 |
+
*
|
591 |
+
* @param $user_id
|
592 |
+
*/
|
593 |
+
function user_register_via_admin( $user_id ) {
|
594 |
+
|
595 |
+
if ( empty( $user_id ) ) {
|
596 |
+
return;
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( is_admin() ) {
|
600 |
+
//if there custom 2 role not empty
|
601 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
602 |
+
$user = get_userdata( $user_id );
|
603 |
+
$user->add_role( sanitize_key( $_POST['um-role'] ) );
|
604 |
+
UM()->user()->profile['role'] = sanitize_key( $_POST['um-role'] );
|
605 |
+
UM()->user()->update_usermeta_info( 'role' );
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* UM hook
|
610 |
+
*
|
611 |
+
* @type action
|
612 |
+
* @title um_user_register
|
613 |
+
* @description Action on user registration
|
614 |
+
* @input_vars
|
615 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
616 |
+
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
617 |
+
* @change_log
|
618 |
+
* ["Since: 2.0"]
|
619 |
+
* @usage add_action( 'um_user_register', 'function_name', 10, 2 );
|
620 |
+
* @example
|
621 |
+
* <?php
|
622 |
+
* add_action( 'um_user_register', 'my_user_register', 10, 2 );
|
623 |
+
* function my_user_register( $user_id, $submitted ) {
|
624 |
+
* // your code here
|
625 |
+
* }
|
626 |
+
* ?>
|
627 |
+
*/
|
628 |
+
do_action( 'um_user_register', $user_id, $_POST );
|
629 |
+
}
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
/**
|
635 |
+
* On wp_update_user function complete
|
636 |
+
*
|
637 |
+
* @param int $user_id
|
638 |
+
* @param \WP_User $old_data
|
639 |
+
*/
|
640 |
+
function profile_update( $user_id, $old_data ) {
|
641 |
+
// Bail if no user ID was passed
|
642 |
+
if ( empty( $user_id ) ) {
|
643 |
+
return;
|
644 |
+
}
|
645 |
+
|
646 |
+
$old_roles = $old_data->roles;
|
647 |
+
$userdata = get_userdata( $user_id );
|
648 |
+
$new_roles = $userdata->roles;
|
649 |
+
|
650 |
+
if ( is_admin() ) {
|
651 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
652 |
+
$new_roles = array_merge( $new_roles, array( sanitize_key( $_POST['um-role'] ) ) );
|
653 |
+
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
654 |
+
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
655 |
+
}
|
656 |
+
}
|
657 |
+
}
|
658 |
+
|
659 |
+
/**
|
660 |
+
* UM hook
|
661 |
+
*
|
662 |
+
* @type action
|
663 |
+
* @title um_after_member_role_upgrade
|
664 |
+
* @description Action on user registration
|
665 |
+
* @input_vars
|
666 |
+
* [{"var":"$new_roles","type":"array","desc":"User new roles"},
|
667 |
+
* {"var":"$old_roles","type":"array","desc":"Old roles"}]
|
668 |
+
* @change_log
|
669 |
+
* ["Since: 2.0"]
|
670 |
+
* @usage add_action( 'um_after_member_role_upgrade', 'function_name', 10, 2 );
|
671 |
+
* @example
|
672 |
+
* <?php
|
673 |
+
* add_action( 'um_after_member_role_upgrade', 'my_after_member_role_upgrade', 10, 2 );
|
674 |
+
* function my_after_member_role_upgrade( $new_roles, $old_roles ) {
|
675 |
+
* // your code here
|
676 |
+
* }
|
677 |
+
* ?>
|
678 |
+
*/
|
679 |
+
do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles, $user_id );
|
680 |
+
|
681 |
+
//Update permalink
|
682 |
+
$this->generate_profile_slug( $user_id, true );
|
683 |
+
|
684 |
+
$this->remove_cache( $user_id );
|
685 |
+
}
|
686 |
+
|
687 |
+
|
688 |
+
/**
|
689 |
+
* Additional section for WP Profile page with UM data fields
|
690 |
+
*
|
691 |
+
* @param \WP_User $userdata User data
|
692 |
+
* @return void
|
693 |
+
*/
|
694 |
+
function profile_form_additional_section( $userdata ) {
|
695 |
+
|
696 |
+
/**
|
697 |
+
* UM hook
|
698 |
+
*
|
699 |
+
* @type filter
|
700 |
+
* @title um_user_profile_additional_fields
|
701 |
+
* @description Make additional content section
|
702 |
+
* @input_vars
|
703 |
+
* [{"var":"$content","type":"array","desc":"Additional section content"},
|
704 |
+
* {"var":"$userdata","type":"array","desc":"Userdata"}]
|
705 |
+
* @change_log
|
706 |
+
* ["Since: 2.0"]
|
707 |
+
* @usage
|
708 |
+
* <?php add_filter( 'um_user_profile_additional_fields', 'function_name', 10, 2 ); ?>
|
709 |
+
* @example
|
710 |
+
* <?php
|
711 |
+
* add_filter( 'um_user_profile_additional_fields', 'my_admin_pending_queue', 10, 2 );
|
712 |
+
* function my_admin_pending_queue( $content, $userdata ) {
|
713 |
+
* // your code here
|
714 |
+
* return $content;
|
715 |
+
* }
|
716 |
+
* ?>
|
717 |
+
*/
|
718 |
+
$section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
|
719 |
+
|
720 |
+
if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
|
721 |
+
|
722 |
+
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) { ?>
|
723 |
+
<h3 id="um_user_screen_block"><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
|
724 |
+
<?php }
|
725 |
+
|
726 |
+
echo $section_content;
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
|
731 |
+
/**
|
732 |
+
* Default interface for setting a ultimatemember role
|
733 |
+
*
|
734 |
+
* @param string $content Section HTML
|
735 |
+
* @param \WP_User $userdata User data
|
736 |
+
* @return string
|
737 |
+
*/
|
738 |
+
public function secondary_role_field( $content, $userdata ) {
|
739 |
+
$roles = array();
|
740 |
+
|
741 |
+
$role_keys = get_option( 'um_roles', array() );
|
742 |
+
if ( $role_keys ) {
|
743 |
+
foreach ( $role_keys as $role_key ) {
|
744 |
+
$role_meta = get_option( "um_role_{$role_key}_meta" );
|
745 |
+
|
746 |
+
if ( $role_meta ) {
|
747 |
+
$roles[ 'um_' . $role_key ] = $role_meta;
|
748 |
+
}
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
if ( empty( $roles ) ) {
|
753 |
+
return $content;
|
754 |
+
}
|
755 |
+
|
756 |
+
global $pagenow;
|
757 |
+
if ( 'profile.php' == $pagenow ) {
|
758 |
+
return $content;
|
759 |
+
}
|
760 |
+
|
761 |
+
$style = '';
|
762 |
+
$user_role = false;
|
763 |
+
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) {
|
764 |
+
// Bail if current user cannot edit users
|
765 |
+
if ( ! current_user_can( 'edit_user', $userdata->ID ) ) {
|
766 |
+
return $content;
|
767 |
+
}
|
768 |
+
|
769 |
+
$user_role = UM()->roles()->get_um_user_role( $userdata->ID );
|
770 |
+
if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 ) {
|
771 |
+
$style = 'style="display:none;"';
|
772 |
+
}
|
773 |
+
|
774 |
+
}
|
775 |
+
|
776 |
+
$class = ( $userdata == 'add-existing-user' ) ? 'um_role_existing_selector_wrapper' : 'um_role_selector_wrapper';
|
777 |
+
|
778 |
+
ob_start(); ?>
|
779 |
+
|
780 |
+
<div id="<?php echo esc_attr( $class ) ?>" <?php echo $style ?>>
|
781 |
+
<table class="form-table">
|
782 |
+
<tbody>
|
783 |
+
<tr>
|
784 |
+
<th><label for="um-role"><?php esc_html_e( 'Ultimate Member Role', 'ultimate-member' ); ?></label></th>
|
785 |
+
<td>
|
786 |
+
<select name="um-role" id="um-role">
|
787 |
+
<option value="" <?php selected( empty( $user_role ) ) ?>><?php esc_html_e( '— No role for Ultimate Member —', 'ultimate-member' ); ?></option>
|
788 |
+
<?php foreach ( $roles as $role_id => $details ) { ?>
|
789 |
+
<option <?php selected( $user_role, $role_id ); ?> value="<?php echo esc_attr( $role_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
|
790 |
+
<?php } ?>
|
791 |
+
</select>
|
792 |
+
</td>
|
793 |
+
</tr>
|
794 |
+
</tbody>
|
795 |
+
</table>
|
796 |
+
</div>
|
797 |
+
|
798 |
+
<?php $content .= ob_get_clean();
|
799 |
+
|
800 |
+
return $content;
|
801 |
+
}
|
802 |
+
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Remove cached queue from Users backend
|
806 |
+
*/
|
807 |
+
function remove_cached_queue() {
|
808 |
+
delete_option( 'um_cached_users_queue' );
|
809 |
+
}
|
810 |
+
|
811 |
+
|
812 |
+
/**
|
813 |
+
* Converts object to array
|
814 |
+
*
|
815 |
+
* @param $obj
|
816 |
+
*
|
817 |
+
* @return array
|
818 |
+
*/
|
819 |
+
function toArray( $obj ) {
|
820 |
+
if ( is_object( $obj ) ) {
|
821 |
+
$obj = (array) $obj;
|
822 |
+
}
|
823 |
+
if ( is_array( $obj ) ) {
|
824 |
+
$new = array();
|
825 |
+
foreach ( $obj as $key => $val ) {
|
826 |
+
$new[ $key ] = $this->toArray( $val );
|
827 |
+
}
|
828 |
+
} else {
|
829 |
+
$new = $obj;
|
830 |
+
}
|
831 |
+
|
832 |
+
return $new;
|
833 |
+
}
|
834 |
+
|
835 |
+
|
836 |
+
/**
|
837 |
+
* @param $user_id
|
838 |
+
*
|
839 |
+
* @return mixed|string
|
840 |
+
*/
|
841 |
+
function get_cached_data( $user_id ) {
|
842 |
+
|
843 |
+
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
|
844 |
+
if ( $disallow_cache ) {
|
845 |
+
return '';
|
846 |
+
}
|
847 |
+
|
848 |
+
if ( is_numeric( $user_id ) && $user_id > 0 ) {
|
849 |
+
$find_user = get_option( "um_cache_userdata_{$user_id}" );
|
850 |
+
if ( $find_user ) {
|
851 |
+
/**
|
852 |
+
* UM hook
|
853 |
+
*
|
854 |
+
* @type filter
|
855 |
+
* @title um_user_permissions_filter
|
856 |
+
* @description Change User Permissions
|
857 |
+
* @input_vars
|
858 |
+
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
859 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
860 |
+
* @change_log
|
861 |
+
* ["Since: 2.0"]
|
862 |
+
* @usage
|
863 |
+
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
864 |
+
* @example
|
865 |
+
* <?php
|
866 |
+
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
867 |
+
* function my_user_permissions( $permissions, $user_id ) {
|
868 |
+
* // your code here
|
869 |
+
* return $permissions;
|
870 |
+
* }
|
871 |
+
* ?>
|
872 |
+
*/
|
873 |
+
$find_user = apply_filters( 'um_user_permissions_filter', $find_user, $user_id );
|
874 |
+
return $find_user;
|
875 |
+
}
|
876 |
+
}
|
877 |
+
return '';
|
878 |
+
}
|
879 |
+
|
880 |
+
|
881 |
+
/**
|
882 |
+
* @param $user_id
|
883 |
+
* @param $profile
|
884 |
+
*/
|
885 |
+
function setup_cache( $user_id, $profile ) {
|
886 |
+
|
887 |
+
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
|
888 |
+
if ( $disallow_cache ) {
|
889 |
+
return;
|
890 |
+
}
|
891 |
+
|
892 |
+
update_option( "um_cache_userdata_{$user_id}", $profile, false );
|
893 |
+
}
|
894 |
+
|
895 |
+
|
896 |
+
/**
|
897 |
+
* @param $user_id
|
898 |
+
*/
|
899 |
+
function remove_cache( $user_id ) {
|
900 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
901 |
+
}
|
902 |
+
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Remove cache for all users
|
906 |
+
*/
|
907 |
+
function remove_cache_all_users() {
|
908 |
+
global $wpdb;
|
909 |
+
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
910 |
+
}
|
911 |
+
|
912 |
+
|
913 |
+
/**
|
914 |
+
* This method lets you set a user. For example, to retrieve a profile or anything related to that user.
|
915 |
+
*
|
916 |
+
* @usage <?php UM()->user()->set( $user_id, $clean = false ); ?>
|
917 |
+
*
|
918 |
+
* @param null|int $user_id Which user to retrieve. A numeric user ID
|
919 |
+
* @param bool $clean Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
|
920 |
+
*
|
921 |
+
* @example The following example makes you set a user and retrieve their display name after that using the user API.
|
922 |
+
|
923 |
+
<?php
|
924 |
+
|
925 |
+
UM()->user()->set( 12 );
|
926 |
+
$display_name = UM()->user()->profile['display_name']; // Should print user display name
|
927 |
+
|
928 |
+
?>
|
929 |
+
*
|
930 |
+
*/
|
931 |
+
function set( $user_id = null, $clean = false ) {
|
932 |
+
if ( isset( $this->profile ) ) {
|
933 |
+
unset( $this->profile );
|
934 |
+
}
|
935 |
+
|
936 |
+
if ( $user_id ) {
|
937 |
+
$this->id = $user_id;
|
938 |
+
} elseif ( is_user_logged_in() && $clean == false ) {
|
939 |
+
$this->id = get_current_user_id();
|
940 |
+
} else {
|
941 |
+
$this->id = 0;
|
942 |
+
}
|
943 |
+
|
944 |
+
if ( $this->get_cached_data( $this->id ) ) {
|
945 |
+
$this->profile = $this->get_cached_data( $this->id );
|
946 |
+
} else {
|
947 |
+
|
948 |
+
if ( $user_id ) {
|
949 |
+
|
950 |
+
$this->id = $user_id;
|
951 |
+
$this->usermeta = get_user_meta( $user_id );
|
952 |
+
$this->data = get_userdata( $this->id );
|
953 |
+
|
954 |
+
} elseif ( is_user_logged_in() && $clean == false ) {
|
955 |
+
|
956 |
+
$this->id = get_current_user_id();
|
957 |
+
$this->usermeta = get_user_meta($this->id);
|
958 |
+
$this->data = get_userdata($this->id);
|
959 |
+
|
960 |
+
} else {
|
961 |
+
|
962 |
+
$this->id = 0;
|
963 |
+
$this->usermeta = null;
|
964 |
+
$this->data = null;
|
965 |
+
|
966 |
+
}
|
967 |
+
|
968 |
+
// we have a user, populate a profile
|
969 |
+
if ( $this->id && $this->toArray( $this->data ) ) {
|
970 |
+
|
971 |
+
// add user data
|
972 |
+
$this->data = $this->toArray( $this->data );
|
973 |
+
|
974 |
+
foreach ( $this->data as $k=>$v ) {
|
975 |
+
if ( $k == 'roles') {
|
976 |
+
$this->profile['wp_roles'] = implode(',',$v);
|
977 |
+
} else if ( is_array( $v ) ) {
|
978 |
+
foreach($v as $k2 => $v2){
|
979 |
+
$this->profile[$k2] = $v2;
|
980 |
+
}
|
981 |
+
} else {
|
982 |
+
$this->profile[$k] = $v;
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
// add account status
|
987 |
+
if ( !isset( $this->usermeta['account_status'][0] ) ) {
|
988 |
+
$this->usermeta['account_status'][0] = 'approved';
|
989 |
+
}
|
990 |
+
|
991 |
+
if ( $this->usermeta['account_status'][0] == 'approved' ) {
|
992 |
+
$this->usermeta['account_status_name'][0] = __('Approved','ultimate-member');
|
993 |
+
}
|
994 |
+
|
995 |
+
if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
|
996 |
+
$this->usermeta['account_status_name'][0] = __('Awaiting E-mail Confirmation','ultimate-member');
|
997 |
+
}
|
998 |
+
|
999 |
+
if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
|
1000 |
+
$this->usermeta['account_status_name'][0] = __('Pending Review','ultimate-member');
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
if ( $this->usermeta['account_status'][0] == 'rejected' ) {
|
1004 |
+
$this->usermeta['account_status_name'][0] = __('Membership Rejected','ultimate-member');
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
if ( $this->usermeta['account_status'][0] == 'inactive' ) {
|
1008 |
+
$this->usermeta['account_status_name'][0] = __('Membership Inactive','ultimate-member');
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
// add user meta
|
1012 |
+
foreach ( $this->usermeta as $k => $v ) {
|
1013 |
+
if ( $k == 'display_name') {
|
1014 |
+
continue;
|
1015 |
+
}
|
1016 |
+
$this->profile[ $k ] = $v[0];
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
// add permissions
|
1020 |
+
$user_role = UM()->roles()->get_priority_user_role( $this->id );
|
1021 |
+
$this->profile['role'] = $user_role;
|
1022 |
+
$this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
|
1023 |
+
|
1024 |
+
$role_meta = UM()->roles()->role_data( $user_role );
|
1025 |
+
/**
|
1026 |
+
* UM hook
|
1027 |
+
*
|
1028 |
+
* @type filter
|
1029 |
+
* @title um_user_permissions_filter
|
1030 |
+
* @description Change User Permissions
|
1031 |
+
* @input_vars
|
1032 |
+
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
1033 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1034 |
+
* @change_log
|
1035 |
+
* ["Since: 2.0"]
|
1036 |
+
* @usage
|
1037 |
+
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
1038 |
+
* @example
|
1039 |
+
* <?php
|
1040 |
+
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
1041 |
+
* function my_user_permissions( $permissions, $user_id ) {
|
1042 |
+
* // your code here
|
1043 |
+
* return $permissions;
|
1044 |
+
* }
|
1045 |
+
* ?>
|
1046 |
+
*/
|
1047 |
+
$role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
|
1048 |
+
|
1049 |
+
/*$role_meta = array_map( function( $key, $item ) {
|
1050 |
+
if ( strpos( $key, '_um_' ) === 0 )
|
1051 |
+
$key = str_replace( '_um_', '', $key );
|
1052 |
+
|
1053 |
+
return array( $key => $item );
|
1054 |
+
}, array_keys( $role_meta ), $role_meta );*/
|
1055 |
+
|
1056 |
+
$this->profile = array_merge( $this->profile, (array)$role_meta );
|
1057 |
+
|
1058 |
+
$this->profile['super_admin'] = ( is_super_admin( $this->id ) ) ? 1 : 0;
|
1059 |
+
|
1060 |
+
// clean profile
|
1061 |
+
$this->clean();
|
1062 |
+
|
1063 |
+
// Setup cache
|
1064 |
+
$this->setup_cache( $this->id, $this->profile );
|
1065 |
+
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
|
1073 |
+
/**
|
1074 |
+
* Reset user data
|
1075 |
+
*
|
1076 |
+
* @param bool $clean
|
1077 |
+
*/
|
1078 |
+
function reset( $clean = false ){
|
1079 |
+
$this->set(0, $clean);
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
|
1083 |
+
/**
|
1084 |
+
* Clean user profile
|
1085 |
+
*/
|
1086 |
+
function clean() {
|
1087 |
+
foreach ( $this->profile as $key => $value ) {
|
1088 |
+
foreach ( $this->banned_keys as $ban ) {
|
1089 |
+
if ( strstr( $key, $ban ) || is_numeric( $key ) ) {
|
1090 |
+
unset( $this->profile[ $key ] );
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
|
1097 |
+
/**
|
1098 |
+
* This method lets you auto sign-in a user to your site.
|
1099 |
+
*
|
1100 |
+
* @usage <?php UM()->user()->auto_login( $user_id, $rememberme = false ); ?>
|
1101 |
+
*
|
1102 |
+
* @param int $user_id Which user ID to sign in automatically
|
1103 |
+
* @param int|bool $rememberme Should be true or false. If you want the user sign in session to use cookies, use true
|
1104 |
+
*
|
1105 |
+
* @example The following example lets you sign in a user automatically by their ID.
|
1106 |
+
|
1107 |
+
<?php UM()->user()->auto_login( 2 ); ?>
|
1108 |
+
*
|
1109 |
+
*
|
1110 |
+
* @example The following example lets you sign in a user automatically by their ID and makes the plugin remember their session.
|
1111 |
+
|
1112 |
+
<?php UM()->user()->auto_login( 10, true ); ?>
|
1113 |
+
*
|
1114 |
+
*/
|
1115 |
+
function auto_login( $user_id, $rememberme = 0 ) {
|
1116 |
+
|
1117 |
+
wp_set_current_user( $user_id );
|
1118 |
+
|
1119 |
+
wp_set_auth_cookie( $user_id, $rememberme );
|
1120 |
+
|
1121 |
+
$user = get_user_by( 'ID', $user_id );
|
1122 |
+
|
1123 |
+
do_action( 'wp_login', $user->user_login, $user );
|
1124 |
+
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
|
1128 |
+
/**
|
1129 |
+
* Set user's registration details
|
1130 |
+
*
|
1131 |
+
* @param array $submitted
|
1132 |
+
* @param array $args
|
1133 |
+
*/
|
1134 |
+
function set_registration_details( $submitted, $args ) {
|
1135 |
+
|
1136 |
+
if ( isset( $submitted['user_pass'] ) ) {
|
1137 |
+
unset( $submitted['user_pass'] );
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
if ( isset( $submitted['user_password'] ) ) {
|
1141 |
+
unset( $submitted['user_password'] );
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
if ( isset( $submitted['confirm_user_password'] ) ) {
|
1145 |
+
unset( $submitted['confirm_user_password'] );
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
//remove all password field values from submitted details
|
1149 |
+
$password_fields = array();
|
1150 |
+
foreach ( $submitted as $k => $v ) {
|
1151 |
+
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
|
1152 |
+
$password_fields[] = $k;
|
1153 |
+
$password_fields[] = 'confirm_' . $k;
|
1154 |
+
}
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
foreach ( $password_fields as $pw_field ) {
|
1158 |
+
unset( $submitted[ $pw_field ] );
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
|
1162 |
+
/**
|
1163 |
+
* UM hook
|
1164 |
+
*
|
1165 |
+
* @type filter
|
1166 |
+
* @title um_before_save_filter_submitted
|
1167 |
+
* @description Change submitted data before save usermeta "submitted" on registration process
|
1168 |
+
* @input_vars
|
1169 |
+
* [{"var":"$submitted","type":"array","desc":"Submitted data"},
|
1170 |
+
* {"var":"$args","type":"array","desc":"Form Args"}]
|
1171 |
+
* @change_log
|
1172 |
+
* ["Since: 2.0"]
|
1173 |
+
* @usage
|
1174 |
+
* <?php add_filter( 'um_before_save_filter_submitted', 'function_name', 10, 2 ); ?>
|
1175 |
+
* @example
|
1176 |
+
* <?php
|
1177 |
+
* add_filter( 'um_before_save_filter_submitted', 'my_before_save_filter_submitted', 10, 2 );
|
1178 |
+
* function my_before_save_filter_submitted( $submitted, $args ) {
|
1179 |
+
* // your code here
|
1180 |
+
* return $submitted;
|
1181 |
+
* }
|
1182 |
+
* ?>
|
1183 |
+
*/
|
1184 |
+
$submitted = apply_filters( 'um_before_save_filter_submitted', $submitted, $args );
|
1185 |
+
|
1186 |
+
/**
|
1187 |
+
* UM hook
|
1188 |
+
*
|
1189 |
+
* @type action
|
1190 |
+
* @title um_before_save_registration_details
|
1191 |
+
* @description Action on user registration before save details
|
1192 |
+
* @input_vars
|
1193 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1194 |
+
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
1195 |
+
* @change_log
|
1196 |
+
* ["Since: 2.0"]
|
1197 |
+
* @usage add_action( 'um_before_save_registration_details', 'function_name', 10, 2 );
|
1198 |
+
* @example
|
1199 |
+
* <?php
|
1200 |
+
* add_action( 'um_before_save_registration_details', 'my_before_save_registration_details', 10, 2 );
|
1201 |
+
* function my_before_save_registration_details( $user_id, $submitted ) {
|
1202 |
+
* // your code here
|
1203 |
+
* }
|
1204 |
+
* ?>
|
1205 |
+
*/
|
1206 |
+
do_action( 'um_before_save_registration_details', $this->id, $submitted );
|
1207 |
+
|
1208 |
+
update_user_meta( $this->id, 'submitted', $submitted );
|
1209 |
+
|
1210 |
+
$this->update_profile( $submitted );
|
1211 |
+
/**
|
1212 |
+
* UM hook
|
1213 |
+
*
|
1214 |
+
* @type action
|
1215 |
+
* @title um_after_save_registration_details
|
1216 |
+
* @description Action on user registration after save details
|
1217 |
+
* @input_vars
|
1218 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1219 |
+
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
1220 |
+
* @change_log
|
1221 |
+
* ["Since: 2.0"]
|
1222 |
+
* @usage add_action( 'um_after_save_registration_details', 'function_name', 10, 2 );
|
1223 |
+
* @example
|
1224 |
+
* <?php
|
1225 |
+
* add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
|
1226 |
+
* function my_after_save_registration_details( $user_id, $submitted ) {
|
1227 |
+
* // your code here
|
1228 |
+
* }
|
1229 |
+
* ?>
|
1230 |
+
*/
|
1231 |
+
do_action( 'um_after_save_registration_details', $this->id, $submitted );
|
1232 |
+
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* Set last login for new registered users
|
1238 |
+
*/
|
1239 |
+
function set_last_login() {
|
1240 |
+
update_user_meta( $this->id, '_um_last_login', current_time( 'timestamp' ) );
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
|
1244 |
+
/**
|
1245 |
+
* Set user's account status
|
1246 |
+
*
|
1247 |
+
* @param $status
|
1248 |
+
*/
|
1249 |
+
function set_status( $status ) {
|
1250 |
+
|
1251 |
+
/**
|
1252 |
+
* UM hook
|
1253 |
+
*
|
1254 |
+
* @type action
|
1255 |
+
* @title um_when_status_is_set
|
1256 |
+
* @description Action on user status changed
|
1257 |
+
* @input_vars
|
1258 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1259 |
+
* @change_log
|
1260 |
+
* ["Since: 2.0"]
|
1261 |
+
* @usage add_action( 'um_when_status_is_set', 'function_name', 10, 1 );
|
1262 |
+
* @example
|
1263 |
+
* <?php
|
1264 |
+
* add_action( 'um_when_status_is_set', 'my_when_status_is_set', 10, 1 );
|
1265 |
+
* function my_when_status_is_set( $user_id ) {
|
1266 |
+
* // your code here
|
1267 |
+
* }
|
1268 |
+
* ?>
|
1269 |
+
*/
|
1270 |
+
do_action( 'um_when_status_is_set', um_user( 'ID' ) );
|
1271 |
+
|
1272 |
+
$this->profile['account_status'] = $status;
|
1273 |
+
|
1274 |
+
$this->update_usermeta_info( 'account_status' );
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* UM hook
|
1278 |
+
*
|
1279 |
+
* @type action
|
1280 |
+
* @title um_after_user_status_is_changed_hook
|
1281 |
+
* @description Action after user status changed
|
1282 |
+
* @input_vars
|
1283 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1284 |
+
* @change_log
|
1285 |
+
* ["Since: 2.0"]
|
1286 |
+
* @usage add_action( 'um_after_user_status_is_changed_hook', 'function_name', 10 );
|
1287 |
+
* @example
|
1288 |
+
* <?php
|
1289 |
+
* add_action( 'um_after_user_status_is_changed_hook', 'my_after_user_status_is_changed', 10 );
|
1290 |
+
* function my_after_user_status_is_changed() {
|
1291 |
+
* // your code here
|
1292 |
+
* }
|
1293 |
+
* ?>
|
1294 |
+
*/
|
1295 |
+
do_action( 'um_after_user_status_is_changed_hook', um_user( 'ID' ) );
|
1296 |
+
|
1297 |
+
/**
|
1298 |
+
* UM hook
|
1299 |
+
*
|
1300 |
+
* @type action
|
1301 |
+
* @title um_after_user_status_is_changed
|
1302 |
+
* @description Action after user status changed
|
1303 |
+
* @input_vars
|
1304 |
+
* [{"var":"$status","type":"string","desc":"User Status"},
|
1305 |
+
* {"var":"$user_id","type":"integer","desc":"User ID"}]
|
1306 |
+
* @change_log
|
1307 |
+
* ["Since: 2.0"]
|
1308 |
+
* @usage add_action( 'um_after_user_status_is_changed', 'function_name', 10, 1 );
|
1309 |
+
* @example
|
1310 |
+
* <?php
|
1311 |
+
* add_action( 'um_after_user_status_is_changed', 'my_after_user_status_is_changed', 10, 1 );
|
1312 |
+
* function my_after_user_status_is_changed( $status ) {
|
1313 |
+
* // your code here
|
1314 |
+
* }
|
1315 |
+
* ?>
|
1316 |
+
*/
|
1317 |
+
do_action( 'um_after_user_status_is_changed', $status, um_user( 'ID' ) );
|
1318 |
+
|
1319 |
+
}
|
1320 |
+
|
1321 |
+
|
1322 |
+
/**
|
1323 |
+
* Set user's hash
|
1324 |
+
*/
|
1325 |
+
function assign_secretkey() {
|
1326 |
+
/**
|
1327 |
+
* UM hook
|
1328 |
+
*
|
1329 |
+
* @type action
|
1330 |
+
* @title um_before_user_hash_is_changed
|
1331 |
+
* @description Action before user hash is changed
|
1332 |
+
* @change_log
|
1333 |
+
* ["Since: 2.0"]
|
1334 |
+
* @usage add_action( 'um_before_user_hash_is_changed', 'function_name', 10 );
|
1335 |
+
* @example
|
1336 |
+
* <?php
|
1337 |
+
* add_action( 'um_before_user_hash_is_changed', 'my_before_user_hash_is_changed', 10 );
|
1338 |
+
* function my_before_user_hash_is_changed() {
|
1339 |
+
* // your code here
|
1340 |
+
* }
|
1341 |
+
* ?>
|
1342 |
+
*/
|
1343 |
+
do_action( 'um_before_user_hash_is_changed' );
|
1344 |
+
|
1345 |
+
$this->profile['account_secret_hash'] = UM()->validation()->generate();
|
1346 |
+
$this->update_usermeta_info( 'account_secret_hash' );
|
1347 |
+
|
1348 |
+
$expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
|
1349 |
+
if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
|
1350 |
+
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
|
1351 |
+
$this->update_usermeta_info( 'account_secret_hash_expiry' );
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
/**
|
1355 |
+
* UM hook
|
1356 |
+
*
|
1357 |
+
* @type action
|
1358 |
+
* @title um_after_user_hash_is_changed
|
1359 |
+
* @description Action after user hash is changed
|
1360 |
+
* @change_log
|
1361 |
+
* ["Since: 2.0"]
|
1362 |
+
* @usage add_action( 'um_after_user_hash_is_changed', 'function_name', 10 );
|
1363 |
+
* @example
|
1364 |
+
* <?php
|
1365 |
+
* add_action( 'um_after_user_hash_is_changed', 'my_after_user_hash_is_changed', 10 );
|
1366 |
+
* function my_after_user_hash_is_changed() {
|
1367 |
+
* // your code here
|
1368 |
+
* }
|
1369 |
+
* ?>
|
1370 |
+
*/
|
1371 |
+
do_action( 'um_after_user_hash_is_changed' );
|
1372 |
+
}
|
1373 |
+
|
1374 |
+
|
1375 |
+
/**
|
1376 |
+
* @param \WP_User $userdata
|
1377 |
+
*
|
1378 |
+
* @return string|\WP_Error
|
1379 |
+
*/
|
1380 |
+
function maybe_generate_password_reset_key( $userdata ) {
|
1381 |
+
if ( empty( $this->password_reset_key ) ) {
|
1382 |
+
$this->password_reset_key = get_password_reset_key( $userdata );
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
return $this->password_reset_key ;
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* Password reset email
|
1391 |
+
*/
|
1392 |
+
function password_reset() {
|
1393 |
+
$userdata = get_userdata( um_user( 'ID' ) );
|
1394 |
+
|
1395 |
+
$this->maybe_generate_password_reset_key( $userdata );
|
1396 |
+
|
1397 |
+
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
1398 |
+
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
1399 |
+
|
1400 |
+
UM()->mail()->send( um_user( 'user_email' ), 'resetpw_email' );
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
|
1404 |
+
/**
|
1405 |
+
* Password changed email
|
1406 |
+
*/
|
1407 |
+
function password_changed() {
|
1408 |
+
UM()->mail()->send( um_user( 'user_email' ), 'changedpw_email' );
|
1409 |
+
}
|
1410 |
+
|
1411 |
+
|
1412 |
+
/**
|
1413 |
+
* This method approves a user membership and sends them an optional welcome/approval e-mail.
|
1414 |
+
*
|
1415 |
+
* @usage <?php UM()->user()->approve(); ?>
|
1416 |
+
*
|
1417 |
+
* @example Approve a pending user and allow him to sign-in to your site.
|
1418 |
+
|
1419 |
+
<?php
|
1420 |
+
|
1421 |
+
um_fetch_user( 352 );
|
1422 |
+
UM()->user()->approve();
|
1423 |
+
|
1424 |
+
?>
|
1425 |
+
*
|
1426 |
+
*/
|
1427 |
+
function approve( $repeat = true ) {
|
1428 |
+
$user_id = um_user('ID');
|
1429 |
+
|
1430 |
+
if ( ! $repeat ) {
|
1431 |
+
$status = get_user_meta( $user_id, 'account_status', true );
|
1432 |
+
if ( 'approved' === $status ) {
|
1433 |
+
return;
|
1434 |
+
}
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
1438 |
+
|
1439 |
+
if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
|
1440 |
+
$userdata = get_userdata( $user_id );
|
1441 |
+
|
1442 |
+
$this->maybe_generate_password_reset_key( $userdata );
|
1443 |
+
|
1444 |
+
UM()->mail()->send( um_user( 'user_email' ), 'approved_email' );
|
1445 |
+
|
1446 |
+
} else {
|
1447 |
+
//$userdata = get_userdata( $user_id );
|
1448 |
+
//get_password_reset_key( $userdata );
|
1449 |
+
UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
$this->set_status( 'approved' );
|
1453 |
+
$this->delete_meta( 'account_secret_hash' );
|
1454 |
+
$this->delete_meta( 'account_secret_hash_expiry' );
|
1455 |
+
|
1456 |
+
/**
|
1457 |
+
* UM hook
|
1458 |
+
*
|
1459 |
+
* @type action
|
1460 |
+
* @title um_after_user_is_approved
|
1461 |
+
* @description Action after user was approved
|
1462 |
+
* @input_vars
|
1463 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1464 |
+
* @change_log
|
1465 |
+
* ["Since: 2.0"]
|
1466 |
+
* @usage add_action( 'um_after_user_is_approved', 'function_name', 10, 1 );
|
1467 |
+
* @example
|
1468 |
+
* <?php
|
1469 |
+
* add_action( 'um_after_user_is_approved', 'my_after_user_is_approved', 10, 1 );
|
1470 |
+
* function my_after_user_hash_is_changed( $user_id ) {
|
1471 |
+
* // your code here
|
1472 |
+
* }
|
1473 |
+
* ?>
|
1474 |
+
*/
|
1475 |
+
do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
|
1476 |
+
}
|
1477 |
+
|
1478 |
+
|
1479 |
+
/**
|
1480 |
+
* Pending email
|
1481 |
+
*/
|
1482 |
+
function email_pending() {
|
1483 |
+
$this->assign_secretkey();
|
1484 |
+
$this->set_status( 'awaiting_email_confirmation' );
|
1485 |
+
UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
|
1489 |
+
/**
|
1490 |
+
* This method puts a user under manual review by administrator and sends them an optional e-mail.
|
1491 |
+
*
|
1492 |
+
* @usage <?php UM()->user()->pending(); ?>
|
1493 |
+
*
|
1494 |
+
* @example An example of putting a user pending manual review
|
1495 |
+
|
1496 |
+
<?php
|
1497 |
+
|
1498 |
+
um_fetch_user( 54 );
|
1499 |
+
UM()->user()->pending();
|
1500 |
+
|
1501 |
+
?>
|
1502 |
+
*
|
1503 |
+
*/
|
1504 |
+
function pending() {
|
1505 |
+
$this->set_status( 'awaiting_admin_review' );
|
1506 |
+
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
1507 |
+
}
|
1508 |
+
|
1509 |
+
|
1510 |
+
/**
|
1511 |
+
* This method rejects a user membership and sends them an optional e-mail.
|
1512 |
+
*
|
1513 |
+
* @usage <?php UM()->user()->reject(); ?>
|
1514 |
+
*
|
1515 |
+
* @example Reject a user membership example
|
1516 |
+
|
1517 |
+
<?php
|
1518 |
+
|
1519 |
+
um_fetch_user( 114 );
|
1520 |
+
UM()->user()->reject();
|
1521 |
+
|
1522 |
+
?>
|
1523 |
+
|
1524 |
+
*
|
1525 |
+
*/
|
1526 |
+
function reject() {
|
1527 |
+
$this->set_status( 'rejected' );
|
1528 |
+
UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
|
1532 |
+
/**
|
1533 |
+
* This method deactivates a user membership and sends them an optional e-mail.
|
1534 |
+
*
|
1535 |
+
* @usage <?php UM()->user()->deactivate(); ?>
|
1536 |
+
*
|
1537 |
+
* @example Deactivate a user membership with the following example
|
1538 |
+
|
1539 |
+
<?php
|
1540 |
+
|
1541 |
+
um_fetch_user( 32 );
|
1542 |
+
$ultimatemember->user->deactivate();
|
1543 |
+
|
1544 |
+
?>
|
1545 |
+
*
|
1546 |
+
*/
|
1547 |
+
function deactivate() {
|
1548 |
+
$this->set_status( 'inactive' );
|
1549 |
+
/**
|
1550 |
+
* UM hook
|
1551 |
+
*
|
1552 |
+
* @type action
|
1553 |
+
* @title um_after_user_is_inactive
|
1554 |
+
* @description Action after user was inactive
|
1555 |
+
* @input_vars
|
1556 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1557 |
+
* @change_log
|
1558 |
+
* ["Since: 2.0"]
|
1559 |
+
* @usage add_action( 'um_after_user_is_inactive', 'function_name', 10, 1 );
|
1560 |
+
* @example
|
1561 |
+
* <?php
|
1562 |
+
* add_action( 'um_after_user_is_inactive', 'my_after_user_is_inactive', 10, 1 );
|
1563 |
+
* function my_after_user_is_inactive( $user_id ) {
|
1564 |
+
* // your code here
|
1565 |
+
* }
|
1566 |
+
* ?>
|
1567 |
+
*/
|
1568 |
+
do_action( 'um_after_user_is_inactive', um_user( 'ID' ) );
|
1569 |
+
|
1570 |
+
UM()->mail()->send( um_user( 'user_email' ), 'inactive_email' );
|
1571 |
+
}
|
1572 |
+
|
1573 |
+
|
1574 |
+
/**
|
1575 |
+
* Delete user
|
1576 |
+
*
|
1577 |
+
* @param bool $send_mail
|
1578 |
+
*/
|
1579 |
+
function delete( $send_mail = true ) {
|
1580 |
+
|
1581 |
+
$this->send_mail_on_delete = $send_mail;
|
1582 |
+
//don't send email notification to not approved user
|
1583 |
+
if ( 'approved' != um_user( 'account_status' ) ) {
|
1584 |
+
$this->send_mail_on_delete = false;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
// remove user
|
1588 |
+
if ( is_multisite() ) {
|
1589 |
+
|
1590 |
+
if ( ! function_exists( 'wpmu_delete_user' ) ) {
|
1591 |
+
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
wpmu_delete_user( $this->id );
|
1595 |
+
|
1596 |
+
} else {
|
1597 |
+
|
1598 |
+
if ( ! function_exists( 'wp_delete_user' ) ) {
|
1599 |
+
require_once( ABSPATH . 'wp-admin/includes/user.php' );
|
1600 |
+
}
|
1601 |
+
|
1602 |
+
wp_delete_user( $this->id );
|
1603 |
+
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
}
|
1607 |
+
|
1608 |
+
|
1609 |
+
/**
|
1610 |
+
* This method gets a user role in slug format. e.g. member
|
1611 |
+
*
|
1612 |
+
* @usage <?php UM()->user()->get_role(); ?>
|
1613 |
+
*
|
1614 |
+
* @return string
|
1615 |
+
*
|
1616 |
+
* @example Do something if the user's role is paid-member
|
1617 |
+
|
1618 |
+
<?php
|
1619 |
+
|
1620 |
+
um_fetch_user( 12 );
|
1621 |
+
|
1622 |
+
if ( UM()->user()->get_role() == 'paid-member' ) {
|
1623 |
+
// Show this to paid customers
|
1624 |
+
} else {
|
1625 |
+
// You are a free member
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
?>
|
1629 |
+
*
|
1630 |
+
*/
|
1631 |
+
function get_role() {
|
1632 |
+
if ( ! empty( $this->profile['role'] ) ) {
|
1633 |
+
return $this->profile['role'];
|
1634 |
+
} else {
|
1635 |
+
if ( ! empty( $this->profile['wp_roles'] ) && $this->profile['wp_roles'] == 'administrator' ) {
|
1636 |
+
return 'admin';
|
1637 |
+
} else {
|
1638 |
+
return 'member';
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
}
|
1642 |
+
|
1643 |
+
|
1644 |
+
/**
|
1645 |
+
* Update one key in user meta
|
1646 |
+
*
|
1647 |
+
* @param $key
|
1648 |
+
*/
|
1649 |
+
function update_usermeta_info( $key ) {
|
1650 |
+
// delete the key first just in case
|
1651 |
+
delete_user_meta( $this->id, $key );
|
1652 |
+
update_user_meta( $this->id, $key, $this->profile[ $key ] );
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
|
1656 |
+
/**
|
1657 |
+
* This method can be used to delete user's meta key.
|
1658 |
+
*
|
1659 |
+
* @usage <?php UM()->user()->delete_meta( $key ); ?>
|
1660 |
+
*
|
1661 |
+
* @param string $key The meta field key to remove from user
|
1662 |
+
*
|
1663 |
+
* @example Delete user's age field
|
1664 |
+
|
1665 |
+
<?php
|
1666 |
+
|
1667 |
+
um_fetch_user( 15 );
|
1668 |
+
UM()->user()->delete_meta( 'age' );
|
1669 |
+
|
1670 |
+
?>
|
1671 |
+
|
1672 |
+
*
|
1673 |
+
*/
|
1674 |
+
function delete_meta( $key ) {
|
1675 |
+
delete_user_meta( $this->id, $key );
|
1676 |
+
}
|
1677 |
+
|
1678 |
+
|
1679 |
+
/**
|
1680 |
+
* Get admin actions for individual user
|
1681 |
+
*
|
1682 |
+
* @return array|bool
|
1683 |
+
*/
|
1684 |
+
function get_admin_actions() {
|
1685 |
+
$items = array();
|
1686 |
+
|
1687 |
+
/**
|
1688 |
+
* UM hook
|
1689 |
+
*
|
1690 |
+
* @type filter
|
1691 |
+
* @title um_admin_user_actions_hook
|
1692 |
+
* @description Extend admin actions for each user
|
1693 |
+
* @input_vars
|
1694 |
+
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
1695 |
+
* @change_log
|
1696 |
+
* ["Since: 2.0"]
|
1697 |
+
* @usage
|
1698 |
+
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
1699 |
+
* @example
|
1700 |
+
* <?php
|
1701 |
+
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
1702 |
+
* function my_admin_user_actions( $actions ) {
|
1703 |
+
* // your code here
|
1704 |
+
* return $actions;
|
1705 |
+
* }
|
1706 |
+
* ?>
|
1707 |
+
*/
|
1708 |
+
$actions = apply_filters( 'um_admin_user_actions_hook', array(), um_profile_id() );
|
1709 |
+
if ( empty( $actions ) ) {
|
1710 |
+
return $items;
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
foreach ( $actions as $id => $arr ) {
|
1714 |
+
$url = add_query_arg( array( 'um_action' => $id, 'uid' => um_profile_id() ) );
|
1715 |
+
/*$url = add_query_arg( 'um_action', $id );
|
1716 |
+
$url = add_query_arg( 'uid', um_profile_id(), $url );*/
|
1717 |
+
$items[] = '<a href="' . esc_url( $url ) .'" class="real_url ' . esc_attr( $id ) . '-item">' . esc_html( $arr['label'] ) . '</a>';
|
1718 |
+
}
|
1719 |
+
return $items;
|
1720 |
+
}
|
1721 |
+
|
1722 |
+
|
1723 |
+
/**
|
1724 |
+
* This method checks if the profile indexing is disabled
|
1725 |
+
*
|
1726 |
+
* @param int $user_id
|
1727 |
+
*
|
1728 |
+
* @since 2.1.16
|
1729 |
+
* @usage <?php UM()->user()->is_profile_noindex( $user_id ); ?>
|
1730 |
+
*
|
1731 |
+
* @return boolean Is the profile indexing disabled?
|
1732 |
+
*/
|
1733 |
+
function is_profile_noindex( $user_id ) {
|
1734 |
+
$profile_noindex = false;
|
1735 |
+
|
1736 |
+
if ( ! get_option( 'blog_public' ) ) {
|
1737 |
+
// Option "Search engine visibility" in [wp-admin > Settings > Reading]
|
1738 |
+
$profile_noindex = true;
|
1739 |
+
|
1740 |
+
} elseif ( $this->is_private_profile( $user_id ) ) {
|
1741 |
+
// Setting "Profile Privacy" in [Account > Privacy]
|
1742 |
+
$profile_noindex = true;
|
1743 |
+
|
1744 |
+
} elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ) {
|
1745 |
+
// Setting "Avoid indexing my profile by search engines in [Account > Privacy]
|
1746 |
+
$profile_noindex = true;
|
1747 |
+
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
if ( ! $profile_noindex ) {
|
1751 |
+
$role = UM()->roles()->get_priority_user_role( $user_id );
|
1752 |
+
$permissions = UM()->roles()->role_data( $role );
|
1753 |
+
|
1754 |
+
if ( isset( $permissions['profile_noindex'] ) && (bool) $permissions['profile_noindex'] ) {
|
1755 |
+
// Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
|
1756 |
+
$profile_noindex = true;
|
1757 |
+
|
1758 |
+
} elseif ( ( ! isset( $permissions['profile_noindex'] ) || $permissions['profile_noindex'] === '' ) && (bool) UM()->options()->get( 'profile_noindex' ) ) {
|
1759 |
+
// Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
|
1760 |
+
$profile_noindex = true;
|
1761 |
+
|
1762 |
+
}
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $user_id, $this );
|
1766 |
+
}
|
1767 |
+
|
1768 |
+
|
1769 |
+
/**
|
1770 |
+
* This method checks if give user profile is private.
|
1771 |
+
*
|
1772 |
+
* @usage <?php UM()->user()->is_private_profile( $user_id ); ?>
|
1773 |
+
*
|
1774 |
+
* @param int $user_id A user ID must be passed to check if the user profile is private
|
1775 |
+
*
|
1776 |
+
* @return bool
|
1777 |
+
*
|
1778 |
+
* @example This example display a specific user's name If his profile is public
|
1779 |
+
|
1780 |
+
<?php
|
1781 |
+
|
1782 |
+
um_fetch_user( 60 );
|
1783 |
+
$is_private = UM()->user()->is_private_profile( 60 );
|
1784 |
+
if ( ! $is_private ) {
|
1785 |
+
echo 'User is public and his name is ' . um_user('display_name');
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
?>
|
1789 |
+
*
|
1790 |
+
*/
|
1791 |
+
function is_private_profile( $user_id ) {
|
1792 |
+
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
1793 |
+
if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
|
1794 |
+
return true;
|
1795 |
+
}
|
1796 |
+
return $this->is_private_case( $user_id, $privacy );
|
1797 |
+
}
|
1798 |
+
|
1799 |
+
|
1800 |
+
/**
|
1801 |
+
* This method can be used to determine If a certain user is approved or not.
|
1802 |
+
*
|
1803 |
+
* @usage <?php UM()->user()->is_approved( $user_id ); ?>
|
1804 |
+
*
|
1805 |
+
* @param int $user_id The user ID to check approval status for
|
1806 |
+
*
|
1807 |
+
* @return bool
|
1808 |
+
*
|
1809 |
+
* @example Do something If a user's membership is approved
|
1810 |
+
|
1811 |
+
<?php
|
1812 |
+
|
1813 |
+
if ( UM()->user()->is_approved( 55 ) {
|
1814 |
+
// User account is approved
|
1815 |
+
} else {
|
1816 |
+
// User account is not approved
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
?>
|
1820 |
+
*
|
1821 |
+
*/
|
1822 |
+
function is_approved( $user_id ) {
|
1823 |
+
$status = get_user_meta( $user_id, 'account_status', true );
|
1824 |
+
if ( $status == 'approved' || $status == '' ) {
|
1825 |
+
return true;
|
1826 |
+
}
|
1827 |
+
return false;
|
1828 |
+
}
|
1829 |
+
|
1830 |
+
|
1831 |
+
/**
|
1832 |
+
* Is private
|
1833 |
+
*
|
1834 |
+
* @param $user_id
|
1835 |
+
* @param $case
|
1836 |
+
*
|
1837 |
+
* @return bool
|
1838 |
+
*/
|
1839 |
+
function is_private_case( $user_id, $case ) {
|
1840 |
+
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
1841 |
+
|
1842 |
+
if ( $privacy == $case ) {
|
1843 |
+
/**
|
1844 |
+
* UM hook
|
1845 |
+
*
|
1846 |
+
* @type filter
|
1847 |
+
* @title um_is_private_filter_hook
|
1848 |
+
* @description Change user privacy
|
1849 |
+
* @input_vars
|
1850 |
+
* [{"var":"$is_private","type":"bool","desc":"Is user private"},
|
1851 |
+
* {"var":"$privacy","type":"bool","desc":"Profile Privacy"},
|
1852 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1853 |
+
* @change_log
|
1854 |
+
* ["Since: 2.0"]
|
1855 |
+
* @usage
|
1856 |
+
* <?php add_filter( 'um_is_private_filter_hook', 'function_name', 10, 3 ); ?>
|
1857 |
+
* @example
|
1858 |
+
* <?php
|
1859 |
+
* add_filter( 'um_is_private_filter_hook', 'my_is_private_filter', 10, 3 );
|
1860 |
+
* function my_is_private_filter( $is_private ) {
|
1861 |
+
* // your code here
|
1862 |
+
* return $is_private;
|
1863 |
+
* }
|
1864 |
+
* ?>
|
1865 |
+
*/
|
1866 |
+
$bool = apply_filters( 'um_is_private_filter_hook', false, $privacy, $user_id );
|
1867 |
+
return $bool;
|
1868 |
+
}
|
1869 |
+
|
1870 |
+
return false;
|
1871 |
+
}
|
1872 |
+
|
1873 |
+
|
1874 |
+
/**
|
1875 |
+
* Update files
|
1876 |
+
*
|
1877 |
+
* @param $changes
|
1878 |
+
*
|
1879 |
+
* @deprecated 2.1.0
|
1880 |
+
*/
|
1881 |
+
function update_files( $changes ) {
|
1882 |
+
um_deprecated_function( 'update_files', '2.1.0', '' );
|
1883 |
+
}
|
1884 |
+
|
1885 |
+
|
1886 |
+
/**
|
1887 |
+
* Update profile
|
1888 |
+
*
|
1889 |
+
* @param $changes
|
1890 |
+
*/
|
1891 |
+
function update_profile( $changes ) {
|
1892 |
+
|
1893 |
+
$args['ID'] = $this->id;
|
1894 |
+
|
1895 |
+
/**
|
1896 |
+
* UM hook
|
1897 |
+
*
|
1898 |
+
* @type filter
|
1899 |
+
* @title um_before_update_profile
|
1900 |
+
* @description Change update profile changes data
|
1901 |
+
* @input_vars
|
1902 |
+
* [{"var":"$changes","type":"array","desc":"User Profile Changes"},
|
1903 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1904 |
+
* @change_log
|
1905 |
+
* ["Since: 2.0"]
|
1906 |
+
* @usage
|
1907 |
+
* <?php add_filter( 'um_before_update_profile', 'function_name', 10, 2 ); ?>
|
1908 |
+
* @example
|
1909 |
+
* <?php
|
1910 |
+
* add_filter( 'um_before_update_profile', 'my_before_update_profile', 10, 2 );
|
1911 |
+
* function my_before_update_profile( $changes, $user_id ) {
|
1912 |
+
* // your code here
|
1913 |
+
* return $changes;
|
1914 |
+
* }
|
1915 |
+
* ?>
|
1916 |
+
*/
|
1917 |
+
$changes = apply_filters( 'um_before_update_profile', $changes, $args['ID'] );
|
1918 |
+
|
1919 |
+
foreach ( $changes as $key => $value ) {
|
1920 |
+
if ( in_array( $key, $this->banned_keys ) ) {
|
1921 |
+
continue;
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
if ( ! in_array( $key, $this->update_user_keys ) ) {
|
1925 |
+
if ( $value === 0 ) {
|
1926 |
+
update_user_meta( $this->id, $key, '0' );
|
1927 |
+
} else {
|
1928 |
+
update_user_meta( $this->id, $key, $value );
|
1929 |
+
}
|
1930 |
+
} else {
|
1931 |
+
$args[ $key ] = esc_attr( $changes[ $key ] );
|
1932 |
+
}
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
|
1936 |
+
// update user
|
1937 |
+
if ( count( $args ) > 1 ) {
|
1938 |
+
//if isset roles argument validate role to properly for security reasons
|
1939 |
+
if ( isset( $args['role'] ) ) {
|
1940 |
+
global $wp_roles;
|
1941 |
+
$um_roles = get_option( 'um_roles', array() );
|
1942 |
+
|
1943 |
+
if ( ! empty( $um_roles ) ) {
|
1944 |
+
$role_keys = array_map( function( $item ) {
|
1945 |
+
return 'um_' . $item;
|
1946 |
+
}, $um_roles );
|
1947 |
+
} else {
|
1948 |
+
$role_keys = array();
|
1949 |
+
}
|
1950 |
+
|
1951 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
1952 |
+
|
1953 |
+
if ( in_array( $args['role'], $exclude_roles ) ) {
|
1954 |
+
unset( $args['role'] );
|
1955 |
+
}
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
wp_update_user( $args );
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
}
|
1962 |
+
|
1963 |
+
|
1964 |
+
/**
|
1965 |
+
* User exists by meta key and value
|
1966 |
+
*
|
1967 |
+
* @param $key
|
1968 |
+
* @param $value
|
1969 |
+
*
|
1970 |
+
* @return bool|int
|
1971 |
+
*/
|
1972 |
+
function user_has_metadata( $key, $value ) {
|
1973 |
+
|
1974 |
+
$value = UM()->validation()->safe_name_in_url( $value );
|
1975 |
+
|
1976 |
+
$ids = get_users( array( 'fields' => 'ID', 'meta_key' => $key, 'meta_value' => $value, 'meta_compare' => '=' ) );
|
1977 |
+
if ( ! isset( $ids ) || empty( $ids ) ) {
|
1978 |
+
return false;
|
1979 |
+
}
|
1980 |
+
|
1981 |
+
foreach ( $ids as $k => $id ) {
|
1982 |
+
|
1983 |
+
if ( $id == um_user('ID') ) {
|
1984 |
+
unset( $ids[ $k ] );
|
1985 |
+
} else {
|
1986 |
+
$duplicates[] = $id;
|
1987 |
+
}
|
1988 |
+
|
1989 |
+
}
|
1990 |
+
|
1991 |
+
if ( ! empty( $duplicates ) ) {
|
1992 |
+
return count( $duplicates );
|
1993 |
+
}
|
1994 |
+
return false;
|
1995 |
+
}
|
1996 |
+
|
1997 |
+
|
1998 |
+
/**
|
1999 |
+
* User exists by name
|
2000 |
+
*
|
2001 |
+
* @param $value
|
2002 |
+
*
|
2003 |
+
* @return bool
|
2004 |
+
*/
|
2005 |
+
function user_exists_by_name( $value ) {
|
2006 |
+
|
2007 |
+
// Permalink base
|
2008 |
+
$permalink_base = UM()->options()->get( 'permalink_base' );
|
2009 |
+
|
2010 |
+
$raw_value = $value;
|
2011 |
+
$value = UM()->validation()->safe_name_in_url( $value );
|
2012 |
+
$value = um_clean_user_basename( $value );
|
2013 |
+
|
2014 |
+
// Search by Profile Slug
|
2015 |
+
$args = array(
|
2016 |
+
'fields' => array( 'ID' ),
|
2017 |
+
'meta_query' => array(
|
2018 |
+
'relation' => 'OR',
|
2019 |
+
array(
|
2020 |
+
'key' => 'um_user_profile_url_slug_' . $permalink_base,
|
2021 |
+
'value' => strtolower( $raw_value ),
|
2022 |
+
'compare' => '=',
|
2023 |
+
),
|
2024 |
+
),
|
2025 |
+
);
|
2026 |
+
|
2027 |
+
|
2028 |
+
$ids = new \WP_User_Query( $args );
|
2029 |
+
|
2030 |
+
if ( $ids->total_users > 0 ) {
|
2031 |
+
$um_user_query = current( $ids->get_results() );
|
2032 |
+
return $um_user_query->ID;
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
// Search by Display Name or ID
|
2036 |
+
$args = array(
|
2037 |
+
'fields' => array( 'ID' ),
|
2038 |
+
'search' => $value,
|
2039 |
+
'search_columns' => array( 'display_name', 'ID' ),
|
2040 |
+
);
|
2041 |
+
|
2042 |
+
$ids = new \WP_User_Query( $args );
|
2043 |
+
|
2044 |
+
if ( $ids->total_users > 0 ) {
|
2045 |
+
$um_user_query = current( $ids->get_results() );
|
2046 |
+
return $um_user_query->ID;
|
2047 |
+
}
|
2048 |
+
|
2049 |
+
|
2050 |
+
// Search By User Login
|
2051 |
+
$value = str_replace( ".", "_", $value );
|
2052 |
+
$value = str_replace( " ", "", $value );
|
2053 |
+
|
2054 |
+
$args = array(
|
2055 |
+
'fields' => array( 'ID' ),
|
2056 |
+
'search' => $value,
|
2057 |
+
'search_columns' => array(
|
2058 |
+
'user_login',
|
2059 |
+
)
|
2060 |
+
);
|
2061 |
+
|
2062 |
+
$ids = new \WP_User_Query( $args );
|
2063 |
+
|
2064 |
+
if ( $ids->total_users > 0 ) {
|
2065 |
+
$um_user_query = current( $ids->get_results() );
|
2066 |
+
return $um_user_query->ID;
|
2067 |
+
}
|
2068 |
+
|
2069 |
+
return false;
|
2070 |
+
}
|
2071 |
+
|
2072 |
+
|
2073 |
+
/**
|
2074 |
+
* This method checks if a user exists or not in your site based on the user ID.
|
2075 |
+
*
|
2076 |
+
* @usage <?php UM()->user()->user_exists_by_id( $user_id ); ?>
|
2077 |
+
*
|
2078 |
+
* @param int $user_id A user ID must be passed to check if the user exists
|
2079 |
+
*
|
2080 |
+
* @return bool|int
|
2081 |
+
*
|
2082 |
+
* @example Basic Usage
|
2083 |
+
|
2084 |
+
<?php
|
2085 |
+
|
2086 |
+
$boolean = UM()->user()->user_exists_by_id( 15 );
|
2087 |
+
if ( $boolean ) {
|
2088 |
+
// That user exists
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
?>
|
2092 |
+
|
2093 |
+
*
|
2094 |
+
*/
|
2095 |
+
function user_exists_by_id( $user_id ) {
|
2096 |
+
$aux = get_userdata( absint( $user_id ) );
|
2097 |
+
if ( $aux == false ) {
|
2098 |
+
return false;
|
2099 |
+
} else {
|
2100 |
+
return $user_id;
|
2101 |
+
}
|
2102 |
+
}
|
2103 |
+
|
2104 |
+
|
2105 |
+
/**
|
2106 |
+
* This method checks if a user exists or not in your site based on the user email as username
|
2107 |
+
*
|
2108 |
+
* @param string $slug A user slug must be passed to check if the user exists
|
2109 |
+
*
|
2110 |
+
* @usage <?php UM()->user()->user_exists_by_email_as_username( $slug ); ?>
|
2111 |
+
*
|
2112 |
+
* @return bool
|
2113 |
+
*
|
2114 |
+
* @example Basic Usage
|
2115 |
+
|
2116 |
+
<?php
|
2117 |
+
|
2118 |
+
$boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' );
|
2119 |
+
if ( $boolean ) {
|
2120 |
+
// That user exists
|
2121 |
+
}
|
2122 |
+
|
2123 |
+
?>
|
2124 |
+
*/
|
2125 |
+
function user_exists_by_email_as_username( $slug ) {
|
2126 |
+
|
2127 |
+
$user_id = false;
|
2128 |
+
|
2129 |
+
$ids = get_users( array( 'fields' => 'ID', 'meta_key' => 'um_email_as_username_' . $slug ) );
|
2130 |
+
if ( ! empty( $ids[0] ) ) {
|
2131 |
+
$user_id = $ids[0];
|
2132 |
+
}
|
2133 |
+
|
2134 |
+
return $user_id;
|
2135 |
+
}
|
2136 |
+
|
2137 |
+
|
2138 |
+
/**
|
2139 |
+
* Set gravatar hash id
|
2140 |
+
*
|
2141 |
+
* @param $user_id
|
2142 |
+
* @return string
|
2143 |
+
*/
|
2144 |
+
function set_gravatar( $user_id ) {
|
2145 |
+
|
2146 |
+
um_fetch_user( $user_id );
|
2147 |
+
$email_address = um_user( 'user_email' );
|
2148 |
+
$hash_email_address = '';
|
2149 |
+
|
2150 |
+
if ( $email_address ) {
|
2151 |
+
$hash_email_address = md5( $email_address );
|
2152 |
+
$this->profile['synced_gravatar_hashed_id'] = $hash_email_address;
|
2153 |
+
$this->update_usermeta_info( 'synced_gravatar_hashed_id' );
|
2154 |
+
}
|
2155 |
+
|
2156 |
+
return $hash_email_address;
|
2157 |
+
}
|
2158 |
+
|
2159 |
+
|
2160 |
+
/**
|
2161 |
+
* UM Placeholders for activation link in email
|
2162 |
+
*
|
2163 |
+
* @param $placeholders
|
2164 |
+
*
|
2165 |
+
* @return array
|
2166 |
+
*/
|
2167 |
+
function add_activation_placeholder( $placeholders ) {
|
2168 |
+
$placeholders[] = '{account_activation_link}';
|
2169 |
+
return $placeholders;
|
2170 |
+
}
|
2171 |
+
|
2172 |
+
|
2173 |
+
/**
|
2174 |
+
* UM Replace Placeholders for activation link in email
|
2175 |
+
*
|
2176 |
+
* @param $replace_placeholders
|
2177 |
+
*
|
2178 |
+
* @return array
|
2179 |
+
*/
|
2180 |
+
function add_activation_replace_placeholder( $replace_placeholders ) {
|
2181 |
+
$replace_placeholders[] = um_user( 'account_activation_link' );
|
2182 |
+
return $replace_placeholders;
|
2183 |
+
}
|
2184 |
+
}
|
2185 |
+
}
|
includes/core/um-actions-account.php
CHANGED
@@ -1,752 +1,764 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
-
exit;
|
3 |
-
}
|
4 |
-
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Validate for errors in account form
|
8 |
-
*
|
9 |
-
* @param array $args
|
10 |
-
*/
|
11 |
-
function um_submit_account_errors_hook( $args ) {
|
12 |
-
if ( ! isset( $args['_um_account'] ) && ! isset( $args['_um_account_tab'] ) ) {
|
13 |
-
return;
|
14 |
-
}
|
15 |
-
|
16 |
-
$tab = sanitize_key( $args['_um_account_tab'] );
|
17 |
-
|
18 |
-
if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
|
19 |
-
UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
|
20 |
-
}
|
21 |
-
|
22 |
-
$user = get_user_by( 'login', um_user( 'user_login' ) );
|
23 |
-
|
24 |
-
switch ( $tab ) {
|
25 |
-
case 'delete': {
|
26 |
-
// delete account
|
27 |
-
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
28 |
-
if ( strlen( trim( sanitize_text_field( $args['single_user_password'] ) ) ) === 0 ) {
|
29 |
-
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
30 |
-
} else {
|
31 |
-
if ( ! wp_check_password( sanitize_text_field( $args['single_user_password'] ), $user->data->user_pass, $user->data->ID ) ) {
|
32 |
-
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
33 |
-
}
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
UM()->account()->current_tab = 'delete';
|
38 |
-
|
39 |
-
break;
|
40 |
-
}
|
41 |
-
|
42 |
-
case 'password': {
|
43 |
-
|
44 |
-
// change password
|
45 |
-
UM()->account()->current_tab = 'password';
|
46 |
-
|
47 |
-
if ( isset( $args['user_password'] ) ) {
|
48 |
-
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
49 |
-
}
|
50 |
-
|
51 |
-
if ( isset( $args['confirm_user_password'] ) ) {
|
52 |
-
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_passwo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|